| 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 |
| 11 # with the distribution. | 11 # with the distribution. |
| 12 # * Neither the name of Google Inc. nor the names of its | 12 # * Neither the name of Google Inc. nor the names of its |
| 13 # contributors may be used to endorse or promote products derived | 13 # contributors may be used to endorse or promote products derived |
| 14 # from this software without specific prior written permission. | 14 # from this software without specific prior written permission. |
| 15 # | 15 # |
| 16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 # Character classes and auxiliary regexps. |
| 29 |
| 28 line_terminator = [:line_terminator:]; | 30 line_terminator = [:line_terminator:]; |
| 29 identifier_start = [$_:letter:]; | 31 identifier_start = [$_:letter:]; |
| 30 identifier_char = [:identifier_start::identifier_part_not_letter:]; | 32 identifier_char = [:identifier_start::identifier_part_not_letter:]; |
| 31 digit = [0-9]; | 33 digit = [0-9]; |
| 32 hex_digit = [0-9a-fA-F]; | 34 hex_digit = [0-9a-fA-F]; |
| 33 single_escape_char = ['"\\bfnrtv]; | 35 single_escape_char = ['"\\bfnrtv]; |
| 34 maybe_exponent = /([eE][\-+]?[:digit:]+)?/; | 36 maybe_exponent = /([eE][\-+]?[:digit:]+)?/; |
| 35 octal_number = /0[0-7]+/; | 37 octal_number = /0[0-7]+/; |
| 36 | 38 |
| 37 # Octal numbers are pretty complicated. For example, 01.0 is invalid, since it's | 39 # Octal numbers are pretty complicated. For example, 01.0 is invalid, since it's |
| 38 # parsed as 2 numbers (01 and .0), since 01 is a valid octal number. However, | 40 # parsed as 2 numbers (01 and .0), since 01 is a valid octal number. However, |
| 39 # 09.0 is a valid, since 09 cannot be octal. In addition, 0 and 0.1 are valid | 41 # 09.0 is a valid, since 09 cannot be octal. In addition, 0 and 0.1 are valid |
| 40 # numbers starting with 0. | 42 # numbers starting with 0. |
| 41 | 43 |
| 42 non_octal_whole_part = "0" | ( | 44 non_octal_whole_part = "0" | ( |
| 43 /0[:digit:]*[8-9][:digit:]*/ | | 45 /0[:digit:]*[8-9][:digit:]*/ | |
| 44 /[1-9][:digit:]*/ ); | 46 /[1-9][:digit:]*/ ); |
| 45 | 47 |
| 46 number = | 48 number = |
| 47 /0[xX][:hex_digit:]+/ | ( | 49 /0[xX][:hex_digit:]+/ | ( |
| 48 /\.[:digit:]+/ maybe_exponent | | 50 /\.[:digit:]+/ maybe_exponent | |
| 49 non_octal_whole_part /(\.[:digit:]*)?/ maybe_exponent ); | 51 non_octal_whole_part /(\.[:digit:]*)?/ maybe_exponent ); |
| 50 harmony_number = "0"[bBoO][:digit:]+; | 52 harmony_number = "0"[bBoO][:digit:]+; |
| 51 line_terminator_sequence = /[:line_terminator:]|(\r\n|\n\r)/; | 53 line_terminator_sequence = /[:line_terminator:]|(\r\n|\n\r)/; |
| 52 eos = [:eos:]; | 54 eos = [:eos:]; |
| 53 | 55 |
| 54 # grammar is | 56 # Rules. |
| 55 # regex <action_on_state_entry|action_on_match|transition> | 57 |
| 58 # Grammar is |
| 59 # regex <entry_action|match_action|transition> |
| 56 # | 60 # |
| 57 # actions are identifiers to be passed to codegen | 61 # Actions are identifiers to be passed to codegen. |
| 58 # transition must be 'continue' or the name of a subgraph | 62 # |
| 63 # Entry action is executed when we enter the corresponding automaton state, that |
| 64 # is, right after seeing something that matches the regex. Match action is |
| 65 # executed when we have matched the regex but cannot continue to match something |
| 66 # bigger (there is no legal transition out with the next character we're |
| 67 # lexing). |
| 68 # |
| 69 # Transition must be 'continue' or the name of a subgraph. |
| 59 | 70 |
| 60 <<default>> | 71 <<default>> |
| 61 | 72 |
| 62 "|=" <|token(ASSIGN_BIT_OR)|> | 73 "|=" <|token(ASSIGN_BIT_OR)|> |
| 63 "^=" <|token(ASSIGN_BIT_XOR)|> | 74 "^=" <|token(ASSIGN_BIT_XOR)|> |
| 64 "&=" <|token(ASSIGN_BIT_AND)|> | 75 "&=" <|token(ASSIGN_BIT_AND)|> |
| 65 "+=" <|token(ASSIGN_ADD)|> | 76 "+=" <|token(ASSIGN_ADD)|> |
| 66 "-=" <|token(ASSIGN_SUB)|> | 77 "-=" <|token(ASSIGN_SUB)|> |
| 67 "*=" <|token(ASSIGN_MUL)|> | 78 "*=" <|token(ASSIGN_MUL)|> |
| 68 "/=" <|token(ASSIGN_DIV)|> | 79 "/=" <|token(ASSIGN_DIV)|> |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 eos <|skip_and_terminate|> | 238 eos <|skip_and_terminate|> |
| 228 catch_all <||continue> | 239 catch_all <||continue> |
| 229 | 240 |
| 230 <<MultiLineComment>> | 241 <<MultiLineComment>> |
| 231 /\*+\// <|skip|> | 242 /\*+\// <|skip|> |
| 232 # TODO find a way to generate the below rule | 243 # TODO find a way to generate the below rule |
| 233 /\*+[^\/*]/ <||continue> | 244 /\*+[^\/*]/ <||continue> |
| 234 line_terminator <line_terminator_in_multiline_comment||continue> | 245 line_terminator <line_terminator_in_multiline_comment||continue> |
| 235 eos <|terminate_illegal|> | 246 eos <|terminate_illegal|> |
| 236 catch_all <||continue> | 247 catch_all <||continue> |
| OLD | NEW |