Home » Modeling » TMF (Xtext) » Fix for Bug 349992 does not fix "Too many constants error in generated internalXXXParser.java&q
Fix for Bug 349992 does not fix "Too many constants error in generated internalXXXParser.java&q [message #721081] |
Wed, 31 August 2011 20:42 |
Alex Ruiz Messages: 103 Registered: March 2011 |
Senior Member |
|
|
Greetings,
I'm working on a Xtext-based editor with a humongous grammar (it is an existing language, and no chance to make changes to it.) I was hit by Bug 349992 ( https://bugs.eclipse.org/bugs/show_bug.cgi?id=349992 ) and tried the fix with this build: https://hudson.eclipse.org/hudson/view/Modeling/job/Xtext-nightly-HEAD/1325/ and it worked fine.
I kept working on the grammar and then I got hit with the error "Too many constants error in generated internalXXXParser.java". I tried to lower the number of "fieldsPerClass" to 250 and 200 and nothing seems to work.
The grammar I'm working on is for the Google BUILD language, as described here: http://google-engtools.blogspot.com/2011/08/build-in-cloud-how-build-system-works.html . The grammar has a lot of rules, some of them sharing the same attributes (but it looks like I can not create something like an "abstract grammar" and have concrete ones extend it. Here is an example of how the grammar looks like:
CcBinaryRule:
'cc_binary' '(' 'name' '=' name=Name
(',' 'srcs' '=' srcs=Labels)?
(',' 'data' '=' data=Labels)?
(',' 'deps' '=' deps=Labels)?
(',' 'defines' '=' defines=Strings)?
(',' 'includes' '=' includes=Strings)?
(',' 'hdrs_check' '=' hdrs_check=HdrsCheck)?
(',' 'copts' '=' copts=Opts)?
(',' 'nocopts' '=' nocopts=NoCOpts)?
(',' 'linkopts' '=' linkopts=LinkOpts)?
(',' 'linkstatic' '=' linkstatic=Bool)?
(',' 'linkshared' '=' linkshared=Bool)?
(',' 'stamp' '=' stamp=Stamp)?
(',' 'malloc' '=' malloc=Label)?
(',' 'abi' '=' abi=Abi)?
(',' 'abi_deps' '=' abi_deps=AbiDeps)?
(',' 'plugins' '=' plugins=CCPlugin)?
(',' 'deprecation' '=' deprecation=STRING)?
(',' 'distribs' '=' distribs=Strings)?
(',' 'licenses' '=' licenses=Strings)?
(',' 'obsolete' '=' obsolete=Bool)?
(',' 'tags' '=' tags=Strings)?
(',' 'testonly' '=' testonly=Bool)?
(',' 'visibility' '=' visibility=Visibility)?
(',' 'output_licenses' '=' output_licenses=Strings)?
(',')? ')';
JavaBinaryRule:
'java_binary' '(' 'name' '=' name=Name
(',' 'srcs' '=' srcs=Labels)?
(',' 'data' '=' data=Labels)?
(',' 'deps' '=' deps=Labels)?
(',' 'strict_java_deps' '=' strict_java_deps=Bool)?
(',' 'main_class' '=' main_class=STRING)?
(',' 'classpath_resources' '=' classpath_resources=Strings)?
(',' 'jvm_flags' '=' jvm_flags=Opts)?
(',' 'resources' '=' resources=Labels)?
(',' 'javacopts' '=' javacopts=Opts)?
(',' 'use_testrunner' '=' use_testrunner=Bool)?
(',' 'deploy_manifest_lines' '=' deploy_manifest_lines=Strings)?
(',' 'stamp' '=' stamp=Stamp)?
(',' 'create_executable' '=' create_executable=Bool)?
(',' 'plugins' '=' plugins=Labels)?
(',' 'args' '=' args=Opts)?
(',' 'output_licenses' '=' output_licenses=Strings)?
(',' 'deprecation' '=' deprecation=STRING)?
(',' 'distribs' '=' distribs=Strings)?
(',' 'licenses' '=' licenses=Strings)?
(',' 'obsolete' '=' obsolete=Bool)?
(',' 'tags' '=' tags=Strings)?
(',' 'testonly' '=' testonly=Bool)?
(',' 'visibility' '=' visibility=Visibility)?
(',')? ')';
Any hints on how to fix this problem (by either refactoring the grammar) or if you already have plans to fix this issue?
Many thanks in advance,
-Alex
|
|
| |
Re: Fix for Bug 349992 does not fix "Too many constants error in generated internalXXXParse [message #721142 is a reply to message #721081] |
Thu, 01 September 2011 00:40 |
Henrik Lindberg Messages: 2509 Registered: July 2009 |
Senior Member |
|
|
One way would naturally be to make the grammar more abstract - the part
shown looks like it could be expressed as:
TypeWithParameters :
type = typeName '(' name = Name
(',' properties += PropertyAssignment)*
')' ;
PropertyAssignment : name = ID '=' value = Value ;
Value : STRING | INT | ID | ... ;
....or somesuch
You would naturally take on more responsability in the checker (match
type with possible property names, flag errors, etc.), you also need to
tweak how proposals work.
I do something similar in cloudsmith/Geppeto (at github), where I have a
type to "properties and parameters" model that holds the information. In
my case, the set of types, properties and parameters is extensible in
ruby code and in the DSL language so I deal with the issues during
linking. If the set is not that dynamic, it could simply be kept in a
resource that represents the "standard type library".
I hope that is of some help.
Regards
- henrik
On 8/31/11 10:42 PM, Alex Ruiz wrote:
> Greetings,
>
> I'm working on a Xtext-based editor with a humongous grammar (it is an
> existing language, and no chance to make changes to it.) I was hit by
> Bug 349992 ( https://bugs.eclipse.org/bugs/show_bug.cgi?id=349992 ) and
> tried the fix with this build:
> https://hudson.eclipse.org/hudson/view/Modeling/job/Xtext-nightly-HEAD/1325/
> and it worked fine.
>
> I kept working on the grammar and then I got hit with the error "Too
> many constants error in generated internalXXXParser.java". I tried to
> lower the number of "fieldsPerClass" to 250 and 200 and nothing seems to
> work.
>
> The grammar I'm working on is for the Google BUILD language, as
> described here:
> http://google-engtools.blogspot.com/2011/08/build-in-cloud-how-build-system-works.html
> . The grammar has a lot of rules, some of them sharing the same
> attributes (but it looks like I can not create something like an
> "abstract grammar" and have concrete ones extend it. Here is an example
> of how the grammar looks like:
>
>
> CcBinaryRule:
> 'cc_binary' '(' 'name' '=' name=Name
> (',' 'srcs' '=' srcs=Labels)? (',' 'data' '=' data=Labels)?
> (',' 'deps' '=' deps=Labels)? (',' 'defines' '=' defines=Strings)?
> (',' 'includes' '=' includes=Strings)?
> (',' 'hdrs_check' '=' hdrs_check=HdrsCheck)?
> (',' 'copts' '=' copts=Opts)?
> (',' 'nocopts' '=' nocopts=NoCOpts)?
> (',' 'linkopts' '=' linkopts=LinkOpts)?
> (',' 'linkstatic' '=' linkstatic=Bool)?
> (',' 'linkshared' '=' linkshared=Bool)?
> (',' 'stamp' '=' stamp=Stamp)?
> (',' 'malloc' '=' malloc=Label)?
> (',' 'abi' '=' abi=Abi)?
> (',' 'abi_deps' '=' abi_deps=AbiDeps)?
> (',' 'plugins' '=' plugins=CCPlugin)?
> (',' 'deprecation' '=' deprecation=STRING)?
> (',' 'distribs' '=' distribs=Strings)?
> (',' 'licenses' '=' licenses=Strings)?
> (',' 'obsolete' '=' obsolete=Bool)?
> (',' 'tags' '=' tags=Strings)?
> (',' 'testonly' '=' testonly=Bool)?
> (',' 'visibility' '=' visibility=Visibility)?
> (',' 'output_licenses' '=' output_licenses=Strings)?
> (',')? ')';
> JavaBinaryRule:
> 'java_binary' '(' 'name' '=' name=Name
> (',' 'srcs' '=' srcs=Labels)? (',' 'data' '=' data=Labels)?
> (',' 'deps' '=' deps=Labels)? (',' 'strict_java_deps' '='
> strict_java_deps=Bool)?
> (',' 'main_class' '=' main_class=STRING)?
> (',' 'classpath_resources' '=' classpath_resources=Strings)?
> (',' 'jvm_flags' '=' jvm_flags=Opts)?
> (',' 'resources' '=' resources=Labels)?
> (',' 'javacopts' '=' javacopts=Opts)?
> (',' 'use_testrunner' '=' use_testrunner=Bool)?
> (',' 'deploy_manifest_lines' '=' deploy_manifest_lines=Strings)?
> (',' 'stamp' '=' stamp=Stamp)?
> (',' 'create_executable' '=' create_executable=Bool)?
> (',' 'plugins' '=' plugins=Labels)?
> (',' 'args' '=' args=Opts)?
> (',' 'output_licenses' '=' output_licenses=Strings)?
> (',' 'deprecation' '=' deprecation=STRING)?
> (',' 'distribs' '=' distribs=Strings)?
> (',' 'licenses' '=' licenses=Strings)?
> (',' 'obsolete' '=' obsolete=Bool)?
> (',' 'tags' '=' tags=Strings)?
> (',' 'testonly' '=' testonly=Bool)?
> (',' 'visibility' '=' visibility=Visibility)?
> (',')? ')';
>
> Any hints on how to fix this problem (by either refactoring the grammar)
> or if you already have plans to fix this issue?
>
> Many thanks in advance,
> -Alex
>
|
|
| | | | | |
Goto Forum:
Current Time: Thu Apr 25 19:40:15 GMT 2024
Powered by FUDForum. Page generated in 0.12539 seconds
|