From b822bc1f923dcfac0cabcf8a3abc01241c290e0d Mon Sep 17 00:00:00 2001 From: Victor Fernandes Date: Sat, 18 Mar 2017 20:04:24 -0400 Subject: [PATCH] test files --- scanner.c | 8 +++++--- src_test_files/a2empty.pls | 0 src_test_files/a2error.pls | 39 ++++++++++++++++++++++++++++++++++++++ src_test_files/ass2r.pls | 28 +++++++++++++++++++++++++++ src_test_files/ass2w.pls | 28 +++++++++++++++++++++++++++ 5 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 src_test_files/a2empty.pls create mode 100644 src_test_files/a2error.pls create mode 100644 src_test_files/ass2r.pls create mode 100644 src_test_files/ass2w.pls diff --git a/scanner.c b/scanner.c index 32e0a81..a194b23 100755 --- a/scanner.c +++ b/scanner.c @@ -194,14 +194,16 @@ Token malar_next_token(Buffer * sc_buf) for (; c != '\"'; c = b_getc(sc_buf), ++lexend) { if (c == '\n' || c == '\r') ++line; - if (c == '\0' || c == EOF) { /* Illegal string, make it an error token */ + if (c == '\0' || b_eob(sc_buf)) { /* Illegal string, make it an error token */ b_retract_to_mark(sc_buf); b_retract(sc_buf); b_retract(sc_buf); t.code = ERR_T; for (i = 0; i < lexend; ++i) { - if (i == ERR_LEN) continue; + /* Continue until the end of the lexeme where error was found + * (error string attribute full) */ + if (i == ERR_LEN) continue; if (i < (ERR_LEN - 3)) t.attribute.err_lex[i] = b_getc(sc_buf); else { @@ -283,7 +285,7 @@ Token malar_next_token(Buffer * sc_buf) - }//end while(1) + } /*end while(1)*/ } diff --git a/src_test_files/a2empty.pls b/src_test_files/a2empty.pls new file mode 100644 index 0000000..e69de29 diff --git a/src_test_files/a2error.pls b/src_test_files/a2error.pls new file mode 100644 index 0000000..c55a326 --- /dev/null +++ b/src_test_files/a2error.pls @@ -0,0 +1,39 @@ +!8..AND.i>012)THEN + OUTPUT(sum008); + OUTPUT(); + ELSE{}; +} diff --git a/src_test_files/ass2w.pls b/src_test_files/ass2w.pls new file mode 100644 index 0000000..c47a5eb --- /dev/null +++ b/src_test_files/ass2w.pls @@ -0,0 +1,28 @@ +! = .0 !< illegal floating point literal +Read(ElSe) +If=0.l !< letter l not digit 1 +o=018a !< possible error +b10 = 1O1.0; !< letter O follows 1 +3C=7.0O2; !< digit in VID and letter O precedes 2 +name#S = Last# << " S.#" !< wrong string VID +USING(b10 > 00 OR. <= b10.AND a !- 0.0)DO{ + a=a+1..; + c=01.0; !< leading zero not allowed in floating point +} +WRITE#("No Luck Today); +WRITE (""My Scanner has gone astray"); +} +"There is always one more bug \ No newline at end of file