@ -181,7 +181,7 @@ describe("PEG.js grammar parser", function() {
initializer : null ,
rules : [ ruleA ]
} ) ;
expect ( '{ code } a = "abcd"') . toParseAs ( {
expect ( '{ code } ; a = "abcd"') . toParseAs ( {
type : "grammar" ,
initializer : { type : "initializer" , code : " code " } ,
rules : [ ruleA ]
@ -200,8 +200,7 @@ describe("PEG.js grammar parser", function() {
code : " code "
} ) ;
expect ( '{ code } start = "abcd"' ) . toParseAs ( grammar ) ;
expect ( '{ code }\n; start = "abcd"' ) . toParseAs ( grammar ) ;
expect ( '{ code }; start = "abcd"' ) . toParseAs ( grammar ) ;
} ) ;
/* Canonical Rule is "a: \"abcd\"". */
@ -382,6 +381,16 @@ describe("PEG.js grammar parser", function() {
expect ( 'start =/**/*/"abcd"' ) . toFailToParse ( ) ;
} ) ;
// Canonical MultiLineCommentNoLineTerminator is "/* comment */".
it ( "parses MultiLineCommentNoLineTerminator" , function ( ) {
expect ( 'start = "abcd"/**/\r\n' ) . toParseAs ( trivialGrammar ) ;
expect ( 'start = "abcd"/*a*/\r\n' ) . toParseAs ( trivialGrammar ) ;
expect ( 'start = "abcd"/*aaa*/\r\n' ) . toParseAs ( trivialGrammar ) ;
expect ( '{ code }/**/*/\r\nstart = "abcd"' ) . toFailToParse ( ) ;
expect ( '{ code }/*\n*/\r\nstart = "abcd"' ) . toFailToParse ( ) ;
} ) ;
/* Canonical SingleLineComment is "// comment". */
it ( "parses SingleLineComment" , function ( ) {
expect ( 'start =//\n"abcd"' ) . toParseAs ( trivialGrammar ) ;
@ -593,4 +602,25 @@ describe("PEG.js grammar parser", function() {
expect ( 'start =/* comment */"abcd"' ) . toParseAs ( trivialGrammar ) ;
expect ( 'start = "abcd"' ) . toParseAs ( trivialGrammar ) ;
} ) ;
/* Canonical _ is " ". */
it ( "parses _" , function ( ) {
expect ( 'start = "abcd"\r\n' ) . toParseAs ( trivialGrammar ) ;
expect ( 'start = "abcd" \r\n' ) . toParseAs ( trivialGrammar ) ;
expect ( 'start = "abcd"/* comment */\r\n' ) . toParseAs ( trivialGrammar ) ;
expect ( 'start = "abcd" \r\n' ) . toParseAs ( trivialGrammar ) ;
} ) ;
/* Canonical EOS is ";". */
it ( "parses EOS" , function ( ) {
expect ( 'start = "abcd"\n;' ) . toParseAs ( trivialGrammar ) ;
expect ( 'start = "abcd" \r\n' ) . toParseAs ( trivialGrammar ) ;
expect ( 'start = "abcd" // comment\r\n' ) . toParseAs ( trivialGrammar ) ;
expect ( 'start = "abcd"\n' ) . toParseAs ( trivialGrammar ) ;
} ) ;
/* Canonical EOF is the end of input. */
it ( "parses EOS" , function ( ) {
expect ( 'start = "abcd"\n' ) . toParseAs ( trivialGrammar ) ;
} ) ;
} ) ;