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

Type FoamFileParser

object --+    
         |    
 PlyParser --+
             |
            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
Method Summary
  __init__(self, content, debug, noHeader)
  getData(self)
Get the data structure
  getHeader(self)
Get the OpenFOAM-header
  p_dictbody(self, p)
dictbody : dictbody dictline | dictline | empty
  p_dictionary(self, p)
dictionary : '{' dictbody '}' | '{' '}'
  p_dictitem(self, p)
dictitem : longitem | pitem
  p_dictline(self, p)
dictline : NAME dictitem ';' | NAME list ';' | NAME fieldvalue ';' | NAME dictionary
  p_dimension(self, p)
dimension : '[' number number number number number number number ']'
  p_empty(self, p)
empty :
  p_error(self, p)
  p_fieldvalue_nonuniform(self, p)
fieldvalue : NONUNIFORM NAME list
  p_fieldvalue_uniform(self, p)
fieldvalue : UNIFORM number | UNIFORM vector
  p_global(self, p)
global : header dictbody
  p_header(self, p)
header : FOAMFILE dictionary
  p_item(self, p)
item : pitem | list | dictionary
  p_itemlist(self, p)
itemlist : itemlist item | item
  p_list_normal(self, p)
list : '(' itemlist ')'
  p_list_prefixed(self, p)
list : ICONST '(' itemlist ')'
  p_longitem(self, p)
longitem : pitemlist pitem
  p_noHeader(self, p)
noHeader : dictbody
  p_number(self, p)
number : ICONST | FCONST
  p_pitem(self, p)
pitem : NAME | SCONST | number | dimension | empty
  p_pitemlist(self, p)
pitemlist : pitemlist pitem | pitem
  p_vector(self, p)
vector : '(' number number number ')'
  parserError(self, text, c, ind)
Prints the error message of the parser and exit
  printContext(self, c, ind)
Prints the context of the current index
  t_ccode_comment(self, t)
(/\*(.|\n)*\*/)|(//.*)
  t_error(self, t)
  t_NAME(self, t)
[a-zA-Z_][<>(),.\*|a-zA-Z_0-9]*
  t_newline(self, t)
\n+
    Inherited from PlyParser
  parse(self, content)
Do the actual parsing
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
x.__repr__() <==> repr(x)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Class Variable Summary
str literals = '(){};[]'
dict reserved = {'FoamFile': 'FOAMFILE', 'nonuniform': 'NONUN...
str t_FCONST = '(-|)((\\d+)(\\.\\d+)(e(\\+|-)?(\\d+))? | (\\...
str t_ICONST = '(-|)\\d+([uU]|[lL]|[uU][lL]|[lL][uU])?'
str t_ignore = ' \t'
str t_SCONST = '\\"([^\\\\\\n]|(\\\\.))*?\\"'
tuple tokens = ('NAME', 'ICONST', 'FCONST', 'SCONST', 'FOAMFIL...
    Inherited from PlyParser
tuple precedence = ()

Method Details

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

Parameters:
content - the string to be parsed
debug - output debug information during parsing
noHeader - switch that turns off the parsing of the header
Overrides:
PyFoam.Basics.PlyParser.PlyParser.__init__

getData(self)

Get the data structure

getHeader(self)

Get the OpenFOAM-header

p_dictbody(self, p)

dictbody : dictbody dictline | dictline | empty

p_dictionary(self, p)

dictionary : '{' dictbody '}' | '{' '}'

p_dictitem(self, p)

dictitem : longitem | pitem

p_dictline(self, p)

dictline : NAME dictitem ';' | NAME list ';' | NAME fieldvalue ';' | NAME dictionary

p_dimension(self, p)

dimension : '[' number number number number number number number ']'

p_empty(self, p)

empty :

p_fieldvalue_nonuniform(self, p)

fieldvalue : NONUNIFORM NAME list

p_fieldvalue_uniform(self, p)

fieldvalue : UNIFORM number | UNIFORM vector

p_global(self, p)

global : header dictbody

p_header(self, p)

header : FOAMFILE dictionary

p_item(self, p)

item : pitem | list | dictionary

p_itemlist(self, p)

itemlist : itemlist item | item

p_list_normal(self, p)

list : '(' itemlist ')'

p_list_prefixed(self, p)

list : ICONST '(' itemlist ')'

p_longitem(self, p)

longitem : pitemlist pitem

p_noHeader(self, p)

noHeader : dictbody

p_number(self, p)

number : ICONST | FCONST

p_pitem(self, p)

pitem : NAME | SCONST | number | dimension | empty

p_pitemlist(self, p)

pitemlist : pitemlist pitem | pitem

p_vector(self, p)

vector : '(' number number number ')'

parserError(self, text, c, ind)

Prints the error message of the parser and exit

printContext(self, c, ind)

Prints the context of the current index

t_ccode_comment(self, t)

(/\*(.|\n)*\*/)|(//.*)

t_NAME(self, t)

[a-zA-Z_][<>(),.\*|a-zA-Z_0-9]*

t_newline(self, t)

\n+

Class Variable Details

literals

Type:
str
Value:
'(){};[]'                                                              

reserved

Type:
dict
Value:
{'FoamFile': 'FOAMFILE', 'nonuniform': 'NONUNIFORM', 'uniform': 'UNIFO\
RM'}                                                                   

t_FCONST

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

t_ICONST

Type:
str
Value:
'(-|)\\d+([uU]|[lL]|[uU][lL]|[lL][uU])?'                               

t_ignore

Type:
str
Value:
' \t'                                                                  

t_SCONST

Type:
str
Value:
'''\\"([^\\\\\
]|(\\\\.))*?\\"'''                                                     

tokens

Type:
tuple
Value:
('NAME', 'ICONST', 'FCONST', 'SCONST', 'FOAMFILE', 'UNIFORM', 'NONUNIF\
ORM')                                                                  

Generated by Epydoc 2.1 on Mon Jan 22 23:52:48 2007 http://epydoc.sf.net