Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Tidied up grammar in readme

  • Loading branch information...
commit dd94abc4b65fdba2ced235aca49492a5110d74fe 1 parent 71d93aa
@beelsebob beelsebob authored
Showing with 4 additions and 8 deletions.
  1. +1 −2  CoreParseTests/CoreParseTests.m
  2. +3 −6 README.md
View
3  CoreParseTests/CoreParseTests.m
@@ -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
9 README.md
@@ -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];
Please sign in to comment.
Something went wrong with that request. Please try again.