Skip to content

Commit

Permalink
fix to the grammar to address #75 code with double quotes now raises …
Browse files Browse the repository at this point in the history
…an error
  • Loading branch information
Felienne committed Jun 14, 2020
1 parent 64c0a0e commit 4aba6c2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions grammars/level6.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ assign_list: var " is " textwithspaces ((", "|",") textwithspaces)+

//TODO: sum needs to be expression here too (like in 7 and up)

assign : var " is " sum
assign : var " is " sum | var " is " textwithoutspaces
invalid: /^(?!(repeat|print|if|and )).+/ //everything that is not the start of a regular command

// new commands for level 4
Expand All @@ -41,7 +41,7 @@ repeat: "repeat " (NUMBER | var) " times " command
| product " "* "*" " "* atom -> multiplication
| product " "* "/" " "* atom -> division

?atom: NUMBER | textwithoutspaces //TODO: means we cannot assign strings with spaces? would we want that?
?atom: NUMBER | var //TODO: means we cannot assign strings with spaces? would we want that?


var: NAME -> var
Expand Down
1 change: 1 addition & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ def test_print_with_var(self):
result = hedy.transpile("naam is Hedy\nprint 'ik heet' naam", 6)
self.assertEqual("import random\nnaam = 'Hedy'\nprint('ik heet'+str(naam))",result)


def test_transpile_ask(self):
result = hedy.transpile("antwoord is ask wat is je lievelingskleur?", 6)
self.assertEqual(result, "import random\nantwoord = input('wat is je lievelingskleur?')")
Expand Down

0 comments on commit 4aba6c2

Please sign in to comment.