|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: The code for the static initializer is exceeding the 65535 bytes limit [message #924902 is a reply to message #924151] |
Thu, 27 September 2012 08:11 |
Sebastian Zarnekow Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
Am 26.09.12 17:02, schrieb Vil Lpz:
> Hello again.
>
> Attached to this post is my grammar in a single file and the mwe2.
>
> If you go to line 641 of xtext file and uncomment and that line (or any of the others that are commented) is when the error "The code for the static initializer is exceeding the 65535 bytes limit" appears ...
>
> I took several days mulling over this and I don't know what can I do to generate all my grammar without problems... :?
>
> Any help is welcome.
>
> Thank you!
> Virgilio
>
Hi Vil,
there are some suspicuous parts in your grammar:
TdType - the unordered group has to be put into parentheses, though I'm
not sure that your really want an unordered group here or just a loop
over an alternative:
(
'>'
/*
* Content Model
* ( PCDATA | output? | span* | image* | p* )
*/
( tdMix += TdMix* & text = (StringPart | IdealExpressionPart) )
'</td>'
)
This construct will lead to an ambiguity in the UI grammar. Therefore I
recommend to rewrite it to something along these lines:
( tdMix += TdMix*
| text = (StringPart | IdealExpressionPart)
) // | Expresion // ojo en este expresion faltan los ${...}
This matches the patterns that you applied in other parts of your grammar.
SelectContent - the rule matches the empty input. Better make the rule
call optional and rewrite it to something like:
SelectContent:
{SelectContent}
/*
* Content Model
* ( label? , ( ( item | separator )* | repeat )? )
*/
label=LabelType (
selectMix+=SelectMix+ repeat=RepeatType?
| repeat=RepeatType selectMix+=SelectMix*
)?
| selectMix+=SelectMix+ repeat=RepeatType?
| repeat=RepeatType selectMix+=SelectMix*
;
Please note that it's often better to manually transform unordered
groups if they are sufficiently small (2 or 3 elements). Also note that
your SelectContent (and my rewritten version) does not seem to match the
DTD snippet in the comment.
In order to split the generated 17MB file properly, you have to apply
the following substitutions by means of regular expressions:
search for: "class DFA\d+ extends DFA \{"
replace with: "" (empty string)
search for: "(static final String DFA(\d+)_eotS =)"
replace with: "static class DFA$2 extends HackedDFA {\n $1"
search for: "this\.recognizer = recognizer;"
replace with: "super(recognizer);"
Add this method to the IntegernalXXXParser1 class (at the top):
RecognizerSharedState getRecognizerSharedState() {
return state;
}
and add this class to UI Parser file:
class HackedDFA extends DFA {
protected RecognizerSharedState state;
protected XXXGrammarAccess grammarAccess;
HackedDFA(BaseRecognizer recognizer) {
this.recognizer = recognizer;
this.grammarAccess =
((IntegernalXXXParser1)recognizer).grammarAccess;
this.state =
((IntegernalXXXParser1)recognizer).getRecognizerSharedState();
}
protected IUnorderedGroupHelper getUnorderedGroupHelper() {
return getRecognizer().getUnorderedGroupHelper();
}
}
where XXX is the name of your language.
If you do frequent changes in your grammar, I recommend to write a small
IGeneratorFragment that performs these steps automatically and use that
one in the MWE workflow.
Please not that you most likely cannot open the generated Parser file
with the Eclipse Java editor and try to perform those steps. The text
editor works fine, though you probably have to ignore some OutOfMemory
errors from Eclipse.
Since these extraction steps are easy to automate, I confident that
we'll be able to provide them with Eclipse Kepler as part of the class
splitting.
Regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
|
|
|
Re: The code for the static initializer is exceeding the 65535 bytes limit [message #925244 is a reply to message #924902] |
Thu, 27 September 2012 14:28 |
Vil Lpz Messages: 24 Registered: April 2012 |
Junior Member |
|
|
Hello Sebastian, thanks a lot for your time.
Thanks a lot for the grammar advices. I't my first serious grammar and I supose I have mistakes, so any advice is very welcome, even about the style.
I tried your solution. But isn't worked ... I try to make the changes only the UI project and the grammar and UI project both. But the result is that when I execute the UI project and try to use the context proposal (CTRL+Space) I obtain the following error:
!SESSION 2012-09-27 13:49:52.247 -----------------------------------------------
eclipse.buildId=I20120608-1400
java.version=1.6.0_25
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=es_ES
Framework arguments: -product org.eclipse.sdk.ide
Command-line arguments: -product org.eclipse.sdk.ide -data C:\Users\virgilio.garcia\Desktop\WS/../runtime-EclipseApplication -dev file:C:/Users/virgilio.garcia/Desktop/WS/.metadata/.plugins/org.eclipse.pde.core/Eclipse Application/dev.properties -os win32 -ws win32 -arch x86_64 -consoleLog
!ENTRY org.eclipse.ui 2 2 2012-09-27 13:50:17.076
!MESSAGE Invalid property category path: ValidationPropertiesPage (bundle: org.eclipse.wst.xml.ui, propertyPage: org.eclipse.wst.xml.ui.propertyPage.project.validation)
!ENTRY org.eclipse.e4.ui.workbench 4 0 2012-09-27 13:50:34.652
!MESSAGE
!STACK 0
org.eclipse.e4.core.di.InjectionException: org.eclipse.core.commands.ExecutionException: While executing the action, an exception occurred
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:63)
at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:229)
at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:210)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:131)
at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:171)
at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.executeCommand(KeyBindingDispatcher.java:276)
at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.press(KeyBindingDispatcher.java:494)
at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.processKeyEvent(KeyBindingDispatcher.java:545)
at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.filterKeySequenceBindings(KeyBindingDispatcher.java:366)
at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.access$0(KeyBindingDispatcher.java:313)
at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher$KeyDownFilter.handleEvent(KeyBindingDispatcher.java:82)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1262)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1052)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1104)
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1100)
at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1521)
at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:4640)
at org.eclipse.swt.widgets.Canvas.WM_CHAR(Canvas.java:345)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4528)
at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:341)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4976)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2546)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3756)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1022)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:916)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:585)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:540)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
at org.eclipse.equinox.launcher.Main.main(Main.java:1414)
Caused by: org.eclipse.core.commands.ExecutionException: While executing the action, an exception occurred
at org.eclipse.jface.commands.ActionHandler.execute(ActionHandler.java:124)
at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
... 48 more
Caused by: com.google.inject.ProvisionException: Guice provision errors:
1) Error in custom provider, java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at mymw.ideal2dsl.ui.AbstractIdeal2DslUiModule.configureContentAssistLexerProvider(AbstractIdeal2DslUiModule.java:123)
while locating mymw.ideal2dsl.ui.contentassist.antlr.internal.InternalIdeal2DslLexer
while locating org.eclipse.xtext.ui.editor.contentassist.antlr.internal.Lexer annotated with @com.google.inject.name.Named(value=org.eclipse.xtext.ui.editor.contentassist.antlr.internal.Lexer.CONTENT_ASSIST)
for field at org.eclipse.xtext.ui.editor.contentassist.antlr.ParserBasedContentAssistContextFactory$StatefulFactory.lexer(Unknown Source)
while locating org.eclipse.xtext.ui.editor.contentassist.antlr.ParserBasedContentAssistContextFactory$StatefulFactory
1 error
at com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:987)
at org.eclipse.xtext.ui.editor.contentassist.antlr.ParserBasedContentAssistContextFactory.create(ParserBasedContentAssistContextFactory.java:577)
at org.eclipse.xtext.ui.editor.contentassist.CompletionProposalComputer.exec(CompletionProposalComputer.java:48)
at org.eclipse.xtext.ui.editor.contentassist.CompletionProposalComputer.exec(CompletionProposalComputer.java:1)
at org.eclipse.xtext.util.concurrent.AbstractReadWriteAcces.readOnly(AbstractReadWriteAcces.java:32)
at org.eclipse.xtext.ui.editor.model.XtextDocument.readOnly(XtextDocument.java:78)
at org.eclipse.xtext.ui.editor.contentassist.XtextContentAssistProcessor.computeCompletionProposals(XtextContentAssistProcessor.java:68)
at org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals(ContentAssistant.java:1839)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals(CompletionProposalPopup.java:566)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$16(CompletionProposalPopup.java:563)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup$2.run(CompletionProposalPopup.java:498)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals(CompletionProposalPopup.java:492)
at org.eclipse.jface.text.contentassist.ContentAssistant.showPossibleCompletions(ContentAssistant.java:1665)
at org.eclipse.jface.text.source.SourceViewer.doOperation(SourceViewer.java:932)
at org.eclipse.jface.text.source.projection.ProjectionViewer.doOperation(ProjectionViewer.java:1507)
at org.eclipse.ui.texteditor.ContentAssistAction$1.run(ContentAssistAction.java:82)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ui.texteditor.ContentAssistAction.run(ContentAssistAction.java:80)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
at org.eclipse.jface.commands.ActionHandler.execute(ActionHandler.java:119)
... 54 more
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at org.eclipse.xtext.parser.antlr.LexerProvider.get(LexerProvider.java:46)
at org.eclipse.xtext.parser.antlr.LexerProvider.get(LexerProvider.java:1)
at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:40)
at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:54)
at com.google.inject.internal.SingleFieldInjector.inject(SingleFieldInjector.java:53)
at com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:110)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:94)
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:254)
at com.google.inject.internal.InjectorImpl$4$1.call(InjectorImpl.java:978)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1024)
at com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:974)
... 74 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.eclipse.xtext.parser.antlr.LexerProvider.get(LexerProvider.java:43)
... 84 more
Caused by: java.lang.ClassCastException: mymw.ideal2dsl.ui.contentassist.antlr.internal.InternalIdeal2DslLexer cannot be cast to mymw.ideal2dsl.ui.contentassist.antlr.internal.InternalIdeal2DslParser1
at mymw.ideal2dsl.ui.contentassist.antlr.internal.HackedDFA.<init>(InternalIdeal2DslParser.java:5760)
at mymw.ideal2dsl.ui.contentassist.antlr.internal.InternalIdeal2DslLexer$DFA8.<init>(InternalIdeal2DslLexer.java:10041)
at mymw.ideal2dsl.ui.contentassist.antlr.internal.InternalIdeal2DslLexer.<init>(InternalIdeal2DslLexer.java:8894)
at mymw.ideal2dsl.ui.contentassist.antlr.internal.InternalIdeal2DslLexer.<init>(InternalIdeal2DslLexer.java:318)
... 89 more
I tested with 2 xtext revisions (2.3.1 and 2.2.1) in 2 different eclipses and the problem is the same.
Any idea about can it happen?
Thanks a lot for the support.
Greetings.
|
|
|
Re: The code for the static initializer is exceeding the 65535 bytes limit [message #1037323 is a reply to message #889486] |
Tue, 09 April 2013 12:20 |
|
Hi Frank,
If you are still have this problem, you can work around
by moving the static tokenNames declaration to getTokenNames()
method. I tried the suggestions on the forums (setting
fieldsPerClass and methodsPerClass, etc), but I couldn' t
solved except this manual work around. If I automate this
replacement, I' ll share also.
Best regards,
Sezgin
Delete
private static final String[] tokenNames = new String[] {
// a long token list here
};
Replace
public String[] getTokenNames() { return InternalNgiDslParser.tokenNames; }
with
public String[] getTokenNames() {
return new String[] {
// a long token list here
};
}
|
|
|
Powered by
FUDForum. Page generated in 0.05784 seconds