1 """Parses Chemkin-Files"""
2
3 import string,sys
4
5 from FileBasis import FileBasisBackup
6 from PyFoam.Basics.PlyParser import PlyParser
7
9 """Overclass for the Chemkin-Parsers"""
10
12 """@param content: the string to be parsed
13 @param debug: output debug information during parsing"""
14
15 PlyParser.__init__(self,debug=debug)
16
17 - def printContext(self,c,ind):
18 """Prints the context of the current index"""
19 print "------"
20 print c[max(0,ind-100):max(0,ind-1)]
21 print "------"
22 print ">",c[ind-1],"<"
23 print "------"
24 print c[min(len(c),ind):min(len(c),ind+100)]
25 print "------"
26
28 """Prints the error message of the parser and exit"""
29 print "PARSER ERROR:",text
30 print "On index",ind
31 self.printContext(c,ind)
32 raise ParseError
33 sys.exit(-1)
34
35 tokens = (
36 'THERMO',
37 'ALL',
38 'END',
39 'ELEMENTS',
40 'SPECIE',
41 'REACTIONS',
42 )
43
45 """Parses a Chemkin-Thermo-File and makes it available"""
46
47 - def __init__(self,name,backup=False,debug=False):
48 """@param name: The name of the parameter file
49 @param backup: create a backup-copy of the file"""
50
51 FileBasisBackup.__init__(self,name,backup=backup)
52
54 """Class that parses a string that contains the contents of an
55 Chemkin-Thermo-file and builds a nested structure of directories and
56 lists from it"""
57
59 """@param content: the string to be parsed
60 @param debug: output debug information during parsing"""
61
62 ChemkinParser.__init__(self,content,debug=debug)
63
65 """Parses a Chemkin-Reaction-File and makes it available"""
66
67 - def __init__(self,name,backup=False,debug=False):
68 """@param name: The name of the parameter file
69 @param backup: create a backup-copy of the file"""
70
71 FileBasisBackup.__init__(self,name,backup=backup)
72
74 """Class that parses a string that contains the contents of an
75 Chemkin-Reactions-file and builds a nested structure of directories and
76 lists from it"""
77
78 - def __init__(self,content,debug=False,noHeader=False):
79 """@param content: the string to be parsed
80 @param debug: output debug information during parsing
81 @param noHeader: switch that turns off the parsing of the header"""
82
83 ChemkinParser.__init__(self,content,debug=debug)
84