summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/tparse/tokenize.go12
-rw-r--r--tests/literal-test.tnsl12
-rw-r--r--tests/parameter-test.tnsl4
-rwxr-xr-xtests/run-tests.sh16
4 files changed, 28 insertions, 16 deletions
diff --git a/src/tparse/tokenize.go b/src/tparse/tokenize.go
index 8a79b04..7f57576 100644
--- a/src/tparse/tokenize.go
+++ b/src/tparse/tokenize.go
@@ -26,16 +26,22 @@ import (
// Read in a number (may be a float)
func numericLiteral(r *bufio.Reader, line int, char *int) Token {
- decimal := false
+ decimal, base := false, false
run, _, err := r.ReadRune()
last := *char
b := strings.Builder{}
for ; err == nil; run, _, err = r.ReadRune() {
- if (run == '.') && !decimal {
+ if (run == '.') && !decimal && !base {
decimal = true
- } else if !unicode.IsNumber(run) {
+ } else if (run == '.') && (decimal || base) {
break
+ } else if !unicode.IsNumber(run) {
+ if decimal || checkResRune(run) != -1 || unicode.IsSpace(run) {
+ break
+ } else if !base {
+ base = true
+ }
}
*char++
b.WriteRune(run)
diff --git a/tests/literal-test.tnsl b/tests/literal-test.tnsl
index 6e55323..75789b5 100644
--- a/tests/literal-test.tnsl
+++ b/tests/literal-test.tnsl
@@ -28,19 +28,19 @@
# Invalid (some may be weeded out through the verify phase):
-#;string s ""
+## ;string s ""
-#;int 0 i
+## ;int 0 i
# Invalid ops should also be detected if dealing with literals
-#;char c ~= 's'
+## ;char c ~= 's'
# Debate over weather these are legal
-#;int k = .1
+## ;int k = .1
-;int l = 0x01
+;int l = 01
;int i
-;a a;
+;a a
diff --git a/tests/parameter-test.tnsl b/tests/parameter-test.tnsl
index cae89ab..6db35b1 100644
--- a/tests/parameter-test.tnsl
+++ b/tests/parameter-test.tnsl
@@ -14,5 +14,7 @@
limitations under the License.
#/
;int another = 0
-/; loop (int initial = 0, complex = 2) [initial < max || complex < 40; initial++; complex += 7; another += 2]
+
+/; loop (int initial = 0, complex = 2) [initial < max || complex < 40; initial++; complex = complex + 7; another = another + 2]
+
;/
diff --git a/tests/run-tests.sh b/tests/run-tests.sh
index 6cebbe7..0434b89 100755
--- a/tests/run-tests.sh
+++ b/tests/run-tests.sh
@@ -2,11 +2,15 @@ PARSECMD=../build/parse
PARSEFILE=" "
parse () {
- $PARSECMD -in $1-test.tnsl -out $1-test.tnt
+ echo "ATTEMPTING TO PARSE $1-test.tnsl"
+ $PARSECMD $2 -in $1-test.tnsl -out $1-test.tnt
+ if [ $? -eq 0 ]; then
+ echo "SUCCESS!"
+ fi
}
-parse block
-parse comment
-parse literal
-parse parameter
-parse statement \ No newline at end of file
+parse block "$1"
+parse comment "$1"
+parse literal "$1"
+parse parameter "$1"
+parse statement "$1"