From 29b5b6c1f3abf19087f965c5fb41ed454d9490ed Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Wed, 26 Mar 2025 10:37:08 +0800 Subject: [PATCH] fix scanner error --- scanner.l | 1 - test1 | 5 +++++ test2 | 7 +++++++ test3 | 5 +++++ test4 | 9 +++++++++ 5 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 test1 create mode 100644 test2 create mode 100644 test3 create mode 100644 test4 diff --git a/scanner.l b/scanner.l index b3291fc..428d902 100644 --- a/scanner.l +++ b/scanner.l @@ -182,7 +182,6 @@ BLOCK_COMMENT \/\*(.|\n)*?\*\/ . { errors += 1; fprintf(stderr, "Error type A at Line %d: Mysterious character \"%s\".\n", yylineno, yytext); - return YYerror; } %% diff --git a/test1 b/test1 new file mode 100644 index 0000000..a507b43 --- /dev/null +++ b/test1 @@ -0,0 +1,5 @@ +int main() +{ + int i = 1; + int j = ~i; +} diff --git a/test2 b/test2 new file mode 100644 index 0000000..08a374a --- /dev/null +++ b/test2 @@ -0,0 +1,7 @@ +int main() +{ + float a[10,2]; + int i; + a[5,3] = 1.5; + if (a[1][2] == 0) i = 1 else i = 0; +} diff --git a/test3 b/test3 new file mode 100644 index 0000000..648a039 --- /dev/null +++ b/test3 @@ -0,0 +1,5 @@ +int inc() +{ + int i; + i = i + 1; +} diff --git a/test4 b/test4 new file mode 100644 index 0000000..2abde19 --- /dev/null +++ b/test4 @@ -0,0 +1,9 @@ +struct Complex +{ + float real, image; +}; +int main() +{ + struct Complex x; + y.image = 3.5; +}