1 # Java tests for simple calculator. -*- Autotest -*-
3 # Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 AT_BANNER([[Java Calculator.]])
21 # ------------------------- #
22 # Helping Autotest macros. #
23 # ------------------------- #
26 # _AT_DATA_JAVA_CALC_Y($1, $2, $3, [BISON-DIRECTIVES])
27 # ----------------------------------------------------
28 # Produce `calc.y'. Don't call this macro directly, because it contains
29 # some occurrences of `$1' etc. which will be interpreted by m4. So
30 # you should call it with $1, $2, and $3 as arguments, which is what
31 # AT_DATA_JAVA_CALC_Y does.
32 m4_define([_AT_DATA_JAVA_CALC_Y],
33 [m4_if([$1$2$3], $[1]$[2]$[3], [],
34 [m4_fatal([$0: Invalid arguments: $@])])dnl
36 [[/* Infix notation calculator--calc */
39 %define parser_class_name "Calc"
45 import java.io.StreamTokenizer;
46 import java.io.InputStream;
47 import java.io.InputStreamReader;
48 import java.io.Reader;
49 import java.io.IOException;
52 /* Bison Declarations */
53 %token <Integer> NUM "number"
56 %nonassoc '=' /* comparison */
59 %left NEG /* negation--unary minus */
60 %right '^' /* exponentiation */
79 if ($1.intValue () != $3.intValue ())
80 yyerror ("calc: error: " + $1 + " != " + $3);
82 | exp '+' exp { $$ = new Integer ($1.intValue () + $3.intValue ()); }
83 | exp '-' exp { $$ = new Integer ($1.intValue () - $3.intValue ()); }
84 | exp '*' exp { $$ = new Integer ($1.intValue () * $3.intValue ()); }
85 | exp '/' exp { $$ = new Integer ($1.intValue () / $3.intValue ()); }
86 | '-' exp %prec NEG { $$ = new Integer (-$2.intValue ()); }
87 | exp '^' exp { $$ = new Integer ((int)
88 Math.pow ($1.intValue (),
90 | '(' exp ')' { $$ = $2; }
91 | '(' error ')' { $$ = new Integer (1111); }
92 | '!' { $$ = new Integer (0); return YYERROR; }
93 | '-' error { $$ = new Integer (0); return YYERROR; }
101 class CalcLexer implements Calc.Lexer {
105 public ]AT_LEXPARAM_IF([[YYLexer]], [[CalcLexer]]) (InputStream is)
107 st = new StreamTokenizer (new InputStreamReader (is));
109 st.eolIsSignificant (true);
110 st.whitespaceChars (9, 9);
111 st.whitespaceChars (32, 32);
112 st.wordChars (48, 57);
117 Position yyendpos = new Position (1);
119 public Position getStartPos() {
123 public Position getEndPos() {
127 public void yyerror (Calc.Location l, String s)
130 System.err.println (s);
132 System.err.println (l.begin + ": " + s);
135 public void yyerror (String s)
137 System.err.println (s);
143 public Object getLVal() {
147 public int yylex () throws IOException {
148 int ttype = st.nextToken ();
149 ]AT_LOCATION_IF([[yystartpos = yyendpos;]])[
150 if (ttype == st.TT_EOF)
153 else if (ttype == st.TT_EOL)
155 ]AT_LOCATION_IF([[yyendpos = new Position (yyendpos.lineno () + 1);]])[
159 else if (ttype == st.TT_WORD)
161 yylval = new Integer (st.sval);
184 public Position (int l)
189 public long getHashCode ()
194 public boolean equals (Position l)
196 return l.line == line;
199 public String toString ()
201 return Integer.toString (line);
211 ])# _AT_DATA_JAVA_CALC_Y
214 # AT_DATA_CALC_Y([BISON-OPTIONS])
215 # -------------------------------
217 m4_define([AT_DATA_JAVA_CALC_Y],
218 [_AT_DATA_JAVA_CALC_Y($[1], $[2], $[3], [$1])
222 # _AT_CHECK_JAVA_CALC_ERROR(BISON-OPTIONS, INPUT,
223 # [VERBOSE-AND-LOCATED-ERROR-MESSAGE])
224 # ---------------------------------------------------------
225 # Run `calc' on INPUT, and expect a `syntax error' message.
227 # If INPUT starts with a slash, it is used as absolute input file name,
228 # otherwise as contents.
230 # The VERBOSE-AND-LOCATED-ERROR-MESSAGE is stripped of locations
231 # and expected tokens if necessary, and compared with the output.
232 m4_define([_AT_CHECK_JAVA_CALC_ERROR],
233 [m4_bmatch([$2], [^/],
234 [AT_JAVA_PARSER_CHECK([Calc < $2], 0, [], [stderr])],
238 AT_JAVA_PARSER_CHECK([Calc < input], 0, [], [stderr])])
240 # Normalize the observed and expected error messages, depending upon the
242 # 1. Create the reference error message.
246 # 2. If locations are not used, remove them.
247 AT_YYERROR_SEES_LOC_IF([],
248 [[sed 's/^[-0-9.]*: //' expout >at-expout
249 mv at-expout expout]])
250 # 3. If error-verbose is not used, strip the`, unexpected....' part.
251 m4_bmatch([$1], [%error-verbose], [],
252 [[sed 's/syntax error, .*$/syntax error/' expout >at-expout
253 mv at-expout expout]])
255 AT_CHECK([cat stderr], 0, [expout])
258 # _AT_CHECK_JAVA_CALC([BISON-DIRECTIVES], [BISON-CODE])
259 # -----------------------------------------------------
260 # Start a testing chunk which compiles `calc' grammar with
261 # BISON-DIRECTIVES, and performs several tests over the parser.
262 m4_define([_AT_CHECK_JAVA_CALC],
263 [# We use integers to avoid dependencies upon the precision of doubles.
264 AT_SETUP([Calculator $1])
266 AT_BISON_OPTION_PUSHDEFS([$1])
268 AT_DATA_JAVA_CALC_Y([$1
273 AT_BISON_CHECK([-o Calc.java Calc.y])
274 AT_JAVA_COMPILE([Calc.java])
276 # Test the priorities.
292 AT_JAVA_PARSER_CHECK([Calc < input], 0, [], [stderr])
295 # Some syntax errors.
296 _AT_CHECK_JAVA_CALC_ERROR([$1], [0 0],
297 [1: syntax error, unexpected number])
298 _AT_CHECK_JAVA_CALC_ERROR([$1], [1//2],
299 [1: syntax error, unexpected '/', expecting number or '-' or '(' or '!'])
300 _AT_CHECK_JAVA_CALC_ERROR([$1], [error],
301 [1: syntax error, unexpected $undefined])
302 _AT_CHECK_JAVA_CALC_ERROR([$1], [1 = 2 = 3],
303 [1: syntax error, unexpected '='])
304 _AT_CHECK_JAVA_CALC_ERROR([$1], [
306 [2: syntax error, unexpected '+'])
307 # Exercise error messages with EOF: work on an empty file.
308 _AT_CHECK_JAVA_CALC_ERROR([$1], [/dev/null],
309 [1: syntax error, unexpected end of input])
311 # Exercise the error token: without it, we die at the first error,
314 # - have several errors which exercise different shift/discardings
315 # - (): nothing to pop, nothing to discard
316 # - (1 + 1 + 1 +): a lot to pop, nothing to discard
317 # - (* * *): nothing to pop, a lot to discard
318 # - (1 + 2 * *): some to pop and discard
320 # - test the action associated to `error'
322 # - check the lookahead that triggers an error is not discarded
323 # when we enter error recovery. Below, the lookahead causing the
324 # first error is ")", which is needed to recover from the error and
325 # produce the "0" that triggers the "0 != 1" error.
327 _AT_CHECK_JAVA_CALC_ERROR([$1],
328 [() + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1],
329 [1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
330 1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
331 1: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
332 1: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
333 calc: error: 4444 != 1])
335 # The same, but this time exercising explicitly triggered syntax errors.
336 # POSIX says the lookahead causing the error should not be discarded.
337 _AT_CHECK_JAVA_CALC_ERROR([$1], [(!) + (0 0) = 1],
338 [1: syntax error, unexpected number
339 calc: error: 2222 != 1])
340 _AT_CHECK_JAVA_CALC_ERROR([$1], [(- *) + (0 0) = 1],
341 [1: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
342 1: syntax error, unexpected number
343 calc: error: 2222 != 1])
344 AT_BISON_OPTION_POPDEFS
347 ])# _AT_CHECK_JAVA_CALC
350 # AT_CHECK_JAVA_CALC([BISON-DIRECTIVES])
351 # --------------------------------------
352 # Start a testing chunk which compiles `calc' grammar with
353 # BISON-DIRECTIVES, and performs several tests over the parser.
354 # Run the test with and without %error-verbose.
355 m4_define([AT_CHECK_JAVA_CALC],
356 [_AT_CHECK_JAVA_CALC([$1], [$2])
357 _AT_CHECK_JAVA_CALC([%error-verbose $1], [$2])
358 _AT_CHECK_JAVA_CALC([%locations $1], [$2])
359 _AT_CHECK_JAVA_CALC([%error-verbose %locations $1], [$2])
360 ])# AT_CHECK_JAVA_CALC
363 # ------------------------ #
364 # Simple LALR Calculator. #
365 # ------------------------ #
367 AT_CHECK_JAVA_CALC([], [[
368 public static void main (String args[]) throws IOException
370 CalcLexer l = new CalcLexer (System.in);
371 Calc p = new Calc (l);
376 AT_CHECK_JAVA_CALC([%lex-param { InputStream is } ], [[
377 public static void main (String args[]) throws IOException
379 new Calc (System.in).parse ();
389 AT_BANNER([Java Parameters.])
392 # AT_CHECK_JAVA_MINIMAL([DIRECTIVES], [PARSER_ACTION], [POSITION_CLASS])
393 # ----------------------------------------------------------------------
394 # Check that a mininal parser with DIRECTIVES compiles in Java.
395 # Put the Java code in YYParser.java.
396 m4_define([AT_CHECK_JAVA_MINIMAL],
398 AT_DATA([[YYParser.y]], [
409 class m4_default([$3], [Position]) {}
411 AT_BISON_CHECK([[YYParser.y]])
412 AT_CHECK([[grep '[mb]4_' YYParser.y]], [1], [ignore])
413 AT_JAVA_COMPILE([[YYParser.java]])
417 # AT_CHECK_JAVA_MINIMAL_W_LEXER([1:DIRECTIVES], [2:LEX_THROWS],
418 # [3:YYLEX_ACTION], [4:LEXER_BODY], [5:PARSER_ACTION], [6:STYPE],
419 # [7:POSITION_TYPE], [8:LOCATION_TYPE])
420 # ---------------------------------------------------------------------
421 # Check that a mininal parser with DIRECTIVES and a "%code lexer".
422 # YYLEX is the body of yylex () which throws LEX_THROW.
424 m4_define([AT_CHECK_JAVA_MINIMAL_W_LEXER],
425 [AT_CHECK_JAVA_MINIMAL([$1
429 m4_default([$6], [Object]) yylval;
430 public m4_default([$6], [Object]) getLVal() { return yylval; }
432 public m4_default([$7], [Position]) getStartPos() { return null; }
433 public m4_default([$7], [Position]) getEndPos() { return null; }
435 public void yyerror (m4_default([$8], [Location]) loc, String s)
437 System.err.println (loc + ": " + s);
440 public int yylex ()$2
449 # AT_CHECK_JAVA_GREP([LINE], [COUNT=1])
450 # -------------------------------------
451 # Check that YYParser.java contains exactly COUNT lines matching ^LINE$
453 m4_define([AT_CHECK_JAVA_GREP],
454 [AT_CHECK([grep -c '^$1$' YYParser.java], [], [m4_default([$2], [1])
459 # ------------------------------------- #
460 # Java parser class and package names. #
461 # ------------------------------------- #
463 AT_SETUP([Java parser class and package names])
465 AT_CHECK_JAVA_MINIMAL([])
466 AT_CHECK_JAVA_GREP([[class YYParser]])
468 AT_CHECK_JAVA_MINIMAL([[%name-prefix "Prefix"]])
469 AT_CHECK_JAVA_GREP([[class PrefixParser]])
471 AT_CHECK_JAVA_MINIMAL([[%define api.tokens.prefix "TOK_"]])
472 AT_CHECK_JAVA_GREP([[.*TOK_END.*]])
474 AT_CHECK_JAVA_MINIMAL([[%define parser_class_name "ParserClassName"]])
475 AT_CHECK_JAVA_GREP([[class ParserClassName]])
477 AT_CHECK_JAVA_MINIMAL([[%define package "user_java_package"]])
478 AT_CHECK_JAVA_GREP([[package user_java_package;]])
483 # ----------------------------- #
484 # Java parser class modifiers. #
485 # ----------------------------- #
487 AT_SETUP([Java parser class modifiers])
489 AT_CHECK_JAVA_MINIMAL([[%define abstract]])
490 AT_CHECK_JAVA_GREP([[abstract class YYParser]])
492 AT_CHECK_JAVA_MINIMAL([[%define final]])
493 AT_CHECK_JAVA_GREP([[final class YYParser]])
495 AT_CHECK_JAVA_MINIMAL([[%define strictfp]])
496 AT_CHECK_JAVA_GREP([[strictfp class YYParser]])
498 AT_CHECK_JAVA_MINIMAL([[
501 AT_CHECK_JAVA_GREP([[abstract strictfp class YYParser]])
503 AT_CHECK_JAVA_MINIMAL([[
506 AT_CHECK_JAVA_GREP([[final strictfp class YYParser]])
508 AT_CHECK_JAVA_MINIMAL([[%define public]])
509 AT_CHECK_JAVA_GREP([[public class YYParser]])
511 AT_CHECK_JAVA_MINIMAL([[
514 AT_CHECK_JAVA_GREP([[public abstract class YYParser]])
516 AT_CHECK_JAVA_MINIMAL([[
519 AT_CHECK_JAVA_GREP([[public final class YYParser]])
521 AT_CHECK_JAVA_MINIMAL([[
524 AT_CHECK_JAVA_GREP([[public strictfp class YYParser]])
526 AT_CHECK_JAVA_MINIMAL([[
530 AT_CHECK_JAVA_GREP([[public abstract strictfp class YYParser]])
532 AT_CHECK_JAVA_MINIMAL([[
536 AT_CHECK_JAVA_GREP([[public final strictfp class YYParser]])
538 # FIXME: Can't do a Java compile because javacomp.sh is configured for 1.3
539 AT_CHECK_JAVA_MINIMAL([[
540 %define annotations "/*@Deprecated @SupressWarnings(\"unchecked\") @SupressWarnings({\"unchecked\", \"deprecation\"}) @SupressWarnings(value={\"unchecked\", \"deprecation\"})*/"
542 AT_CHECK_JAVA_GREP([[/\*@Deprecated @SupressWarnings("unchecked") @SupressWarnings({"unchecked", "deprecation"}) @SupressWarnings(value={"unchecked", "deprecation"})\*/ public class YYParser]])
547 # ---------------------------------------- #
548 # Java parser class extends and implements #
549 # ---------------------------------------- #
551 AT_SETUP([Java parser class extends and implements])
553 AT_CHECK_JAVA_MINIMAL([[%define extends "Thread"]])
554 AT_CHECK_JAVA_GREP([[class YYParser extends Thread]])
556 AT_CHECK_JAVA_MINIMAL([[%define implements "Cloneable"]])
557 AT_CHECK_JAVA_GREP([[class YYParser implements Cloneable]])
559 AT_CHECK_JAVA_MINIMAL([[
560 %define extends "Thread"
561 %define implements "Cloneable"]])
562 AT_CHECK_JAVA_GREP([[class YYParser extends Thread implements Cloneable]])
567 # -------------------------------- #
568 # Java %parse-param and %lex-param #
569 # -------------------------------- #
571 AT_SETUP([Java %parse-param and %lex-param])
573 AT_CHECK_JAVA_MINIMAL([])
574 AT_CHECK_JAVA_GREP([[ *public YYParser (Lexer yylexer) *]])
576 AT_CHECK_JAVA_MINIMAL([[%parse-param {int parse_param1}]])
577 AT_CHECK_JAVA_GREP([[ *protected final int parse_param1;]])
578 AT_CHECK_JAVA_GREP([[ *public YYParser (Lexer yylexer, *int parse_param1) *]])
579 AT_CHECK_JAVA_GREP([[ *this.parse_param1 = parse_param1;]])
581 AT_CHECK_JAVA_MINIMAL([[
582 %parse-param {int parse_param1}
583 %parse-param {long parse_param2}]])
584 AT_CHECK_JAVA_GREP([[ *protected final int parse_param1;]])
585 AT_CHECK_JAVA_GREP([[ *protected final long parse_param2;]])
586 AT_CHECK_JAVA_GREP([[ *public YYParser (Lexer yylexer, *int parse_param1, *long parse_param2) *]])
587 AT_CHECK_JAVA_GREP([[ *this.parse_param1 = parse_param1;]])
588 AT_CHECK_JAVA_GREP([[ *this.parse_param2 = parse_param2;]])
590 AT_CHECK_JAVA_MINIMAL_W_LEXER([], [], [[return EOF;]])
591 AT_CHECK_JAVA_GREP([[ *public YYParser () *]])
592 AT_CHECK_JAVA_GREP([[ *protected YYParser (Lexer yylexer) *]])
594 AT_CHECK_JAVA_MINIMAL_W_LEXER([[%parse-param {int parse_param1}]],
596 AT_CHECK_JAVA_GREP([[ *protected final int parse_param1;]])
597 AT_CHECK_JAVA_GREP([[ *public YYParser (int parse_param1) *]])
598 AT_CHECK_JAVA_GREP([[ *protected YYParser (Lexer yylexer, *int parse_param1) *]])
599 AT_CHECK_JAVA_GREP([[ *this.parse_param1 = parse_param1;]], [2])
601 AT_CHECK_JAVA_MINIMAL_W_LEXER([[
602 %parse-param {int parse_param1}
603 %parse-param {long parse_param2}]],
605 AT_CHECK_JAVA_GREP([[ *protected final int parse_param1;]])
606 AT_CHECK_JAVA_GREP([[ *protected final long parse_param2;]])
607 AT_CHECK_JAVA_GREP([[ *public YYParser (int parse_param1, *long parse_param2) *]])
608 AT_CHECK_JAVA_GREP([[ *protected YYParser (Lexer yylexer, *int parse_param1, *long parse_param2) *]])
609 AT_CHECK_JAVA_GREP([[ *this.parse_param1 = parse_param1;]], [2])
610 AT_CHECK_JAVA_GREP([[ *this.parse_param2 = parse_param2;]], [2])
612 AT_CHECK_JAVA_MINIMAL_W_LEXER([[%lex-param {char lex_param1}]],
613 [], [[return EOF;]], [[YYLexer (char lex_param1) {}]])
614 AT_CHECK_JAVA_GREP([[ *public YYParser (char lex_param1) *]])
615 AT_CHECK_JAVA_GREP([[.* = new YYLexer *(lex_param1);]])
617 AT_CHECK_JAVA_MINIMAL_W_LEXER([[
618 %lex-param {char lex_param1}
619 %lex-param {short lex_param2}]],
620 [], [[return EOF;]], [[YYLexer (char lex_param1, short lex_param2) {}]])
621 AT_CHECK_JAVA_GREP([[ *public YYParser (char lex_param1, *short lex_param2) *]])
622 AT_CHECK_JAVA_GREP([[.* = new YYLexer *(lex_param1, *lex_param2);]])
624 AT_CHECK_JAVA_MINIMAL_W_LEXER([[
625 %parse-param {int parse_param1}
626 %parse-param {long parse_param2}
627 %lex-param {char lex_param1}
628 %lex-param {short lex_param2}]],
629 [], [[return EOF;]], [[YYLexer (char lex_param1, short lex_param2) {}]])
630 AT_CHECK_JAVA_GREP([[ *protected final int parse_param1;]])
631 AT_CHECK_JAVA_GREP([[ *protected final long parse_param2;]])
632 AT_CHECK_JAVA_GREP([[ *public YYParser (char lex_param1, *short lex_param2, *int parse_param1, *long parse_param2) *]])
633 AT_CHECK_JAVA_GREP([[.* = new YYLexer *(lex_param1, *lex_param2);]])
634 AT_CHECK_JAVA_GREP([[ *protected YYParser (Lexer yylexer, *int parse_param1, *long parse_param2) *]])
635 AT_CHECK_JAVA_GREP([[ *this.parse_param1 = parse_param1;]], [2])
636 AT_CHECK_JAVA_GREP([[ *this.parse_param2 = parse_param2;]], [2])
641 # ------------------------- #
642 # Java throw specifications #
643 # ------------------------- #
645 AT_SETUP([Java throws specifications])
647 # %define throws - 0 1 2
648 # %define lex-throws - 0 1 2
651 m4_define([AT_JT_lex_throws_define], [m4_case(AT_JT_lex_throws,
653 0, [[%define lex_throws ""]],
654 1, [[%define lex_throws "InterruptedException"]],
655 2, [[%define lex_throws "InterruptedException, IllegalAccessException"]])])
657 m4_define([AT_JT_yylex_throws], [m4_case(AT_JT_lex_throws,
658 -1, [[ throws java.io.IOException]],
660 1, [[ throws InterruptedException]],
661 2, [[ throws InterruptedException, IllegalAccessException]])])
663 m4_define([AT_JT_yylex_action], [m4_case(AT_JT_lex_throws,
664 -1, [[throw new java.io.IOException();]],
666 1, [[throw new InterruptedException();]],
667 2, [[throw new IllegalAccessException();]])])
670 m4_define([AT_JT_throws_define], [m4_case(AT_JT_throws,
672 0, [[%define throws ""]],
673 1, [[%define throws "ClassNotFoundException"]],
674 2, [[%define throws "ClassNotFoundException, InstantiationException"]])])
676 m4_define([AT_JT_yyaction_throws], [m4_case(AT_JT_throws,
679 1, [[ throws ClassNotFoundException]],
680 2, [[ throws ClassNotFoundException, InstantiationException]])])
682 m4_define([AT_JT_parse_throws_2], [m4_case(AT_JT_throws,
685 1, [[, ClassNotFoundException]],
686 2, [[, ClassNotFoundException, InstantiationException]])])
688 m4_define([AT_JT_parse_throws],
689 [m4_if(m4_quote(AT_JT_yylex_throws), [],
690 [AT_JT_yyaction_throws],
691 [AT_JT_yylex_throws[]AT_JT_parse_throws_2])])
693 m4_define([AT_JT_initial_action], [m4_case(AT_JT_throws,
696 1, [[%initial-action {if (true) throw new ClassNotFoundException();}]],
697 2, [[%initial-action {if (true) throw new InstantiationException();}]])])
699 m4_define([AT_JT_parse_action], [m4_case(AT_JT_throws,
702 1, [[throw new ClassNotFoundException();]],
703 2, [[throw new ClassNotFoundException();]])])
705 m4_for([AT_JT_lexer], 0, 1, 1,
706 [m4_for([AT_JT_lex_throws], -1, 2, 1,
707 [m4_for([AT_JT_throws], -1, 2, 1,
708 [m4_if(AT_JT_lexer, 0,
709 [AT_CHECK_JAVA_MINIMAL([
711 AT_JT_lex_throws_define
712 AT_JT_initial_action],
713 [AT_JT_parse_action])],
714 [AT_CHECK_JAVA_MINIMAL_W_LEXER([
716 AT_JT_lex_throws_define
717 AT_JT_initial_action],
718 [AT_JT_yylex_throws],
719 [AT_JT_yylex_action],
721 [AT_JT_parse_action])])
722 AT_CHECK_JAVA_GREP([[ *int yylex ()]AT_JT_yylex_throws *[;]])
723 AT_CHECK_JAVA_GREP([[ *private int yyaction ([^)]*)]AT_JT_yyaction_throws[ *]])
724 AT_CHECK_JAVA_GREP([[ *public boolean parse ()]AT_JT_parse_throws[ *]])
730 # ------------------------------------- #
731 # Java constructor init and init_throws #
732 # ------------------------------------- #
734 AT_SETUP([Java constructor init and init_throws])
736 AT_CHECK_JAVA_MINIMAL([[
737 %define extends "Thread"
738 %code init { super("Test Thread"); if (true) throw new InterruptedException(); }
739 %define init_throws "InterruptedException"
740 %lex-param {int lex_param}]])
741 AT_CHECK([[grep -q 'super("Test Thread"); if (true) throw new InterruptedException();' YYParser.java]])
743 AT_CHECK_JAVA_MINIMAL_W_LEXER([[
744 %define extends "Thread"
745 %code init { super("Test Thread"); if (true) throw new InterruptedException(); }
746 %define init_throws "InterruptedException"]], [], [[return EOF;]])
747 AT_CHECK([[grep -q 'super("Test Thread"); if (true) throw new InterruptedException();' YYParser.java]])
752 # --------------------------------------------- #
753 # Java stype, position_class and location_class #
754 # --------------------------------------------- #
756 AT_SETUP([Java stype, position_class and location_class])
758 AT_CHECK_JAVA_MINIMAL([[
759 %define stype "java.awt.Color"
760 %type<java.awt.Color> start;
761 %define location_type "MyLoc"
762 %define position_type "MyPos"
763 %code { class MyPos {} }]], [[$$ = $<java.awt.Color>1;]], [[MyPos]])
764 AT_CHECK([[grep 'java.awt.Color' YYParser.java]], [0], [ignore])
765 AT_CHECK([[$EGREP -v ' */?\*' YYParser.java | grep 'Position']], [1], [ignore])
766 AT_CHECK([[$EGREP -v ' */?\*' YYParser.java | grep 'Location']], [1], [ignore])
768 AT_CHECK_JAVA_MINIMAL_W_LEXER([[
769 %define stype "java.awt.Color"
770 %type<java.awt.Color> start;
771 %define location_type "MyLoc"
772 %define position_type "MyPos"
773 %code { class MyPos {} }]], [], [[return EOF;]], [],
774 [[$$ = $<java.awt.Color>1;]],
775 [[java.awt.Color]], [[MyPos]], [[MyLoc]])
776 AT_CHECK([[grep 'java.awt.Color' YYParser.java]], [0], [ignore])
777 AT_CHECK([[$EGREP -v ' */?\*' YYParser.java | grep 'Position']], [1], [ignore])
778 AT_CHECK([[$EGREP -v ' */?\*' YYParser.java | grep 'Location']], [1], [ignore])