Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
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 Go to next message
Alex Ruiz is currently offline Alex RuizFriend
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 internalXXXParser.ja [message #721113 is a reply to message #721081] Wed, 31 August 2011 22:40 Go to previous messageGo to next message
Alex Ruiz is currently offline Alex RuizFriend
Messages: 103
Registered: March 2011
Senior Member
Sorry, I meant "abstract rule" Very Happy
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 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
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
>
Re: Fix for Bug 349992 does not fix "Too many constants error in generated internalXXXParse [message #721190 is a reply to message #721142] Thu, 01 September 2011 07:05 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
We want to fix this problem, but I cannot make any promises whether it's going to be in 2.1. Sorry.
Re: Fix for Bug 349992 does not fix "Too many constants error in generated internalXXXParse [message #721410 is a reply to message #721190] Thu, 01 September 2011 17:09 Go to previous messageGo to next message
Alex Ruiz is currently offline Alex RuizFriend
Messages: 103
Registered: March 2011
Senior Member
Thanks Henrik, I was thinking about doing something similar. Thanks for confirming it works!

Sven, no worries. I'm not expecting a fix right away. I took a peek at the Xtext code and it is not an easy task. I just wanted to confirm if there is a planned fix or not, so I can decide what to do Smile

I'll move forward with an approach similar to Henrik's.

Cheers,
-Alex
Re: Fix for Bug 349992 does not fix "Too many constants error in generated internalXXXParse [message #721485 is a reply to message #721410] Thu, 01 September 2011 21:33 Go to previous messageGo to next message
Alex Ruiz is currently offline Alex RuizFriend
Messages: 103
Registered: March 2011
Senior Member
Hi Sven,

A co-worker of mine suggested something even better. Instead of me implementing a simpler grammar and compensate with Java code (for checks, etc.) I could work with a subset of the grammar and wait till the fix is in place. Luckily I have this flexibility Smile

Please don't get me wrong. No pressure on when you'll have the fix in place. I'd really appreciate to be told whenever you have an estimate for the fix, just for planning purposes. Again, no pressure Smile

Should I reopen this bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=328753 or create a new one?

Cheers,
-Alex

Cheers,
Re: Fix for Bug 349992 does not fix "Too many constants error in generated internalXXXParse [message #721618 is a reply to message #721485] Fri, 02 September 2011 10:39 Go to previous messageGo to next message
Elhamlaoui Mahmoud is currently offline Elhamlaoui MahmoudFriend
Messages: 268
Registered: March 2010
Senior Member
Hi Sven & Alex,

There is a temporary solution that you can try(its works fine with me) by doing a manual splitting: your InternalXXXParser class must extend from an other class that you have to create:SplittedInternalXXXParser instead of AbstractInternalContentAssistParser and in your splitted class you move a maximum of constant attributes and operations and you make this class extend from AbstractInternalContentAssistParser.
Doing so will solve your problem,waiting that the xtext team to provide us an automatic one.

Best regards,
Mahmoud

Re: Fix for Bug 349992 does not fix "Too many constants error in generated internalXXXParse [message #722181 is a reply to message #721618] Mon, 05 September 2011 00:44 Go to previous message
Alex Ruiz is currently offline Alex RuizFriend
Messages: 103
Registered: March 2011
Senior Member
Thanks so much Mahmoud! I'll give it a try Smile

Cheers!
-Alex
Previous Topic:Xtext -> XPand Workflow - How to for new Eclipse version
Next Topic:Compile-time expressions: xbase or not ?
Goto Forum:
  


Current Time: Thu Apr 25 19:40:15 GMT 2024

Powered by FUDForum. Page generated in 0.12539 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top