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