]> code.delx.au - gnu-emacs/blob - lisp/cedet/semantic/wisent/js-wy.el
Convert consecutive FSF copyright years to ranges.
[gnu-emacs] / lisp / cedet / semantic / wisent / js-wy.el
1 ;;; semantic/wisent/js-wy.el --- Generated parser support file
2
3 ;; Copyright (C) 2005, 2009-2011 Free Software Foundation, Inc.
4
5 ;; This file is part of GNU Emacs.
6
7 ;; GNU Emacs is free software: you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation, either version 3 of the License, or
10 ;; (at your option) any later version.
11
12 ;; GNU Emacs is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
16
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
19
20 ;;; Commentary:
21 ;;
22 ;; This file was generated from the grammar file
23 ;; semantic/wisent/wisent-javascript-jv.wy in the CEDET repository.
24
25 ;;; Code:
26 (require 'semantic/lex)
27 \f
28 ;;; Prologue
29 ;;
30 \f
31 ;;; Declarations
32 ;;
33 (defconst wisent-javascript-jv-wy--keyword-table
34 (semantic-lex-make-keyword-table
35 '(("if" . IF)
36 ("break" . BREAK)
37 ("continue" . CONTINUE)
38 ("else" . ELSE)
39 ("for" . FOR)
40 ("function" . FUNCTION)
41 ("this" . THIS)
42 ("return" . RETURN)
43 ("while" . WHILE)
44 ("void" . VOID_SYMBOL)
45 ("new" . NEW)
46 ("delete" . DELETE)
47 ("var" . VAR)
48 ("with" . WITH)
49 ("typeof" . TYPEOF)
50 ("in" . IN))
51 '(("in" summary "in something")
52 ("typeof" summary "typeof ")
53 ("with" summary "with ")
54 ("var" summary "var <variablename> [= value];")
55 ("delete" summary "delete(<objectreference>) - Deletes the object.")
56 ("new" summary "new <objecttype> - Creates a new object.")
57 ("void" summary "Method return type: void <name> ...")
58 ("while" summary "while (<expr>) <stmt> | do <stmt> while (<expr>);")
59 ("return" summary "return [<expr>] ;")
60 ("this" summary "this")
61 ("function" summary "function declaration blah blah")
62 ("for" summary "for ([<init-expr>]; [<expr>]; [<update-expr>]) <stmt>")
63 ("else" summary "if (<expr>) <stmt> else <stmt>")
64 ("continue" summary "continue [<label>] ;")
65 ("break" summary "break [<label>] ;")
66 ("if" summary "if (<expr>) <stmt> [else <stmt>] (jv)")))
67 "Table of language keywords.")
68
69 (defconst wisent-javascript-jv-wy--token-table
70 (semantic-lex-make-type-table
71 '(("<no-type>"
72 (NULL_TOKEN)
73 (QUERY)
74 (TRUE)
75 (FALSE))
76 ("number"
77 (NUMBER))
78 ("string"
79 (STRING))
80 ("symbol"
81 (VARIABLE))
82 ("close-paren"
83 (CLOSE_SQ_BRACKETS . "]")
84 (END_BLOCK . "}")
85 (CLOSE_PARENTHESIS . ")"))
86 ("open-paren"
87 (OPEN_SQ_BRACKETS . "[")
88 (START_BLOCK . "{")
89 (OPEN_PARENTHESIS . "("))
90 ("block"
91 (BRACK_BLOCK . "(OPEN_SQ_BRACKETS CLOSE_SQ_BRACKETS)")
92 (BRACE_BLOCK . "(START_BLOCK END_BLOCK)")
93 (PAREN_BLOCK . "(OPEN_PARENTHESIS CLOSE_PARENTHESIS)"))
94 ("punctuation"
95 (ONES_COMPLIMENT . "~")
96 (SEMICOLON . ";")
97 (LINE_TERMINATOR . "\n")
98 (LESS_THAN . "<")
99 (DOT . ".")
100 (COMMA . ",")
101 (COLON . ":")
102 (DIV . "/")
103 (DECREMENT . "--")
104 (INCREMENT . "++")
105 (PLUS_EQUALS . "+=")
106 (PLUS . "+")
107 (MULTIPLY_EQUALS . "*=")
108 (MULTIPLY . "*")
109 (MOD_EQUALS . "%=")
110 (MOD . "%")
111 (MINUS_EQUALS . "-=")
112 (MINUS . "-")
113 (LS_EQUAL . "<=")
114 (LOGICAL_NOT . "!!")
115 (LOGICAL_OR . "||")
116 (LOGICAL_AND . "&&")
117 (GT_EQUAL . ">=")
118 (GREATER_THAN . ">")
119 (EQUALS . "==")
120 (DIV_EQUALS . "/=")
121 (NOT_EQUAL . "!=")
122 (BITWISE_SHIFT_RIGHT_ZERO_FILL_EQUALS . ">>>=")
123 (BITWISE_SHIFT_RIGHT_ZERO_FILL . ">>>")
124 (BITWISE_SHIFT_RIGHT_EQUALS . ">>=")
125 (BITWISE_SHIFT_RIGHT . ">>")
126 (BITWISE_SHIFT_LEFT_EQUALS . "<<=")
127 (BITWISE_SHIFT_LEFT . "<<")
128 (BITWISE_OR_EQUALS . "|=")
129 (BITWISE_OR . "|")
130 (BITWISE_EXCLUSIVE_OR_EQUALS . "^=")
131 (BITWISE_EXCLUSIVE_OR . "^")
132 (BITWISE_AND_EQUALS . "&=")
133 (BITWISE_AND . "&")
134 (ASSIGN_SYMBOL . "=")))
135 '(("number" :declared t)
136 ("string" :declared t)
137 ("symbol" :declared t)
138 ("keyword" :declared t)
139 ("block" :declared t)
140 ("punctuation" :declared t)))
141 "Table of lexical tokens.")
142
143 (defconst wisent-javascript-jv-wy--parse-table
144 (progn
145 (eval-when-compile
146 (require 'semantic/wisent/comp))
147 (wisent-compile-grammar
148 '((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)
149 ((left PLUS MINUS)
150 (left MULTIPLY DIV MOD)
151 (nonassoc FALSE)
152 (nonassoc HIGHER_THAN_FALSE)
153 (nonassoc ELSE)
154 (nonassoc LOWER_THAN_CLOSE_PARENTHESIS)
155 (nonassoc CLOSE_PARENTHESIS))
156 (Program
157 ((SourceElement)))
158 (SourceElement
159 ((Statement))
160 ((FunctionDeclaration)))
161 (Statement
162 ((Block))
163 ((VariableStatement))
164 ((EmptyStatement))
165 ((ExpressionStatement))
166 ((IfStatement))
167 ((IterationExpression))
168 ((ContinueStatement))
169 ((BreakStatement))
170 ((ReturnStatement))
171 ((WithStatement)))
172 (FunctionDeclaration
173 ((FUNCTION VARIABLE FormalParameterListBlock Block)
174 (wisent-raw-tag
175 (semantic-tag-new-function $2 nil $3))))
176 (FormalParameterListBlock
177 ((PAREN_BLOCK)
178 (semantic-parse-region
179 (car $region1)
180 (cdr $region1)
181 'FormalParameterList 1)))
182 (FormalParameterList
183 ((OPEN_PARENTHESIS)
184 nil)
185 ((VARIABLE)
186 (wisent-raw-tag
187 (semantic-tag-new-variable $1 nil nil)))
188 ((CLOSE_PARENTHESIS)
189 nil)
190 ((COMMA)
191 nil))
192 (StatementList
193 ((Statement))
194 ((StatementList Statement)))
195 (Block
196 ((BRACE_BLOCK)))
197 (BlockExpand
198 ((START_BLOCK StatementList END_BLOCK))
199 ((START_BLOCK END_BLOCK)))
200 (VariableStatement
201 ((VAR VariableDeclarationList SEMICOLON)
202 (wisent-raw-tag
203 (semantic-tag-new-variable $2 nil nil))))
204 (VariableDeclarationList
205 ((VariableDeclaration)
206 (list $1))
207 ((VariableDeclarationList COMMA VariableDeclaration)
208 (append $1
209 (list $3))))
210 (VariableDeclaration
211 ((VARIABLE)
212 (append
213 (list $1 nil)
214 $region))
215 ((VARIABLE Initializer)
216 (append
217 (cons $1 $2)
218 $region)))
219 (Initializer
220 ((ASSIGN_SYMBOL AssignmentExpression)
221 (list $2)))
222 (EmptyStatement
223 ((SEMICOLON)))
224 (ExpressionStatement
225 ((Expression SEMICOLON)))
226 (IfStatement
227 ((IF OPEN_PARENTHESIS Expression CLOSE_PARENTHESIS Statement)
228 [HIGHER_THAN_FALSE])
229 ((IF OPEN_PARENTHESIS Expression CLOSE_PARENTHESIS Statement ELSE Statement))
230 ((IF OPEN_PARENTHESIS FALSE CLOSE_PARENTHESIS Statement))
231 ((IF OPEN_PARENTHESIS LeftHandSideExpression AssignmentOperator AssignmentExpression CLOSE_PARENTHESIS Statement)))
232 (IterationExpression
233 ((WHILE OPEN_PARENTHESIS Expression CLOSE_PARENTHESIS Statement)
234 [HIGHER_THAN_FALSE])
235 ((WHILE OPEN_PARENTHESIS FALSE CLOSE_PARENTHESIS Statement))
236 ((WHILE OPEN_PARENTHESIS LeftHandSideExpression AssignmentOperator AssignmentExpression CLOSE_PARENTHESIS Statement))
237 ((FOR OPEN_PARENTHESIS OptionalExpression SEMICOLON OptionalExpression SEMICOLON OptionalExpression CLOSE_PARENTHESIS Statement))
238 ((FOR OPEN_PARENTHESIS VAR VariableDeclarationList SEMICOLON OptionalExpression SEMICOLON OptionalExpression CLOSE_PARENTHESIS Statement))
239 ((FOR OPEN_PARENTHESIS LeftHandSideExpression IN Expression CLOSE_PARENTHESIS Statement))
240 ((FOR OPEN_PARENTHESIS VAR VARIABLE OptionalInitializer IN Expression CLOSE_PARENTHESIS Statement)))
241 (ContinueStatement
242 ((CONTINUE SEMICOLON)))
243 (BreakStatement
244 ((BREAK SEMICOLON)))
245 (ReturnStatement
246 ((RETURN Expression SEMICOLON))
247 ((RETURN SEMICOLON)))
248 (WithStatement
249 ((WITH OPEN_PARENTHESIS Expression CLOSE_PARENTHESIS Statement)))
250 (OptionalInitializer
251 ((Initializer))
252 (nil))
253 (PrimaryExpression
254 ((THIS))
255 ((VARIABLE))
256 ((NUMBER))
257 ((STRING))
258 ((NULL_TOKEN))
259 ((TRUE))
260 ((FALSE))
261 ((OPEN_PARENTHESIS Expression CLOSE_PARENTHESIS)))
262 (MemberExpression
263 ((PrimaryExpression))
264 ((MemberExpression OPEN_SQ_BRACKETS Expression CLOSE_SQ_BRACKETS))
265 ((MemberExpression DOT VARIABLE))
266 ((NEW MemberExpression Arguments)))
267 (NewExpression
268 ((MemberExpression))
269 ((NEW NewExpression)))
270 (CallExpression
271 ((MemberExpression Arguments))
272 ((CallExpression Arguments))
273 ((CallExpression OPEN_SQ_BRACKETS Expression CLOSE_SQ_BRACKETS))
274 ((CallExpression DOT VARIABLE)))
275 (Arguments
276 ((OPEN_PARENTHESIS CLOSE_PARENTHESIS))
277 ((OPEN_PARENTHESIS ArgumentList CLOSE_PARENTHESIS)))
278 (ArgumentList
279 ((AssignmentExpression))
280 ((ArgumentList COMMA AssignmentExpression)))
281 (LeftHandSideExpression
282 ((NewExpression))
283 ((CallExpression)))
284 (PostfixExpression
285 ((LeftHandSideExpression))
286 ((LeftHandSideExpression INCREMENT))
287 ((LeftHandSideExpression DECREMENT)))
288 (UnaryExpression
289 ((PostfixExpression))
290 ((DELETE UnaryExpression))
291 ((VOID_SYMBOL UnaryExpression))
292 ((TYPEOF UnaryExpression))
293 ((INCREMENT UnaryExpression))
294 ((DECREMENT UnaryExpression))
295 ((PLUS UnaryExpression))
296 ((MINUS UnaryExpression))
297 ((ONES_COMPLIMENT UnaryExpression))
298 ((LOGICAL_NOT UnaryExpression)))
299 (MultiplicativeExpression
300 ((UnaryExpression))
301 ((MultiplicativeExpression MULTIPLY UnaryExpression))
302 ((MultiplicativeExpression DIV UnaryExpression))
303 ((MultiplicativeExpression MOD UnaryExpression)))
304 (AdditiveExpression
305 ((MultiplicativeExpression))
306 ((AdditiveExpression PLUS MultiplicativeExpression))
307 ((AdditiveExpression MINUS MultiplicativeExpression)))
308 (ShiftExpression
309 ((AdditiveExpression))
310 ((ShiftExpression BITWISE_SHIFT_LEFT AdditiveExpression))
311 ((ShiftExpression BITWISE_SHIFT_RIGHT AdditiveExpression))
312 ((ShiftExpression BITWISE_SHIFT_RIGHT_ZERO_FILL AdditiveExpression)))
313 (RelationalExpression
314 ((ShiftExpression))
315 ((RelationalExpression LESS_THAN ShiftExpression))
316 ((RelationalExpression GREATER_THAN ShiftExpression))
317 ((RelationalExpression LS_EQUAL ShiftExpression))
318 ((RelationalExpression GT_EQUAL ShiftExpression)))
319 (EqualityExpression
320 ((RelationalExpression))
321 ((EqualityExpression EQUALS RelationalExpression))
322 ((EqualityExpression NOT_EQUAL RelationalExpression)))
323 (BitwiseANDExpression
324 ((EqualityExpression))
325 ((BitwiseANDExpression BITWISE_AND EqualityExpression)))
326 (BitwiseXORExpression
327 ((BitwiseANDExpression))
328 ((BitwiseXORExpression BITWISE_EXCLUSIVE_OR BitwiseANDExpression)))
329 (BitwiseORExpression
330 ((BitwiseXORExpression))
331 ((BitwiseORExpression BITWISE_OR BitwiseXORExpression)))
332 (LogicalANDExpression
333 ((BitwiseORExpression))
334 ((LogicalANDExpression LOGICAL_AND BitwiseORExpression)))
335 (LogicalORExpression
336 ((LogicalANDExpression))
337 ((LogicalORExpression LOGICAL_OR LogicalANDExpression)))
338 (ConditionalExpression
339 ((LogicalORExpression))
340 ((LogicalORExpression QUERY AssignmentExpression COLON AssignmentExpression)))
341 (AssignmentExpression
342 ((ConditionalExpression))
343 ((LeftHandSideExpression AssignmentOperator AssignmentExpression)
344 [LOWER_THAN_CLOSE_PARENTHESIS]))
345 (AssignmentOperator
346 ((ASSIGN_SYMBOL))
347 ((MULTIPLY_EQUALS))
348 ((DIV_EQUALS))
349 ((MOD_EQUALS))
350 ((PLUS_EQUALS))
351 ((MINUS_EQUALS))
352 ((BITWISE_SHIFT_LEFT_EQUALS))
353 ((BITWISE_SHIFT_RIGHT_EQUALS))
354 ((BITWISE_SHIFT_RIGHT_ZERO_FILL_EQUALS))
355 ((BITWISE_AND_EQUALS))
356 ((BITWISE_EXCLUSIVE_OR_EQUALS))
357 ((BITWISE_OR_EQUALS)))
358 (Expression
359 ((AssignmentExpression))
360 ((Expression COMMA AssignmentExpression)))
361 (OptionalExpression
362 ((Expression))
363 (nil)))
364 '(Program FormalParameterList)))
365 "Parser table.")
366
367 (defun wisent-javascript-jv-wy--install-parser ()
368 "Setup the Semantic Parser."
369 (semantic-install-function-overrides
370 '((parse-stream . wisent-parse-stream)))
371 (setq semantic-parser-name "LALR"
372 semantic--parse-table wisent-javascript-jv-wy--parse-table
373 semantic-debug-parser-source "wisent-javascript-jv.wy"
374 semantic-flex-keywords-obarray wisent-javascript-jv-wy--keyword-table
375 semantic-lex-types-obarray wisent-javascript-jv-wy--token-table)
376 ;; Collect unmatched syntax lexical tokens
377 (semantic-make-local-hook 'wisent-discarding-token-functions)
378 (add-hook 'wisent-discarding-token-functions
379 'wisent-collect-unmatched-syntax nil t))
380
381 \f
382 ;;; Analyzers
383 ;;
384 (define-lex-keyword-type-analyzer wisent-javascript-jv-wy--<keyword>-keyword-analyzer
385 "keyword analyzer for <keyword> tokens."
386 "\\(\\sw\\|\\s_\\)+")
387
388 (define-lex-block-type-analyzer wisent-javascript-jv-wy--<block>-block-analyzer
389 "block analyzer for <block> tokens."
390 "\\s(\\|\\s)"
391 '((("(" OPEN_PARENTHESIS PAREN_BLOCK)
392 ("{" START_BLOCK BRACE_BLOCK)
393 ("[" OPEN_SQ_BRACKETS BRACK_BLOCK))
394 (")" CLOSE_PARENTHESIS)
395 ("}" END_BLOCK)
396 ("]" CLOSE_SQ_BRACKETS))
397 )
398
399 (define-lex-regex-type-analyzer wisent-javascript-jv-wy--<symbol>-regexp-analyzer
400 "regexp analyzer for <symbol> tokens."
401 "\\(\\sw\\|\\s_\\)+"
402 nil
403 'VARIABLE)
404
405 (define-lex-sexp-type-analyzer wisent-javascript-jv-wy--<string>-sexp-analyzer
406 "sexp analyzer for <string> tokens."
407 "\\s\""
408 'STRING)
409
410 (define-lex-regex-type-analyzer wisent-javascript-jv-wy--<number>-regexp-analyzer
411 "regexp analyzer for <number> tokens."
412 semantic-lex-number-expression
413 nil
414 'NUMBER)
415
416 (define-lex-string-type-analyzer wisent-javascript-jv-wy--<punctuation>-string-analyzer
417 "string analyzer for <punctuation> tokens."
418 "\\(\\s.\\|\\s$\\|\\s'\\)+"
419 '((ONES_COMPLIMENT . "~")
420 (SEMICOLON . ";")
421 (LINE_TERMINATOR . "\n")
422 (LESS_THAN . "<")
423 (DOT . ".")
424 (COMMA . ",")
425 (COLON . ":")
426 (DIV . "/")
427 (DECREMENT . "--")
428 (INCREMENT . "++")
429 (PLUS_EQUALS . "+=")
430 (PLUS . "+")
431 (MULTIPLY_EQUALS . "*=")
432 (MULTIPLY . "*")
433 (MOD_EQUALS . "%=")
434 (MOD . "%")
435 (MINUS_EQUALS . "-=")
436 (MINUS . "-")
437 (LS_EQUAL . "<=")
438 (LOGICAL_NOT . "!!")
439 (LOGICAL_OR . "||")
440 (LOGICAL_AND . "&&")
441 (GT_EQUAL . ">=")
442 (GREATER_THAN . ">")
443 (EQUALS . "==")
444 (DIV_EQUALS . "/=")
445 (NOT_EQUAL . "!=")
446 (BITWISE_SHIFT_RIGHT_ZERO_FILL_EQUALS . ">>>=")
447 (BITWISE_SHIFT_RIGHT_ZERO_FILL . ">>>")
448 (BITWISE_SHIFT_RIGHT_EQUALS . ">>=")
449 (BITWISE_SHIFT_RIGHT . ">>")
450 (BITWISE_SHIFT_LEFT_EQUALS . "<<=")
451 (BITWISE_SHIFT_LEFT . "<<")
452 (BITWISE_OR_EQUALS . "|=")
453 (BITWISE_OR . "|")
454 (BITWISE_EXCLUSIVE_OR_EQUALS . "^=")
455 (BITWISE_EXCLUSIVE_OR . "^")
456 (BITWISE_AND_EQUALS . "&=")
457 (BITWISE_AND . "&")
458 (ASSIGN_SYMBOL . "="))
459 'punctuation)
460
461 \f
462 ;;; Epilogue
463 ;;
464 ;;here something like:
465 ;;(define-lex wisent-java-tags-lexer
466 ;; should go
467 (define-lex javascript-lexer-jv
468 "javascript thingy"
469 ;;std stuff
470 semantic-lex-ignore-whitespace
471 semantic-lex-ignore-newline
472 semantic-lex-ignore-comments
473
474 ;;stuff generated from the wy file(one for each "type" declaration)
475 wisent-javascript-jv-wy--<number>-regexp-analyzer
476 wisent-javascript-jv-wy--<string>-sexp-analyzer
477
478 wisent-javascript-jv-wy--<keyword>-keyword-analyzer
479
480 wisent-javascript-jv-wy--<symbol>-regexp-analyzer
481 wisent-javascript-jv-wy--<punctuation>-string-analyzer
482 wisent-javascript-jv-wy--<block>-block-analyzer
483
484
485 ;;;;more std stuff
486 semantic-lex-default-action
487 )
488
489 (provide 'semantic/wisent/js-wy)
490
491 ;;; semantic/wisent/js-wy.el ends here