Skip to content

Commit

Permalink
Remove the block comments from the SimpleMaths grammar because they b…
Browse files Browse the repository at this point in the history
…reak the tests and create a vicious cycle by not allowing the release of the version that would fix the bug.
  • Loading branch information
teo-tsirpanis committed Aug 20, 2019
1 parent e704e5f commit 2ecc66d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
Binary file modified sample/SimpleMaths.egt
Binary file not shown.
19 changes: 7 additions & 12 deletions sample/SimpleMaths.grm
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@

"Start Symbol" = <Expression>

Comment Line = '//'

Comment Start = '/*'
Comment End = '*/'

! -------------------------------------------------
! Terminals
! -------------------------------------------------
Expand All @@ -21,18 +16,18 @@ Number = {Number}+
! -------------------------------------------------

! The grammar starts below
<Expression> ::= <Add Exp>
<Expression> ::= <Add Exp>

<Add Exp> ::= <Add Exp> '+' <Mult Exp>
| <Add Exp> '-' <Mult Exp>
| <Mult Exp>
| <Mult Exp>

<Mult Exp> ::= <Mult Exp> '*' <Negate Exp>
| <Mult Exp> '/' <Negate Exp>
| <Negate Exp>
<Mult Exp> ::= <Mult Exp> '*' <Negate Exp>
| <Mult Exp> '/' <Negate Exp>
| <Negate Exp>

<Negate Exp> ::= '-' <Value>
| <Value>
<Negate Exp> ::= '-' <Value>
| <Value>

!Add more values to the rule below - as needed

Expand Down
9 changes: 2 additions & 7 deletions tests/Farkle.Tests/ParserTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ let tests = testList "Parser tests" [
test "Parsing a simple mathematical expression behaves correctly and consistently up to the parsing log" {
let grammar = SimpleMaths.int.TryGetGrammar() |> returnOrFail "%O"
let reduce idx = ParseMessage.Reduction grammar.Productions.[int idx]
let numberTerminal = Terminal(14u, "Number")
let numberTerminal = Terminal(9u, "Number")

let expectedLog = [
ParseMessage.TokenRead {Symbol = numberTerminal; Position = Position.Create 1UL 1UL 0UL; Data = 475}
ParseMessage.Shift 3u
ParseMessage.TokenRead {Symbol = Terminal(13u, "+"); Position = Position.Create 1UL 5UL 4UL; Data = null}
ParseMessage.TokenRead {Symbol = Terminal(8u, "+"); Position = Position.Create 1UL 5UL 4UL; Data = null}
reduce 9u
reduce 8u
reduce 6u
Expand All @@ -70,11 +70,6 @@ let tests = testList "Parser tests" [
Expect.sequenceEqual actualLog expectedLog "The parsing log is different than the usual"
}

test "Parsing a mathematical expression with comments works well" {
let num = RuntimeFarkle.parse SimpleMaths.int "/*I guess that */ 1 + 1\n// Is equal to two"
Expect.equal num (Ok 2) "Parsing a mathematical expression with comments failed"
}

testProperty "The JSON parser works well" (fun json ->
let jsonAsString = Chiron.Formatting.Json.format json
let cs =
Expand Down

0 comments on commit 2ecc66d

Please sign in to comment.