Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » ID being anything except Newlines creating problems
ID being anything except Newlines creating problems [message #1698680] Wed, 17 June 2015 08:55 Go to next message
Anton Bergman is currently offline Anton BergmanFriend
Messages: 34
Registered: June 2015
Member
In my grammar, I want ID's to be any character, except it has to be on a single line of code.

I also want some kind of string, which would be any following of characters and it can be on several lines.

My terminals so far looks like this:

terminal NEWLINE 	: ('\r'? '\n'); 
terminal ID : !(NEWLINE);


This alone creates a lot of errors:
error(100): ../org.xtext.plantuml/src-gen/org/xtext/parser/antlr/internal/InternalPlantuml.g:0:0: syntax error: buildnfa: <AST>:2074:16: unexpected AST node: ?
error(100): ../org.xtext.plantuml/src-gen/org/xtext/parser/antlr/internal/InternalPlantuml.g:0:0: syntax error: buildnfa: <AST>: expecting EOA, found '<empty tree>'
error(139): ../org.xtext.plantuml/src-gen/org/xtext/parser/antlr/internal/InternalPlantuml.g:2076:11: set complement is empty
error(208): ../org.xtext.plantuml/src-gen/org/xtext/parser/antlr/internal/InternalPlantuml.g:2076:1: The following token definitions can never be matched because prior tokens match the same input: RULE_ID
error(100): ../org.xtext.plantuml.ui/src-gen/org/xtext/ui/contentassist/antlr/internal/InternalPlantuml.g:0:0: syntax error: buildnfa: <AST>:4841:16: unexpected AST node: ?
error(100): ../org.xtext.plantuml.ui/src-gen/org/xtext/ui/contentassist/antlr/internal/InternalPlantuml.g:0:0: syntax error: buildnfa: <AST>: expecting EOA, found '<empty tree>'
error(139): ../org.xtext.plantuml.ui/src-gen/org/xtext/ui/contentassist/antlr/internal/InternalPlantuml.g:4843:11: set complement is empty
error(208): ../org.xtext.plantuml.ui/src-gen/org/xtext/ui/contentassist/antlr/internal/InternalPlantuml.g:4843:1: The following token definitions can never be matched because prior tokens match the same input: RULE_ID


Also when I try to add some kind of multiline string I get a lot of different errors. How would one do this in an easy way?

Thanks!

[Updated on: Wed, 17 June 2015 08:56]

Report message to a moderator

Re: ID being anything except Newlines creating problems [message #1698747 is a reply to message #1698680] Wed, 17 June 2015 14:56 Go to previous message
Mohsin waqas is currently offline Mohsin waqasFriend
Messages: 33
Registered: June 2015
Member
hi!!
I am also new to xtext, may be i am wrong.
1. I guess you should change the name of terminal. change it from ID to any other name because there is already a built-in terminal rule named ID. I think error (208) is pointing towards this.
2. instead of using terminal rule may be you could define something like:
MultilineWords:
	 (name = ID)  ('\r'? '\n')  (ID)  ('\r'? '\n')  (ID)  ('\r'? '\n');


I am using this in my grammar and it alow one word than next line (for three lines). you can use multiple IDs if you need arbitrary many words on one line. or if you need one word per line (max three lines) use this one.
Previous Topic:custom declarative scopes stop to work after dsl extend xbase
Next Topic:Using getReferenceDescriptions
Goto Forum:
  


Current Time: Fri Apr 26 22:30:25 GMT 2024

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

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

Back to the top