Commit Graph

2403 Commits

Author SHA1 Message Date
Renata Hodovan 3c21a640cc Fix imports in the Python2 sources.
Contrary to Python3, the lexers and parser generated for Python2 target
support only relative imports which causes a failure in case of
standalone scripts. The patch adapts these imports to work in both
cases.
2019-03-21 15:06:40 +01:00
Eric Vergnaud 81f7aee6ea fix failing tests 2019-01-01 17:02:29 +01:00
parrt 70d9ddcd0a [maven-release-plugin] prepare for next development iteration 2018-12-18 10:35:34 -08:00
parrt be58ebffde [maven-release-plugin] prepare release 4.7.2 2018-12-18 10:35:24 -08:00
parrt 8fab6b98b3 [maven-release-plugin] rollback the release of 4.7.2 2018-12-18 10:33:52 -08:00
parrt 573cb86705 [maven-release-plugin] prepare release 4.7.2 2018-12-18 10:31:44 -08:00
parrt 38a95da397 manual edits of 4.7.1 -> 4.7.2 2018-12-17 14:32:39 -08:00
Ivan Kochurkin 70e3e5de70 ElementFrequenciesVisitor: override stringRef(TerminalAST ref) for correct processing of arrays of string literals 2018-11-18 15:54:20 +03:00
Ivan Kochurkin d3745c7b93 RuleFunction: process STRING_LITERAL along with RULE_REF and TOKEN_REF. Add getRuleTokens method 2018-11-18 15:54:20 +03:00
Ivan Kochurkin 0a6dbc37b7 Grammar.java: add getTokenName(String literal) method 2018-11-18 15:54:20 +03:00
Joseph Smith 6f057dbc59 Use STGroupFile filename constructor
- URL constructor unnecessary
2018-11-13 14:59:12 -06:00
Joe R. Smith 7fcadaa9f7
Use release version of st4 2018-11-13 11:23:39 -06:00
Joe R. Smith 61d8aea398
Merge branch 'master' into master 2018-11-13 10:57:42 -06:00
Joseph Smith 6899cc5c76 update st4 dep 2018-11-13 10:56:25 -06:00
parrt 8047283de7 use latest ST4 2018-11-10 14:54:42 -08:00
parrt f6c6217804 Force usage of previousContext in Cpp 2018-11-09 11:31:59 -08:00
parrt 5aa0df9c45 Fixes #2350 2018-11-09 11:28:30 -08:00
parrt 7591bf1705 updated ST version 2018-11-08 12:27:38 -08:00
Terence Parr 696f9b93df
Merge branch 'master' into master 2018-10-23 08:35:10 -07:00
Terence Parr 03a0a40835
Merge pull request #2373 from renatahodovan/parser-import
[Python3] Fix the import of parser superclasses.
2018-10-08 12:35:48 -07:00
Renata Hodovan 301ac82631 [Python] Add missing lexer super class imports.
Although, both lexer and parser grammars can have a custom super
class set, but only the generated parser sources were prepared to
import these classes. The patch makes custom lexer ancestor
classes imported, too.
2018-10-08 14:42:30 +02:00
Renata Hodovan b748545707 [Python3] Fix the import of parser superclasses.
Until now, the generated Python3 code imported the custom parser
superclasses relatively. However, this only worked in Python3 if
the module was inside a package, since relative imports rely on
__name__ to determine the current module's position in the package
hierarchy. In case of a standalone script, this was always __main__
and hence these relative imports failed.
The patch handles this issue them same way as it is handled by
listener imports.
2018-10-08 13:59:57 +02:00
Terence Parr 1375995edb
Merge pull request #2190 from ericvergnaud/fix-#2188
fixes #2188
2018-07-24 15:56:43 -07:00
Terence Parr 171ef99e04
Merge branch 'master' into master 2018-07-13 17:44:53 -07:00
Terence Parr 61acb35f0c
Merge pull request #2299 from dhalperi/streamline-java-statics
Java.stg: use static functions instead of inline arrays
2018-06-02 13:00:42 -07:00
Daniel Halperin 2a6a107b49 Java.stg: use static functions instead of inline arrays 2018-05-30 21:17:59 -07:00
Stephen Vance 2971f37323 Update icu4j version to address CVEs 2018-05-23 09:01:07 -04:00
Joseph Smith 2daa261772 Don't generate interpreter data files if gencode is false 2018-04-26 13:06:04 -05:00
Joseph Smith 7e89f26e9b Initialize STGroupFile with url, not file path
- absolute file paths not reliable way to find resources on classpath
- requires changes to ST4 in this PR:
https://github.com/antlr/stringtemplate4/pull/199
2018-04-24 17:43:00 -05:00
Joseph Smith 6469934441 revert groupId change 2018-04-24 07:27:26 -05:00
Joseph Smith 8ce79eec81 Ensure file paths passed to STGroup[File] are absolute
- gracefully handle grammars without source fileNames
2018-04-23 18:55:23 -05:00
Eric Vergnaud 8629d46bbe fixes #2188 2018-01-01 14:13:11 +08:00
parrt 17b6277502 [maven-release-plugin] prepare for next development iteration 2017-12-09 12:04:26 -08:00
parrt bdc05c87be [maven-release-plugin] prepare release 4.7.1 2017-12-09 12:04:17 -08:00
parrt 763a1242b7 update version number and tweak doc 2017-12-08 12:47:11 -08:00
Terence Parr 489a11b7a2
Merge pull request #2066 from KvanTTT/unreachable-tokens
New unreachable token value warning
2017-12-06 12:35:53 -08:00
Terence Parr dd4a1c8709
Merge branch 'master' into lexer-atn-prop 2017-12-06 12:10:14 -08:00
Oran Epelbaum e22fbbcce8 [JavaScript] Added atn property to generated lexers, similarly to generated parsers. 2017-12-03 12:42:33 +02:00
Terence Parr edcf275a3c
Merge branch 'master' into Issue160_import_lexer_grammars 2017-11-29 09:59:50 -08:00
Nicolas d02844c813 This is one implementation addressing issue 160.
Change to support import of lexer grammars containing modes into other
lexer grammars. The semantics for this are,
   * sets of channels from all grammars are merged
   * rules of modes found in an imported grammar which are in the root
     grammar are merged into the root grammar mode.
   * modes which are not in the root grammar are added to the root
     grammar, excluding modes which become empty due to a re-definition of
     rules in the root grammar.
2017-11-28 21:57:57 +13:00
Ivan Kochurkin 07a0a80992 Yes another formatting fixes. 2017-11-25 16:29:03 +03:00
Ivan Kochurkin 5b11aed48d Restored formatting. 2017-11-25 16:24:13 +03:00
Ivan Kochurkin 64b2ced763 Added check for fragment rules. 2017-11-25 16:24:13 +03:00
Ivan Kochurkin f4c4e8b4a7 Added comments to checkForUnreachableTokens and getSingleTokenValues methods. 2017-11-25 16:24:13 +03:00
Ivan Kochurkin 58349e5ad3 } on line by themselves. 2017-11-25 16:24:13 +03:00
Ivan Kochurkin 328cdf3583 Fixed TOKEN_UNREACHABLE warning checks. 2017-11-25 16:24:13 +03:00
Ivan Kochurkin da57241c1d Added checkForUnreachableTokens method, added new TOKEN_UNREACHABLE error type.
tabs normalized.
2017-11-25 16:24:13 +03:00
Ewan Mellor ed52b5a053
Add an accessLevel parser option.
Add an accessLevel parser option.  Use this to specify the access level
(public, etc) used on the classes and protocols in the generated
parser / lexer / listeners.  This required adding the option to
tool.Grammar.parserOptions so that it was known as a valid option, and
to codegen.model.{Recognizer,ListenerFile,VisitorFile} so that it was
available to the template in all the necessary contexts.

The Swift template has been extended to recognize this option, and generate
classes and members using "open", "public" or "internal" as appropriate.

This is only fully implemented for Swift.  The option is generic, but
the language-specific templates will need to be updated for any language
that would like similar support.

Closes #1597.
2017-11-16 00:18:28 -08:00
Terence Parr 0e895afb04 don't generate interp data if there are errors (it needs to serialize ATN which can fail upon error). 2017-11-12 15:47:46 -08:00
Mike Lischke eaed562cb3 Merge branch 'master' into interpreter2 2017-11-11 11:06:53 +01:00
parrt b4c34da1f0 Merge branch 'master' of github.com:antlr/antlr4 2017-11-05 08:49:04 -08:00
Terence Parr c1b7bf94f6
Merge pull request #2098 from jasonmoo/rule_context_methods_fix
Add RuleContext interface methods to reserved words
2017-11-04 12:17:13 -07:00
Terence Parr 58ddf07905
Merge pull request #2093 from ewanmellor/swift-lexer-init-required
Make CharStream.init(CharStream) required (in the Swift runtime).
2017-11-04 10:50:51 -07:00
Terence Parr 21a38b3cea
Merge pull request #2086 from ewanmellor/message-output
Improve the "gnu" message format
2017-11-04 10:49:37 -07:00
Terence Parr 22842da4cb
Merge pull request #2085 from ewanmellor/fix-message-format-cmdline-option
Fix the -message-format command line option.
2017-11-04 10:48:39 -07:00
parrt 121e767409 fold in Mike Lischke's PR https://github.com/antlr/antlr4/pull/2065 to make the output directory exact if you use a new option `-Xexact-output-dir`. Fixes #1087, Fixes #753, Fixes #638. 2017-11-04 10:34:09 -07:00
parrt 5665502bf9 Merge branch 'output-path' of git://github.com/mike-lischke/antlr4 into mike-lischke-output-path 2017-11-04 09:48:12 -07:00
Jason Mooberry ff2b6344b5 Exclude RuleContext interface methods from parse rule names to avoid rule/method name collision. Fixes #2080. 2017-11-02 17:19:22 -04:00
Ewan Mellor 5bb93813a0
Make CharStream.init(CharStream) required (in the Swift runtime).
This makes it possible for client code to use CharStream as a generic type
constraint and construct Lexer subclasses generically.
2017-10-31 14:44:43 -07:00
Ewan Mellor 4729fe8285
Change the "gnu" message format.
Add the column to the location; this is something that GCC and other
GNU tools do, and is obviously useful for IDEs.

Move the message ID so that it reads e.g. "... [error 50]". This mimics
GCC's [-Wformat] kind of thing and is more obvious than the (50) that we
were using before.
2017-10-29 12:03:04 -07:00
Ewan Mellor 8f639f28dd
Put full filepaths in error messages when not using the default message format.
When the default "antlr" message format is used, ErrorManager deliberately
only includes the filename in any error message, not the full path, to
keep the messages short.  However, if the error message is intended to be
parsed by an IDE, this is no good.

Address this by printing the full path when using alternate message formats.
There are two formats available today -- "gnu" and "vs2005".  I think it's
reasonable to assume that people would use these for IDE compatibility, and
so using the full path for these is appropriate.  Also, they didn't work
until very recently, so this isn't breaking any existing behavior.
2017-10-29 12:03:04 -07:00
Ewan Mellor f2638b290d
Fix the -message-format command line option.
ErrorManager.setFormat was being called before the command line options
were parsed in handleArgs.  This meant that setFormat was always called
with the default, and so the command line option never took effect.

This option apparently only worked for 2.5 hours on Sep 6 2012 ;-)

Closes #992.
2017-10-29 11:58:16 -07:00
Ewan Mellor c8c577c332
Very minor fix in error handling path for the -o command line option.
If the specified output path was a file and not a directory, the error
handling intended to invalidate outputDirectory, but due to an apparent
copy-paste error, it invalidated libDirectory instead.
2017-10-29 11:49:06 -07:00
Ewan Mellor fbe8c0d2a6
Tidy up the exception handling around RecognitionException.
This removes the generic parameter on RecognitionException, to make it
easier to handle them.  This means that we no longer need to store them as
AnyObject and cast them back again.  To do this, we add RecognizerProtocol,
which is a non-generic equivalent of the Recognizer interface (at least, the
parts of it that we need for error handling).

Remove all paths where the RecognitionException subclasses were throwing
exceptions in their initializers.  This is just insane.
2017-10-25 13:30:08 -07:00
Ewan Mellor 6c11160b51
Remove tokenNames / getTokenNames from the Recognizer interface.
This has been ported over from the Java code, but it was deprecated there.
There's no point having it in the Swift runtime because we don't have the
legacy code to support.  Also, it wasn't implemented properly, so it
never worked.

Remove {DFA,IntervalSet}.toString(_:[String?]?)
and the inits in ParserInterpreter and DFASerializer for the same reason.
Switch the unit tests to use the alternate toString(_:Vocabulary).
2017-10-25 13:28:40 -07:00
Ewan Mellor 23f532ddbd
Minor tidyups in the Swift runtime.
This fixes some hangovers from the port from Java:
* unnecessary type annotations;
* failure to use "if let" for nil checks;
* comments with Java code in them;
* a couple of fields that should have been declared private;
* some whitespace issues.

No semantic change.
2017-10-25 13:28:40 -07:00
rlfnb 639a6995f1 added SVG export to the TestRig 2017-10-22 15:48:54 +02:00
Mike Lischke 16242e43c0 Merge branch 'master' into interpreter2 2017-10-22 13:48:10 +02:00
Mike Lischke 593da3df5e Reapplied changes that got lost during merge. 2017-10-22 12:27:49 +02:00
Terence Parr 8778ad65c4 Merge pull request #2047 from bramp/commonsetstuff
[Go] Placed the CommonSetStuff code inside a scope
2017-10-12 09:42:32 -07:00
Terence Parr 2b529d8529 Merge branch 'master' into fragment_only_grammar 2017-10-10 12:55:01 -07:00
Terence Parr 2938e7a3ab Merge pull request #1870 from KvanTTT/master
All error codes distinct
2017-10-10 12:41:50 -07:00
Terence Parr f6b3571e97 Merge branch 'master' into master 2017-10-10 12:39:18 -07:00
Andrew Brampton 9f90d51442
Placed the CommonSetStuff code inside a scope, this is to avoid two _lt variables in the same scope. This happens with the mysql grammar: `build: previous declaration at mysql/mysql_parser.go:12215:6` 2017-10-06 08:06:56 -07:00
Ewan Mellor 99d32dc861
Add some version numbers to pom.xml.
This silences warnings from Maven.
2017-09-28 16:10:26 -07:00
Terence Parr f8b272a721 Merge pull request #1950 from ericvergnaud/fix-naming-issue
fix inconsistent naming in target stg
2017-09-17 11:18:44 -07:00
Bráulio Bezerra dc77aacfcd Fix codegen error (Java) when a lexer has only fragment tokens
Solves issue #1999.
2017-09-09 12:02:42 -03:00
Venkat Peri e123bb8cea removed proto level stuff (one more) 2017-07-24 15:11:00 -04:00
Venkat Peri caa5e46def removed proto level stuff 2017-07-24 15:09:43 -04:00
Venkat Peri e01af374d2 'requires' SUPERclass for Lexers in split mode, symbols/modes/channels available on Lexer prototype for use in lexer actions (this.SOME_MODE) like in Java actions, Utils.escapeWhiteSpace uses regex for global replace (was replacing only first occurnce of \n etc). 2017-07-22 18:11:37 -04:00
Eric Vergnaud 0930095207 fix inconsistent naming in target stg 2017-07-15 12:19:54 +08:00
Mike Lischke aa2d34bdfd Merge branch 'master' into interpreter2 2017-06-30 13:44:11 +02:00
Sergey Parshukov 49b462f960 Go file header complies with standardised Go 'generated code' header 2017-06-28 11:43:50 +03:00
Terence Parr 916a872529 Merge pull request #1918 from renatahodovan/indent-with-spaces
Use spaces consistently to indent the generated Python code.
2017-06-27 08:16:02 -07:00
Terence Parr 3a7c6a662a Merge pull request #1910 from mike-lischke/optimizations
Reverted removal of namespace.
2017-06-25 08:36:02 -07:00
Renata Hodovan 96d42d833a Use spaces consistently to indent the generated Python code. 2017-06-15 18:29:53 +02:00
Mike Lischke 2b3dd222bd Reverted removal of namespace. 2017-06-12 09:26:11 +02:00
Terence Parr 35cf1ba4ff Merge pull request #1907 from mike-lischke/optimizations
[C++] Small optimizations
2017-06-11 08:54:21 -07:00
Ivan Kochurkin 7dc17ace6e Distinct error codes, added unit-test. fixes #1865. 2017-05-14 13:23:53 +03:00
Mike Lischke 25eeb94498 Rule names are now always written to interpreter data file.
Updated loaders for Java and C++.
2017-05-05 17:00:41 +02:00
Mike Lischke 126eec7092 2 corrections (C++ runtime and interpreter data writer)
- A wrong check for EOF has been corrected in the UnbufferedTokenStream (now using the correct data type for the cast to avoid warnings).
- The interpreter data write function no longer implicitly writes out imported grammars. Grammars are merged and hence contain everything from imported grammars already. If interpreter data for an imported grammar is required pass that grammar explicitly to the ANTLR tool.
2017-04-23 13:05:27 +02:00
Mike Lischke 3bffb070b2 Final touches on Java part. 2017-04-21 17:32:44 +02:00
Mike Lischke 3f7c67106b Interpreter is now always generated. Doc updated. 2017-04-21 17:15:51 +02:00
Mike Lischke 8995f0559f Adds a new option to allow ANTLR to generate interpreter data.
Especially when you want to use LexerInterpreter and/or ParserInterpreter in any of the non-Java targets you have to provide the ATN and other data. The classes to generate these values are not in the runtime, however. Hence we need a way to tell ANTLR to produce that in a way that can be consumed by all targets.

This patch adds a new command line parameter (-interpreter) which causes ANTLR to parse the given grammars as usual and then let it generated a file for each grammar with the required interpreter values. A new InterpreterDataReader class has been added to the Java + C++ runtimes. This class can load the data file (a plain text file) and generate the structures that can directly be fed to the interpreters.
2017-04-15 16:55:49 +02:00
parrt f858cd5948 Fixes #1815 (for real this time!). Fix text set for erroneous escapes so tool doesn't fail later. Remove some duplicate error messages. Add test for #1815. 2017-04-06 14:34:37 -07:00
parrt 80aa7907a4 Fixes #1815. Add info on what the invalid escape is. Match \x for any x but give error. This prevents \x from appearing like a sequence of 2 char. Updated unit tests. 2017-04-06 10:26:03 -07:00
Ben Hamilton 1fd2d1b434 Python 3 codegen probably didn't mean to limit ATN segment size to 2 XOR 31 2017-03-31 09:27:23 -07:00
parrt 62baf4bd0a [maven-release-plugin] prepare for next development iteration 2017-03-30 14:11:59 -07:00
parrt d4d7e3d3bc [maven-release-plugin] prepare release 4.7 2017-03-30 14:11:49 -07:00
parrt b5648f405b tweak documentation about various targets 2017-03-30 10:44:28 -07:00