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