From 3bb307b470876561509904172d3aaede10e5eb62 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 19 Dec 2016 11:16:00 -0700 Subject: Parser updates, it's having trouble with command parameters. should be an easy fix. --- src/parser.cpp | 47 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) (limited to 'src/parser.cpp') diff --git a/src/parser.cpp b/src/parser.cpp index 8e30d24..c83c156 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -201,13 +201,50 @@ void Parser::statement() { lex.setMode( Lexer::modeCommand ); output( lex[0] ); - for(;;) + switch( lex[0].eType ) { - lex.nextToken(); - if( lex[0].eType == Token::tEndOfLine || - lex[0].eType == Token::tEndOfInput ) + case Token::tCmdScale: + { + lex.nextToken(); + Bu::sio << "token: " << lex[0] << Bu::sio.nl; + if( lex[0].eType != Token::tCmdParam ) + throw Bu::ExceptionBase("\\scale requires a single parameter."); + int iScale = strtol(lex[0].sVal->getStr(), NULL, 10); + output( lex[0] ); + lex.nextToken(); + if( lex[0].eType != Token::tCmdEndParams ) + throw Bu::ExceptionBase("\\scale requires a single parameter."); + output( lex[0] ); + + lex.setScale( iScale ); + } + break; + + case Token::tCmdRadix: + { + lex.nextToken(); + if( lex[0].eType != Token::tCmdParam ) + throw Bu::ExceptionBase("\\radix requires a single parameter."); + int iRadix = strtol(lex[0].sVal->getStr(), NULL, 10); + output( lex[0] ); + lex.nextToken(); + if( lex[0].eType != Token::tCmdEndParams ) + throw Bu::ExceptionBase("\\radix requires a single parameter."); + output( lex[0] ); + + lex.setRadix( iRadix ); + } + break; + + default: + for(;;) + { + lex.nextToken(); + output( lex[0] ); + if( lex[0].eType == Token::tCmdEndParams ) + break; + } break; - output( lex[0] ); } lex.setMode( Lexer::modeNormal ); } -- cgit v1.2.3