Package PyFoam :: Package RunDictionary :: Module OldParsedParameterFile :: Class FoamFileParser
[hide private]
[frames] | no frames]

Class FoamFileParser

source code

object --+
         |
        FoamFileParser

Class that parses a string that contains the contents of an OpenFOAM-file and bilds a nested structure of directories and lists from it

Instance Methods [hide private]
  __init__(self, content, debug=False)
  getData(self)
Get the data structure
  getChar(self, c, ind)
Get the next character from a string (if there is any)
  peekChar(self, c, ind)
  isOK(self, c, ind)
Check whether there are still characters in the string
  skipSpace(self, c, ind)
Skip spaces and set index to the next non-whitespace character
  getName(self, c, ind)
Gets a name for a dictionary entry
  getString(self, c, ind)
Get a quoted string and return it (including the quotes)
  checkForList(self, c, ind)
Look-ahead to find out whether the next thing is a list
  parseList(self, c, ind)
Parse a list
  getValue(self, c, ind)
Get characters up to the next white-space
  parseValue(self, c, ind)
Parse a value that ends withe semi-colon
  printContext(self, c, ind)
Prints the context of the current index
  parserError(self, text, c, ind)
Prints the error message of the parser and exit
  parseDict(self, c, ind)
Parse assuming a dictionary
  rmComments(self, c)
Removes the comments from a string

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__


Properties [hide private]

Inherited from object: __class__


Method Details [hide private]

__init__(self, content, debug=False)
(Constructor)

source code 
Parameters:
  • content - the string to be parsed
  • debug - output debug information during parsing
Overrides: object.__init__

getData(self)

source code 
Get the data structure

getChar(self, c, ind)

source code 
Get the next character from a string (if there is any)
Parameters:
  • c - the string
  • ind - the current index
Returns:
the character (empty string if past the end) and the new index

peekChar(self, c, ind)

source code 
None

isOK(self, c, ind)

source code 
Check whether there are still characters in the string

skipSpace(self, c, ind)

source code 
Skip spaces and set index to the next non-whitespace character
Returns:
The index of the next non-whitespace character

getName(self, c, ind)

source code 
Gets a name for a dictionary entry
Returns:
name and index of the next char after it

getString(self, c, ind)

source code 
Get a quoted string and return it (including the quotes)

checkForList(self, c, ind)

source code 
Look-ahead to find out whether the next thing is a list

parseList(self, c, ind)

source code 
Parse a list

getValue(self, c, ind)

source code 
Get characters up to the next white-space

parseValue(self, c, ind)

source code 
Parse a value that ends withe semi-colon

printContext(self, c, ind)

source code 
Prints the context of the current index

parserError(self, text, c, ind)

source code 
Prints the error message of the parser and exit

parseDict(self, c, ind)

source code 
Parse assuming a dictionary
Parameters:
  • c - the string that is to be parsed
  • ind - index of the next chatacter to analyze

rmComments(self, c)

source code 
Removes the comments from a string