Help for grammar [message #704218] |
Thu, 28 July 2011 11:53 |
Caner Messages: 98 Registered: July 2011 |
Member |
|
|
Hello
I am in trouble. Please have a look this with fresh eyes , I dont know what i have to do. I have a grammar as below.
While im coding in something.mydsl I want to allow users to give space as much as they want between of parameter while they are declaring the type NonEmtyLine.
I have multiple terminal Rules Because my some parameters contains some strange characters.
file.modern.novel.someoneelse : boookName :languagenumber[%d],languageId, (orginallanguage|translated)byTranslator : ,,,numbers...so on
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
LibModel:
(types+=Type)*;
Type:
LibComment1|NonEmpityLine|AtShell |Version| languages;
LcfComment1:
text=HASH_COMMENT
;
AtShell:
"@" ShellName=ID ('=' DOUBLE|INT|'-'INT)?
;
Version:
{Version}
'@logstart' ('='startNumber=(DOUBLE|'X' ))?;
languages:
{languages}
'@translators=' mytrans=(myID ) ;
NonEmpityLine :
//allow users leave some space between of parameters
Writer=Writer ':' WritersBooks=WritersBooks':' NELTranslator=NELTranslator':' ('store')? ( isbn=isbn',' pageNumber=pageNumber)? (',' Amaunt=Amaunt)? (':')?
(filter=filter ('&&') | ('||') | ('==') filtered=filtered)?
;
filtered:
filtered=Words
;
filter:
filter=Words
;
NELTranslator:
NELTranslator= Characters
;
Writer:
Writer=Words
;
WritersBooks:
WritersBooks= Words
;
isbn:
{isbn}
isbn= ('-')?((INT)|DOUBLE)
;
pageNumber:
{pageNumber}
pageNumber=('-')?((INT)|DOUBLE)
;
//for new orders it might me negative value
Amaunt:
{Amaunt}
Amaunt=('-')?((INT)|DOUBLE)
;
Words hidden (): ID (WS ID)* ;
Characters hidden () : myID (WS myID)* ;
terminal WS : (' '|'\t'|'\r'|'\n')+ ;
terminal HASH_COMMENT : '#' !('\n'|'\r')* ('\r'? '\n')? ;
terminal ID : '^'?('a'..'z'|'A'..'Z'|'_'|'.') ('a'..'z'|'A'..'Z'|'_'|'0'..'9'|'.')* ;
terminal DOUBLE : INT '.' INT;
terminal INT returns ecore::EInt: ('0'..'9')+ ;
terminal myID: '^'?('a'..'z'|'A'..'Z'|'_'|'.') ('a'..'z'|'A'..'Z'|'_'|'0'..'9'|'%'|'['|']'|'('|')'|'.'|' '|','|'|' )* ;
[Updated on: Thu, 28 July 2011 13:38] Report message to a moderator
|
|
|
|
|
Re: Help for grammar [message #704268 is a reply to message #704218] |
Thu, 28 July 2011 12:15 |
Henrik Lindberg Messages: 2509 Registered: July 2009 |
Senior Member |
|
|
For starters, the terminals ID and myID overlap, you will never get a
myID token if ID matches the input.
To solve the issue use a data rule and have a terminal for only the
additional special characters.
myID = ID (ExtID | ID)* ;
terminal ID = ...as is...;
terminal ExtID = ('%'|'['|']'|'('|')'|'.'|' '|','|'|' )+ ;
Regarding hidden WS - you have to state what to hide for the root node
if you want hiding of WS to take place.
LibModel hidden(WS) : ..... ;
Hope that helps.
Regards
- henrik
On 7/28/11 1:53 PM, Caner wrote:
> Hello
> I am in trouble. Please have a look this with fresh eyes , I dont know
> what i have to do. I have a grammar as below.
>
> While im coding in something.mydsl I want to give allow users to give
> space as much as they want between of parameter while they are typing
> the for NonEmtyLine.
>
> I have multiple terminal Rules Because my some parameters contains some
> strange characters.
>
> file.modern.novel.someoneelse : boookName
> :languagenumber[%d],languageId, (orginallanguage|translated)byTranslator
> ,,,so on
>
>
>
> import "http://www.eclipse.org/emf/2002/Ecore" as ecore
>
> LibModel:
> (types+=Type)*;
> Type:
> LibComment1|NonEmpityLine|AtShell |Version| languages;
>
> LcfComment1: text=HASH_COMMENT
> ;
> AtShell:
> "@" ShellName=ID ('=' DOUBLE|INT|'-'INT)?
> ;
>
> Version:
> {Version}
> '@logstart' ('='startNumber=(DOUBLE|'X' ))?;
>
> languages:
> {languages}
> '@translators=' mytrans=(myID ) ;
>
> NonEmpityLine :
> //allow users leave some space between of parameters
>
> Writer=Writer ':' WritersBooks=WritersBooks':'
> NELTranslator=NELTranslator':' ('store')? ( isbn=isbn','
> pageNumber=pageNumber)? (',' Amaunt=Amaunt)? (':')?
> ;
>
> NELTranslator:
> NELTranslator= Characters ;
>
> Writer:
> Writer=Words
> ;
>
> WritersBooks:
> WritersBooks= Words
> ;
>
> isbn:
> {isbn}
> isbn= ('-')?((INT)|DOUBLE)
> ;
>
> pageNumber:
>
> {pageNumber}
> pageNumber=('-')?((INT)|DOUBLE)
> ;
>
> //for new orders it might me negative value
> Amaunt:
> {Amaunt}
> Amaunt=('-')?((INT)|DOUBLE)
>
> ;
>
> Words hidden (): ID (WS ID)* ;
>
> Characters hidden () : myID (WS myID)* ;
>
> terminal WS : (' '|'\t'|'\r'|'\n')+ ;
>
> terminal HASH_COMMENT : '#' !('\n'|'\r')* ('\r'? '\n')? ;
>
> terminal ID : '^'?('a'..'z'|'A'..'Z'|'_'|'.')
> ('a'..'z'|'A'..'Z'|'_'|'0'..'9'|'.')* ;
> terminal DOUBLE : INT '.' INT;
>
> terminal INT returns ecore::EInt: ('0'..'9')+ ;
>
> terminal myID: '^'?('a'..'z'|'A'..'Z'|'_'|'.')
> ('a'..'z'|'A'..'Z'|'_'|'0'..'9'|'%'|'['|']'|'('|')'|'.'|' '|','|'|' )* ;
>
>
>
|
|
|
Re: Help for grammar [message #704276 is a reply to message #704268] |
Thu, 28 July 2011 12:57 |
Caner Messages: 98 Registered: July 2011 |
Member |
|
|
Thank you so much, According your explanations ,I have modified my grammar and I still have the same problem
I am not able to leave white space between of parameters at NonEmptyline here What i did
the interesting thing is Iam able to leave WS before Writer or book names like " Writer: BookName:.."
but I m not allowed to type as " Writer : BookName :.."
[Updated on: Wed, 03 August 2011 20:28] Report message to a moderator
|
|
|
|
|
|
|
Re: Help for grammar [message #704882 is a reply to message #704414] |
Fri, 29 July 2011 07:05 |
Caner Messages: 98 Registered: July 2011 |
Member |
|
|
Hello
@Hendrik, I have tried your adviced;
I took away hidden(WS) from NonEmptiyLine ( NonEmptiyLine hidden(WS):....etc; -----> NonEmptiyLine :___etc;
and modified LibModel as you said, I dont know why it is not working
And Christian here my sample grammar, what i am trying to type in mydsl file
(space)= is white space
Thanks
caner
[Updated on: Wed, 03 August 2011 20:29] Report message to a moderator
|
|
|
|
|
|
Re: Help for grammar [message #704943 is a reply to message #704936] |
Fri, 29 July 2011 08:47 |
Caner Messages: 98 Registered: July 2011 |
Member |
|
|
file.pl.tc.oEy.Perday:somename :otherName .subcriber(A|B),isDl :21,22.5,0.005
here also isDl does not any strange character so it give errors
and I modified Characters like this;
Characters hidden () : ID (myID |ID );
and I had "Decision can match input such as "RULE_ID" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input"
caner
[Updated on: Fri, 29 July 2011 09:03] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
Re: Help for grammar [message #705174 is a reply to message #705090] |
Fri, 29 July 2011 14:35 |
Caner Messages: 98 Registered: July 2011 |
Member |
|
|
Hi
I confused little bit, i missed understood what you pointed out,
you said Characters and myID I tired and missed understood I was focused on Characters and Words
Now I am not sure is that what you wanted to light on, but i deleted Characters now and replaced references of characters with myID.
So far im able to leave space but stil get error for a line which is like ;
if i dont type "(space)" for the line i get error like this;
mismatched input '] ,' expecting ':'
- mismatched input '[%' expecting ':'
- mismatched input '|' expecting ':'
- mismatched input ' , (' expecting ':'
- mismatched input '),' expecting ':'
- no viable alternative at input ','
BR
Caner
[Updated on: Wed, 03 August 2011 20:30] Report message to a moderator
|
|
|
|
|
|
Re: Help for grammar [message #707049 is a reply to message #705230] |
Mon, 01 August 2011 07:08 |
Caner Messages: 98 Registered: July 2011 |
Member |
|
|
Hi Christian
thanks a lot for your support.
So far i came over with target errors. However there is an unexpected error
when I type like;
something.file.writer.somefile.anywriter: attend:accord
now in second field and third field if the types starts with "a" i get error. This is so weird.
Why do you think
BR
caner
[Updated on: Mon, 01 August 2011 07:09] Report message to a moderator
|
|
|
|
Re: Help for grammar [message #707077 is a reply to message #707053] |
Mon, 01 August 2011 07:59 |
Caner Messages: 98 Registered: July 2011 |
Member |
|
|
for example if I type like this without space;
something.file.writer.somefile.anywriter:(no_WS)attempt :(no_WS)arqAtt:1,1:
if the second and third type initiated with "a" I get this error,
Multiple markers at this line
- extraneous input 'tempt' expecting ':'
- mismatched character 't' expecting 'l'
- missing RULE_ID at '1'
[Updated on: Mon, 01 August 2011 08:06] Report message to a moderator
|
|
|
|
|
|
|
|
|