From b4510a2861acabf1f27ecbd8c42602a0c342763d Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 28 Nov 2014 11:01:34 -0700 Subject: Switched to using bin2cpp for the help. I think that's a better practice, it'll be a lot easier to expand it and format it in general, plus it could be compressed if it got too much bigger. --- .gitignore | 2 ++ parserhelp.txt | 21 +++++++++++++++++++++ src/parser.cpp | 27 +++------------------------ 3 files changed, 26 insertions(+), 24 deletions(-) create mode 100644 parserhelp.txt diff --git a/.gitignore b/.gitignore index b6500cb..fbc5251 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ *.exe /clic /.build_cache +/src/datafiles.cpp +/src/datafiles.h diff --git a/parserhelp.txt b/parserhelp.txt new file mode 100644 index 0000000..0da866c --- /dev/null +++ b/parserhelp.txt @@ -0,0 +1,21 @@ +All commands start with a '\'. The following commands are defined: + \help, \h, \? - This help + \exit, \quit - Exit the program + \radix - Display the current radix (base) + \radix - Set the radix to anything between 2 and 36 (inclusive) + \scale - Display the current scale + \scale - Set the current scale + \vars - List all defined variables + +All variables must prefixed with a $ but otherwise can be used anywhere a +number can be used. To assign a variable use =, i.e.: + $amnt = $rate * 144000.09 + +When using a radix greater than 10 all extended digits are lowercase letters +starting with 'a'. Upper case is not currently supported. + +All numeric command parameters (i.e. \scale, \radix) are in base 10 no +matter what radix is currently set. These are also displayed in base 10 +at all times. + +Changing the radix always clears all variables. diff --git a/src/parser.cpp b/src/parser.cpp index f97078a..72f7bb3 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -1,6 +1,7 @@ #include "parser.h" #include "lexer.h" #include "number.h" +#include "datafiles.h" #include #include @@ -35,6 +36,7 @@ void Parser::parse() if( !tsTerminal.isEmpty() ) { Bu::println( rOut, "%1").arg( deref( tsTerminal.peek() ) ); + hVars.insert("ans", deref( tsTerminal.peek() ) ); } tsTerminal.clear(); lex.setMode( Lexer::modeNormal ); @@ -118,30 +120,7 @@ void Parser::parse() } else if( *t.sVal == "help" || *t.sVal == "h" || *t.sVal == "?" ) { - Bu::println( rOut, - "All commands start with a '\\'. The following commands are defined:\n" - " \\help, \\h, \\? - This help\n" - " \\exit, \\quit - Exit the program\n" - " \\radix - Display the current radix (base)\n" - " \\radix - Set the radix to anything between 2 and 36 (inclusive)\n" - " \\scale - Display the current scale\n" - " \\scale - Set the current scale\n" - " \\vars - List all defined variables\n" - "\n" - "All variables must prefixed with a $ but otherwise can be used anywhere a\n" - "number can be used. To assign a variable use =, i.e.:\n" - " $amnt = $rate * 144000.09\n" - "\n" - "When using a radix greater than 10 all extended digits are lowercase letters\n" - "starting with 'a'. Upper case is not currently supported.\n" - "\n" - "All numeric command parameters (i.e. \\scale, \\radix) are in base 10 no\n" - "matter what radix is currently set. These are also displayed in base 10\n" - "at all times.\n" - "\n" - "Changing the radix always clears all variables.\n" - ); - + Bu::println( rOut, Datafiles::getString("parserhelp.txt") ); } else { -- cgit v1.2.3