Commit | Line | Data |
---|---|---|
62f43d66 CY |
1 | ;;; java-tags.wy -- Semantic LALR grammar for Java |
2 | ||
3 | ;; Copyright (C) 2002-2011 Free Software Foundation, Inc. | |
469d2149 CY |
4 | ;; |
5 | ;; Author: David Ponce <david@dponce.com> | |
6 | ;; Maintainer: David Ponce <david@dponce.com> | |
62f43d66 | 7 | ;; Created: 26 Aug 2002 |
469d2149 | 8 | ;; Keywords: syntax |
62f43d66 CY |
9 | |
10 | ;; This file is part of GNU Emacs. | |
11 | ||
12 | ;; GNU Emacs is free software: you can redistribute it and/or modify | |
13 | ;; it under the terms of the GNU General Public License as published by | |
14 | ;; the Free Software Foundation, either version 3 of the License, or | |
15 | ;; (at your option) any later version. | |
16 | ||
17 | ;; GNU Emacs is distributed in the hope that it will be useful, | |
469d2149 | 18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
62f43d66 CY |
19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20 | ;; GNU General Public License for more details. | |
21 | ||
469d2149 | 22 | ;; You should have received a copy of the GNU General Public License |
62f43d66 | 23 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
469d2149 | 24 | |
f79fbbc7 | 25 | %package wisent-java-tags-wy |
469d2149 CY |
26 | |
27 | %languagemode java-mode | |
28 | ||
29 | ;; The default start symbol | |
30 | %start compilation_unit | |
31 | ;; Alternate entry points | |
32 | ;; - Needed by partial re-parse | |
33 | %start package_declaration | |
34 | %start import_declaration | |
35 | %start class_declaration | |
36 | %start field_declaration | |
37 | %start method_declaration | |
38 | %start formal_parameter | |
39 | %start constructor_declaration | |
40 | %start interface_declaration | |
41 | ;; - Needed by EXPANDFULL clauses | |
42 | %start class_member_declaration | |
43 | %start interface_member_declaration | |
44 | %start formal_parameters | |
45 | ||
46 | ;; ----------------------------- | |
47 | ;; Block & Parenthesis terminals | |
48 | ;; ----------------------------- | |
49 | %type <block> ;;syntax "\\s(\\|\\s)" matchdatatype block | |
50 | ||
51 | %token <block> PAREN_BLOCK "(LPAREN RPAREN)" | |
52 | %token <block> BRACE_BLOCK "(LBRACE RBRACE)" | |
53 | %token <block> BRACK_BLOCK "(LBRACK RBRACK)" | |
54 | ||
55 | %token <open-paren> LPAREN "(" | |
56 | %token <close-paren> RPAREN ")" | |
57 | %token <open-paren> LBRACE "{" | |
58 | %token <close-paren> RBRACE "}" | |
59 | %token <open-paren> LBRACK "[" | |
60 | %token <close-paren> RBRACK "]" | |
61 | ||
62 | ;; ------------------ | |
63 | ;; Operator terminals | |
64 | ;; ------------------ | |
65 | %type <punctuation> ;;syntax "\\(\\s.\\|\\s$\\|\\s'\\)+" matchdatatype string | |
66 | ||
67 | %token <punctuation> NOT "!" | |
68 | %token <punctuation> NOTEQ "!=" | |
69 | %token <punctuation> MOD "%" | |
70 | %token <punctuation> MODEQ "%=" | |
71 | %token <punctuation> AND "&" | |
72 | %token <punctuation> ANDAND "&&" | |
73 | %token <punctuation> ANDEQ "&=" | |
74 | %token <punctuation> MULT "*" | |
75 | %token <punctuation> MULTEQ "*=" | |
76 | %token <punctuation> PLUS "+" | |
77 | %token <punctuation> PLUSPLUS "++" | |
78 | %token <punctuation> PLUSEQ "+=" | |
79 | %token <punctuation> COMMA "," | |
80 | %token <punctuation> MINUS "-" | |
81 | %token <punctuation> MINUSMINUS "--" | |
82 | %token <punctuation> MINUSEQ "-=" | |
83 | %token <punctuation> DOT "." | |
84 | %token <punctuation> DIV "/" | |
85 | %token <punctuation> DIVEQ "/=" | |
86 | %token <punctuation> COLON ":" | |
87 | %token <punctuation> SEMICOLON ";" | |
88 | %token <punctuation> LT "<" | |
89 | %token <punctuation> LSHIFT "<<" | |
90 | %token <punctuation> LSHIFTEQ "<<=" | |
91 | %token <punctuation> LTEQ "<=" | |
92 | %token <punctuation> EQ "=" | |
93 | %token <punctuation> EQEQ "==" | |
94 | %token <punctuation> GT ">" | |
95 | %token <punctuation> GTEQ ">=" | |
96 | %token <punctuation> RSHIFT ">>" | |
97 | %token <punctuation> RSHIFTEQ ">>=" | |
98 | %token <punctuation> URSHIFT ">>>" | |
99 | %token <punctuation> URSHIFTEQ ">>>=" | |
100 | %token <punctuation> QUESTION "?" | |
101 | %token <punctuation> XOR "^" | |
102 | %token <punctuation> XOREQ "^=" | |
103 | %token <punctuation> OR "|" | |
104 | %token <punctuation> OREQ "|=" | |
105 | %token <punctuation> OROR "||" | |
106 | %token <punctuation> COMP "~" | |
107 | ||
108 | ;; ----------------- | |
109 | ;; Literal terminals | |
110 | ;; ----------------- | |
111 | %type <symbol> ;;syntax "\\(\\sw\\|\\s_\\)+" | |
112 | %token <symbol> IDENTIFIER | |
113 | ||
114 | %type <string> ;;syntax "\\s\"" matchdatatype sexp | |
115 | %token <string> STRING_LITERAL | |
116 | ||
117 | %type <number> ;;syntax semantic-lex-number-expression | |
118 | %token <number> NUMBER_LITERAL | |
119 | ||
120 | %type <unicode> syntax "\\\\u[0-9a-f][0-9a-f][0-9a-f][0-9a-f]" | |
121 | %token <unicode> unicodecharacter | |
122 | ||
123 | ;; ----------------- | |
124 | ;; Keyword terminals | |
125 | ;; ----------------- | |
126 | ||
127 | ;; Generate a keyword analyzer | |
128 | %type <keyword> ;;syntax "\\(\\sw\\|\\s_\\)+" matchdatatype keyword | |
129 | ||
130 | %keyword ABSTRACT "abstract" | |
131 | %put ABSTRACT summary | |
132 | "Class|Method declaration modifier: abstract {class|<type>} <name> ..." | |
133 | ||
134 | %keyword BOOLEAN "boolean" | |
135 | %put BOOLEAN summary | |
136 | "Primitive logical quantity type (true or false)" | |
137 | ||
138 | %keyword BREAK "break" | |
139 | %put BREAK summary | |
140 | "break [<label>] ;" | |
141 | ||
142 | %keyword BYTE "byte" | |
143 | %put BYTE summary | |
144 | "Integral primitive type (-128 to 127)" | |
145 | ||
146 | %keyword CASE "case" | |
147 | %put CASE summary | |
148 | "switch(<expr>) {case <const-expr>: <stmts> ... }" | |
149 | ||
150 | %keyword CATCH "catch" | |
151 | %put CATCH summary | |
152 | "try {<stmts>} catch(<parm>) {<stmts>} ... " | |
153 | ||
154 | %keyword CHAR "char" | |
155 | %put CHAR summary | |
156 | "Integral primitive type ('\u0000' to '\uffff') (0 to 65535)" | |
157 | ||
158 | %keyword CLASS "class" | |
159 | %put CLASS summary | |
160 | "Class declaration: class <name>" | |
161 | ||
162 | %keyword CONST "const" | |
163 | %put CONST summary | |
164 | "Unused reserved word" | |
165 | ||
166 | %keyword CONTINUE "continue" | |
167 | %put CONTINUE summary | |
168 | "continue [<label>] ;" | |
169 | ||
170 | %keyword DEFAULT "default" | |
171 | %put DEFAULT summary | |
172 | "switch(<expr>) { ... default: <stmts>}" | |
173 | ||
174 | %keyword DO "do" | |
175 | %put DO summary | |
176 | "do <stmt> while (<expr>);" | |
177 | ||
178 | %keyword DOUBLE "double" | |
179 | %put DOUBLE summary | |
180 | "Primitive floating-point type (double-precision 64-bit IEEE 754)" | |
181 | ||
182 | %keyword ELSE "else" | |
183 | %put ELSE summary | |
184 | "if (<expr>) <stmt> else <stmt>" | |
185 | ||
186 | %keyword EXTENDS "extends" | |
187 | %put EXTENDS summary | |
188 | "SuperClass|SuperInterfaces declaration: extends <name> [, ...]" | |
189 | ||
190 | %keyword FINAL "final" | |
191 | %put FINAL summary | |
192 | "Class|Member declaration modifier: final {class|<type>} <name> ..." | |
193 | ||
194 | %keyword FINALLY "finally" | |
195 | %put FINALLY summary | |
196 | "try {<stmts>} ... finally {<stmts>}" | |
197 | ||
198 | %keyword FLOAT "float" | |
199 | %put FLOAT summary | |
200 | "Primitive floating-point type (single-precision 32-bit IEEE 754)" | |
201 | ||
202 | %keyword FOR "for" | |
203 | %put FOR summary | |
204 | "for ([<init-expr>]; [<expr>]; [<update-expr>]) <stmt>" | |
205 | ||
206 | %keyword GOTO "goto" | |
207 | %put GOTO summary | |
208 | "Unused reserved word" | |
209 | ||
210 | %keyword IF "if" | |
211 | %put IF summary | |
212 | "if (<expr>) <stmt> [else <stmt>]" | |
213 | ||
214 | %keyword IMPLEMENTS "implements" | |
215 | %put IMPLEMENTS summary | |
216 | "Class SuperInterfaces declaration: implements <name> [, ...]" | |
217 | ||
218 | %keyword IMPORT "import" | |
219 | %put IMPORT summary | |
220 | "Import package declarations: import <package>" | |
221 | ||
222 | %keyword INSTANCEOF "instanceof" | |
223 | ||
224 | %keyword INT "int" | |
225 | %put INT summary | |
226 | "Integral primitive type (-2147483648 to 2147483647)" | |
227 | ||
228 | %keyword INTERFACE "interface" | |
229 | %put INTERFACE summary | |
230 | "Interface declaration: interface <name>" | |
231 | ||
232 | %keyword LONG "long" | |
233 | %put LONG summary | |
234 | "Integral primitive type (-9223372036854775808 to 9223372036854775807)" | |
235 | ||
236 | %keyword NATIVE "native" | |
237 | %put NATIVE summary | |
238 | "Method declaration modifier: native <type> <name> ..." | |
239 | ||
240 | %keyword NEW "new" | |
241 | ||
242 | %keyword PACKAGE "package" | |
243 | %put PACKAGE summary | |
244 | "Package declaration: package <name>" | |
245 | ||
246 | %keyword PRIVATE "private" | |
247 | %put PRIVATE summary | |
248 | "Access level modifier: private {class|interface|<type>} <name> ..." | |
249 | ||
250 | %keyword PROTECTED "protected" | |
251 | %put PROTECTED summary | |
252 | "Access level modifier: protected {class|interface|<type>} <name> ..." | |
253 | ||
254 | %keyword PUBLIC "public" | |
255 | %put PUBLIC summary | |
256 | "Access level modifier: public {class|interface|<type>} <name> ..." | |
257 | ||
258 | %keyword RETURN "return" | |
259 | %put RETURN summary | |
260 | "return [<expr>] ;" | |
261 | ||
262 | %keyword SHORT "short" | |
263 | %put SHORT summary | |
264 | "Integral primitive type (-32768 to 32767)" | |
265 | ||
266 | %keyword STATIC "static" | |
267 | %put STATIC summary | |
268 | "Declaration modifier: static {class|interface|<type>} <name> ..." | |
269 | ||
270 | %keyword STRICTFP "strictfp" | |
271 | %put STRICTFP summary | |
272 | "Declaration modifier: strictfp {class|interface|<type>} <name> ..." | |
273 | ||
274 | %keyword SUPER "super" | |
275 | ||
276 | %keyword SWITCH "switch" | |
277 | %put SWITCH summary | |
278 | "switch(<expr>) {[case <const-expr>: <stmts> ...] [default: <stmts>]}" | |
279 | ||
280 | ||
281 | %keyword SYNCHRONIZED "synchronized" | |
282 | %put SYNCHRONIZED summary | |
283 | "synchronized (<expr>) ... | Method decl. modifier: synchronized <type> <name> ..." | |
284 | ||
285 | %keyword THIS "this" | |
286 | ||
287 | %keyword THROW "throw" | |
288 | %put THROW summary | |
289 | "throw <expr> ;" | |
290 | ||
291 | %keyword THROWS "throws" | |
292 | %put THROWS summary | |
293 | "Method|Constructor declaration: throws <classType>, ..." | |
294 | ||
295 | %keyword TRANSIENT "transient" | |
296 | %put TRANSIENT summary | |
297 | "Field declaration modifier: transient <type> <name> ..." | |
298 | ||
299 | %keyword TRY "try" | |
300 | %put TRY summary | |
301 | "try {<stmts>} [catch(<parm>) {<stmts>} ...] [finally {<stmts>}]" | |
302 | ||
303 | %keyword VOID "void" | |
304 | %put VOID summary | |
305 | "Method return type: void <name> ..." | |
306 | ||
307 | %keyword VOLATILE "volatile" | |
308 | %put VOLATILE summary | |
309 | "Field declaration modifier: volatile <type> <name> ..." | |
310 | ||
311 | %keyword WHILE "while" | |
312 | %put WHILE summary | |
313 | "while (<expr>) <stmt> | do <stmt> while (<expr>);" | |
314 | ||
315 | ;; -------------------------- | |
316 | ;; Official javadoc line tags | |
317 | ;; -------------------------- | |
318 | ||
319 | ;; Javadoc tags are identified by a 'javadoc' keyword property. The | |
320 | ;; value of this property must be itself a property list where the | |
321 | ;; following properties are recognized: | |
322 | ;; | |
323 | ;; - `seq' (mandatory) is the tag sequence number used to check if tags | |
324 | ;; are correctly ordered in a javadoc comment block. | |
325 | ;; | |
326 | ;; - `usage' (mandatory) is the list of token categories for which this | |
327 | ;; documentation tag is allowed. | |
328 | ;; | |
329 | ;; - `opt' (optional) if non-nil indicates this is an optional tag. | |
330 | ;; By default tags are mandatory. | |
331 | ;; | |
332 | ;; - `with-name' (optional) if non-nil indicates that this tag is | |
333 | ;; followed by an identifier like in "@param <var-name> description" | |
334 | ;; or "@exception <class-name> description". | |
335 | ;; | |
336 | ;; - `with-ref' (optional) if non-nil indicates that the tag is | |
337 | ;; followed by a reference like in "@see <reference>". | |
338 | ||
339 | %keyword _AUTHOR "@author" | |
340 | %put _AUTHOR javadoc (seq 1 usage (type)) | |
341 | %keyword _VERSION "@version" | |
342 | %put _VERSION javadoc (seq 2 usage (type)) | |
343 | %keyword _PARAM "@param" | |
344 | %put _PARAM javadoc (seq 3 usage (function) with-name t) | |
345 | %keyword _RETURN "@return" | |
346 | %put _RETURN javadoc (seq 4 usage (function)) | |
347 | %keyword _EXCEPTION "@exception" | |
348 | %put _EXCEPTION javadoc (seq 5 usage (function) with-name t) | |
349 | %keyword _THROWS "@throws" | |
350 | %put _THROWS javadoc (seq 6 usage (function) with-name t) | |
351 | %keyword _SEE "@see" | |
352 | %put _SEE javadoc (seq 7 usage (type function variable) opt t with-ref t) | |
353 | %keyword _SINCE "@since" | |
354 | %put _SINCE javadoc (seq 8 usage (type function variable) opt t) | |
355 | %keyword _SERIAL "@serial" | |
356 | %put _SERIAL javadoc (seq 9 usage (variable) opt t) | |
357 | %keyword _SERIALDATA "@serialData" | |
358 | %put _SERIALDATA javadoc (seq 10 usage (function) opt t) | |
359 | %keyword _SERIALFIELD "@serialField" | |
360 | %put _SERIALFIELD javadoc (seq 11 usage (variable) opt t) | |
361 | %keyword _DEPRECATED "@deprecated" | |
362 | %put _DEPRECATED javadoc (seq 12 usage (type function variable) opt t) | |
363 | ||
364 | %% | |
365 | ||
366 | ;; ------------ | |
367 | ;; LALR Grammar | |
368 | ;; ------------ | |
369 | ||
370 | ;; This grammar is not designed to fully parse correct Java syntax. It | |
371 | ;; is optimized to work in an interactive environment to extract tokens | |
372 | ;; (tags) needed by Semantic. In some cases a syntax not allowed by | |
373 | ;; the Java Language Specification will be accepted by this grammar. | |
374 | ||
375 | compilation_unit | |
376 | : package_declaration | |
377 | | import_declaration | |
378 | | type_declaration | |
379 | ; | |
380 | ||
381 | ;;; Package statement token | |
382 | ;; ("NAME" package DETAIL "DOCSTRING") | |
383 | package_declaration | |
384 | : PACKAGE qualified_name SEMICOLON | |
385 | (PACKAGE-TAG $2 nil) | |
386 | ; | |
387 | ||
388 | ;;; Include file token | |
389 | ;; ("FILE" include SYSTEM "DOCSTRING") | |
390 | import_declaration | |
391 | : IMPORT qualified_name SEMICOLON | |
392 | (INCLUDE-TAG $2 nil) | |
393 | | IMPORT qualified_name DOT MULT SEMICOLON | |
394 | (INCLUDE-TAG (concat $2 $3 $4) nil) | |
395 | ; | |
396 | ||
397 | type_declaration | |
398 | : SEMICOLON | |
399 | () | |
400 | | class_declaration | |
401 | | interface_declaration | |
402 | ; | |
403 | ||
404 | ;;; Type Declaration token | |
405 | ;; ("NAME" type "TYPE" ( PART-LIST ) ( PARENTS ) EXTRA-SPEC "DOCSTRING") | |
406 | class_declaration | |
407 | : modifiers_opt CLASS qualified_name superc_opt interfaces_opt class_body | |
408 | (TYPE-TAG $3 $2 $6 (if (or $4 $5) (cons $4 $5)) :typemodifiers $1) | |
409 | ; | |
410 | ||
411 | superc_opt | |
412 | : ;;EMPTY | |
413 | | EXTENDS qualified_name | |
414 | (identity $2) | |
415 | ; | |
416 | ||
417 | interfaces_opt | |
418 | : ;;EMPTY | |
419 | | IMPLEMENTS qualified_name_list | |
420 | (nreverse $2) | |
421 | ; | |
422 | ||
423 | class_body | |
424 | : BRACE_BLOCK | |
425 | (EXPANDFULL $1 class_member_declaration) | |
426 | ; | |
427 | ||
428 | class_member_declaration | |
429 | : LBRACE | |
430 | () | |
431 | | RBRACE | |
432 | () | |
433 | | block | |
434 | () | |
435 | | static_initializer | |
436 | () | |
437 | | constructor_declaration | |
438 | | interface_declaration | |
439 | | class_declaration | |
440 | | method_declaration | |
441 | | field_declaration | |
442 | ; | |
443 | ||
444 | ;;; Type Declaration token | |
445 | ;; ("NAME" type "TYPE" ( PART-LIST ) ( PARENTS ) EXTRA-SPEC "DOCSTRING") | |
446 | interface_declaration | |
447 | : modifiers_opt INTERFACE IDENTIFIER extends_interfaces_opt interface_body | |
448 | (TYPE-TAG $3 $2 $5 (if $4 (cons nil $4)) :typemodifiers $1) | |
449 | ; | |
450 | ||
451 | extends_interfaces_opt | |
452 | : ;;EMPTY | |
453 | | EXTENDS qualified_name_list | |
454 | (identity $2) | |
455 | ; | |
456 | ||
457 | interface_body | |
458 | : BRACE_BLOCK | |
459 | (EXPANDFULL $1 interface_member_declaration) | |
460 | ; | |
461 | ||
462 | interface_member_declaration | |
463 | : LBRACE | |
464 | () | |
465 | | RBRACE | |
466 | () | |
467 | | interface_declaration | |
468 | | class_declaration | |
469 | | method_declaration | |
470 | | field_declaration | |
471 | ; | |
472 | ||
473 | static_initializer | |
474 | : STATIC block | |
475 | ; | |
476 | ||
477 | ;;; Function token | |
478 | ;; ("NAME" function "TYPE" ( ARG-LIST ) EXTRA-SPEC "DOCSTRING") | |
479 | constructor_declaration | |
480 | : modifiers_opt constructor_declarator throwsc_opt constructor_body | |
481 | (FUNCTION-TAG (car $2) nil (cdr $2) | |
482 | :typemodifiers $1 | |
483 | :throws $3 | |
484 | :constructor-flag t) | |
485 | ; | |
486 | ||
487 | constructor_declarator | |
488 | : IDENTIFIER formal_parameter_list | |
489 | (cons $1 $2) | |
490 | ; | |
491 | ||
492 | constructor_body | |
493 | : block | |
494 | ; | |
495 | ||
496 | ;;; Function token | |
497 | ;; ("NAME" function "TYPE" ( ARG-LIST ) EXTRA-SPEC "DOCSTRING") | |
498 | method_declaration | |
499 | : modifiers_opt VOID method_declarator throwsc_opt method_body | |
500 | (FUNCTION-TAG (car $3) $2 (cdr $3) :typemodifiers $1 :throws $4) | |
501 | | modifiers_opt type method_declarator throwsc_opt method_body | |
502 | (FUNCTION-TAG (car $3) $2 (cdr $3) :typemodifiers $1 :throws $4) | |
503 | ; | |
504 | ||
505 | method_declarator | |
506 | : IDENTIFIER formal_parameter_list dims_opt | |
507 | (cons (concat $1 $3) $2) | |
508 | ; | |
509 | ||
510 | throwsc_opt | |
511 | : ;;EMPTY | |
512 | | THROWS qualified_name_list | |
513 | (nreverse $2) | |
514 | ; | |
515 | ||
516 | qualified_name_list | |
517 | : qualified_name_list COMMA qualified_name | |
518 | (cons $3 $1) | |
519 | | qualified_name | |
520 | (list $1) | |
521 | ; | |
522 | ||
523 | method_body | |
524 | : SEMICOLON | |
525 | | block | |
526 | ; | |
527 | ||
528 | ;; Just eat {...} block! | |
529 | block | |
530 | : BRACE_BLOCK | |
531 | ; | |
532 | ||
533 | formal_parameter_list | |
534 | : PAREN_BLOCK | |
535 | (EXPANDFULL $1 formal_parameters) | |
536 | ; | |
537 | ||
538 | formal_parameters | |
539 | : LPAREN | |
540 | () | |
541 | | RPAREN | |
542 | () | |
543 | | formal_parameter COMMA | |
544 | | formal_parameter RPAREN | |
545 | ; | |
546 | ||
547 | ;;; Variable token | |
548 | ;; ("NAME" variable "TYPE" DEFAULT-VALUE EXTRA-SPEC "DOCSTRING") | |
549 | formal_parameter | |
550 | : formal_parameter_modifier_opt type variable_declarator_id | |
551 | (VARIABLE-TAG $3 $2 nil :typemodifiers $1) | |
552 | ; | |
553 | ||
554 | formal_parameter_modifier_opt | |
555 | : ;;EMPTY | |
556 | | FINAL | |
557 | (list $1) | |
558 | ; | |
559 | ||
560 | ;;; Variable token | |
561 | ;; ("NAME" variable "TYPE" DEFAULT-VALUE EXTRA-SPEC "DOCSTRING") | |
562 | field_declaration | |
563 | : modifiers_opt type variable_declarators SEMICOLON | |
564 | (VARIABLE-TAG $3 $2 nil :typemodifiers $1) | |
565 | ; | |
566 | ||
567 | variable_declarators | |
568 | : variable_declarators COMMA variable_declarator | |
569 | (progn | |
570 | ;; Set the end of the compound declaration to the end of the | |
571 | ;; COMMA delimiter. | |
572 | (setcdr (cdr (car $1)) (cdr $region2)) | |
573 | (cons $3 $1)) | |
574 | | variable_declarator | |
575 | (list $1) | |
576 | ; | |
577 | ||
578 | variable_declarator | |
579 | : variable_declarator_id EQ variable_initializer | |
580 | (cons $1 $region) | |
581 | | variable_declarator_id | |
582 | (cons $1 $region) | |
583 | ; | |
584 | ||
585 | variable_declarator_id | |
586 | : IDENTIFIER dims_opt | |
587 | (concat $1 $2) | |
588 | ; | |
589 | ||
590 | variable_initializer | |
591 | : expression | |
592 | ; | |
593 | ||
594 | ;; Just eat expression! | |
595 | expression | |
596 | : expression term | |
597 | | term | |
598 | ; | |
599 | ||
600 | term | |
601 | : literal | |
602 | | operator | |
603 | | primitive_type | |
604 | | IDENTIFIER | |
605 | | BRACK_BLOCK | |
606 | | PAREN_BLOCK | |
607 | | BRACE_BLOCK | |
608 | | NEW | |
609 | | CLASS | |
610 | | THIS | |
611 | | SUPER | |
612 | ; | |
613 | ||
614 | literal | |
615 | ;; : NULL_LITERAL | |
616 | ;; | BOOLEAN_LITERAL | |
617 | : STRING_LITERAL | |
618 | | NUMBER_LITERAL | |
619 | ; | |
620 | ||
621 | operator | |
622 | : NOT | |
623 | | PLUS | |
624 | | PLUSPLUS | |
625 | | MINUS | |
626 | | MINUSMINUS | |
627 | | NOTEQ | |
628 | | MOD | |
629 | | MODEQ | |
630 | | AND | |
631 | | ANDAND | |
632 | | ANDEQ | |
633 | | MULT | |
634 | | MULTEQ | |
635 | | PLUSEQ | |
636 | | MINUSEQ | |
637 | | DOT | |
638 | | DIV | |
639 | | DIVEQ | |
640 | | COLON | |
641 | | LT | |
642 | | LSHIFT | |
643 | | LSHIFTEQ | |
644 | | LTEQ | |
645 | | EQ | |
646 | | EQEQ | |
647 | | GT | |
648 | | GTEQ | |
649 | | RSHIFT | |
650 | | RSHIFTEQ | |
651 | | URSHIFT | |
652 | | URSHIFTEQ | |
653 | | QUESTION | |
654 | | XOR | |
655 | | XOREQ | |
656 | | OR | |
657 | | OREQ | |
658 | | OROR | |
659 | | COMP | |
660 | | INSTANCEOF | |
661 | ; | |
662 | ||
663 | primitive_type | |
664 | : BOOLEAN | |
665 | | CHAR | |
666 | | LONG | |
667 | | INT | |
668 | | SHORT | |
669 | | BYTE | |
670 | | DOUBLE | |
671 | | FLOAT | |
672 | ; | |
673 | ||
674 | modifiers_opt | |
675 | : ;;EMPTY | |
676 | | modifiers | |
677 | (nreverse $1) | |
678 | ; | |
679 | ||
680 | modifiers | |
681 | : modifiers modifier | |
682 | (cons $2 $1) | |
683 | | modifier | |
684 | (list $1) | |
685 | ; | |
686 | ||
687 | modifier | |
688 | : STRICTFP | |
689 | | VOLATILE | |
690 | | TRANSIENT | |
691 | | SYNCHRONIZED | |
692 | | NATIVE | |
693 | | FINAL | |
694 | | ABSTRACT | |
695 | | STATIC | |
696 | | PRIVATE | |
697 | | PROTECTED | |
698 | | PUBLIC | |
699 | ; | |
700 | ||
701 | type | |
702 | : qualified_name dims_opt | |
703 | (concat $1 $2) | |
704 | | primitive_type dims_opt | |
705 | (concat $1 $2) | |
706 | ; | |
707 | ||
708 | qualified_name | |
709 | : qualified_name DOT IDENTIFIER | |
710 | (concat $1 $2 $3) | |
711 | | IDENTIFIER | |
712 | ; | |
713 | ||
714 | dims_opt | |
715 | : ;;EMPTY | |
716 | (identity "") | |
717 | | dims | |
718 | ; | |
719 | ||
720 | dims | |
721 | : dims BRACK_BLOCK | |
722 | (concat $1 "[]") | |
723 | | BRACK_BLOCK | |
724 | (identity "[]") | |
725 | ; | |
726 | ||
727 | %% | |
728 | ;; Define the lexer for this grammar | |
729 | (define-lex wisent-java-tags-lexer | |
730 | "Lexical analyzer that handles Java buffers. | |
731 | It ignores whitespaces, newlines and comments." | |
732 | semantic-lex-ignore-whitespace | |
733 | semantic-lex-ignore-newline | |
734 | semantic-lex-ignore-comments | |
735 | ;;;; Auto-generated analyzers. | |
f79fbbc7 CY |
736 | wisent-java-tags-wy--<number>-regexp-analyzer |
737 | wisent-java-tags-wy--<string>-sexp-analyzer | |
469d2149 | 738 | ;; Must detect keywords before other symbols |
f79fbbc7 CY |
739 | wisent-java-tags-wy--<keyword>-keyword-analyzer |
740 | wisent-java-tags-wy--<symbol>-regexp-analyzer | |
741 | wisent-java-tags-wy--<punctuation>-string-analyzer | |
742 | wisent-java-tags-wy--<block>-block-analyzer | |
fe7a3057 | 743 | ;; In theory, Unicode chars should be turned into normal chars |
469d2149 CY |
744 | ;; and then combined into regular ascii keywords and text. This |
745 | ;; analyzer just keeps these things from making the lexer go boom. | |
f79fbbc7 | 746 | wisent-java-tags-wy--<unicode>-regexp-analyzer |
469d2149 CY |
747 | ;;;; |
748 | semantic-lex-default-action) | |
749 | ||
62f43d66 | 750 | ;;; java-tags.wy ends here |