diff options
Diffstat (limited to 'src/parser.cpp')
-rw-r--r-- | src/parser.cpp | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index 7015070..e8e8ff2 100644 --- a/src/parser.cpp +++ b/src/parser.cpp | |||
@@ -41,3 +41,96 @@ void Bu::Parser::parse() | |||
41 | } | 41 | } |
42 | } | 42 | } |
43 | 43 | ||
44 | void Bu::Parser::setRootNonTerminal( int iRoot ) | ||
45 | { | ||
46 | iRootNonTerminal = iRoot; | ||
47 | } | ||
48 | |||
49 | void Bu::Parser::setRootNonTerminal( const Bu::FString &sRoot ) | ||
50 | { | ||
51 | setRootNonTerminal( hNonTerminalName.get( sRoot ) ); | ||
52 | } | ||
53 | |||
54 | int Bu::Parser::addNonTerminal( const Bu::FString &sName, NonTerminal &nt ) | ||
55 | { | ||
56 | int iId = aNonTerminal.getSize(); | ||
57 | aNonTerminal.append( nt ); | ||
58 | hNonTerminalName.insert( sName, iId ); | ||
59 | return iId; | ||
60 | } | ||
61 | |||
62 | int Bu::Parser::addNonTerminal( const Bu::FString &sName ) | ||
63 | { | ||
64 | int iId = aNonTerminal.getSize(); | ||
65 | aNonTerminal.append( NonTerminal() ); | ||
66 | hNonTerminalName.insert( sName, iId ); | ||
67 | return iId; | ||
68 | } | ||
69 | |||
70 | void Bu::Parser::setNonTerminal( const Bu::FString &sName, NonTerminal &nt ) | ||
71 | { | ||
72 | aNonTerminal[hNonTerminalName.get(sName)] = nt; | ||
73 | } | ||
74 | |||
75 | int Bu::Parser::getNonTerminalId( const Bu::FString &sName ) | ||
76 | { | ||
77 | return hNonTerminalName.get( sName ); | ||
78 | } | ||
79 | |||
80 | int Bu::Parser::addReduction( const Bu::FString &sName, const Reduction &r ) | ||
81 | { | ||
82 | int iId = aReduction.getSize(); | ||
83 | aReduction.append( r ); | ||
84 | hReductionName.insert( sName, iId ); | ||
85 | return iId; | ||
86 | } | ||
87 | |||
88 | int Bu::Parser::addReduction( const Bu::FString &sName ) | ||
89 | { | ||
90 | int iId = aReduction.getSize(); | ||
91 | aReduction.append( Reduction() ); | ||
92 | hReductionName.insert( sName, iId ); | ||
93 | return iId; | ||
94 | } | ||
95 | |||
96 | void Bu::Parser::setReduction( const Bu::FString &sName, const Reduction &r ) | ||
97 | { | ||
98 | aReduction[hReductionName.get(sName)] = r; | ||
99 | } | ||
100 | |||
101 | int Bu::Parser::getReductionId( const Bu::FString &sName ) | ||
102 | { | ||
103 | return hReductionName.get( sName ); | ||
104 | } | ||
105 | |||
106 | // | ||
107 | // Bu::Parser::State | ||
108 | // | ||
109 | |||
110 | Bu::Parser::State::State( Bu::Parser::State::Type eType, int iIndex ) : | ||
111 | eType( eType ), | ||
112 | iIndex( iIndex ) | ||
113 | { | ||
114 | } | ||
115 | |||
116 | Bu::Parser::State::~State() | ||
117 | { | ||
118 | } | ||
119 | |||
120 | // | ||
121 | // Bu::Parser::NonTerminal | ||
122 | // | ||
123 | |||
124 | Bu::Parser::NonTerminal::NonTerminal() | ||
125 | { | ||
126 | } | ||
127 | |||
128 | Bu::Parser::NonTerminal::~NonTerminal() | ||
129 | { | ||
130 | } | ||
131 | |||
132 | void Bu::Parser::NonTerminal::addProduction( Production p ) | ||
133 | { | ||
134 | lProduction.append( p ); | ||
135 | } | ||
136 | |||