summaryrefslogtreecommitdiff
path: root/src/parser.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser.h')
-rw-r--r--src/parser.h37
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
14class Lexer; 14class 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 */
16class Parser 45class Parser
17{ 46{
18public: 47public:
@@ -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
26private: 55private:
56 void expr();
57 void exprP();
58
59private:
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};