Permalink
Browse files

Tidied up grammar in readme

  • Loading branch information...
1 parent 71d93aa commit dd94abc4b65fdba2ced235aca49492a5110d74fe @beelsebob beelsebob committed Jun 26, 2011
Showing with 4 additions and 8 deletions.
  1. +1 −2 CoreParseTests/CoreParseTests.m
  2. +3 −6 README.md
@@ -603,8 +603,7 @@ - (void)testParseResultParsing
CPTokenStream *tokenStream = [tokeniser tokenise:@"5 + 9 + 2 + 7"];
NSString *testGrammar =
- @"Expression ::= <Term>;"
- @"Expression ::= <Expression> \"+\" <Term>;"
+ @"Expression ::= <Term> | <Expression> \"+\" <Term>;"
@"Term ::= \"Number\";";
CPGrammar *grammar = [CPGrammar grammarWithStart:@"Expression" backusNaurForm:testGrammar];
CPParser *parser = [CPSLRParser parserWithGrammar:grammar];
View
@@ -56,12 +56,9 @@ Parsing
We construct parsers by specifying their grammar. We can construct a grammar simply using a simple BNF like language:
NSString *expressionGrammar =
- @"Expression ::= <Term>;"
- @"Expression ::= <Expression> <AddOp> <Term>;"
- @"Term ::= <Factor>;"
- @"Term ::= <Term> <MultOp> <Factor>;"
- @"Factor ::= \"Number\";"
- @"Factor ::= \"(\" <Expression> \")\";"
+ @"Expression ::= <Term> | <Expression> <AddOp> <Term>;"
+ @"Term ::= <Factor> | <Term> <MultOp> <Factor>;"
+ @"Factor ::= \"Number\" | \"(\" <Expression> \")\";"
@"AddOp ::= \"+\" | \"-\";"
@"MultOp ::= \"*\" | \"/\";";
CPGrammar *grammar = [CPGrammar grammarWithStart:@"Expression" backusNaurForm:expressionGrammar];

0 comments on commit dd94abc

Please sign in to comment.