Skip to content

Commit

Permalink
Add single line comments to grammar
Browse files Browse the repository at this point in the history
Currently our syntax does not allow any kind of comments. Introduce
single line comments into parser grammar.
  • Loading branch information
RauliL committed Jul 16, 2017
1 parent a90644f commit 18cc2a6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/parser.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,13 @@
}

Start
= LineTerminator* first:Line tail:(LineTerminator+ Line)* LineTerminator* {
= EndOfLine* first:Line tail:(EndOfLine+ Line)* EndOfLine* {
return start(first, tail);
}

SourceCharacter
= .

WhiteSpace
= [ \t]+ ('\\' LineTerminator+ [ \t]*)?

Expand All @@ -56,6 +59,13 @@ LineTerminator
/ '\u2028'
/ '\u2029'

EndOfLine
= LineTerminator+
/ SingleLineComment+

SingleLineComment
= '#' (!LineTerminator SourceCharacter)*

Word
= id:[^ \t\r\n\u2028\u2029;:\\#]+ WhiteSpace? {
return id.join('');
Expand Down

0 comments on commit 18cc2a6

Please sign in to comment.