summaryrefslogtreecommitdiff
path: root/examples/java
Commit message (Collapse)AuthorAgeFilesLines
* package: bump copyrights to 2022Paul Eggert2022-01-158-8/+8
| | | | Run "make update-copyright".
* examples: modernize the example MakefilesAkim Demaille2021-08-042-14/+4
| | | | | | | | | | | | | | | | | * examples/c++/Makefile, examples/c++/calc++/Makefile, * examples/c++/glr/Makefile, examples/c/bistromathic/Makefile, * examples/c/calc/Makefile, examples/c/glr/Makefile, * examples/c/lexcalc/Makefile, examples/c/mfcalc/Makefile, * examples/c/pushcalc/Makefile, examples/c/reccalc/Makefile, * examples/c/rpcalc/Makefile, examples/d/calc/Makefile, * examples/d/simple/Makefile, examples/java/calc/Makefile, * examples/java/simple/Makefile: Use --html to generate *.html directly. No longer demonstrate --xml. No longer show rules for xml to html. Use --header, not --defines. Use --graph without specifying the output file now that we generate *.gv by default.
* Update URLs to prefer https: to http:Paul Eggert2021-01-297-7/+7
| | | | Also, fix a few http: URLs that were no longer working.
* package: bump copyrights to 2021Akim Demaille2021-01-168-8/+8
| | | | Run 'make update-copyright'.
* java: avoid Integer(String), use parseIntAkim Demaille2020-11-032-2/+2
| | | | | | | | | examples/java/calc/Calc.java:1531: warning: [deprecation] Integer(String) in Integer has been deprecated yylval = new Integer(st.sval); ^ * examples/java/calc/Calc.y, examples/java/simple/Calc.y, * tests/calc.at, tests/scanner.at: Use Integer.parseInt.
* java: add support for lookahead correctionAkim Demaille2020-11-031-1/+7
| | | | | | | | | | Shamelessly stolen from Adrian Vogelsgesang's implementation in lalr1.cc. * data/skeletons/lalr1.java (yycdebugNnl, yyLacCheck, yyLacEstablish) (yyLacDiscard, yylacStack, yylacEstablished): New. (Context): Use it. * examples/java/calc/Calc.y: Enable LAC.
* build: beware of POSIX modeAkim Demaille2020-08-302-2/+2
| | | | | | | | | Reported by Dennis Clarke. https://lists.gnu.org/r/bug-bison/2020-08/msg00013.html * examples/d/local.mk, examples/java/calc/local.mk, * examples/java/simple/local.mk: Pass bison's options before its argument, in case we're in POSIX mode.
* examples: add license headersAkim Demaille2020-07-082-0/+38
| | | | | | | | | | | | | Prompted by Rici Lake. https://stackoverflow.com/questions/62658368/#comment110853985_62661621 Discussed with Paul Eggert. * doc/bison.texi, examples/c/bistromathic/parse.y, * examples/c/lexcalc/parse.y, examples/c/lexcalc/scan.l, * examples/c/pushcalc/calc.y, examples/c/reccalc/parse.y, * examples/c/reccalc/scan.l, examples/d/calc.y, * examples/java/calc/Calc.y, examples/java/simple/Calc.y: Install the GPL3+ header.
* java: demonstrate push parsersAkim Demaille2020-05-032-14/+28
| | | | | | | | | * data/skeletons/lalr1.java (Location): Make it a static class. (Lexer.yylex, Lexer.getLVal, Lexer.getStartPos, Lexer.getEndPos): These are not needed in push parsers. * examples/java/calc/Calc.y: Demonstrate push parsers in the Java. * doc/bison.texi: Push parsers have been supported for a long time, remove incorrect statements stating the opposite.
* java: comment changesAkim Demaille2020-05-011-5/+20
| | | | * data/skeletons/lalr1.java, examples/java/calc/Calc.y: here.
* java: clean up the definition of token kindsAkim Demaille2020-04-282-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From public interface Lexer { /* Token kinds. */ /** Token number, to be returned by the scanner. */ static final int YYEOF = 0; /** Token number, to be returned by the scanner. */ static final int YYERRCODE = 256; /** Token number, to be returned by the scanner. */ static final int YYUNDEF = 257; /** Token number, to be returned by the scanner. */ static final int BANG = 258; ... /** Deprecated, use b4_symbol(0, id) instead. */ public static final int EOF = YYEOF; to public interface Lexer { /* Token kinds. */ /** Token "end of file", to be returned by the scanner. */ static final int YYEOF = 0; /** Token error, to be returned by the scanner. */ static final int YYerror = 256; /** Token "invalid token", to be returned by the scanner. */ static final int YYUNDEF = 257; /** Token "!", to be returned by the scanner. */ static final int BANG = 258; ... /** Deprecated, use YYEOF instead. */ public static final int EOF = YYEOF; * data/skeletons/java.m4 (b4_token_enum): Display the symbol's tag in comment. * data/skeletons/lalr1.java: Address overquotation issue. * examples/java/calc/Calc.y, examples/java/simple/Calc.y: Use YYEOF, not EOF.
* doc: java: SymbolKind, etc.Akim Demaille2020-04-131-2/+2
| | | | | | | | | | | | | Why didn't I think about this before??? symbolName should be a method of SymbolKind. * data/skeletons/lalr1.java (YYParser::yysymbolName): Move as... * data/skeletons/java.m4 (SymbolKind::getName): this. Make the table a static final table, not a local variable. Adjust dependencies. * doc/bison.texi (Java Parser Interface): Document i18n. (Java Parser Context Interface): Document SymbolKind. * examples/java/calc/Calc.y, tests/local.at: Adjust.
* style: java: get closer to the Java styleAkim Demaille2020-04-132-143/+125
| | | | * examples/java/calc/Calc.y, examples/java/simple/Calc.y: here.
* java: prefer null to YYSYMBOL_YYEMPTYAkim Demaille2020-04-061-1/+1
| | | | | | | | That's one nice benefit from using enums. * data/skeletons/lalr1.java (YYSYMBOL_YYEMPTY): No longer define it. Use 'null' instead. * examples/java/calc/Calc.y, tests/local.at: Adjust.
* java: rename Lexer.yyreportSyntaxError as reportSyntaxErrorAkim Demaille2020-04-061-1/+1
| | | | | * data/skeletons/lalr1.java: here. * examples/java/calc/Calc.y, tests/local.at: Adjust.
* java: use getExpectedTokens, not yyexpectedTokensAkim Demaille2020-04-061-1/+1
| | | | | * data/skeletons/lalr1.java, examples/java/calc/Calc.y, tests/local.at: here.
* d, java: rename SymbolType as SymbolKindAkim Demaille2020-04-051-3/+3
| | | | | | | | | | See https://lists.gnu.org/r/bison-patches/2020-04/msg00031.html. * data/skeletons/d.m4, data/skeletons/lalr1.d, * data/skeletons/java.m4, data/skeletons/lalr1.java (SymbolType): Rename as... (SymbolKind): this. Adjust dependencies.
* java: use SymbolTypeAkim Demaille2020-04-041-3/+3
| | | | | | | | | | | | The Java enums are very different from the C model. As a consequence, one cannot "build" an enum directly from an integer, we must retrieve it. That's the purpose of the SymbolType.get class method. * data/skeletons/java.m4 (b4_symbol_enum, b4_case_code_symbol) (b4_declare_symbol_enum): New. * data/skeletons/lalr1.java: Use SymbolType, SymbolType.YYSYMBOL_YYEMPTY, etc. * examples/java/calc/Calc.y, tests/local.at: Adjust.
* examples: java: use explicit token identifiersAkim Demaille2020-04-042-23/+50
| | | | | | * examples/java/calc/Calc.y: Declare all the tokens, so that we are compatibile with api.token.raw. * examples/java/calc/Calc.test: Adjust.
* java: move away from _ for internationalizationAkim Demaille2020-03-301-4/+5
| | | | | | | | | | The "_" is becoming a keyword in Java, which causes tons of warnings currently in our test suite. GNU Gettext is now using "i18n" instead of "_" (https://git.savannah.gnu.org/gitweb/?p=gettext.git;a=commitdiff;h=e89fea36545f27487d9652a13e6a0adbea1117d0). * data/skeletons/java.m4: Use "i18n", not "_". * examples/java/calc/Calc.y, tests/calc.at: Adjust.
* examples: don't use yysyntax_error_argumentsAkim Demaille2020-03-281-8/+13
| | | | | | | | | | | | | | | | Suggested by Adrian Vogelsgesang. https://lists.gnu.org/archive/html/bison-patches/2020-02/msg00069.html * data/skeletons/lalr1.java (Context.EMPTY, Context.getToken): New. (Context.yyntokens): Rename as... (Context.NTOKENS): this. Because (i) all the Java coding styles recommend upper case for constants, and (ii) the Java Skeleton exposes Lexer.EOF, not Lexer.YYEOF. * data/skeletons/yacc.c (yyparse_context_token): New. * examples/c/bistromathic/parse.y (yyreport_syntax_error): Don't use yysyntax_error_arguments. * examples/java/calc/Calc.y (yyreportSyntaxError): Likewise.
* java: beware not to alias the locations of the various symbolsAkim Demaille2020-02-111-2/+8
| | | | | | * examples/java/calc/Calc.y, tests/calc.at, tests/local.at (getStartPos, getEndPos): Always return a new object. * doc/bison.texi: Clarify this.
* java: don't expose the Context's membersAkim Demaille2020-02-111-1/+1
| | | | | | * data/skeletons/lalr1.java (Context): Make data members private. (Context.getLocation): New. * examples/java/calc/Calc.y, tests/java.at, tests/local.at: Adjust.
* java: provide Context with a more OO interfaceAkim Demaille2020-02-081-3/+3
| | | | | | | * data/skeletons/lalr1.java (yyexpectedTokens) (yysyntaxErrorArguments): Make them methods of Context. (Context.yysymbolName): New. * tests/local.at: Adjust.
* java: add support for parse.error customAkim Demaille2020-02-082-5/+25
| | | | | | | | | | | | | * data/skeletons/lalr1.java: Add support for custom parse errors. (yyntokens_): Make it public. Under... (yyntokens): this name. (Context): Capture the location too. * examples/c/bistromathic/parse.y, * examples/c/bistromathic/bistromathic.test: Improve error message. * examples/java/calc/Calc.test, examples/java/calc/Calc.y: Use custom error messages. * tests/calc.at, tests/local.at: Check custom error messages.
* java: add support for parse.error=detailedAkim Demaille2020-02-081-1/+1
| | | | | | | | | | | | | | In Java there is no need for N_ and yytranslate_. So instead of hard-coding the use of N_ in the table of the symbol names, rely on b4_symbol_translate. * src/output.c (prepare_symbol_names): Use b4_symbol_translate instead of N_. * data/skeletons/c.m4 (b4_symbol_translate): New. * data/skeletons/lalr1.java (yysymbolName): New. Use it. * examples/java/calc/Calc.y: Use parse.error=detailed. * tests/calc.at: Check parse.error=detailed.
* java: style: prefer putting the square brackets on the typeAkim Demaille2020-02-052-2/+2
| | | | | * examples/java/calc/Calc.y, examples/java/simple/Calc.y, * tests/calc.at, tests/local.at: here.
* java: examples: fix the tracking of locationsAkim Demaille2020-02-052-4/+18
| | | | | | | | * examples/java/calc/Calc.y: The StreamTokenizer cannot "peek" for the next character, it reads it, and keeps it for the next call. So the current location is one passed the end of the current token. To avoid this, keep the previous position, and use it to end the current token. * examples/java/calc/Calc.test: Adjust.
* java: examples: prefer switch to chains of else-ifAkim Demaille2020-02-052-19/+19
| | | | | * examples/java/calc/Calc.y, examples/java/simple/Calc.y: here. * examples/java/simple/Calc.y: Use the tokenizer's handling of blanks.
* java: examples: split in twoAkim Demaille2020-02-0510-25/+252
| | | | | * examples/java: Split in... * examples/java/simple, examples/java/calc: these.
* java: example: properly track the locationsAkim Demaille2020-02-022-21/+59
| | | | | | | | | This example, so far, was tracking the current token number, not the current column number. This is not nice for an example... * examples/java/Calc.y (PositionReader): New. Use it. * examples/java/Calc.test: Check the output.
* java: example: improveAkim Demaille2020-02-021-1/+7
| | | | | * examples/java/Calc.y: Propagate the exit status. Support -p.
* java: example: rely on autoboxingAkim Demaille2020-02-022-13/+18
| | | | | | | | | | | | AFAICT, autoboxing/unboxing was added in Java 5 (September 30, 2004). I think we can afford to use it. It should help us merge some Java tests with the main ones. However, beware that != does not unbox: it compares the object addresses. * examples/java/Calc.y, tests/java.at: Simplify. * examples/java/Calc.test, tests/java.at: Improve tests.
* package: bump copyrights to 2020Akim Demaille2020-01-053-3/+3
| | | | Run 'make update-copyright'.
* java: style changesAkim Demaille2019-06-191-3/+3
| | | | | | | | | | | | | | * data/skeletons/lalr1.java: Use more conventional function names for Java. Prefer < and <= to => and >. Use the same approach for m4 quotation as in the other skeletons. Fix indentation issues. * tests/calc.at, tests/java.at, tests/javapush.at: Fix quotation style. (main): Use 'args', not 'argv', the former seems more conventional and is used elsewhere in Bison. Prefer character literals to integers to denote characters. * examples/java/Calc.y: Likewise.
* examples: fix srcdir/builddir issuesAkim Demaille2019-05-181-1/+1
| | | | * examples/d/local.mk, examples/java/local.mk: here.
* build: do not use $< in plain rulesAkim Demaille2019-05-131-2/+2
| | | | | | | | | | | | It works only in implicit rules (or with GNU Make, but not with Solaris Make). Reported by Bruno Haible. http://lists.gnu.org/archive/html/bug-bison/2019-05/msg00009.html Diagnosed thanks to Kiyoshi Kanazawa. * examples/c/reccalc/local.mk, examples/d/local.mk, * examples/java/local.mk: Don't use $< in non implicit rules.
* package: bump copyrights to 2019Akim Demaille2019-01-053-3/+3
|
* java/d: rename some %define variables for consistencyAkim Demaille2019-01-051-1/+1
| | | | | | | | | | | | | | | | | | | See 890ee8a1fd288b3cc1c21c49ea0ece696ef40565 and https://lists.gnu.org/archive/html/bison-patches/2019-01/msg00024.html. * data/skeletons/d.m4, data/skeletons/java.m4 (abstract, annotations, extends, final, implements, public, strictfp): Rename as... (api.parser.abstract, api.parser.annotations, api.parser.extends) (api.parser.final, api.parser.implements, api.parser.public) (api.parser.strictfp): these. * src/muscle-tab.c (muscle_percent_variable_update): Ensure backward compatibility. * doc/bison.texi, examples/d/calc.y, examples/java/Calc.y, tests/input.at: Adjust.
* examples: clean up the Java/D examplesAkim Demaille2019-01-031-10/+12
| | | | | | | * examples/java/Calc.y: Fix indentation. Sort. Don't use %name-prefix, since api.parser.class is already defined. * examples/d/calc.y: Likewise.
* rename parser_class_name as api.parser.classAkim Demaille2019-01-021-1/+1
| | | | | | | | | | | | | | | The previous name was historical and inconsistent. * src/muscle-tab.c (define_directive): Use the proper value passing syntax, based on the muscle kind. (muscle_percent_variable_update): Use the right value passing syntax. Migrate from parser_class_name to api.parser.class. * data/skeletons: Migrate from parser_class_name to api.parser.class. * doc/bison.texi (%define Summary): Document both parser_class_name and api.parser.class. Promote the latter over the former.
* examples: fix dependenciesAkim Demaille2018-12-261-1/+1
| | | | | | | | Commit 112ccb5ed73ba5c64b0b5300d8b9b686f02f094c moved the skeletons from dist_pkgdata_DATA to dist_skeletons_DATA, hence broke the dependencies. * Makefile.am (dependencies): New. Use it where appropriate.
* examples: sort them per language and complete themAkim Demaille2018-12-093-3/+31
| | | | | | | | | | | | | | | | | | | | | Convert some of the READMEs to Markdown, which is now more common, and nicely displayed in some git hosting services. Add missing READMEs and Makefiles. Generate XML, HTML and Dot files. Be sure to ship the test files. Complete CLEANFILES to remove all generated files. * examples/calc++: Move into... * examples/c++: here. * examples/mfcalc, examples/rpcalc: Move into... * examples/c: here. * examples/README.md, examples/c++/calc++/Makefile, examples/c/local.mk, * examples/c/mfcalc/Makefile, examples/c/rpcalc/Makefile, * examples/d/README.md, examples/java/README.md: New files. * examples/test (medir): Be robust to deeper directory nesting.
* java, d: add a Makefile for the exampleAkim Demaille2018-12-062-1/+27
| | | | * examples/java/Makefile, examples/d/Makefile: New.
* java: make sure the build dir existsAkim Demaille2018-12-031-1/+2
| | | | * examples/java/local.mk (%D%/Calc.java): here.
* java: add an exampleAkim Demaille2018-12-013-0/+226
* examples/java/Calc.y: New, based on test 495: "Calculator parse.error=verbose %locations". * examples/java/Calc.test, examples/java/local.mk: New. * configure.ac (ENABLE_JAVA): New. * examples/test (prog): Be ready to run Java programs.