Beginner grammar problem [message #692143] |
Sun, 03 July 2011 17:48 |
Caner Messages: 98 Registered: July 2011 |
Member |
|
|
Hello EveryBody!
I have some problems with definition of mydsl grammar
I have several Lists<String> which are Writers, Books PageNumber, Isb respectively in my ProposalProvider class
in myDsl I will create a text line which is called NonEmptyline which consists of the lists of Writers, Books PageNumber, Isbn respectively
for example: in my DSL, each line has to be just like this
Stefen_King:Full_Dark_No_Stars:789:1234567
each element will be called from a different List by content assist. Here my code is below, when i run as .MWE2 i get errors
Librarymodel:
(elements+=NonEmptyline)*;
NonEmptyline:
Writers':' Books ':'PageNumber ':' IsbnNumber
;
Writers:
name=WriterName ':';
WriterName hidden(): ID (WS ID)* ;
Books:
name=BookName ':'
BookName hidden (): ID (WS ID)* ;
PageNumber:
name=Page ':'
Page hidden (): ID (WS ID)* ;
;
IsbnNumber:
name=Isbn ':'
Isbn hidden (): ID (WS ID)* ;
I look forward to hear your solutions
Sincerely
[Updated on: Sun, 03 July 2011 17:49] Report message to a moderator
|
|
|
Re: Beginner grammar problem [message #692147 is a reply to message #692143] |
Sun, 03 July 2011 17:59 |
|
Hi,
there a lots of complicated stuff in your grammar. its way to complicated. what about something like
in parser rules you should always assign stuff.
each rule must be closed with a semicolon.
Librarymodel:
(elements+=NonEmptyline)*;
NonEmptyline:
writer=Words ':' book=Words ':'pageNumber=INT ':' isbn=INT
;
Words hidden (): ID (WS ID)* ;
~Christian
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
[Updated on: Sun, 03 July 2011 18:00] Report message to a moderator
|
|
|
|
Re: Beginner grammar problem [message #692157 is a reply to message #692155] |
Sun, 03 July 2011 18:39 |
|
Hi,
what about a filtered content assist for the books? just query the Context (downcasting EObject model to NonEmptyline andf ask it for the writer)
but what i do not understand is: if you have all the data why to do the modeling stuff at all???
~Christian
~Christian
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
|
|
|
Re: Beginner grammar problem [message #692405 is a reply to message #692396] |
Mon, 04 July 2011 11:47 |
Caner Messages: 98 Registered: July 2011 |
Member |
|
|
Librarymodel:
(elements+=CrossReference)*;
CrossReference:
referencedObjct=[NonEmpityLine];
NonEmptyline:
writer=Words ':' book=Words ':'pageNumber=INT ':' isbn=INT
;
Words hidden (): ID (WS ID)* ;
is this right as grammar?
~ProposalProvider extends Abstract~..~ProposalProvider implements ILinkingService {
......
ArrayList<String> writers = new ArrayList<String>();
writers.add("writer1");
writers.add("writer2");
writers.add("writer3");
....
@Override
public void complete_writers(EObject model, RuleCall ruleCall,
ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
for(String writer: writers){
acceptor.accept(createCompletionProposal(writer,context));
}
// TODO Auto-generated method stub
super.complete_LogItem(model, ruleCall, context, acceptor);
}
.....
// Actually, I dont know how to context this with writer
@Override
public List<EObject> getLinkedObjects(EObject context,
EReference reference, INode node) throws IllegalNodeException {
// TODO Auto-generated method stub
return null;
}
}//class end
[Updated on: Mon, 04 July 2011 12:32] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05436 seconds