From 0321e6e39b8cf24718cf853c28f0f35443753264 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 30 Nov 2016 13:57:04 -0700 Subject: Working on the parser, some issues. --- src/parser.h | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'src/parser.h') 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 class Lexer; +/** + * + * expr: literal + * | variable + * | expr '+' expr + * | expr '-' expr + * | expr '*' expr + * | expr '/' expr + * | '(' expr ')' + * | '-' expr + * | variable '=' expr + * ; + * + * ----- + * + * expr': literal + * | variable + * | '(' expr ')' + * | '-' expr' + * ; + * + * expr: expr' '+' expr + * | expr' '-' expr + * | expr' '*' expr + * | expr' '/' expr + * | expr' + * | variable '=' expr + * ; + */ class Parser { public: @@ -23,6 +52,10 @@ public: Number getVariable( const Bu::String &sName ); void setVariable( const Bu::String &sName, const Number &rValue ); +private: + void expr(); + void exprP(); + private: void unwind(); int reqTokens( Token::Type eType ); @@ -34,8 +67,8 @@ private: Bu::Stream &rOut; typedef Bu::List TokenStack; typedef Bu::Hash VarHash; - TokenStack tsTerminal; - TokenStack tsNonTerminal; + TokenStack tsStack; +// TokenStack tsNonTerminal; Number nZero; VarHash hVars; }; -- cgit v1.2.3