| OLD | NEW |
| 1 # Copyright 2013 the V8 project authors. All rights reserved. | 1 # Copyright 2013 the V8 project authors. All rights reserved. |
| 2 # Redistribution and use in source and binary forms, with or without | 2 # Redistribution and use in source and binary forms, with or without |
| 3 # modification, are permitted provided that the following conditions are | 3 # modification, are permitted provided that the following conditions are |
| 4 # met: | 4 # met: |
| 5 # | 5 # |
| 6 # * Redistributions of source code must retain the above copyright | 6 # * Redistributions of source code must retain the above copyright |
| 7 # notice, this list of conditions and the following disclaimer. | 7 # notice, this list of conditions and the following disclaimer. |
| 8 # * Redistributions in binary form must reproduce the above | 8 # * Redistributions in binary form must reproduce the above |
| 9 # copyright notice, this list of conditions and the following | 9 # copyright notice, this list of conditions and the following |
| 10 # disclaimer in the documentation and/or other materials provided | 10 # disclaimer in the documentation and/or other materials provided |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 line_terminator_sequence = /[:line_terminator:]|\r\n/; | 40 line_terminator_sequence = /[:line_terminator:]|\r\n/; |
| 41 eos = [:eos:]; | 41 eos = [:eos:]; |
| 42 | 42 |
| 43 # grammar is | 43 # grammar is |
| 44 # regex <action_on_state_entry|action_on_match|transition> | 44 # regex <action_on_state_entry|action_on_match|transition> |
| 45 # | 45 # |
| 46 # actions can be c code enclosed in {} or identifiers to be passed to codegen | 46 # actions can be c code enclosed in {} or identifiers to be passed to codegen |
| 47 # transition must be in continue or the name of a subgraph | 47 # transition must be in continue or the name of a subgraph |
| 48 | 48 |
| 49 <<default>> | 49 <<default>> |
| 50 "|=" <|push_token(ASSIGN_BIT_OR)|> | |
| 51 "^=" <|push_token(ASSIGN_BIT_XOR)|> | |
| 52 "&=" <|push_token(ASSIGN_BIT_AND)|> | |
| 53 "+=" <|push_token(ASSIGN_ADD)|> | |
| 54 "-=" <|push_token(ASSIGN_SUB)|> | |
| 55 "*=" <|push_token(ASSIGN_MUL)|> | |
| 56 "/=" <|push_token(ASSIGN_DIV)|> | |
| 57 "%=" <|push_token(ASSIGN_MOD)|> | |
| 58 | 50 |
| 59 "===" <|push_token(EQ_STRICT)|> | 51 "|=" <|token(ASSIGN_BIT_OR)|> |
| 60 "==" <|push_token(EQ)|> | 52 "^=" <|token(ASSIGN_BIT_XOR)|> |
| 61 "=" <|push_token(ASSIGN)|> | 53 "&=" <|token(ASSIGN_BIT_AND)|> |
| 62 "!==" <|push_token(NE_STRICT)|> | 54 "+=" <|token(ASSIGN_ADD)|> |
| 63 "!=" <|push_token(NE)|> | 55 "-=" <|token(ASSIGN_SUB)|> |
| 64 "!" <|push_token(NOT)|> | 56 "*=" <|token(ASSIGN_MUL)|> |
| 57 "/=" <|token(ASSIGN_DIV)|> |
| 58 "%=" <|token(ASSIGN_MOD)|> |
| 59 |
| 60 "===" <|token(EQ_STRICT)|> |
| 61 "==" <|token(EQ)|> |
| 62 "=" <|token(ASSIGN)|> |
| 63 "!==" <|token(NE_STRICT)|> |
| 64 "!=" <|token(NE)|> |
| 65 "!" <|token(NOT)|> |
| 65 | 66 |
| 66 "//" <||SingleLineComment> | 67 "//" <||SingleLineComment> |
| 67 "/*" <set_marker(2)||MultiLineComment> | 68 "/*" <set_marker(2)||MultiLineComment> |
| 68 "<!--" <||SingleLineComment> | 69 "<!--" <||SingleLineComment> |
| 69 | 70 |
| 70 "<!-" <|{ | 71 "<!-" <|{ |
| 71 BACKWARD(2); | 72 BACKWARD(2); |
| 72 PUSH_TOKEN(Token::LT); | 73 DO_TOKEN(Token::LT); |
| 73 }|> | 74 }|> |
| 74 | 75 |
| 75 "<!" <|{ | 76 "<!" <|{ |
| 76 BACKWARD(1); | 77 BACKWARD(1); |
| 77 PUSH_TOKEN(Token::LT); | 78 DO_TOKEN(Token::LT); |
| 78 }|> | 79 }|> |
| 79 | 80 |
| 80 | |
| 81 "-->" <{ | 81 "-->" <{ |
| 82 if (!has_line_terminator_before_next_) { | 82 if (!has_line_terminator_before_next_) { |
| 83 BACKWARD(1); | 83 BACKWARD(1); |
| 84 PUSH_TOKEN(Token::DEC); | 84 DO_TOKEN(Token::DEC); |
| 85 } | 85 } |
| 86 }||SingleLineComment> | 86 }||SingleLineComment> |
| 87 | 87 |
| 88 ">>>=" <|push_token(ASSIGN_SHR)|> | 88 ">>>=" <|token(ASSIGN_SHR)|> |
| 89 ">>>" <|push_token(SHR)|> | 89 ">>>" <|token(SHR)|> |
| 90 "<<=" <|push_token(ASSIGN_SHL)|> | 90 "<<=" <|token(ASSIGN_SHL)|> |
| 91 ">>=" <|push_token(ASSIGN_SAR)|> | 91 ">>=" <|token(ASSIGN_SAR)|> |
| 92 "<=" <|push_token(LTE)|> | 92 "<=" <|token(LTE)|> |
| 93 ">=" <|push_token(GTE)|> | 93 ">=" <|token(GTE)|> |
| 94 "<<" <|push_token(SHL)|> | 94 "<<" <|token(SHL)|> |
| 95 ">>" <|push_token(SAR)|> | 95 ">>" <|token(SAR)|> |
| 96 "<" <|push_token(LT)|> | 96 "<" <|token(LT)|> |
| 97 ">" <|push_token(GT)|> | 97 ">" <|token(GT)|> |
| 98 | 98 |
| 99 number <|push_token(NUMBER)|> | 99 number <|token(NUMBER)|> |
| 100 number identifier_char <|push_token(ILLEGAL)|> | 100 number identifier_char <|token(ILLEGAL)|> |
| 101 number "\\" <|push_token(ILLEGAL)|> | 101 number "\\" <|token(ILLEGAL)|> |
| 102 | 102 |
| 103 harmony_number <|push_harmony_token(numeric_literals, NUMBER, ILLEGAL)|> | 103 harmony_number <|harmony_token(numeric_literals, NUMBER, ILLEGA
L)|> |
| 104 harmony_number identifier_char <|push_token(ILLEGAL)|> | 104 harmony_number identifier_char <|token(ILLEGAL)|> |
| 105 harmony_number "\\" <|push_token(ILLEGAL)|> | 105 harmony_number "\\" <|token(ILLEGAL)|> |
| 106 | 106 |
| 107 "(" <|push_token(LPAREN)|> | 107 "(" <|token(LPAREN)|> |
| 108 ")" <|push_token(RPAREN)|> | 108 ")" <|token(RPAREN)|> |
| 109 "[" <|push_token(LBRACK)|> | 109 "[" <|token(LBRACK)|> |
| 110 "]" <|push_token(RBRACK)|> | 110 "]" <|token(RBRACK)|> |
| 111 "{" <|push_token(LBRACE)|> | 111 "{" <|token(LBRACE)|> |
| 112 "}" <|push_token(RBRACE)|> | 112 "}" <|token(RBRACE)|> |
| 113 ":" <|push_token(COLON)|> | 113 ":" <|token(COLON)|> |
| 114 ";" <|push_token(SEMICOLON)|> | 114 ";" <|token(SEMICOLON)|> |
| 115 "." <|push_token(PERIOD)|> | 115 "." <|token(PERIOD)|> |
| 116 "?" <|push_token(CONDITIONAL)|> | 116 "?" <|token(CONDITIONAL)|> |
| 117 "++" <|push_token(INC)|> | 117 "++" <|token(INC)|> |
| 118 "--" <|push_token(DEC)|> | 118 "--" <|token(DEC)|> |
| 119 | 119 |
| 120 "||" <|push_token(OR)|> | 120 "||" <|token(OR)|> |
| 121 "&&" <|push_token(AND)|> | 121 "&&" <|token(AND)|> |
| 122 | 122 |
| 123 "|" <|push_token(BIT_OR)|> | 123 "|" <|token(BIT_OR)|> |
| 124 "^" <|push_token(BIT_XOR)|> | 124 "^" <|token(BIT_XOR)|> |
| 125 "&" <|push_token(BIT_AND)|> | 125 "&" <|token(BIT_AND)|> |
| 126 "+" <|push_token(ADD)|> | 126 "+" <|token(ADD)|> |
| 127 "-" <|push_token(SUB)|> | 127 "-" <|token(SUB)|> |
| 128 "*" <|push_token(MUL)|> | 128 "*" <|token(MUL)|> |
| 129 "/" <|push_token(DIV)|> | 129 "/" <|token(DIV)|> |
| 130 "%" <|push_token(MOD)|> | 130 "%" <|token(MOD)|> |
| 131 "~" <|push_token(BIT_NOT)|> | 131 "~" <|token(BIT_NOT)|> |
| 132 "," <|push_token(COMMA)|> | 132 "," <|token(COMMA)|> |
| 133 | 133 |
| 134 line_terminator+ <|push_line_terminator|> | 134 line_terminator+ <|line_terminator|> |
| 135 /[:whitespace:]+/ <|skip|> | 135 /[:whitespace:]+/ <|skip|> |
| 136 | 136 |
| 137 "\"" <set_marker(1)||DoubleQuoteString> | 137 "\"" <set_marker(1)||DoubleQuoteString> |
| 138 "'" <set_marker(1)||SingleQuoteString> | 138 "'" <set_marker(1)||SingleQuoteString> |
| 139 | 139 |
| 140 # all keywords | 140 # all keywords |
| 141 "break" <|push_token(BREAK)|> | 141 "break" <|token(BREAK)|> |
| 142 "case" <|push_token(CASE)|> | 142 "case" <|token(CASE)|> |
| 143 "catch" <|push_token(CATCH)|> | 143 "catch" <|token(CATCH)|> |
| 144 "class" <|push_token(FUTURE_RESERVED_WORD)|> | 144 "class" <|token(FUTURE_RESERVED_WORD)|> |
| 145 "const" <|push_token(CONST)|> | 145 "const" <|token(CONST)|> |
| 146 "continue" <|push_token(CONTINUE)|> | 146 "continue" <|token(CONTINUE)|> |
| 147 "debugger" <|push_token(DEBUGGER)|> | 147 "debugger" <|token(DEBUGGER)|> |
| 148 "default" <|push_token(DEFAULT)|> | 148 "default" <|token(DEFAULT)|> |
| 149 "delete" <|push_token(DELETE)|> | 149 "delete" <|token(DELETE)|> |
| 150 "do" <|push_token(DO)|> | 150 "do" <|token(DO)|> |
| 151 "else" <|push_token(ELSE)|> | 151 "else" <|token(ELSE)|> |
| 152 "enum" <|push_token(FUTURE_RESERVED_WORD)|> | 152 "enum" <|token(FUTURE_RESERVED_WORD)|> |
| 153 "export" <|push_harmony_token(modules, EXPORT, FUTURE_RESERVED_WORD)|> | 153 "export" <|harmony_token(modules, EXPORT, FUTURE_RESERVED_WORD)|> |
| 154 "extends" <|push_token(FUTURE_RESERVED_WORD)|> | 154 "extends" <|token(FUTURE_RESERVED_WORD)|> |
| 155 "false" <|push_token(FALSE_LITERAL)|> | 155 "false" <|token(FALSE_LITERAL)|> |
| 156 "finally" <|push_token(FINALLY)|> | 156 "finally" <|token(FINALLY)|> |
| 157 "for" <|push_token(FOR)|> | 157 "for" <|token(FOR)|> |
| 158 "function" <|push_token(FUNCTION)|> | 158 "function" <|token(FUNCTION)|> |
| 159 "if" <|push_token(IF)|> | 159 "if" <|token(IF)|> |
| 160 "implements" <|push_token(FUTURE_STRICT_RESERVED_WORD)|> | 160 "implements" <|token(FUTURE_STRICT_RESERVED_WORD)|> |
| 161 "import" <|push_harmony_token(modules, IMPORT, FUTURE_RESERVED_WORD)|> | 161 "import" <|harmony_token(modules, IMPORT, FUTURE_RESERVED_WORD)|> |
| 162 "in" <|push_token(IN)|> | 162 "in" <|token(IN)|> |
| 163 "instanceof" <|push_token(INSTANCEOF)|> | 163 "instanceof" <|token(INSTANCEOF)|> |
| 164 "interface" <|push_token(FUTURE_STRICT_RESERVED_WORD)|> | 164 "interface" <|token(FUTURE_STRICT_RESERVED_WORD)|> |
| 165 "let" <|push_harmony_token(scoping, LET, FUTURE_STRICT_RESERVED_WORD)|> | 165 "let" <|harmony_token(scoping, LET, FUTURE_STRICT_RESERVED_WORD)|> |
| 166 "new" <|push_token(NEW)|> | 166 "new" <|token(NEW)|> |
| 167 "null" <|push_token(NULL_LITERAL)|> | 167 "null" <|token(NULL_LITERAL)|> |
| 168 "package" <|push_token(FUTURE_STRICT_RESERVED_WORD)|> | 168 "package" <|token(FUTURE_STRICT_RESERVED_WORD)|> |
| 169 "private" <|push_token(FUTURE_STRICT_RESERVED_WORD)|> | 169 "private" <|token(FUTURE_STRICT_RESERVED_WORD)|> |
| 170 "protected" <|push_token(FUTURE_STRICT_RESERVED_WORD)|> | 170 "protected" <|token(FUTURE_STRICT_RESERVED_WORD)|> |
| 171 "public" <|push_token(FUTURE_STRICT_RESERVED_WORD)|> | 171 "public" <|token(FUTURE_STRICT_RESERVED_WORD)|> |
| 172 "return" <|push_token(RETURN)|> | 172 "return" <|token(RETURN)|> |
| 173 "static" <|push_token(FUTURE_STRICT_RESERVED_WORD)|> | 173 "static" <|token(FUTURE_STRICT_RESERVED_WORD)|> |
| 174 "super" <|push_token(FUTURE_RESERVED_WORD)|> | 174 "super" <|token(FUTURE_RESERVED_WORD)|> |
| 175 "switch" <|push_token(SWITCH)|> | 175 "switch" <|token(SWITCH)|> |
| 176 "this" <|push_token(THIS)|> | 176 "this" <|token(THIS)|> |
| 177 "throw" <|push_token(THROW)|> | 177 "throw" <|token(THROW)|> |
| 178 "true" <|push_token(TRUE_LITERAL)|> | 178 "true" <|token(TRUE_LITERAL)|> |
| 179 "try" <|push_token(TRY)|> | 179 "try" <|token(TRY)|> |
| 180 "typeof" <|push_token(TYPEOF)|> | 180 "typeof" <|token(TYPEOF)|> |
| 181 "var" <|push_token(VAR)|> | 181 "var" <|token(VAR)|> |
| 182 "void" <|push_token(VOID)|> | 182 "void" <|token(VOID)|> |
| 183 "while" <|push_token(WHILE)|> | 183 "while" <|token(WHILE)|> |
| 184 "with" <|push_token(WITH)|> | 184 "with" <|token(WITH)|> |
| 185 "yield" <|push_token(YIELD)|> | 185 "yield" <|token(YIELD)|> |
| 186 | 186 |
| 187 identifier_start <|push_token(IDENTIFIER)|Identifier> | 187 identifier_start <|token(IDENTIFIER)|Identifier> |
| 188 /\\u[:hex_digit:]{4}/ <{ | 188 /\\u[:hex_digit:]{4}/ <{ |
| 189 if (V8_UNLIKELY(!ValidIdentifierStart())) { | 189 if (V8_UNLIKELY(!ValidIdentifierStart())) { |
| 190 goto default_action; | 190 goto default_action; |
| 191 } | 191 } |
| 192 }|push_token(IDENTIFIER)|Identifier> | 192 }|token(IDENTIFIER)|Identifier> |
| 193 | 193 |
| 194 eos <|terminate|> | 194 eos <|terminate|> |
| 195 default_action <push_token_and_go_forward(ILLEGAL)> | 195 default_action <do_token_and_go_forward(ILLEGAL)> |
| 196 | 196 |
| 197 <<DoubleQuoteString>> | 197 <<DoubleQuoteString>> |
| 198 "\\" line_terminator_sequence <||continue> | 198 "\\" line_terminator_sequence <||continue> |
| 199 /\\[x][:hex_digit:]{2}/ <||continue> | 199 /\\[x][:hex_digit:]{2}/ <||continue> |
| 200 /\\[u][:hex_digit:]{4}/ <||continue> | 200 /\\[u][:hex_digit:]{4}/ <||continue> |
| 201 /\\[^xu:line_terminator:]/ <||continue> | 201 /\\[^xu:line_terminator:]/ <||continue> |
| 202 "\\" <|push_token(ILLEGAL)|> | 202 "\\" <|token(ILLEGAL)|> |
| 203 line_terminator <|push_token(ILLEGAL)|> | 203 line_terminator <|token(ILLEGAL)|> |
| 204 "\"" <|push_token(STRING)|> | 204 "\"" <|token(STRING)|> |
| 205 eos <|terminate_illegal|> | 205 eos <|terminate_illegal|> |
| 206 catch_all <||continue> | 206 catch_all <||continue> |
| 207 | 207 |
| 208 <<SingleQuoteString>> | 208 <<SingleQuoteString>> |
| 209 # TODO subgraph for '\' | 209 # TODO subgraph for '\' |
| 210 "\\" line_terminator_sequence <||continue> | 210 "\\" line_terminator_sequence <||continue> |
| 211 /\\[x][:hex_digit:]{2}/ <||continue> | 211 /\\[x][:hex_digit:]{2}/ <||continue> |
| 212 /\\[u][:hex_digit:]{4}/ <||continue> | 212 /\\[u][:hex_digit:]{4}/ <||continue> |
| 213 /\\[^xu:line_terminator:]/ <||continue> | 213 /\\[^xu:line_terminator:]/ <||continue> |
| 214 "\\" <|push_token(ILLEGAL)|> | 214 "\\" <|token(ILLEGAL)|> |
| 215 line_terminator <|push_token(ILLEGAL)|> | 215 line_terminator <|token(ILLEGAL)|> |
| 216 "'" <|push_token(STRING)|> | 216 "'" <|token(STRING)|> |
| 217 eos <|terminate_illegal|> | 217 eos <|terminate_illegal|> |
| 218 catch_all <||continue> | 218 catch_all <||continue> |
| 219 | 219 |
| 220 <<Identifier>> | 220 <<Identifier>> |
| 221 identifier_char <|push_token(IDENTIFIER)|continue> | 221 identifier_char <|token(IDENTIFIER)|continue> |
| 222 /\\u[:hex_digit:]{4}/ <{ | 222 /\\u[:hex_digit:]{4}/ <{ |
| 223 if (V8_UNLIKELY(!ValidIdentifierPart())) { | 223 if (V8_UNLIKELY(!ValidIdentifierPart())) { |
| 224 goto default_action; | 224 goto default_action; |
| 225 } | 225 } |
| 226 }|push_token(IDENTIFIER)|continue> | 226 }|token(IDENTIFIER)|continue> |
| 227 | 227 |
| 228 <<SingleLineComment>> | 228 <<SingleLineComment>> |
| 229 line_terminator <|push_line_terminator|> | 229 line_terminator <|line_terminator|> |
| 230 eos <|skip_and_terminate|> | 230 eos <|skip_and_terminate|> |
| 231 catch_all <||continue> | 231 catch_all <||continue> |
| 232 | 232 |
| 233 <<MultiLineComment>> | 233 <<MultiLineComment>> |
| 234 /\*+\// <|skip|> | 234 /\*+\// <|skip|> |
| 235 # TODO find a way to generate the below rule | 235 # TODO find a way to generate the below rule |
| 236 /\*+[^\/*]/ <||continue> | 236 /\*+[^\/*]/ <||continue> |
| 237 line_terminator <push_line_terminator||continue> | 237 line_terminator <line_terminator||continue> |
| 238 eos <|terminate_illegal|> | 238 eos <|terminate_illegal|> |
| 239 catch_all <||continue> | 239 catch_all <||continue> |
| OLD | NEW |