Commit 549a71f0 authored by Tom Zhao's avatar Tom Zhao
Browse files

xz1919: added progressive pipeline scripts

parent d4b85120
...@@ -40,13 +40,13 @@ test-parser-semantic-err: ...@@ -40,13 +40,13 @@ test-parser-semantic-err:
test-semantics-check-syntax-valid: test-semantics-check-syntax-valid:
stage: test stage: test
script: script:
- echo "Using valid examples to test frontend.SemanticChecker, should NOT generate any semantics error" - echo "Using valid examples to test SemanticChecker, should NOT generate any semantics error"
- make - make
- ./scripts/semanticCheckerValid - ./scripts/semanticCheckerValid
test-semantics-check-semantic-err: test-semantics-check-semantic-err:
stage: test stage: test
script: script:
- echo "Using invalid examples with only semantic error to test frontend.SemanticChecker, SHOULD generate any semantics error and NOT syntax error" - echo "Using invalid examples with only semantic error to test SemanticChecker, SHOULD generate any semantics error and NOT syntax error"
- make - make
- ./scripts/semanticCheckerSemanticErr - ./scripts/semanticCheckerSemanticErr
\ No newline at end of file
...@@ -14,7 +14,7 @@ details below). ...@@ -14,7 +14,7 @@ details below).
> lib < > lib <
The lib directory contains the ANTLR library files in frontend.antlr-4.9.1-complete.jar. The lib directory contains the ANTLR library files in antlr-4.9.1-complete.jar.
You should not need to make any changes in this directory. You should not need to make any changes in this directory.
> src < > src <
...@@ -48,15 +48,15 @@ Using the provided scripts ...@@ -48,15 +48,15 @@ Using the provided scripts
This script takes a pair of ANTLR lexer and parser configuration files (set This script takes a pair of ANTLR lexer and parser configuration files (set
within the script) and creates the corresponding Java classes that you can use within the script) and creates the corresponding Java classes that you can use
in your compiler. The Java files are written to the src/frontend.antlr directory and in your compiler. The Java files are written to the src/antlr directory and
should not be modified by hand. By default this script is set up to generate a should not be modified by hand. By default this script is set up to generate a
parse tree and a listerner pattern for traversing this tree, but you can modify parse tree and a listerner pattern for traversing this tree, but you can modify
the compilation options within the script if you want to produce different the compilation options within the script if you want to produce different
outputs outputs
Important! - running the antlrBuild script will overwrite the frontend.antlr directory in Important! - running the antlrBuild script will overwrite the antlr directory in
the src directory. We heavily suggest you do not write any of your the src directory. We heavily suggest you do not write any of your
code within the src/frontend.antlr directory code within the src/antlr directory
> grun < > grun <
...@@ -66,17 +66,17 @@ the TestRig in the project environment. You need to tell it what grammar to use ...@@ -66,17 +66,17 @@ the TestRig in the project environment. You need to tell it what grammar to use
what rule to start parsing with and what kind of output you want. what rule to start parsing with and what kind of output you want.
For example: For example:
./grun frontend.antlr.Basic prog -tokens ./grun antlr.Basic prog -tokens
will run the TestRig using the 'Basic' grammar, starting from the rule for will run the TestRig using the 'Basic' grammar, starting from the rule for
'prog' and outputting the tokens seen by the lexer. To see how the parser groups 'prog' and outputting the tokens seen by the lexer. To see how the parser groups
these tokens you can use the -tree or -gui options instead, such as: these tokens you can use the -tree or -gui options instead, such as:
./grun frontend.antlr.Basic prog -gui ./grun antlr.Basic prog -gui
In either case you will need to frontend.type in your input program and then close the In either case you will need to type in your input program and then close the
input stream with ctrl-D. input stream with ctrl-D.
Rather than typing your input programs in by hand, you can pass the TestRig a Rather than typing your input programs in by hand, you can pass the TestRig a
file to read by piping it in through stdin with file to read by piping it in through stdin with
./grun frontend.antlr.Basic expr -gui < testfile ./grun antlr.Basic expr -gui < testfile
When using the TestRig in this way you won't need to hit ctrl-D to close the When using the TestRig in this way you won't need to hit ctrl-D to close the
input stream as the EOF character in the file does this for you. input stream as the EOF character in the file does this for you.
...@@ -90,7 +90,7 @@ script as the access point to your compiler. ...@@ -90,7 +90,7 @@ script as the access point to your compiler.
You will need to add the ANTLR jar file to the classpath of your calls to Java You will need to add the ANTLR jar file to the classpath of your calls to Java
if you want to be able to use any of the built in ANTLR features. You can do if you want to be able to use any of the built in ANTLR features. You can do
this be setting the -cp option on the command line this be setting the -cp option on the command line
e.g. java -cp bin:lib/frontend.antlr-4.9.1-complete.jar ...rest of call... e.g. java -cp bin:lib/antlr-4.9.1-complete.jar ...rest of call...
note that the bin: ensures that the bin directory is still part of your java note that the bin: ensures that the bin directory is still part of your java
classpath. classpath.
line 13:4 Symbol x is not found in the current scope of the program line 12:7 Incompatible type at ''a''': Expected type INTEGER, but the actual type is CHAR
line 12:8 Symbol tru is not found in the current scope of the program line 13:7 Incompatible type at 'x'': Expected type INTEGER, but the actual type is CHAR
line 12:10 Expected frontend.type BOOLEAN for variable i, while the actual frontend.type is INTEGER line 12:2 Call return in main function body is not allowed
line 13:11 Expected frontend.type CHAR for variable b, while the actual frontend.type is BOOLEAN line 12:7 Incompatible type at ''a''': Expected type INTEGER, but the actual type is CHAR
line 14:11 Expected frontend.type INTEGER for variable c, while the actual frontend.type is CHAR line 13:7 Incompatible type at 'x'': Expected type INTEGER, but the actual type is CHAR
line 13:16 Expected frontend.type INTEGER, but the actual frontend.type is BOOLEAN line 12:2 Call return in main function body is not allowed
line 13:29 Expected frontend.type INTEGER, but the actual frontend.type is BOOLEAN line 12:7 Incompatible type at ''a''': Expected type INTEGER, but the actual type is CHAR
line 13:10 Expected frontend.type BOOLEAN, but the actual frontend.type is INTEGER line 13:7 Incompatible type at 'x'': Expected type INTEGER, but the actual type is CHAR
line 13:40 Expected frontend.type BOOLEAN, but the actual frontend.type is INTEGER line 12:2 Call return in main function body is not allowed
line 13:10 Expected frontend.type BOOLEAN for variable x, while the actual frontend.type is INTEGER line 12:7 Incompatible type at ''a''': Expected type INTEGER, but the actual type is CHAR
line 13:10 Symbol NUMBER is not found in the current scope of the program line 13:7 Incompatible type at 'x'': Expected type INTEGER, but the actual type is CHAR
line 12:14 Calling fst/snd on uninitialised pair expr is not allowed line 12:2 Call return in main function body is not allowed
line 12:14 Calling fst/snd on uninitialised pair expr is not allowed line 12:7 Incompatible type at ''a''': Expected type INTEGER, but the actual type is CHAR
line 14:7 Expected types are [Pair<null, null>, Array<null>], but the actual frontend.type is INTEGER line 13:7 Incompatible type at 'x'': Expected type INTEGER, but the actual type is CHAR
line 13:7 Expected types are [STRING, CHAR, INTEGER], but the actual frontend.type is Pair<INTEGER, INTEGER> line 12:2 Call return in main function body is not allowed
line 12:5 Expected frontend.type BOOLEAN, but the actual frontend.type is INTEGER line 12:7 Incompatible type at ''a''': Expected type INTEGER, but the actual type is CHAR
line 13:7 Expected types are [CHAR, INTEGER, STRING], but the actual frontend.type is BOOLEAN line 13:7 Incompatible type at 'x'': Expected type INTEGER, but the actual type is CHAR
line 15:8 Expected frontend.type BOOLEAN, but the actual frontend.type is INTEGER line 12:2 Call return in main function body is not allowed
line 15:9 Invalid number of arguments: Expected 2 argument(s), but actual number is 3 line 12:7 Incompatible type at ''a''': Expected type INTEGER, but the actual type is CHAR
line 13:4 Symbol x is not found in the current scope of the program line 13:7 Incompatible type at 'x'': Expected type INTEGER, but the actual type is CHAR
line 16:2 Symbol f is not found in the current scope of the program line 12:2 Call return in main function body is not allowed
line 13:13 Expected frontend.type BOOLEAN, but the actual frontend.type is INTEGER line 12:7 Incompatible type at ''a''': Expected type INTEGER, but the actual type is CHAR
line 13:9 Expected frontend.type INTEGER, but the actual frontend.type is CHAR line 13:7 Incompatible type at 'x'': Expected type INTEGER, but the actual type is CHAR
line 15:9 Invalid number of arguments: Expected 2 argument(s), but actual number is 1 line 12:2 Call return in main function body is not allowed
line 11:0 Symbol f has already been declared in the current scope of the program line 12:7 Incompatible type at ''a''': Expected type INTEGER, but the actual type is CHAR
line 15:10 Expected frontend.type INTEGER for variable b, while the actual frontend.type is BOOLEAN line 13:7 Incompatible type at 'x'': Expected type INTEGER, but the actual type is CHAR
line 16:17 Expected frontend.type INTEGER, but the actual frontend.type is BOOLEAN line 12:2 Call return in main function body is not allowed
line 15:16 Expected frontend.type INTEGER, but the actual frontend.type is BOOLEAN line 12:7 Incompatible type at ''a''': Expected type INTEGER, but the actual type is CHAR
line 15:21 Expected frontend.type BOOLEAN, but the actual frontend.type is INTEGER line 13:7 Incompatible type at 'x'': Expected type INTEGER, but the actual type is CHAR
line 14:14 Expected frontend.type INTEGER, but the actual frontend.type is CHAR line 12:2 Call return in main function body is not allowed
line 12:13 Expected frontend.type CHAR for variable s, while the actual frontend.type is STRING line 12:7 Incompatible type at ''a''': Expected type INTEGER, but the actual type is CHAR
line 12:11 Expected frontend.type INTEGER for variable b, while the actual frontend.type is BOOLEAN line 13:7 Incompatible type at 'x'': Expected type INTEGER, but the actual type is CHAR
Symbol x has already been declared in the current scope of the program line 12:2 Call return in main function body is not allowed
line 12:11 Expected frontend.type BOOLEAN for variable c, while the actual frontend.type is CHAR line 12:7 Incompatible type at ''a''': Expected type INTEGER, but the actual type is CHAR
line 12:11 Expected frontend.type STRING for variable c, while the actual frontend.type is CHAR line 13:7 Incompatible type at 'x'': Expected type INTEGER, but the actual type is CHAR
line 12:11 Expected frontend.type CHAR for variable b, while the actual frontend.type is BOOLEAN line 12:2 Call return in main function body is not allowed
line 12:10 Expected frontend.type CHAR for variable i, while the actual frontend.type is INTEGER
line 12:10 Expected frontend.type STRING for variable i, while the actual frontend.type is INTEGER
line 15:2 Symbol x is not found in the current scope of the program
line 12:2 Symbol x is not found in the current scope of the program
line 13:10 Symbol y is not found in the current scope of the program
line 12:10 Expected frontend.type BOOLEAN for variable i, while the actual frontend.type is INTEGER
line 12:11 Expected frontend.type STRING for variable b, while the actual frontend.type is BOOLEAN
line 12:13 Expected frontend.type INTEGER for variable s, while the actual frontend.type is STRING
line 14:10 Symbol NUMBER is not found in the current scope of the program
line 12:13 Expected frontend.type BOOLEAN for variable s, while the actual frontend.type is STRING
line 12:11 Expected frontend.type INTEGER for variable c, while the actual frontend.type is CHAR
line 12:18 Expected frontend.type INTEGER, but the actual frontend.type is BOOLEAN
line 12:11 Expected frontend.type BOOLEAN, but the actual frontend.type is INTEGER
line 12:16 Expected frontend.type BOOLEAN, but the actual frontend.type is INTEGER
line 12:10 Expected frontend.type INTEGER, but the actual frontend.type is BOOLEAN
line 12:17 Expected frontend.type INTEGER, but the actual frontend.type is BOOLEAN
line 12:10 Expected frontend.type BOOLEAN, but the actual frontend.type is INTEGER
line 12:20 Expected frontend.type BOOLEAN, but the actual frontend.type is INTEGER
line 12:10 Expected frontend.type BOOLEAN for variable b, while the actual frontend.type is INTEGER
line 16:10 Expected types are [INTEGER, CHAR, STRING], but the actual frontend.type is Pair<INTEGER, INTEGER>
line 16:14 Expected types are [INTEGER, CHAR, STRING], but the actual frontend.type is Pair<INTEGER, INTEGER>
line 14:10 Expected types are [INTEGER, STRING, CHAR], but the actual frontend.type is Array<INTEGER>
line 14:14 Expected types are [INTEGER, STRING, CHAR], but the actual frontend.type is Array<INTEGER>
line 14:2 Expected frontend.type Array<null>, but the actual frontend.type is STRING
line 12:7 Expected frontend.type INTEGER, but the actual frontend.type is CHAR
line 13:7 Expected frontend.type INTEGER, but the actual frontend.type is CHAR
line 12:2 Call return in main function body
line 12:8 Symbol tru is not found in the current scope of the program
line 12:8 Symbol fals is not found in the current scope of the program
line 12:8 Expected frontend.type BOOLEAN, but the actual frontend.type is INTEGER
line 27:26 token recognition error at: '.'
line 27:27 extraneous input 'node' expecting '='
line 12:22 mismatched input '+' expecting {'end', ';'} line 12:22 mismatched input '+' expecting {'end', ';'}
line 13:10 extraneous input 'fst' expecting {BOOL_LITER, CHAR_LITER, STR_LITER, 'null', '(', '+', '-', '!', 'len', 'ord', 'chr', INT_LITER, IDENT}
line 13:10 extraneous input 'snd' expecting {BOOL_LITER, CHAR_LITER, STR_LITER, 'null', '(', '+', '-', '!', 'len', 'ord', 'chr', INT_LITER, IDENT}
line 15:2 mismatched input 'fi' expecting {'else', ';'}
line 17:0 missing 'fi' at 'end'
line 13:2 mismatched input 'else' expecting {'then', '+', '-', '*', '/', '%', '>', '>=', '<', '<=', '==', '!=', '&&', '||'}
line 12:6 missing '=' at 'true'
line 11:0 missing 'begin' at 'bgn' line 11:0 missing 'begin' at 'bgn'
line 12:11 token recognition error at: ''\H' line 12:11 token recognition error at: ''\H'
line 12:14 token recognition error at: ''\ne' line 12:14 token recognition error at: ''\ne'
...@@ -18,7 +12,10 @@ line 11:10 mismatched input 'end' expecting '=' ...@@ -18,7 +12,10 @@ line 11:10 mismatched input 'end' expecting '='
line 12:11 token recognition error at: ''"' line 12:11 token recognition error at: ''"'
line 12:13 token recognition error at: ''\ne' line 12:13 token recognition error at: ''\ne'
line 14:0 missing 'end' at '<EOF>' line 14:0 missing 'end' at '<EOF>'
line 12:4 Statement exits after return statement. line 13:0 mismatched input 'end' expecting {BOOL_LITER, CHAR_LITER, STR_LITER, 'null', '(', '+', '-', '!', 'len', 'ord', 'chr', INT_LITER, IDENT}
line 12:22 mismatched input '"World!"' expecting INT_LITER
line 12:10 extraneous input '*' expecting {BOOL_LITER, CHAR_LITER, STR_LITER, 'fst', 'snd', 'null', 'newpair', 'call', '(', '[', '+', '-', '!', 'len', 'ord', 'chr', INT_LITER, IDENT}
line 12:4 Other statements exist after function return statement.
line 12:6 missing '=' at '(' line 12:6 missing '=' at '('
line 10:0 Function r2 has not returned or exited properly. line 10:0 Function r2 has not returned or exited properly.
line 10:0 Function f has not returned or exited properly. line 10:0 Function f has not returned or exited properly.
...@@ -35,20 +32,23 @@ line 11:0 missing 'begin' at 'int' ...@@ -35,20 +32,23 @@ line 11:0 missing 'begin' at 'int'
line 12:21 mismatched input ')' expecting {'int', 'bool', 'char', 'string', 'pair'} line 12:21 mismatched input ')' expecting {'int', 'bool', 'char', 'string', 'pair'}
line 12:3 missing '=' at '(' line 12:3 missing '=' at '('
line 12:12 extraneous input '*' expecting IDENT line 12:12 extraneous input '*' expecting IDENT
line 15:2 mismatched input 'fi' expecting {'else', ';'}
line 17:0 missing 'fi' at 'end'
line 13:2 mismatched input 'else' expecting {'then', '+', '-', '*', '/', '%', '>', '>=', '<', '<=', '==', '!=', '&&', '||'}
line 12:6 missing '=' at 'true'
line 13:10 extraneous input 'fst' expecting {BOOL_LITER, CHAR_LITER, STR_LITER, 'null', '(', '+', '-', '!', 'len', 'ord', 'chr', INT_LITER, IDENT}
line 13:10 extraneous input 'snd' expecting {BOOL_LITER, CHAR_LITER, STR_LITER, 'null', '(', '+', '-', '!', 'len', 'ord', 'chr', INT_LITER, IDENT}
line 12:10 extraneous input '[' expecting {BOOL_LITER, CHAR_LITER, STR_LITER, 'null', '(', '+', '-', '!', 'len', 'ord', 'chr', INT_LITER, IDENT} line 12:10 extraneous input '[' expecting {BOOL_LITER, CHAR_LITER, STR_LITER, 'null', '(', '+', '-', '!', 'len', 'ord', 'chr', INT_LITER, IDENT}
line 12:13 extraneous input '0' expecting 'end'
line 13:6 no viable alternative at input 'int='
line 12:13 mismatched input '0' expecting {'end', ';', '+', '-', '*', '/', '%', '>', '>=', '<', '<=', '==', '!=', '&&', '||'}
line 12:10 Integer 2200000000 format not compatible with 32bit int
line 12:11 extraneous input 'A4' expecting 'end'
line 13:0 mismatched input 'end' expecting {BOOL_LITER, CHAR_LITER, STR_LITER, 'null', '(', '+', '-', '!', 'len', 'ord', 'chr', INT_LITER, IDENT}
line 12:22 mismatched input '"World!"' expecting INT_LITER
line 12:10 extraneous input '*' expecting {BOOL_LITER, CHAR_LITER, STR_LITER, 'fst', 'snd', 'null', 'newpair', 'call', '(', '[', '+', '-', '!', 'len', 'ord', 'chr', INT_LITER, IDENT}
line 13:2 extraneous input 'skip' expecting 'end' line 13:2 extraneous input 'skip' expecting 'end'
line 11:6 mismatched input ';' expecting {'int', 'bool', 'char', 'string', 'fst', 'snd', 'pair', 'begin', 'skip', 'read', 'free', 'return', 'exit', 'print', 'println', 'if', 'while', IDENT} line 11:6 mismatched input ';' expecting {'int', 'bool', 'char', 'string', 'fst', 'snd', 'pair', 'begin', 'skip', 'read', 'free', 'return', 'exit', 'print', 'println', 'if', 'while', IDENT}
line 11:14 extraneous input ';' expecting <EOF> line 11:14 extraneous input ';' expecting <EOF>
line 11:12 mismatched input 'end' expecting {'int', 'bool', 'char', 'string', 'fst', 'snd', 'pair', 'begin', 'skip', 'read', 'free', 'return', 'exit', 'print', 'println', 'if', 'while', IDENT} line 11:12 mismatched input 'end' expecting {'int', 'bool', 'char', 'string', 'fst', 'snd', 'pair', 'begin', 'skip', 'read', 'free', 'return', 'exit', 'print', 'println', 'if', 'while', IDENT}
line 12:7 extraneous input ';' expecting {'int', 'bool', 'char', 'string', 'fst', 'snd', 'pair', 'begin', 'skip', 'read', 'free', 'return', 'exit', 'print', 'println', 'if', 'while', IDENT} line 12:7 extraneous input ';' expecting {'int', 'bool', 'char', 'string', 'fst', 'snd', 'pair', 'begin', 'skip', 'read', 'free', 'return', 'exit', 'print', 'println', 'if', 'while', IDENT}
line 12:13 extraneous input '0' expecting 'end'
line 13:6 no viable alternative at input 'int='
line 12:13 mismatched input '0' expecting {'end', ';', '+', '-', '*', '/', '%', '>', '>=', '<', '<=', '==', '!=', '&&', '||'}
line 12:10 Integer 2200000000 format not compatible with 32bit int
line 12:11 extraneous input 'A4' expecting 'end'
line 13:4 missing 'do' at 'skip' line 13:4 missing 'do' at 'skip'
line 12:7 missing '=' at 'false' line 12:7 missing '=' at 'false'
line 12:14 missing 'do' at 'doo' line 12:14 missing 'do' at 'doo'
......
#!/bin/sh #!/bin/sh
INVALID_SEMANTIC_ERR="./src/test/examples/invalid/semanticErr" INVALID_SEMANTIC_ERR=("./src/test/examples/invalid/semanticErr/exit"
INVALID_PARSER_SEMANTIC_ERR_LOG="./log/parse_invalid_semantic_error.log" "./src/test/examples/invalid/semanticErr/expressions"
"./src/test/examples/invalid/semanticErr/function"
"./src/test/examples/invalid/semanticErr/if"
"./src/test/examples/invalid/semanticErr/IO"
"./src/test/examples/invalid/semanticErr/multiple"
"./src/test/examples/invalid/semanticErr/pairs"
"./src/test/examples/invalid/semanticErr/print"
"./src/test/examples/invalid/semanticErr/read"
"./src/test/examples/invalid/semanticErr/scope"
"./src/test/examples/invalid/semanticErr/variables"
"./src/test/examples/invalid/semanticErr/while")
INVALID_PARSER_SEMANTIC_ERR_LOG="./log/parse_invalid_semantic_error.log"
> $INVALID_PARSER_SEMANTIC_ERR_LOG > $INVALID_PARSER_SEMANTIC_ERR_LOG
for file in $(find $INVALID_SEMANTIC_ERR -name "*.wacc") # counters to represent the total number of test files to be processed
do TOTAL_COUNT=$(find ${INVALID_SEMANTIC_ERR[@]} -name "*.wacc" | wc -l)
./compile -p $file 2>> $INVALID_PARSER_SEMANTIC_ERR_LOG COUNTER=0
ret=$?
echo "exit status with parsing only: " $ret for folder in ${INVALID_SEMANTIC_ERR[@]}; do
if [ $ret -ne 0 ]; then for file in $(find $folder -name "*.wacc")
echo "status code incorrect: " $ret do
exit 1 ./compile -p $file 2>> $INVALID_PARSER_SEMANTIC_ERR_LOG
fi ret=$?
echo "exit status with parsing only: " $ret
if [ $ret -ne 0 ]; then
echo "status code incorrect: " $ret
exit 1
fi
if grep "line [0-9]*:[0-9]*" $INVALID_PARSER_SEMANTIC_ERR_LOG > /dev/null; then
echo "expecting no error but found the following:"
cat $INVALID_PARSER_SEMANTIC_ERR_LOG
exit 1
fi
(( COUNTER += 1 ))
echo "$COUNTER / $(($TOTAL_COUNT)) finished\n"
done
if grep "line [0-9]*:[0-9]*" $INVALID_PARSER_SEMANTIC_ERR_LOG > /dev/null; then echo "========================================================================================"
echo "expecting no error but found the following:" echo "Test Folder" $folder "has been processed" "($COUNTER / $(($TOTAL_COUNT)))"
cat $INVALID_PARSER_SEMANTIC_ERR_LOG echo "========================================================================================"
exit 1
fi
done done
\ No newline at end of file
#!/bin/sh #!/bin/sh
INVALID_SYNTAX_ERR="./src/test/examples/invalid/syntaxErr" INVALID_SYNTAX_ERR=("./src/test/examples/invalid/syntaxErr/array"
INVALID_PARSER_SYNTAX_ERR_LOG="./log/parse_invalid_syntax_error.log" "./src/test/examples/invalid/syntaxErr/basic"
"./src/test/examples/invalid/syntaxErr/expressions"
"./src/test/examples/invalid/syntaxErr/function"
"./src/test/examples/invalid/syntaxErr/if"
"./src/test/examples/invalid/syntaxErr/pairs"
"./src/test/examples/invalid/syntaxErr/print"
"./src/test/examples/invalid/syntaxErr/sequence"
"./src/test/examples/invalid/syntaxErr/variables"
"./src/test/examples/invalid/syntaxErr/while")
INVALID_PARSER_SYNTAX_ERR_LOG="./log/parse_invalid_syntax_error.log"
> $INVALID_PARSER_SYNTAX_ERR_LOG > $INVALID_PARSER_SYNTAX_ERR_LOG
for file in $(find $INVALID_SYNTAX_ERR -name "*.wacc") # counters to represent the total number of test files to be processed
do TOTAL_COUNT=$(find ${INVALID_SYNTAX_ERR[@]} -name "*.wacc" | wc -l)
./compile $file 2>> $INVALID_PARSER_SYNTAX_ERR_LOG COUNTER=0
ret=$?
echo "exit status: " $ret for folder in ${INVALID_SYNTAX_ERR[@]}; do
if [ $ret -ne 100 ]; then for file in $(find $folder -name "*.wacc")
echo "status code incorrect: " $ret do
exit 1 ./compile $file 2>> $INVALID_PARSER_SYNTAX_ERR_LOG
fi ret=$?
echo "exit status: " $ret
if ! grep "line [0-9]*:[0-9]*" $INVALID_PARSER_SYNTAX_ERR_LOG > /dev/null; then if [ $ret -ne 100 ]; then
echo "expecting error but found none:" echo "status code incorrect: " $ret
exit 1 exit 1
fi fi
if ! grep "line [0-9]*:[0-9]*" $INVALID_PARSER_SYNTAX_ERR_LOG > /dev/null; then
echo "expecting error but found none:"
exit 1
fi
(( COUNTER += 1 ))
echo "$COUNTER / $(($TOTAL_COUNT)) finished\n"
done
echo "========================================================================================"
echo "Test Folder" $folder "has been processed" "($COUNTER / $(($TOTAL_COUNT)))"
echo "========================================================================================"
done done
\ No newline at end of file
#!/bin/sh #!/bin/sh
VALID_EXAMPLES="./src/test/examples/valid" VALID_EXAMPLES=("./src/test/examples/valid/advanced"
VALID_PARSER_EXAMPLES_LOG="./log/parse_valid_error.log" "./src/test/examples/valid/array"
"./src/test/examples/valid/basic"
"./src/test/examples/valid/expressions"
"./src/test/examples/valid/function"
"./src/test/examples/valid/if"
"./src/test/examples/valid/IO"
"./src/test/examples/valid/pairs"
"./src/test/examples/valid/runtimeErr"
"./src/test/examples/valid/scope"
"./src/test/examples/valid/sequence"
"./src/test/examples/valid/variables"
"./src/test/examples/valid/while")
VALID_PARSER_EXAMPLES_LOG="./log/parse_valid_error.log"
> $VALID_PARSER_EXAMPLES_LOG > $VALID_PARSER_EXAMPLES_LOG
for file in $(find $VALID_EXAMPLES -name "*.wacc") # counters to represent the total number of test files to be processed
do TOTAL_COUNT=$(find ${VALID_EXAMPLES[@]} -name "*.wacc" | wc -l)
./compile $file 2>> $VALID_PARSER_EXAMPLES_LOG COUNTER=0
ret=$?
echo "exit status: " $ret for folder in ${VALID_EXAMPLES[@]}; do
if [ $ret -ne 0 ]; then for file in $(find $folder -name "*.wacc")
echo "status code incorrect: " $ret do
exit 1 ./compile $file 2>> $VALID_PARSER_EXAMPLES_LOG
fi ret=$?
echo "exit status: " $ret
if grep "line [0-9]*:[0-9]*" $VALID_PARSER_EXAMPLES_LOG > /dev/null; then if [ $ret -ne 0 ]; then
echo "expecting no error but found the following:" echo "status code incorrect: " $ret
cat $VALID_PARSER_EXAMPLES_LOG exit 1
exit 1 fi
fi
if grep "line [0-9]*:[0-9]*" $VALID_PARSER_EXAMPLES_LOG > /dev/null; then
echo "expecting no error but found the following:"
cat $VALID_PARSER_EXAMPLES_LOG
exit 1
fi
(( COUNTER += 1 ))
echo "$COUNTER / $(($TOTAL_COUNT)) finished\n"
done
echo "========================================================================================"
echo "Test Folder" $folder "has been processed" "($COUNTER / $(($TOTAL_COUNT)))"
echo "========================================================================================"
done done
\ No newline at end of file
#!/bin/sh #!/bin/sh
INVALID_SEMANTIC_ERR="./src/test/examples/invalid/semanticErr" INVALID_SEMANTIC_ERR=("./src/test/examples/invalid/semanticErr/exit"
INVALID_CHECKER_SEMANTIC_ERR_LOG="./log/checker_invalid_semantic_error.log" "./src/test/examples/invalid/semanticErr/expressions"
"./src/test/examples/invalid/semanticErr/function"
"./src/test/examples/invalid/semanticErr/if"
"./src/test/examples/invalid/semanticErr/IO"
"./src/test/examples/invalid/semanticErr/multiple"
"./src/test/examples/invalid/semanticErr/pairs"
"./src/test/examples/invalid/semanticErr/print"
"./src/test/examples/invalid/semanticErr/read"
"./src/test/examples/invalid/semanticErr/scope"
"./src/test/examples/invalid/semanticErr/variables"
"./src/test/examples/invalid/semanticErr/while")
INVALID_CHECKER_SEMANTIC_ERR_LOG="./log/checker_invalid_semantic_error.log"
> $INVALID_CHECKER_SEMANTIC_ERR_LOG > $INVALID_CHECKER_SEMANTIC_ERR_LOG
for file in $(find $INVALID_SEMANTIC_ERR -name "*.wacc") # counters to represent the total number of test files to be processed
do TOTAL_COUNT=$(find ${INVALID_SEMANTIC_ERR[@]} -name "*.wacc" | wc -l)
./compile $file 2>> $INVALID_CHECKER_SEMANTIC_ERR_LOG COUNTER=0
ret=$?
echo "exit status: " $ret for folder in ${INVALID_SEMANTIC_ERR[@]}; do
if [ $ret -ne 200 ]; then for file in $(find $folder -name "*.wacc")
echo "status code incorrect: " $ret do
exit 1 ./compile $file 2>> $INVALID_CHECKER_SEMANTIC_ERR_LOG
fi ret=$?
echo "exit status: " $ret
if ! grep "line [0-9]*:[0-9]*" $INVALID_CHECKER_SEMANTIC_ERR_LOG > /dev/null; then if [ $ret -ne 200 ]; then
echo "expecting error but the following has none:" echo "status code incorrect: " $ret
cat $INVALID_CHECKER_SEMANTIC_ERR_LOG exit 1
echo $file fi
exit 1
fi if ! grep "line [0-9]*:[0-9]*" $INVALID_CHECKER_SEMANTIC_ERR_LOG > /dev/null; then
echo "expecting error but the following has none:"
cat $INVALID_CHECKER_SEMANTIC_ERR_LOG
echo $file
exit 1
fi
(( COUNTER += 1 ))
echo "$COUNTER / $(($TOTAL_COUNT)) finished\n"
done
echo "========================================================================================"
echo "Test Folder" $folder "has been processed" "($COUNTER / $(($TOTAL_COUNT)))"
echo "========================================================================================"
done done
\ No newline at end of file
#!/bin/sh #!/bin/sh
VALID_EXAMPLES="./src/test/examples/valid" VALID_EXAMPLES=("./src/test/examples/valid/advanced"
VALID_CHECKER_EXAMPLES_LOG="./log/checker_valid_error.log" "./src/test/examples/valid/array"
"./src/test/examples/valid/basic"
"./src/test/examples/valid/expressions"
"./src/test/examples/valid/function"
"./src/test/examples/valid/if"
"./src/test/examples/valid/IO"
"./src/test/examples/valid/pairs"
"./src/test/examples/valid/runtimeErr"
"./src/test/examples/valid/scope"
"./src/test/examples/valid/sequence"
"./src/test/examples/valid/variables"
"./src/test/examples/valid/while")
VALID_CHECKER_EXAMPLES_LOG="./log/checker_valid_error.log"
> $VALID_CHECKER_EXAMPLES_LOG > $VALID_CHECKER_EXAMPLES_LOG
for file in $(find $VALID_EXAMPLES -name "*.wacc") for folder in ${VALID_EXAMPLES[@]}; do
do for file in $(find $folder -name "*.wacc")
./compile $file 2>> $VALID_CHECKER_EXAMPLES_LOG do
ret=$? ./compile $file 2>> $VALID_CHECKER_EXAMPLES_LOG
if [ $ret -ne 0 ]; then ret=$?
echo "status code incorrect: " $ret if [ $ret -ne 0 ]; then
exit 1 echo "status code incorrect: " $ret
fi exit 1
echo "exit code: " $ret fi
if grep "line [0-9]*:[0-9]*" $VALID_CHECKER_EXAMPLES_LOG > /dev/null || grep "Exception" $VALID_CHECKER_EXAMPLES_LOG > /dev/null; then echo "exit code: " $ret
echo "expecting no error but found the following:" if grep "line [0-9]*:[0-9]*" $VALID_CHECKER_EXAMPLES_LOG > /dev/null || grep "Exception" $VALID_CHECKER_EXAMPLES_LOG > /dev/null; then
cat $VALID_CHECKER_EXAMPLES_LOG echo "expecting no error but found the following:"
echo $file cat $VALID_CHECKER_EXAMPLES_LOG
exit 1 echo $file
fi exit 1
done fi
(( COUNTER += 1 ))
echo "$COUNTER / $(($TOTAL_COUNT)) finished\n"
done
echo "========================================================================================"
echo "Test Folder" $folder "has been processed" "($COUNTER / $(($TOTAL_COUNT)))"
echo "========================================================================================"
done
\ No newline at end of file
import frontend.SemanticChecker;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
...@@ -14,6 +13,7 @@ import frontend.antlr.*; ...@@ -14,6 +13,7 @@ import frontend.antlr.*;
import frontend.antlr.WACCParser.ProgramContext; import frontend.antlr.WACCParser.ProgramContext;
import frontend.node.Node; import frontend.node.Node;
import frontend.utils.ParserErrorHandler; import frontend.utils.ParserErrorHandler;
import frontend.SemanticChecker;
public class Compiler { public class Compiler {
......