Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Beginner problem using EOF token(Trying to consume the complete remaining input of a file)
Beginner problem using EOF token [message #698819] Wed, 20 July 2011 09:57 Go to next message
Carmela  is currently offline Carmela Friend
Messages: 10
Registered: July 2011
Junior Member
Hi all,

maybe I miss some concepts or definitions here, but I hope I make myself understandable.

I'm using Xtext in order to parse and generate a metamodel of a vhdl module. However, I'm just interested in the interface of the vhdl module, not in the implementation of it. (I want to use it later to generate some code)
So I created a grammar for the interface part and now I just want to consume the rest of the text, without carrying about what is in it.

I looked at the documentation of Xtext and found the "Untill token" and "EOF", where EOF would better suit my needs, as it is described in the example given there:

"This allows to consume the complete remaining input of a file starting with a special delimiter.

terminal UNCLOSED_COMMENT : '/*' (!EOF)* EOF;"

However, when I add this terminal to the grammar, I got the following error twice:

error(154): ../esd.tools.vhdlinterface/src-gen/esd/tools/vhdlinterface/parser/antlr/internal/InternalVhdlModel.g:2672:32: Cannot complement rule EOF; not a simple set or element
error(139): ../esd.tools.vhdlinterface/src-gen/esd/tools/vhdlinterface/parser/antlr/internal/InternalVhdlModel.g:2672:30: set complement is empty

So... Is it something I'm doing wrong, an error in the documentation, a bug, something else?
If there is no fix for this, can anyone suggest me another way to get this done?

Thanks,
Carmela
Re: Beginner problem using EOF token [message #698824 is a reply to message #698819] Wed, 20 July 2011 10:19 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

does
terminal UNCLOSED_COMMENT : '/*' -> EOF;
work?

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Beginner problem using EOF token [message #698871 is a reply to message #698824] Wed, 20 July 2011 12:07 Go to previous messageGo to next message
Carmela  is currently offline Carmela Friend
Messages: 10
Registered: July 2011
Junior Member
Thanks for answering!

Actually, I've already tried this before. It doesn't really help...

In order to don't cause any conflict with ML_COMMENT, I changed it a little, but using the construction you suggested:

terminal READ_THE_REST : 'architecture' -> EOF;

If I use the terminal in a rule, I get the same error as before. If I don't, then I get this:



0 [main] INFO lipse.emf.mwe.utils.StandaloneSetup - Registering platform uri 'C:\Carmela\XTextWorkspace'
697 [main] INFO ipse.emf.mwe.utils.DirectoryCleaner - Cleaning C:\Carmela\XTextWorkspace\esd.tools.vhdlInterface\..\esd.tools.vhdlInterface\src-gen
718 [main] INFO ipse.emf.mwe.utils.DirectoryCleaner - Cleaning C:\Carmela\XTextWorkspace\esd.tools.vhdlInterface\..\esd.tools.vhdlInterface.ui\src-gen
858 [main] INFO ipse.xtext.generator.LanguageConfig - generating infrastructure for esd.tools.vhdlInterface.VhdlModel with fragments : ImplicitRuntimeFragment, ImplicitUiFragment, GrammarAccessFragment, EcoreGeneratorFragment, SerializerFragment, ResourceFactoryFragment, XtextAntlrGeneratorFragment, JavaValidatorFragment, ImportNamespacesScopingFragment, QualifiedNamesFragment, BuilderIntegrationFragment, GeneratorFragment, FormatterFragment, LabelProviderFragment, OutlineTreeProviderFragment, QuickOutlineFragment, QuickfixProviderFragment, JavaBasedContentAssistFragment, XtextAntlrUiGeneratorFragment, Junit4Fragment, TypesGeneratorFragment, XbaseGeneratorFragment, CodetemplatesGeneratorFragment, RefactorElementNameFragment, CompareFragment
2887 [main] INFO clipse.emf.mwe.utils.GenModelHelper - Registered GenModel '.tools.esd/vhdlInterface/VhdlModel' from 'file:/C:/Carmela/XTextWorkspace/esd.tools.vhdlInterface/src-gen/esd/tools/vhdlInterface/VhdlModel.genmodel'

error(201): ../esd.tools.vhdlInterface/src-gen/esd/tools/vhdlInterface/parser/antlr/internal/InternalVhdlModel.g:2672:62: The following alternatives can never be matched: 1

6125 [main] ERROR enerator.CompositeGeneratorFragment - java.io.FileNotFoundException: ..\esd.tools.vhdlInterface\src-gen\esd\tools\vhdlInterface\parser\antlr\internal\InternalVhdlModelLexer.java (The system cannot find the file specified)
org.eclipse.emf.common.util.WrappedException: java.io.FileNotFoundException: ..\esd.tools.vhdlInterface\src-gen\esd\tools\vhdlInterface\parser\antlr\internal\InternalVhdlModelLexer.java (The system cannot find the file specified)
at org.eclipse.xtext.util.Files.readFileIntoString(Files.java:124)
at org.eclipse.xtext.generator.parser.antlr.AbstractAntlrGeneratorFragment.suppressWarningsImpl(AbstractAntlrGeneratorFragment.java:130)
at org.eclipse.xtext.generator.parser.antlr.AbstractAntlrGeneratorFragment.suppressWarnings(AbstractAntlrGeneratorFragment.java:140)
at org.eclipse.xtext.generator.parser.antlr.AbstractAntlrGeneratorFragment.suppressWarnings(AbstractAntlrGeneratorFragment.java:136)
at org.eclipse.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment.generate(XtextAntlrGeneratorFragment.java:49)
at org.eclipse.xtext.generator.CompositeGeneratorFragment.generate(CompositeGeneratorFragment.java:81)
at org.eclipse.xtext.generator.LanguageConfig.generate(LanguageConfig.java:69)
at org.eclipse.xtext.generator.Generator.generate(Generator.java:351)
at org.eclipse.xtext.generator.Generator.invokeInternal(Generator.java:125)
at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:126)
at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.invoke(Mwe2Bridge.java:34)
at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:201)
at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.invoke(AbstractCompositeWorkflowComponent.java:35)
at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:19)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:97)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:73)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:64)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:55)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:74)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:35)
Caused by: java.io.FileNotFoundException: ..\esd.tools.vhdlInterface\src-gen\esd\tools\vhdlInterface\parser\antlr\internal\InternalVhdlModelLexer.java (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at org.eclipse.xtext.util.Files.readFileIntoString(Files.java:121)
... 19 more
6127 [main] INFO or.validation.JavaValidatorFragment - generating Java-based EValidator API

error(201): ../esd.tools.vhdlInterface.ui/src-gen/esd/tools/vhdlInterface/ui/contentassist/antlr/internal/InternalVhdlModel.g:5754:62: The following alternatives can never be matched: 1

7885 [main] ERROR enerator.CompositeGeneratorFragment - java.io.FileNotFoundException: ..\esd.tools.vhdlInterface.ui\src-gen\esd\tools\vhdlInterface\ui\contentassist\antlr\internal\InternalVhdlModelLexer.java (The system cannot find the file specified)
org.eclipse.emf.common.util.WrappedException: java.io.FileNotFoundException: ..\esd.tools.vhdlInterface.ui\src-gen\esd\tools\vhdlInterface\ui\contentassist\antlr\internal\InternalVhdlModelLexer.java (The system cannot find the file specified)
at org.eclipse.xtext.util.Files.readFileIntoString(Files.java:124)
at org.eclipse.xtext.generator.parser.antlr.AbstractAntlrGeneratorFragment.suppressWarningsImpl(AbstractAntlrGeneratorFragment.java:130)
at org.eclipse.xtext.generator.parser.antlr.AbstractAntlrGeneratorFragment.suppressWarnings(AbstractAntlrGeneratorFragment.java:140)
at org.eclipse.xtext.generator.parser.antlr.AbstractAntlrGeneratorFragment.suppressWarnings(AbstractAntlrGeneratorFragment.java:136)
at org.eclipse.xtext.generator.parser.antlr.XtextAntlrUiGeneratorFragment.generate(XtextAntlrUiGeneratorFragment.java:53)
at org.eclipse.xtext.generator.CompositeGeneratorFragment.generate(CompositeGeneratorFragment.java:81)
at org.eclipse.xtext.generator.LanguageConfig.generate(LanguageConfig.java:69)
at org.eclipse.xtext.generator.Generator.generate(Generator.java:351)
at org.eclipse.xtext.generator.Generator.invokeInternal(Generator.java:125)
at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:126)
at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.invoke(Mwe2Bridge.java:34)
at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:201)
at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.invoke(AbstractCompositeWorkflowComponent.java:35)
at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:19)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:97)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:73)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:64)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:55)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:74)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:35)
Caused by: java.io.FileNotFoundException: ..\esd.tools.vhdlInterface.ui\src-gen\esd\tools\vhdlInterface\ui\contentassist\antlr\internal\InternalVhdlModelLexer.java (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at org.eclipse.xtext.util.Files.readFileIntoString(Files.java:121)
... 19 more
7885 [main] INFO text.generator.junit.Junit4Fragment - generating Junit4 Test support classes
7899 [main] INFO text.generator.junit.Junit4Fragment - generating Compare Framework infrastructure
7991 [main] INFO .emf.mwe2.runtime.workflow.Workflow - Done.
Re: Beginner problem using EOF token [message #698877 is a reply to message #698871] Wed, 20 July 2011 12:16 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

sorry, I just saw that the documentation gives the rule just like in your first post. Have you tried the rule with a completely trivial grammar? If not, I'd say file a bug report.

Alex
Re: Beginner problem using EOF token [message #698897 is a reply to message #698877] Wed, 20 July 2011 12:40 Go to previous messageGo to next message
Carmela  is currently offline Carmela Friend
Messages: 10
Registered: July 2011
Junior Member
Hi,

I just created a new Xtext project and added the terminal rule to the example grammar. As simple as can be:

grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals

generate myDsl " xtext.org/example/mydsl/MyDsl"

Model:
greetings+=Greeting*;

Greeting:
'Hello' name=ID '!';

terminal READ_THE_REST : 'architecture' (!EOF)* EOF;



It returns the same problem as in the first post.
So, it seems I'll have to file a bug report.
But I still have to consume the rest of the file... Could you suggest any work around?

Thanks,
Carmela

PS. "generate MyDsl" is shortened because I'm still not allowed to use links.. :P
Re: Beginner problem using EOF token [message #698934 is a reply to message #698897] Wed, 20 July 2011 14:05 Go to previous message
Carmela  is currently offline Carmela Friend
Messages: 10
Registered: July 2011
Junior Member
Ok.. I think I found a workaround (at least I got no errors and it seems to do what I want so far...))

I created the following terminal:

terminal GetTheRest:
('architecture'|'ARCHITECTURE') (ANY_OTHER)*
;


where the word 'architecture' is my start delimiter...
Then I put 'GetTheRest' as the last element of the first parser rule of my grammar.

Actually not that complicated. It's just a little confusing for beginners to figure it out when the solution in the documentation keeps giving some errors...

Thanks Alex for your attention!

Carmela
Previous Topic:problem with pom.xml for my xtext example project
Next Topic:Automatic Code completion & automatic indents
Goto Forum:
  


Current Time: Wed Sep 30 22:37:27 GMT 2020

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

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

Back to the top