MTK doesn't like strings containing double quotes. We can work around
this by minimizing the use of double quotes sent to MTK.
Since this changes all the error messages in the regression tests
anyway, we can use the opportunity and also make the message format
a little nicer.
---
src/compiler/parser_helper.c | 10 +++++-----
src/compiler/test/comment | 6 +++---
src/compiler/test/error | 8 ++++----
src/compiler/test/location | 26 +++++++++++++-------------
src/compiler/test/number | 2 +-
src/compiler/test/wrap | 4 ++--
6 files changed, 28 insertions(+), 28 deletions(-)
diff --git a/src/compiler/parser_helper.c b/src/compiler/parser_helper.c
index 79c6c9b..4003bc3 100644
--- a/src/compiler/parser_helper.c
+++ b/src/compiler/parser_helper.c
@@ -104,7 +104,7 @@ const char *fpvm_parse(const char *expr, int start_token,
state.id = identifier;
if(tok == TOK_ERROR) {
error = alloc_printf(
- "FPVM, line %d, near \"%c\": scan error",
+ "FPVM, line %d: scan error near '%c'",
s->lineno, printable_char(s->cursor[-1]));
ParseFree(p, free);
delete_scanner(s);
@@ -119,10 +119,10 @@ const char *fpvm_parse(const char *expr, int start_token,
if(!state.success) {
error = alloc_printf(
- "FPVM, line %d, near \"%.*s\": %s",
- state.error_lineno, printable_label(state.error_label),
- state.error_label,
- state.error ? state.error : "parse error");
+ "FPVM, line %d: %s near '%.*s'",
+ state.error_lineno,
+ state.error ? state.error : "parse error",
+ printable_label(state.error_label), state.error_label);
free((void *) state.error);
}
diff --git a/src/compiler/test/comment b/src/compiler/test/comment
index 3199bd9..b72253d 100755
--- a/src/compiler/test/comment
+++ b/src/compiler/test/comment
@@ -113,7 +113,7 @@ a = 9 /*/
b = a
EOF
expect <<EOF
-FPVM, line 1, near "*/": parse error
+FPVM, line 1: parse error near '*/'
EOF
#------------------------------------------------------------------------------
@@ -123,14 +123,14 @@ a = b + c /* comment
d = e + f
EOF
expect <<EOF
-FPVM, line 1, near "*": parse error
+FPVM, line 1: parse error near '*'
EOF
#------------------------------------------------------------------------------
ptest_fail "comment: unterminated /* ... without newline" "a = b+c /* comment"
expect <<EOF
-FPVM, line 1, near "*": parse error
+FPVM, line 1: parse error near '*'
EOF
#------------------------------------------------------------------------------
diff --git a/src/compiler/test/error b/src/compiler/test/error
index 1beadc4..c8a07cf 100755
--- a/src/compiler/test/error
+++ b/src/compiler/test/error
@@ -7,7 +7,7 @@ ptest_fail "syntax error: x = backtick" <<EOF
x = \`
EOF
expect <<EOF
-FPVM, line 1, near "\`": scan error
+FPVM, line 1: scan error near '\`'
EOF
#------------------------------------------------------------------------------
@@ -17,7 +17,7 @@ x = a b
EOF
expect <<EOF
x = a
-FPVM, line 1, near "b": parse error
+FPVM, line 1: parse error near 'b'
EOF
#------------------------------------------------------------------------------
@@ -26,7 +26,7 @@ ptest_fail "syntax error: x = a + + b" <<EOF
x = a + + b
EOF
expect <<EOF
-FPVM, line 1, near "+": parse error
+FPVM, line 1: parse error near '+'
EOF
#------------------------------------------------------------------------------
@@ -35,7 +35,7 @@ ptest_fail "code generation error" -f "codegen" <<EOF
x = a + b
EOF
expect <<EOF
-FPVM, line 1, near "b": codegen
+FPVM, line 1: codegen near 'b'
EOF
###############################################################################
diff --git a/src/compiler/test/location b/src/compiler/test/location
index aabee2d..c9bee39 100755
--- a/src/compiler/test/location
+++ b/src/compiler/test/location
@@ -10,7 +10,7 @@ c = d
EOF
expect <<EOF
a = b
-FPVM, line 2, near "\`": scan error
+FPVM, line 2: scan error near '\`'
EOF
#------------------------------------------------------------------------------
@@ -21,7 +21,7 @@ a = b
c = d
EOF
expect <<EOF
-FPVM, line 2, near "\`": scan error
+FPVM, line 2: scan error near '\`'
EOF
#------------------------------------------------------------------------------
@@ -33,7 +33,7 @@ c = d
EOF
expect <<EOF
a = b
-FPVM, line 2, near "\`": scan error
+FPVM, line 2: scan error near '\`'
EOF
#------------------------------------------------------------------------------
@@ -45,7 +45,7 @@ c = d
EOF
expect <<EOF
a = b
-FPVM, line 2, near "*": parse error
+FPVM, line 2: parse error near '*'
EOF
#------------------------------------------------------------------------------
@@ -57,7 +57,7 @@ c = d
EOF
expect <<EOF
a = b
-FPVM, line 2, near ")x": parse error
+FPVM, line 2: parse error near ')x'
EOF
#------------------------------------------------------------------------------
@@ -70,7 +70,7 @@ EOF
expect <<EOF
a = b
x = y
-FPVM, line 2, near "(": parse error
+FPVM, line 2: parse error near '('
EOF
#------------------------------------------------------------------------------
@@ -82,7 +82,7 @@ c = d
EOF
expect <<EOF
a = b
-FPVM, line 2, near ")": parse error
+FPVM, line 2: parse error near ')'
EOF
#------------------------------------------------------------------------------
@@ -93,14 +93,14 @@ x =
EOF
expect <<EOF
a = b
-FPVM, line 2, near "=": parse error
+FPVM, line 2: parse error near '='
EOF
#------------------------------------------------------------------------------
ptest_fail "location: error is EOF" "x="
expect <<EOF
-FPVM, line 1, near "=": parse error
+FPVM, line 1: parse error near '='
EOF
#------------------------------------------------------------------------------
@@ -110,7 +110,7 @@ foo = this is an error
EOF
expect <<EOF
foo = this
-FPVM, line 1, near "an": parse error
+FPVM, line 1: parse error near 'an'
EOF
#------------------------------------------------------------------------------
@@ -123,7 +123,7 @@ EOF
expect <<EOF
a = b
c = d
-FPVM, line 3, near ")": parse error
+FPVM, line 3: parse error near ')'
EOF
#------------------------------------------------------------------------------
@@ -138,7 +138,7 @@ EOF
expect <<EOF
a = b
c = d
-FPVM, line 5, near ")": parse error
+FPVM, line 5: parse error near ')'
EOF
#------------------------------------------------------------------------------
@@ -152,7 +152,7 @@ EOF
expect <<EOF
a = b
c = d
-FPVM, line 4, near ")": parse error
+FPVM, line 4: parse error near ')'
EOF
###############################################################################
diff --git a/src/compiler/test/number b/src/compiler/test/number
index 2162eaf..17a142e 100755
--- a/src/compiler/test/number
+++ b/src/compiler/test/number
@@ -52,7 +52,7 @@ ptest_fail "number: f = ." <<EOF
f = .
EOF
expect <<EOF
-FPVM, line 1, near ".": scan error
+FPVM, line 1: scan error near '.'
EOF
###############################################################################
diff --git a/src/compiler/test/wrap b/src/compiler/test/wrap
index e3ed6c4..982cf32 100755
--- a/src/compiler/test/wrap
+++ b/src/compiler/test/wrap
@@ -75,7 +75,7 @@ ptest_fail "wrap: one assignment containing semicolon (1)"
<<EOF
a = b +; c
EOF
expect <<EOF
-FPVM, line 1, near ";": parse error
+FPVM, line 1: parse error near ';'
EOF
#------------------------------------------------------------------------------
@@ -85,7 +85,7 @@ a = b; + c
EOF
expect <<EOF
a = b
-FPVM, line 1, near "+": parse error
+FPVM, line 1: parse error near '+'
EOF
###############################################################################
--
1.7.1
_______________________________________________
http://lists.milkymist.org/listinfo.cgi/devel-milkymist.org
IRC: #milkymist@Freenode