summaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index 153b6fe..1f9a193 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -22,6 +22,58 @@ void Parser::parse()
22{ 22{
23 for(;;) 23 for(;;)
24 { 24 {
25 lex.nextToken();
26 expr();
27
28 for( TokenStack::iterator i = tsStack.begin(); i; i++ )
29 {
30 Bu::sio << *i << " ";
31 }
32 }
33}
34
35void Parser::expr()
36{
37 if( lex[0].eType == Token::tVariable &&
38 lex[1].eType == Token::tEquals )
39 {
40 // Assignment!
41 expr();
42 return;
43 }
44 exprP();
45}
46
47void Parser::exprP()
48{
49 switch( lex[0].eType )
50 {
51 case Token::tNumber:
52 case Token::tVariable:
53 tsStack.push( lex[0] );
54 lex.nextToken();
55 break;
56
57 case Token::tOpenParen:
58 lex.nextToken();
59 expr();
60 if( lex[0].eType != Token::tCloseParen )
61 {
62 throw Bu::ExceptionBase("Expected close paren");
63 }
64 lex.nextToken();
65 break;
66
67 case Token::tMinus:
68 lex.nextToken();
69 exprP();
70 tsStack.push( Token( Token::tNegate ) );
71 break;
72 }
73}
74/*
75 for(;;)
76 {
25 Token t = lex.nextToken(); 77 Token t = lex.nextToken();
26 switch( t.eType ) 78 switch( t.eType )
27 { 79 {
@@ -158,6 +210,7 @@ void Parser::parse()
158 } 210 }
159 } 211 }
160} 212}
213*/
161 214
162Number Parser::getVariable( const Bu::String &sName ) 215Number Parser::getVariable( const Bu::String &sName )
163{ 216{
@@ -171,6 +224,7 @@ void Parser::setVariable( const Bu::String &sName, const Number &rValue )
171 224
172void Parser::unwind() 225void Parser::unwind()
173{ 226{
227 /*
174 for(;;) 228 for(;;)
175 { 229 {
176 DBS_START( PARSE ); 230 DBS_START( PARSE );
@@ -312,6 +366,7 @@ void Parser::unwind()
312 getPriority( t.eType ) ) 366 getPriority( t.eType ) )
313 return; 367 return;
314 } 368 }
369 */
315} 370}
316 371
317int Parser::reqTokens( Token::Type eType ) 372int Parser::reqTokens( Token::Type eType )