diff options
Diffstat (limited to 'src/parser.cpp')
| -rw-r--r-- | src/parser.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index 804e595..57144c2 100644 --- a/src/parser.cpp +++ b/src/parser.cpp | |||
| @@ -31,9 +31,11 @@ void Parser::parse() | |||
| 31 | Bu::println( rOut, "%1").arg( deref( tsTerminal.peek() ) ); | 31 | Bu::println( rOut, "%1").arg( deref( tsTerminal.peek() ) ); |
| 32 | } | 32 | } |
| 33 | tsTerminal.clear(); | 33 | tsTerminal.clear(); |
| 34 | lex.setMode( Lexer::modeNormal ); | ||
| 34 | break; | 35 | break; |
| 35 | 36 | ||
| 36 | case Token::tCommand: | 37 | case Token::tCommand: |
| 38 | lex.setMode( Lexer::modeCommand ); | ||
| 37 | if( *t.sVal == "exit" || *t.sVal == "quit" ) | 39 | if( *t.sVal == "exit" || *t.sVal == "quit" ) |
| 38 | return; | 40 | return; |
| 39 | else if( *t.sVal == "scale" ) | 41 | else if( *t.sVal == "scale" ) |
| @@ -44,9 +46,9 @@ void Parser::parse() | |||
| 44 | Bu::println( rOut, "Current scale: %1"). | 46 | Bu::println( rOut, "Current scale: %1"). |
| 45 | arg( lex.getScale() ); | 47 | arg( lex.getScale() ); |
| 46 | } | 48 | } |
| 47 | else if( t2.eType == Token::tNumber ) | 49 | else if( t2.eType == Token::tString ) |
| 48 | { | 50 | { |
| 49 | int32_t i = t2.nVal->toInt32(); | 51 | int32_t i = strtol( t2.sVal->getStr(), 0, 10 ); |
| 50 | lex.setScale( i ); | 52 | lex.setScale( i ); |
| 51 | if( i < 0 ) | 53 | if( i < 0 ) |
| 52 | { | 54 | { |
| @@ -77,9 +79,9 @@ void Parser::parse() | |||
| 77 | Bu::println( rOut, "Current radix: %1"). | 79 | Bu::println( rOut, "Current radix: %1"). |
| 78 | arg( lex.getRadix() ); | 80 | arg( lex.getRadix() ); |
| 79 | } | 81 | } |
| 80 | else if( t2.eType == Token::tNumber ) | 82 | else if( t2.eType == Token::tString ) |
| 81 | { | 83 | { |
| 82 | int32_t i = t2.nVal->toInt32(); | 84 | int32_t i = strtol( t2.sVal->getStr(), 0, 10 ); |
| 83 | if( i < 2 || i > 36 ) | 85 | if( i < 2 || i > 36 ) |
| 84 | Bu::println( rOut, "ERROR: Radix must be between " | 86 | Bu::println( rOut, "ERROR: Radix must be between " |
| 85 | "2 and 36 inclusive"); | 87 | "2 and 36 inclusive"); |
| @@ -127,13 +129,9 @@ void Parser::parse() | |||
| 127 | "When using a radix greater than 10 all extended digits are lowercase letters\n" | 129 | "When using a radix greater than 10 all extended digits are lowercase letters\n" |
| 128 | "starting with 'a'. Upper case is not currently supported.\n" | 130 | "starting with 'a'. Upper case is not currently supported.\n" |
| 129 | "\n" | 131 | "\n" |
| 130 | "All numbers are interpreted in the current radix, this means that you need to\n" | 132 | "All numeric command parameters (i.e. \\scale, \\radix) are in base 10 no\n" |
| 131 | "set the radix using the current radix, even though the current value is aways\n" | 133 | "matter what radix is currently set. These are also displayed in base 10\n" |
| 132 | "displayed in decimal. That is, to go to base 8 and back to base 10 you would:\n" | 134 | "at all times.\n" |
| 133 | " \\radix 8\n" | ||
| 134 | " Radix changed to: 8\n" | ||
| 135 | " \\radix 12\n" | ||
| 136 | " Radix changed to: 10\n" | ||
| 137 | "\n" | 135 | "\n" |
| 138 | "Changing the radix always clears all variables.\n" | 136 | "Changing the radix always clears all variables.\n" |
| 139 | ); | 137 | ); |
| @@ -144,6 +142,7 @@ void Parser::parse() | |||
| 144 | Bu::println( rOut, "ERROR: Unknown command '%1'"). | 142 | Bu::println( rOut, "ERROR: Unknown command '%1'"). |
| 145 | arg( *t.sVal ); | 143 | arg( *t.sVal ); |
| 146 | } | 144 | } |
| 145 | lex.setMode( Lexer::modeNormal ); | ||
| 147 | break; | 146 | break; |
| 148 | 147 | ||
| 149 | case Token::tNumber: | 148 | case Token::tNumber: |
| @@ -292,6 +291,7 @@ void Parser::unwind() | |||
| 292 | case Token::tNumber: | 291 | case Token::tNumber: |
| 293 | case Token::tVariable: | 292 | case Token::tVariable: |
| 294 | case Token::tCommand: | 293 | case Token::tCommand: |
| 294 | case Token::tString: | ||
| 295 | case Token::tEndOfLine: | 295 | case Token::tEndOfLine: |
| 296 | case Token::tEndOfInput: | 296 | case Token::tEndOfInput: |
| 297 | // These should never show up at all | 297 | // These should never show up at all |
