diff --git a/invalid/semanticErr/expressions/stringElemErr.wacc b/invalid/semanticErr/expressions/stringElemErr.wacc new file mode 100644 index 0000000000000000000000000000000000000000..b4102e6c533ba5f45a7b6415a4b9821e972f55fa --- /dev/null +++ b/invalid/semanticErr/expressions/stringElemErr.wacc @@ -0,0 +1,16 @@ +# element access is not permitted for strings + +# Output: +# #semantic_error# + +# Exit: +# 200 + +# Program: + +begin + string str = "hello world!" ; + println str ; + str[0] = 'H' ; + println str +end diff --git a/invalid/semanticErr/print/printTypeErr02.wacc b/invalid/semanticErr/print/printTypeErr02.wacc new file mode 100644 index 0000000000000000000000000000000000000000..b05deadf9c050d5f421d51684cce45204b8e4417 --- /dev/null +++ b/invalid/semanticErr/print/printTypeErr02.wacc @@ -0,0 +1,14 @@ +# type mismatch: string <- char[] + +# Output: +# #semantic_error# + +# Exit: +# 200 + +# Program: + +begin + string s = ['h','i','!']; + println s +end diff --git a/invalid/syntaxErr/print/printlnCharArry.wacc b/invalid/syntaxErr/print/printlnCharArry.wacc new file mode 100644 index 0000000000000000000000000000000000000000..5241c89e6989d0c3e0f841d1237c46878071a972 --- /dev/null +++ b/invalid/syntaxErr/print/printlnCharArry.wacc @@ -0,0 +1,13 @@ +# You cannot directly print a char[] in WACC + +# Output: +# #syntax_error# + +# Exit: +# 100 + +# Program: + +begin + println ['H','e','l','l','o',' ','W','o','r','l','d','!'] +end diff --git a/valid/IO/print/printCharArray.wacc b/valid/IO/print/printCharArray.wacc new file mode 100644 index 0000000000000000000000000000000000000000..49e312cfcfb7929f117640af9277c69146e8eac4 --- /dev/null +++ b/valid/IO/print/printCharArray.wacc @@ -0,0 +1,14 @@ +# printing the contents of a char[] is possible via an intermediate variable + +# Output: +# hi! + +# Exit: +# 0 + +# Program: + +begin + char[] s = ['h','i','!']; + println s +end