diff options
| author | Mike Buland <mike@xagasoft.com> | 2014-11-28 11:01:34 -0700 |
|---|---|---|
| committer | Mike Buland <mike@xagasoft.com> | 2014-11-28 11:01:34 -0700 |
| commit | b4510a2861acabf1f27ecbd8c42602a0c342763d (patch) | |
| tree | 94e16d1318c5f7e8da00d1a73b648fc26463deb8 | |
| parent | 145c88f23e6587e310d3ca974365d20d373d8e1b (diff) | |
| download | clic-b4510a2861acabf1f27ecbd8c42602a0c342763d.tar.gz clic-b4510a2861acabf1f27ecbd8c42602a0c342763d.tar.bz2 clic-b4510a2861acabf1f27ecbd8c42602a0c342763d.tar.xz clic-b4510a2861acabf1f27ecbd8c42602a0c342763d.zip | |
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.
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | parserhelp.txt | 21 | ||||
| -rw-r--r-- | src/parser.cpp | 27 |
3 files changed, 26 insertions, 24 deletions
| @@ -3,4 +3,6 @@ | |||
| 3 | *.exe | 3 | *.exe |
| 4 | /clic | 4 | /clic |
| 5 | /.build_cache | 5 | /.build_cache |
| 6 | /src/datafiles.cpp | ||
| 7 | /src/datafiles.h | ||
| 6 | 8 | ||
diff --git a/parserhelp.txt b/parserhelp.txt new file mode 100644 index 0000000..0da866c --- /dev/null +++ b/parserhelp.txt | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | All commands start with a '\'. The following commands are defined: | ||
| 2 | \help, \h, \? - This help | ||
| 3 | \exit, \quit - Exit the program | ||
| 4 | \radix - Display the current radix (base) | ||
| 5 | \radix <num> - Set the radix to anything between 2 and 36 (inclusive) | ||
| 6 | \scale - Display the current scale | ||
| 7 | \scale <num> - Set the current scale | ||
| 8 | \vars - List all defined variables | ||
| 9 | |||
| 10 | All variables must prefixed with a $ but otherwise can be used anywhere a | ||
| 11 | number can be used. To assign a variable use =, i.e.: | ||
| 12 | $amnt = $rate * 144000.09 | ||
| 13 | |||
| 14 | When using a radix greater than 10 all extended digits are lowercase letters | ||
| 15 | starting with 'a'. Upper case is not currently supported. | ||
| 16 | |||
| 17 | All numeric command parameters (i.e. \scale, \radix) are in base 10 no | ||
| 18 | matter what radix is currently set. These are also displayed in base 10 | ||
| 19 | at all times. | ||
| 20 | |||
| 21 | 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 @@ | |||
| 1 | #include "parser.h" | 1 | #include "parser.h" |
| 2 | #include "lexer.h" | 2 | #include "lexer.h" |
| 3 | #include "number.h" | 3 | #include "number.h" |
| 4 | #include "datafiles.h" | ||
| 4 | 5 | ||
| 5 | #include <bu/sio.h> | 6 | #include <bu/sio.h> |
| 6 | #include <stdlib.h> | 7 | #include <stdlib.h> |
| @@ -35,6 +36,7 @@ void Parser::parse() | |||
| 35 | if( !tsTerminal.isEmpty() ) | 36 | if( !tsTerminal.isEmpty() ) |
| 36 | { | 37 | { |
| 37 | Bu::println( rOut, "%1").arg( deref( tsTerminal.peek() ) ); | 38 | Bu::println( rOut, "%1").arg( deref( tsTerminal.peek() ) ); |
| 39 | hVars.insert("ans", deref( tsTerminal.peek() ) ); | ||
| 38 | } | 40 | } |
| 39 | tsTerminal.clear(); | 41 | tsTerminal.clear(); |
| 40 | lex.setMode( Lexer::modeNormal ); | 42 | lex.setMode( Lexer::modeNormal ); |
| @@ -118,30 +120,7 @@ void Parser::parse() | |||
| 118 | } | 120 | } |
| 119 | else if( *t.sVal == "help" || *t.sVal == "h" || *t.sVal == "?" ) | 121 | else if( *t.sVal == "help" || *t.sVal == "h" || *t.sVal == "?" ) |
| 120 | { | 122 | { |
| 121 | Bu::println( rOut, | 123 | Bu::println( rOut, Datafiles::getString("parserhelp.txt") ); |
| 122 | "All commands start with a '\\'. The following commands are defined:\n" | ||
| 123 | " \\help, \\h, \\? - This help\n" | ||
| 124 | " \\exit, \\quit - Exit the program\n" | ||
| 125 | " \\radix - Display the current radix (base)\n" | ||
| 126 | " \\radix <num> - Set the radix to anything between 2 and 36 (inclusive)\n" | ||
| 127 | " \\scale - Display the current scale\n" | ||
| 128 | " \\scale <num> - Set the current scale\n" | ||
| 129 | " \\vars - List all defined variables\n" | ||
| 130 | "\n" | ||
| 131 | "All variables must prefixed with a $ but otherwise can be used anywhere a\n" | ||
| 132 | "number can be used. To assign a variable use =, i.e.:\n" | ||
| 133 | " $amnt = $rate * 144000.09\n" | ||
| 134 | "\n" | ||
| 135 | "When using a radix greater than 10 all extended digits are lowercase letters\n" | ||
| 136 | "starting with 'a'. Upper case is not currently supported.\n" | ||
| 137 | "\n" | ||
| 138 | "All numeric command parameters (i.e. \\scale, \\radix) are in base 10 no\n" | ||
| 139 | "matter what radix is currently set. These are also displayed in base 10\n" | ||
| 140 | "at all times.\n" | ||
| 141 | "\n" | ||
| 142 | "Changing the radix always clears all variables.\n" | ||
| 143 | ); | ||
| 144 | |||
| 145 | } | 124 | } |
| 146 | else | 125 | else |
| 147 | { | 126 | { |
