diff options
Diffstat (limited to '')
-rw-r--r-- | src/parser.h | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/src/parser.h b/src/parser.h index e163212..d50951b 100644 --- a/src/parser.h +++ b/src/parser.h | |||
@@ -13,6 +13,35 @@ namespace Bu | |||
13 | 13 | ||
14 | class Lexer; | 14 | class Lexer; |
15 | 15 | ||
16 | /** | ||
17 | * | ||
18 | * expr: literal | ||
19 | * | variable | ||
20 | * | expr '+' expr | ||
21 | * | expr '-' expr | ||
22 | * | expr '*' expr | ||
23 | * | expr '/' expr | ||
24 | * | '(' expr ')' | ||
25 | * | '-' expr | ||
26 | * | variable '=' expr | ||
27 | * ; | ||
28 | * | ||
29 | * ----- | ||
30 | * | ||
31 | * expr': literal | ||
32 | * | variable | ||
33 | * | '(' expr ')' | ||
34 | * | '-' expr' | ||
35 | * ; | ||
36 | * | ||
37 | * expr: expr' '+' expr | ||
38 | * | expr' '-' expr | ||
39 | * | expr' '*' expr | ||
40 | * | expr' '/' expr | ||
41 | * | expr' | ||
42 | * | variable '=' expr | ||
43 | * ; | ||
44 | */ | ||
16 | class Parser | 45 | class Parser |
17 | { | 46 | { |
18 | public: | 47 | public: |
@@ -24,6 +53,10 @@ public: | |||
24 | void setVariable( const Bu::String &sName, const Number &rValue ); | 53 | void setVariable( const Bu::String &sName, const Number &rValue ); |
25 | 54 | ||
26 | private: | 55 | private: |
56 | void expr(); | ||
57 | void exprP(); | ||
58 | |||
59 | private: | ||
27 | void unwind(); | 60 | void unwind(); |
28 | int reqTokens( Token::Type eType ); | 61 | int reqTokens( Token::Type eType ); |
29 | int getPriority( Token::Type eType ); | 62 | int getPriority( Token::Type eType ); |
@@ -34,8 +67,8 @@ private: | |||
34 | Bu::Stream &rOut; | 67 | Bu::Stream &rOut; |
35 | typedef Bu::List<Token> TokenStack; | 68 | typedef Bu::List<Token> TokenStack; |
36 | typedef Bu::Hash<Bu::String, Number> VarHash; | 69 | typedef Bu::Hash<Bu::String, Number> VarHash; |
37 | TokenStack tsTerminal; | 70 | TokenStack tsStack; |
38 | TokenStack tsNonTerminal; | 71 | // TokenStack tsNonTerminal; |
39 | Number nZero; | 72 | Number nZero; |
40 | VarHash hVars; | 73 | VarHash hVars; |
41 | }; | 74 | }; |