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

Class FoamFileParser

source code

                object --+    
                         |    
Basics.PlyParser.PlyParser --+
                             |
                            FoamFileParser
Known Subclasses:

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

Instance Methods [hide private]
 
__init__(self, content, fName=None, debug=False, noHeader=False, noBody=False, doMacroExpansion=False, boundaryDict=False, listDict=False, listDictWithHeader=False, listLengthUnparsed=None)
Constructs the parser and the lexer
source code
 
__contains__(self, key) source code
 
__getitem__(self, key) source code
 
__setitem__(self, key, value) source code
 
__delitem__(self, key) source code
 
directory(self) source code
 
getData(self)
Get the data structure
source code
 
getHeader(self)
Get the OpenFOAM-header
source code
 
printContext(self, c, ind)
Prints the context of the current index
source code
 
parserError(self, text, c, ind)
Prints the error message of the parser and exit
source code
 
t_unparsed_left(self, t)
\(
source code
 
t_unparsed_right(self, t)
\)
source code
 
t_unparsed_error(self, t) source code
 
t_NAME(self, t)
[a-zA-Z_][+\-<>(),.\*|a-zA-Z_0-9&%:]*
source code
 
t_SUBSTITUITION(self, t)
\$[a-zA-Z_][+\-<>(),.\*|a-zA-Z_0-9&%:]*
source code
 
t_newline(self, t)
\n+
source code
 
t_ccode_comment(self, t)
(/\*(.|\n)*?\*/)|(//.*)
source code
 
t_error(self, t) source code
 
p_global(self, p)
global : header clearTemp dictbody
source code
 
p_clearTemp(self, p)
clearTemp :
source code
 
p_gotHeader(self, p)
gotHeader :
source code
 
p_noBody(self, p)
noBody : FOAMFILE '{' dictbody gotHeader '}'
source code
 
p_noHeader(self, p)
noHeader : dictbody
source code
 
p_pureList(self, p)
pureList : list
source code
 
p_pureListWithHeader(self, p)
pureListWithHeader : header list | header prelist
source code
 
p_boundaryDict(self, p)
boundaryDict : header list | header prelist
source code
 
p_header(self, p)
header : FOAMFILE dictionary
source code
 
p_macro(self, p)
macro : KANALGITTER include | KANALGITTER inputMode | KANALGITTER remove
source code
 
p_include(self, p)
include : INCLUDE SCONST
source code
 
p_inputMode(self, p)
inputMode : INPUTMODE ERROR | INPUTMODE DEFAULT | INPUTMODE MERGE | INPUTMODE OVERWRITE
source code
 
p_remove(self, p)
remove : REMOVE word | REMOVE wlist
source code
 
p_integer(self, p)
integer : ICONST
source code
 
p_float(self, p)
integer : FCONST
source code
 
p_dictionary(self, p)
dictionary : '{' dictbody '}' | '{' '}'
source code
 
p_dictbody(self, p)
dictbody : dictbody dictline | dictline | empty
source code
 
p_list(self, p)
list : '(' itemlist ')'
source code
 
p_wlist(self, p)
wlist : '(' wordlist ')'
source code
 
p_unparsed(self, p)
unparsed : UNPARSEDCHUNK
source code
 
p_prelist_seen(self, p)
prelist_seen :
source code
 
p_prelist(self, p)
prelist : integer prelist_seen '(' itemlist ')' | integer prelist_seen '(' unparsed ')'
source code
 
p_itemlist(self, p)
itemlist : itemlist item | item
source code
 
p_wordlist(self, p)
wordlist : wordlist word | word
source code
 
p_word(self, p)
word : NAME | UNIFORM | NONUNIFORM | MERGE | OVERWRITE | DEFAULT | ERROR
source code
 
p_substitution(self, p)
substitution : SUBSTITUTION
source code
 
p_dictline(self, p)
dictline : word dictitem ';' | word list ';' | word prelist ';' | word fieldvalue ';' | macro | word dictionary
source code
 
p_number(self, p)
number : integer | FCONST
source code
 
p_dimension(self, p)
dimension : '[' number number number number number number number ']' | '[' number number number number number ']'
source code
 
p_vector(self, p)
vector : '(' number number number ')'
source code
 
p_tensor(self, p)
tensor : '(' number number number number number number number number number ')'
source code
 
p_symmtensor(self, p)
symmtensor : '(' number number number number number number ')'
source code
 
p_fieldvalue_uniform(self, p)
fieldvalue : UNIFORM number | UNIFORM vector | UNIFORM tensor | UNIFORM symmtensor
source code
 
p_fieldvalue_nonuniform(self, p)
fieldvalue : NONUNIFORM NAME list | NONUNIFORM NAME prelist
source code
 
p_dictitem(self, p)
dictitem : longitem | pitem
source code
 
p_longitem(self, p)
longitem : pitemlist pitem
source code
 
p_pitemlist(self, p)
pitemlist : pitemlist pitem | pitem
source code
 
p_pitem(self, p)
pitem : word | SCONST | number | dictionary | list | dimension | substitution | empty
source code
 
p_item(self, p)
item : pitem | REACTION | list | dictionary
source code
 
p_empty(self, p)
empty :
source code
 
p_error(self, p) source code

Inherited from Basics.PlyParser.PlyParser: parse

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

Class Variables [hide private]
  tokens = ('NAME', 'ICONST', 'FCONST', 'SCONST', 'FOAMFILE', 'U...
  reserved = {'FoamFile': 'FOAMFILE', 'default': 'DEFAULT', 'err...
  states = (('unparsed', 'exclusive'))
  t_unparsed_ignore = ' \t\n0123456789.-+e'
  t_KANALGITTER = '\\#'
  t_ICONST = '(-|)\\d+([uU]|[lL]|[uU][lL]|[lL][uU])?'
  t_FCONST = '(-|)((\\d+)(\\.\\d*)(e(\\+|-)?(\\d+))? | (\\d+)e(\...
  t_SCONST = '\\"([^\\\\\\n]|(\\\\.))*?\\"'
  literals = '(){};[]'
  t_ignore = ' \t\r'

Inherited from Basics.PlyParser.PlyParser: precedence

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, content, fName=None, debug=False, noHeader=False, noBody=False, doMacroExpansion=False, boundaryDict=False, listDict=False, listDictWithHeader=False, listLengthUnparsed=None)
(Constructor)

source code 

Constructs the parser and the lexer

Parameters:
  • content - the string to be parsed
  • fName - Name of the actual file (if any)
  • debug - output debug information during parsing
  • noHeader - switch that turns off the parsing of the header
Overrides: object.__init__

Class Variable Details [hide private]

tokens

Value:
('NAME',
 'ICONST',
 'FCONST',
 'SCONST',
 'FOAMFILE',
 'UNIFORM',
 'NONUNIFORM',
 'UNPARSEDCHUNK',
...

reserved

Value:
{'FoamFile': 'FOAMFILE',
 'default': 'DEFAULT',
 'error': 'ERROR',
 'include': 'INCLUDE',
 'inputMode': 'INPUTMODE',
 'merge': 'MERGE',
 'nonuniform': 'NONUNIFORM',
 'overwrite': 'OVERWRITE',
...

t_FCONST

Value:
'(-|)((\\d+)(\\.\\d*)(e(\\+|-)?(\\d+))? | (\\d+)e(\\+|-)?(\\d+))([lL]|\
[fF])?'