Fix handling of _ and $ in Javascript names

db4
Chris Double 2008-06-19 00:51:47 +12:00
parent 6f8e2a4b0d
commit fc7baebacb
1 changed files with 3 additions and 1 deletions

View File

@ -6,6 +6,8 @@ IN: peg.javascript.tokenizer
#! Grammar for JavaScript. Based on OMeta-JS example from:
#! http://jarrett.cs.ucla.edu/ometa-js/#JavaScript_Compiler
USE: prettyprint
EBNF: tokenizer
Letter = [a-zA-Z]
Digit = [0-9]
@ -14,7 +16,7 @@ SingleLineComment = "//" (!("\n") .)* "\n" => [[ ignore ]]
MultiLineComment = "/*" (!("*/") .)* "*/" => [[ ignore ]]
Space = " " | "\t" | "\r" | "\n" | SingleLineComment | MultiLineComment
Spaces = Space* => [[ ignore ]]
NameFirst = Letter | "$" | "_"
NameFirst = Letter | "$" => [[ CHAR: $ ]] | "_" => [[ CHAR: _ ]]
NameRest = NameFirst | Digit
iName = NameFirst NameRest* => [[ first2 swap prefix >string ]]
Keyword = ("break"