1 ;;; semantic/wisent/js-wy.el --- Generated parser support file
3 ;; Copyright (C) 2005, 2009-2012 Free Software Foundation, Inc.
4 ;; Copyright (C) 1998-2011 Ecma International
6 ;; This file is part of GNU Emacs.
8 ;; GNU Emacs is free software: you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
13 ;; GNU Emacs is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23 ;; This file was generated from admin/grammars/js.wy.
25 ;; It is derived from the grammar in the ECMAScript Language
26 ;; Specification published at
28 ;; http://www.ecma-international.org/publications/standards/Ecma-262.htm
30 ;; and redistributed under the following license:
32 ;; Redistribution and use in source and binary forms, with or without
33 ;; modification, are permitted provided that the following conditions
36 ;; 1. Redistributions of source code must retain the above copyright
37 ;; notice, this list of conditions and the following disclaimer.
39 ;; 2. Redistributions in binary form must reproduce the above
40 ;; copyright notice, this list of conditions and the following
41 ;; disclaimer in the documentation and/or other materials provided
42 ;; with the distribution.
44 ;; 3. Neither the name of the authors nor Ecma International may be
45 ;; used to endorse or promote products derived from this software
46 ;; without specific prior written permission. THIS SOFTWARE IS
47 ;; PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR
48 ;; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
49 ;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
50 ;; ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR
51 ;; ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
52 ;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
53 ;; OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
54 ;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
55 ;; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
56 ;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
57 ;; USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
62 (require 'semantic
/lex
)
69 (defconst wisent-javascript-jv-wy--keyword-table
70 (semantic-lex-make-keyword-table
73 ("continue" . CONTINUE
)
76 ("function" . FUNCTION
)
80 ("void" . VOID_SYMBOL
)
87 '(("in" summary
"in something")
88 ("typeof" summary
"typeof ")
89 ("with" summary
"with ")
90 ("var" summary
"var <variablename> [= value];")
91 ("delete" summary
"delete(<objectreference>) - Deletes the object.")
92 ("new" summary
"new <objecttype> - Creates a new object.")
93 ("void" summary
"Method return type: void <name> ...")
94 ("while" summary
"while (<expr>) <stmt> | do <stmt> while (<expr>);")
95 ("return" summary
"return [<expr>] ;")
96 ("this" summary
"this")
97 ("function" summary
"function declaration blah blah")
98 ("for" summary
"for ([<init-expr>]; [<expr>]; [<update-expr>]) <stmt>")
99 ("else" summary
"if (<expr>) <stmt> else <stmt>")
100 ("continue" summary
"continue [<label>] ;")
101 ("break" summary
"break [<label>] ;")
102 ("if" summary
"if (<expr>) <stmt> [else <stmt>] (jv)")))
103 "Table of language keywords.")
105 (defconst wisent-javascript-jv-wy--token-table
106 (semantic-lex-make-type-table
119 (CLOSE_SQ_BRACKETS .
"]")
121 (CLOSE_PARENTHESIS .
")"))
123 (OPEN_SQ_BRACKETS .
"[")
125 (OPEN_PARENTHESIS .
"("))
127 (BRACK_BLOCK .
"(OPEN_SQ_BRACKETS CLOSE_SQ_BRACKETS)")
128 (BRACE_BLOCK .
"(START_BLOCK END_BLOCK)")
129 (PAREN_BLOCK .
"(OPEN_PARENTHESIS CLOSE_PARENTHESIS)"))
131 (ONES_COMPLIMENT .
"~")
133 (LINE_TERMINATOR .
"\n")
143 (MULTIPLY_EQUALS .
"*=")
147 (MINUS_EQUALS .
"-=")
158 (BITWISE_SHIFT_RIGHT_ZERO_FILL_EQUALS .
">>>=")
159 (BITWISE_SHIFT_RIGHT_ZERO_FILL .
">>>")
160 (BITWISE_SHIFT_RIGHT_EQUALS .
">>=")
161 (BITWISE_SHIFT_RIGHT .
">>")
162 (BITWISE_SHIFT_LEFT_EQUALS .
"<<=")
163 (BITWISE_SHIFT_LEFT .
"<<")
164 (BITWISE_OR_EQUALS .
"|=")
166 (BITWISE_EXCLUSIVE_OR_EQUALS .
"^=")
167 (BITWISE_EXCLUSIVE_OR .
"^")
168 (BITWISE_AND_EQUALS .
"&=")
170 (ASSIGN_SYMBOL .
"=")))
171 '(("number" :declared t
)
172 ("string" :declared t
)
173 ("symbol" :declared t
)
174 ("keyword" :declared t
)
175 ("block" :declared t
)
176 ("punctuation" :declared t
)))
177 "Table of lexical tokens.")
179 (defconst wisent-javascript-jv-wy--parse-table
182 (require 'semantic
/wisent
/comp
))
183 (wisent-compile-grammar
184 '((ASSIGN_SYMBOL BITWISE_AND BITWISE_AND_EQUALS BITWISE_EXCLUSIVE_OR BITWISE_EXCLUSIVE_OR_EQUALS BITWISE_OR BITWISE_OR_EQUALS BITWISE_SHIFT_LEFT BITWISE_SHIFT_LEFT_EQUALS BITWISE_SHIFT_RIGHT BITWISE_SHIFT_RIGHT_EQUALS BITWISE_SHIFT_RIGHT_ZERO_FILL BITWISE_SHIFT_RIGHT_ZERO_FILL_EQUALS NOT_EQUAL DIV_EQUALS EQUALS GREATER_THAN GT_EQUAL LOGICAL_AND LOGICAL_OR LOGICAL_NOT LS_EQUAL MINUS MINUS_EQUALS MOD MOD_EQUALS MULTIPLY MULTIPLY_EQUALS PLUS PLUS_EQUALS INCREMENT DECREMENT DIV COLON COMMA DOT LESS_THAN LINE_TERMINATOR SEMICOLON ONES_COMPLIMENT PAREN_BLOCK BRACE_BLOCK BRACK_BLOCK OPEN_PARENTHESIS CLOSE_PARENTHESIS START_BLOCK END_BLOCK OPEN_SQ_BRACKETS CLOSE_SQ_BRACKETS IF BREAK CONTINUE ELSE FOR FUNCTION THIS RETURN WHILE VOID_SYMBOL NEW DELETE VAR WITH TYPEOF IN VARIABLE STRING NUMBER FALSE TRUE QUERY NULL_TOKEN
)
186 (left MULTIPLY DIV MOD
)
188 (nonassoc HIGHER_THAN_FALSE
)
190 (nonassoc LOWER_THAN_CLOSE_PARENTHESIS
)
191 (nonassoc CLOSE_PARENTHESIS
))
196 ((FunctionDeclaration)))
199 ((VariableStatement))
201 ((ExpressionStatement))
203 ((IterationExpression))
204 ((ContinueStatement))
209 ((FUNCTION VARIABLE FormalParameterListBlock Block
)
211 (semantic-tag-new-function $
2 nil $
3))))
212 (FormalParameterListBlock
214 (semantic-parse-region
217 'FormalParameterList
1)))
223 (semantic-tag-new-variable $
1 nil nil
)))
230 ((StatementList Statement
)))
234 ((START_BLOCK StatementList END_BLOCK
))
235 ((START_BLOCK END_BLOCK
)))
237 ((VAR VariableDeclarationList SEMICOLON
)
239 (semantic-tag-new-variable $
2 nil nil
))))
240 (VariableDeclarationList
241 ((VariableDeclaration)
243 ((VariableDeclarationList COMMA VariableDeclaration
)
251 ((VARIABLE Initializer
)
256 ((ASSIGN_SYMBOL AssignmentExpression
)
261 ((Expression SEMICOLON
)))
263 ((IF OPEN_PARENTHESIS Expression CLOSE_PARENTHESIS Statement
)
265 ((IF OPEN_PARENTHESIS Expression CLOSE_PARENTHESIS Statement ELSE Statement))
266 ((IF OPEN_PARENTHESIS FALSE CLOSE_PARENTHESIS Statement))
267 ((IF OPEN_PARENTHESIS LeftHandSideExpression AssignmentOperator AssignmentExpression CLOSE_PARENTHESIS Statement)))
269 ((WHILE OPEN_PARENTHESIS Expression CLOSE_PARENTHESIS Statement)
271 ((WHILE OPEN_PARENTHESIS FALSE CLOSE_PARENTHESIS Statement
))
272 ((WHILE OPEN_PARENTHESIS LeftHandSideExpression AssignmentOperator AssignmentExpression CLOSE_PARENTHESIS Statement
))
273 ((FOR OPEN_PARENTHESIS OptionalExpression SEMICOLON OptionalExpression SEMICOLON OptionalExpression CLOSE_PARENTHESIS Statement
))
274 ((FOR OPEN_PARENTHESIS VAR VariableDeclarationList SEMICOLON OptionalExpression SEMICOLON OptionalExpression CLOSE_PARENTHESIS Statement
))
275 ((FOR OPEN_PARENTHESIS LeftHandSideExpression IN Expression CLOSE_PARENTHESIS Statement
))
276 ((FOR OPEN_PARENTHESIS VAR VARIABLE OptionalInitializer IN Expression CLOSE_PARENTHESIS Statement
)))
278 ((CONTINUE SEMICOLON
)))
282 ((RETURN Expression SEMICOLON
))
283 ((RETURN SEMICOLON
)))
285 ((WITH OPEN_PARENTHESIS Expression CLOSE_PARENTHESIS Statement
)))
297 ((OPEN_PARENTHESIS Expression CLOSE_PARENTHESIS
)))
299 ((PrimaryExpression))
300 ((MemberExpression OPEN_SQ_BRACKETS Expression CLOSE_SQ_BRACKETS
))
301 ((MemberExpression DOT VARIABLE
))
302 ((NEW MemberExpression Arguments
)))
305 ((NEW NewExpression
)))
307 ((MemberExpression Arguments
))
308 ((CallExpression Arguments
))
309 ((CallExpression OPEN_SQ_BRACKETS Expression CLOSE_SQ_BRACKETS
))
310 ((CallExpression DOT VARIABLE
)))
312 ((OPEN_PARENTHESIS CLOSE_PARENTHESIS
))
313 ((OPEN_PARENTHESIS ArgumentList CLOSE_PARENTHESIS
)))
315 ((AssignmentExpression))
316 ((ArgumentList COMMA AssignmentExpression
)))
317 (LeftHandSideExpression
321 ((LeftHandSideExpression))
322 ((LeftHandSideExpression INCREMENT
))
323 ((LeftHandSideExpression DECREMENT
)))
325 ((PostfixExpression))
326 ((DELETE UnaryExpression
))
327 ((VOID_SYMBOL UnaryExpression
))
328 ((TYPEOF UnaryExpression
))
329 ((INCREMENT UnaryExpression
))
330 ((DECREMENT UnaryExpression
))
331 ((PLUS UnaryExpression
))
332 ((MINUS UnaryExpression
))
333 ((ONES_COMPLIMENT UnaryExpression
))
334 ((LOGICAL_NOT UnaryExpression
)))
335 (MultiplicativeExpression
337 ((MultiplicativeExpression MULTIPLY UnaryExpression
))
338 ((MultiplicativeExpression DIV UnaryExpression
))
339 ((MultiplicativeExpression MOD UnaryExpression
)))
341 ((MultiplicativeExpression))
342 ((AdditiveExpression PLUS MultiplicativeExpression
))
343 ((AdditiveExpression MINUS MultiplicativeExpression
)))
345 ((AdditiveExpression))
346 ((ShiftExpression BITWISE_SHIFT_LEFT AdditiveExpression
))
347 ((ShiftExpression BITWISE_SHIFT_RIGHT AdditiveExpression
))
348 ((ShiftExpression BITWISE_SHIFT_RIGHT_ZERO_FILL AdditiveExpression
)))
349 (RelationalExpression
351 ((RelationalExpression LESS_THAN ShiftExpression
))
352 ((RelationalExpression GREATER_THAN ShiftExpression
))
353 ((RelationalExpression LS_EQUAL ShiftExpression
))
354 ((RelationalExpression GT_EQUAL ShiftExpression
)))
356 ((RelationalExpression))
357 ((EqualityExpression EQUALS RelationalExpression
))
358 ((EqualityExpression NOT_EQUAL RelationalExpression
)))
359 (BitwiseANDExpression
360 ((EqualityExpression))
361 ((BitwiseANDExpression BITWISE_AND EqualityExpression
)))
362 (BitwiseXORExpression
363 ((BitwiseANDExpression))
364 ((BitwiseXORExpression BITWISE_EXCLUSIVE_OR BitwiseANDExpression
)))
366 ((BitwiseXORExpression))
367 ((BitwiseORExpression BITWISE_OR BitwiseXORExpression
)))
368 (LogicalANDExpression
369 ((BitwiseORExpression))
370 ((LogicalANDExpression LOGICAL_AND BitwiseORExpression
)))
372 ((LogicalANDExpression))
373 ((LogicalORExpression LOGICAL_OR LogicalANDExpression
)))
374 (ConditionalExpression
375 ((LogicalORExpression))
376 ((LogicalORExpression QUERY AssignmentExpression COLON AssignmentExpression
)))
377 (AssignmentExpression
378 ((ConditionalExpression))
379 ((LeftHandSideExpression AssignmentOperator AssignmentExpression
)
380 [LOWER_THAN_CLOSE_PARENTHESIS]))
388 ((BITWISE_SHIFT_LEFT_EQUALS))
389 ((BITWISE_SHIFT_RIGHT_EQUALS))
390 ((BITWISE_SHIFT_RIGHT_ZERO_FILL_EQUALS))
391 ((BITWISE_AND_EQUALS))
392 ((BITWISE_EXCLUSIVE_OR_EQUALS))
393 ((BITWISE_OR_EQUALS)))
395 ((AssignmentExpression))
396 ((Expression COMMA AssignmentExpression)))
400 '(Program FormalParameterList)))
403 (defun wisent-javascript-jv-wy--install-parser ()
404 "Setup the Semantic Parser."
405 (semantic-install-function-overrides
406 '((parse-stream . wisent-parse-stream)))
407 (setq semantic-parser-name "LALR"
408 semantic--parse-table wisent-javascript-jv-wy--parse-table
409 semantic-debug-parser-source "js.wy"
410 semantic-flex-keywords-obarray wisent-javascript-jv-wy--keyword-table
411 semantic-lex-types-obarray wisent-javascript-jv-wy--token-table)
412 ;; Collect unmatched syntax lexical tokens
413 (semantic-make-local-hook 'wisent-discarding-token-functions)
414 (add-hook 'wisent-discarding-token-functions
415 'wisent-collect-unmatched-syntax nil t))
420 (define-lex-string-type-analyzer wisent-javascript-jv-wy--<punctuation>-string-analyzer
421 "string analyzer for <punctuation> tokens."
422 "\\(\\s.\\|\\s$\\|\\s'\\)+"
423 '((ONES_COMPLIMENT . "~")
425 (LINE_TERMINATOR . "\n")
435 (MULTIPLY_EQUALS . "*=")
439 (MINUS_EQUALS . "-=")
450 (BITWISE_SHIFT_RIGHT_ZERO_FILL_EQUALS . ">>>=")
451 (BITWISE_SHIFT_RIGHT_ZERO_FILL . ">>>")
452 (BITWISE_SHIFT_RIGHT_EQUALS . ">>=")
453 (BITWISE_SHIFT_RIGHT . ">>")
454 (BITWISE_SHIFT_LEFT_EQUALS . "<<=")
455 (BITWISE_SHIFT_LEFT . "<<")
456 (BITWISE_OR_EQUALS . "|=")
458 (BITWISE_EXCLUSIVE_OR_EQUALS . "^=")
459 (BITWISE_EXCLUSIVE_OR . "^")
460 (BITWISE_AND_EQUALS . "&=")
462 (ASSIGN_SYMBOL . "="))
465 (define-lex-block-type-analyzer wisent-javascript-jv-wy--<block>-block-analyzer
466 "block analyzer for <block> tokens."
468 '((("(" OPEN_PARENTHESIS PAREN_BLOCK)
469 ("{" START_BLOCK BRACE_BLOCK)
470 ("[" OPEN_SQ_BRACKETS BRACK_BLOCK))
471 (")" CLOSE_PARENTHESIS)
473 ("]" CLOSE_SQ_BRACKETS))
476 (define-lex-regex-type-analyzer wisent-javascript-jv-wy--<symbol>-regexp-analyzer
477 "regexp analyzer for <symbol> tokens."
482 (define-lex-regex-type-analyzer wisent-javascript-jv-wy--<number>-regexp-analyzer
483 "regexp analyzer for <number> tokens."
484 semantic-lex-number-expression
488 (define-lex-sexp-type-analyzer wisent-javascript-jv-wy--<string>-sexp-analyzer
489 "sexp analyzer for <string> tokens."
493 (define-lex-keyword-type-analyzer wisent-javascript-jv-wy--<keyword>-keyword-analyzer
494 "keyword analyzer for <keyword> tokens."
495 "\\(\\sw\\|\\s_\\)+")
500 ;;here something like:
501 ;;(define-lex wisent-java-tags-lexer
503 (define-lex javascript-lexer-jv
506 semantic-lex-ignore-whitespace
507 semantic-lex-ignore-newline
508 semantic-lex-ignore-comments
510 ;;stuff generated from the wy file(one for each "type" declaration)
511 wisent-javascript-jv-wy--<number>-regexp-analyzer
512 wisent-javascript-jv-wy--<string>-sexp-analyzer
514 wisent-javascript-jv-wy--<keyword>-keyword-analyzer
516 wisent-javascript-jv-wy--<symbol>-regexp-analyzer
517 wisent-javascript-jv-wy--<punctuation>-string-analyzer
518 wisent-javascript-jv-wy--<block>-block-analyzer
522 semantic-lex-default-action
525 (provide 'semantic/wisent/js-wy)
527 ;;; semantic/wisent/js-wy.el ends here