|
|
|
|
Re: Content Assistant in a Xtext custom language [message #1765348 is a reply to message #1765319] |
Thu, 08 June 2017 15:20 |
Udeshika Sewwandi Messages: 118 Registered: March 2017 |
Senior Member |
|
|
A part of grammar is as follows.
definition_stream:
(ann += annotation)* DEFINE STREAM source '(' feature += Features (',' feature += Features )* ')'';'?
;
annotation:
'@' name = name ('(' (ann_element += annotation_element | ann += annotation)
( ',' (ann_element += annotation_element | ann += annotation))* ')' )
;
annotation_element:
(prop_name = property_name '=')? prop_val = property_value
;
property_value:
string_value
;
property_name:
{property_name} name (property_separator name += name )*
;
property_separator:
DOT | MINUS | COL
;
source:
inner='#'? (str_id = stream_id)
;
stream_id:
name
;
Features:
(att_name = attribute_name) (type = attribute_type)
;
attribute_name:
name
;
attribute_type:
STRINGS | INTS| LONG | FLOAT | DOUBLE| BOOL| OBJECT
;
keyword:
STREAM
| DEFINE
;
fragment STREAM: ('stream');
fragment DEFINE: ('define' );
fragment STRINGS: ('string');
fragment INTS: ('int');
fragment LONG: ('long');
fragment DOUBLE: ('double');
fragment FLOAT: ('float');
fragment BOOL: ('bool');
fragment OBJECT: ('object');
COL : ':';
DOT : '.';
MINUS : '-';
I want to auto complete the define and stream keywords in define_stream rule. How can I achieve this? Also when I press ctrl+space no default proposals are shown in the editor.
Thank you.
[Updated on: Thu, 08 June 2017 15:23] Report message to a moderator
|
|
|
Re: Content Assistant in a Xtext custom language [message #1765351 is a reply to message #1765348] |
Thu, 08 June 2017 15:35 |
|
a minimal grammar would look likeModel:
DEFINE STREAM name=ID
;
fragment STREAM: ('stream');
fragment DEFINE: ('define' );
well these should be automatically done. but they are not.
thats a bug
https://github.com/eclipse/xtext-core/issues/341
workaround
Model:
DEFINE STREAM name=ID
;
fragment STREAM: (str='stream');
fragment DEFINE: (def='define' );
or
class MyDslProposalProvider extends AbstractMyDslProposalProvider {
@Inject MyDslGrammarAccess ga
override complete_DEFINE(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
super.complete_DEFINE(model, ruleCall, context, acceptor)
completeKeyword(ga.DEFINEAccess.defineKeyword, context, acceptor)
}
override complete_STREAM(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
super.complete_STREAM(model, ruleCall, context, acceptor)
completeKeyword(ga.STREAMAccess.streamKeyword, context, acceptor)
}
}
p.s: please please please use xtext naming conventions
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Content Assistant in a Xtext custom language [message #1766482 is a reply to message #1766302] |
Thu, 22 June 2017 02:20 |
Udeshika Sewwandi Messages: 118 Registered: March 2017 |
Senior Member |
|
|
Hi
Thank you very much and the names suggest as proposals when ctrl+space is pressed. But once I type below in the editor it works fine.
@info(name1 = 'query2')
define stream cseEventStream (symbol string, price float, volume long);
and when I type the below:
@info(name1 = 'query2')
define stream StockStream (symbol string, price float, volume long);
it says "Couldn't resolve reference to Name 'StockStream'". That is because the stream name expects only a completion proposal.
My grammar related is:
DefinitionStream:
DEFINE STREAM src=Source
;
Source:
inner='#'? strId =[Name|IdNew]
;
Name:
name=IdNew//k_word=Keyword |
;
IdNew: ID| ID_QUOTES;
terminal ID_QUOTES:
'`'('a'..'z'|'A'..'Z'|'_')('a'..'z'|'A'..'Z'|'_'|'0'..'9')* '`' ;
@Override
terminal ID:
('a'..'z'|'A'..'Z'|'_')('a'..'z'|'A'..'Z'|'_'|'0'..'9')*
;
Keyword:
{Keyword} STREAM
|{Keyword} DEFINE
;
Why is it this happening?
Thank you.
[Updated on: Thu, 22 June 2017 02:21] Report message to a moderator
|
|
|
|
Re: Content Assistant in a Xtext custom language [message #1766691 is a reply to message #1766484] |
Mon, 26 June 2017 01:57 |
Udeshika Sewwandi Messages: 118 Registered: March 2017 |
Senior Member |
|
|
Hi,
In the same previous grammar:
DefinitionStream:
DEFINE STREAM src=Source1
;
Source:
strId=[Source1|IdNew]//inner='#'? strId =[Name|IdNew]
;
Source1:
inner='#'? name = IdNew
;
QueryInput:
FROM src=Source
;
Here all the previously used id values of Source1 type are shown as suggestions in the editor. I want only to show the stream name right before the query. Can I achieve it using cross references itself ?
For instance:
define stream inputStream (symbol string, price object, volume long);
@info(name = 'query1') from inputStream select symbol,price,
cast(price, 'double') as priceInDouble insert into outputStream;
define stream cseEventStream (symbol string, price1 double, price2 float, volume long , quantity int);
@info(name = 'query1') from cseEventStream select symbol, coalesce(price1,price2) as price,quantity
insert into outputStream ;
When there are 2 queries like this I want only "cseEventStream " stream name to be suggested for the second query.
Thank you.
|
|
|
|
Re: Content Assistant in a Xtext custom language [message #1767520 is a reply to message #1766692] |
Thu, 06 July 2017 17:48 |
Udeshika Sewwandi Messages: 118 Registered: March 2017 |
Senior Member |
|
|
Hi
Thank you very much for the information. I have referred https://eclipse.org/Xtext/documentation/303_runtime_concepts.html , https://github.com/LorenzoBettini/xtext-scoping/blob/master/org.xtext.example.helloscoping/org.xtext.example.helloscoping/src/org/xtext/example/helloscoping/scoping/HelloScopingScopeProvider.java and https://web.archive.org/web/20120618184943/http://blogs.itemis.de:80/stundzig/archives/809 on scoping in xtext. I think local scoping needed to be implemented in my scenario.
The grammar is:
DefinitionStream:
DEFINE STREAM src=Source1
;
Source:
strId=[Source1|IdNew]//inner='#'? strId =[Name|IdNew]
;
Source1:
inner='#'? name = IdNew
;
QueryInput:
FROM src=Source
;
Since DefinitionStream and QueryInput are not directly I am having a doubt whether local scoping can be done here.
define stream inputStream (symbol string, price object, volume long);
from inputStream
define stream cseEventStream (symbol string, price1 double, price2 float, volume long , quantity int);
from cseEventStream
I want only 'cseEventStream ' to suggest for the query.
I have extended custom ScopeProvider from AbstractDeclarativeScopeProvider and added the following override the getScope method as follows.
@Override
public IScope getScope(EObject context, EReference reference) {
if (context instanceof Source1) {
Source1 src1 = (Source1)context;
MainSource src = (MainSource) src1.eContainer();
}
return super.getScope(context, reference);
}
But no local scoping happens here. Can you provide some reference? Thank you.
[Updated on: Fri, 07 July 2017 03:46] Report message to a moderator
|
|
|
|
|
|
|
|
|
Re: Content Assistant in a Xtext custom language [message #1767620 is a reply to message #1767619] |
Fri, 07 July 2017 17:00 |
|
Lists.newArrayList(object) should give you that iterable?
and it is not possible to have different references with same syntax
but what about a common reference
name1=SourceOrEventReference;
Source1OrStandardStatefulSource: StandardStatefulSource | Source1;
SourceOrEventReference: myRef=[Source1OrStandardStatefulSource|IdNew];
or you need something with a different syntax
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
Re: Content Assistant in a Xtext custom language [message #1767644 is a reply to message #1767643] |
Sat, 08 July 2017 07:51 |
|
i strongly recommend you to use ad debugger.
context can be a DefinitionStream !!! during content assist but will be a Source !!!! during build.
=> you need to handle that in your scoping !!!
you can use context object to move up and down the ast and search whatever you want.
and fron the snippet you posted i dont see how DefinitionStream and Source relate to each other
=> with that kind of question quality i feel pain to give you any answers
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
|
|
|
|
|
|
|
Re: Content Assistant in a Xtext custom language [message #1767666 is a reply to message #1767662] |
Sat, 08 July 2017 20:08 |
|
here is an example for such a code
class MyDslScopeProvider extends AbstractMyDslScopeProvider {
override getScope(EObject context, EReference reference) {
if (reference === MyDslPackage.eINSTANCE.source_StrId) {
val execPlan = EcoreUtil2.getContainerOfType(context, ExecutionPlan)
if (execPlan !== null) {
return Scopes.scopeFor(execPlan.defStream.map[src].toList)
}
}
super.getScope(context, reference)
}
}
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
|
|
Re: Content Assistant in a Xtext custom language [message #1767680 is a reply to message #1767679] |
Sun, 09 July 2017 13:21 |
|
the grammar you share is ambigous.
i wonder how this works at all.
do you still have backtracking enabled?
there is nothing that properly separates two execution plans.
what are the rules for that?
why are there somtimes multiple querys why sometimes only one?
maybe you want to do something like
ExecutionPlan:
{ExecutionPlan}
(defStream+=DefinitionStream|defTable+=DefinitionTable)(->';' (defStream+=DefinitionStream|defTable+=DefinitionTable))* (->';' qi+=QueryInput) ';'?
|
(qi+=QueryInput) (->';' qi+=QueryInput)* ';'?
;
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
Re: Content Assistant in a Xtext custom language [message #1767709 is a reply to message #1767681] |
Mon, 10 July 2017 07:54 |
Udeshika Sewwandi Messages: 118 Registered: March 2017 |
Senior Member |
|
|
Hi,
Yes I have backtracking enabled and now I have disabled it. There are several errors and warnings coming up. The errors are as follows.
error(211): ../org.example.siddhi/src-gen/org/xtext/example/siddhiql/parser/antlr/internal/InternalSiddhiQLParser.g:151:6: [fatal] rule ruleExecutionPlan has non-LL(*) decision due to recursive rule invocations reachable from alts 2,3. Resolve by left-factoring or using syntactic predicates or using backtrack=true option.
error(211): ../org.example.siddhi/src-gen/org/xtext/example/siddhiql/parser/antlr/internal/InternalSiddhiQLParser.g:257:7: [fatal] rule ruleExecutionPlan has non-LL(*) decision due to recursive rule invocations reachable from alts 2,3. Resolve by left-factoring or using syntactic predicates or using backtrack=true option.
error(211): ../org.example.siddhi/src-gen/org/xtext/example/siddhiql/parser/antlr/internal/InternalSiddhiQLParser.g:358:6: [fatal] rule ruleExecutionPlan has non-LL(*) decision due to recursive rule invocations reachable from alts 1,2. Resolve by left-factoring or using syntactic predicates or using backtrack=true option.
error(211): ../org.example.siddhi/src-gen/org/xtext/example/siddhiql/parser/antlr/internal/InternalSiddhiQLParser.g:129:4: [fatal] rule ruleExecutionPlan has non-LL(*) decision due to recursive rule invocations reachable from alts 1,2. Resolve by left-factoring or using syntactic predicates or using backtrack=true option.
error(211): ../org.example.siddhi/src-gen/org/xtext/example/siddhiql/parser/antlr/internal/InternalSiddhiQLParser.g:385:4: [fatal] rule ruleExecutionPlan has non-LL(*) decision due to recursive rule invocations reachable from alts 1,2. Resolve by left-factoring or using syntactic predicates or using backtrack=true option.
error(211): ../org.example.siddhi/src-gen/org/xtext/example/siddhiql/parser/antlr/internal/InternalSiddhiQLParser.g:411:2: [fatal] rule ruleExecutionElement has non-LL(*) decision due to recursive rule invocations reachable from alts 1,2. Resolve by left-factoring or using syntactic predicates or using backtrack=true option.
error(211): ../org.example.siddhi/src-gen/org/xtext/example/siddhiql/parser/antlr/internal/InternalSiddhiQLParser.g:3446:2: [fatal] rule ruleJoinStream has non-LL(*) decision due to recursive rule invocations reachable from alts 3,4. Resolve by left-factoring or using syntactic predicates or using backtrack=true option.
error(211): ../org.example.siddhi/src-gen/org/xtext/example/siddhiql/parser/antlr/internal/InternalSiddhiQLParser.g:3972:3: [fatal] rule ruleMainSource has non-LL(*) decision due to recursive rule invocations reachable from alts 1,2. Resolve by left-factoring or using syntactic predicates or using backtrack=true option.
error(211): ../org.example.siddhi/src-gen/org/xtext/example/siddhiql/parser/antlr/internal/InternalSiddhiQLParser.g:4711:2: [fatal] rule ruleEveryPatternSourceChain1 has non-LL(*) decision due to recursive rule invocations reachable from alts 1,2. Resolve by left-factoring or using syntactic predicates or using backtrack=true option.
error(211): ../org.example.siddhi/src-gen/org/xtext/example/siddhiql/parser/antlr/internal/InternalSiddhiQLParser.g:5106:2: [fatal] rule rulePatternSource has non-LL(*) decision due to recursive rule invocations reachable from alts 1,3. Resolve by left-factoring or using syntactic predicates or using backtrack=true option.
error(211): ../org.example.siddhi/src-gen/org/xtext/example/siddhiql/parser/antlr/internal/InternalSiddhiQLParser.g:5364:2: [fatal] rule ruleLogicalStatefulSource has non-LL(*) decision due to recursive rule invocations reachable from alts 2,3. Resolve by left-factoring or using syntactic predicates or using backtrack=true option.
error(211): ../org.example.siddhi/src-gen/org/xtext/example/siddhiql/parser/antlr/internal/InternalSiddhiQLParser.g:6014:2: [fatal] rule ruleSequenceSource has non-LL(*) decision due to recursive rule invocations reachable from alts 1,2. Resolve by left-factoring or using syntactic predicates or using backtrack=true option.
error(211): ../org.example.siddhi/src-gen/org/xtext/example/siddhiql/parser/antlr/internal/InternalSiddhiQLParser.g:6484:2: [fatal] rule rulePartitionWithStream has non-LL(*) decision due to recursive rule invocations reachable from alts 1,2. Resolve by left-factoring or using syntactic predicates or using backtrack=true option.
The relevant grammar rules are as follows.
ExecutionPlan:
(appAnn+=AppAnnotation)* ( //(defStream+=DefinitionStream| def_table+=DefinitionTable| def_window+=DefinitionWindow | defTrigger+=DefinitionTrigger | defFunction+=DefinitionFunction | err+=Error) (';' (defStream+=DefinitionStream| def_table+=DefinitionTable| def_window+=DefinitionWindow | defTrigger+=DefinitionTrigger | defFunction+=DefinitionFunction | err+=Error))* ';'?
((exElement+=ExecutionElement)
|(defStream+=DefinitionStream| def_table+=DefinitionTable| def_window+=DefinitionWindow | defTrigger+=DefinitionTrigger | defFunction+=DefinitionFunction)(';' (defStream+=DefinitionStream| def_table+=DefinitionTable| def_window+=DefinitionWindow | defTrigger+=DefinitionTrigger | defFunction+=DefinitionFunction))*) (';' (exElement+=ExecutionElement))* ';'?)
;
ExecutionElement:
que=Query|execPartition=ExecPartition
;
JoinStream:
left_source=JoinSource right_source=JoinSource right_uni=UNIDIRECTIONAL (on=ON expr=Expression)? wt=WithinTime?
|left_source=JoinSource join=joins right_source=JoinSource (on=ON expr=Expression)? wt=WithinTime?
|left_source=JoinSource left_uni=UNIDIRECTIONAL join=joins right_source=JoinSource (on=ON expr=Expression)? wt=WithinTime?
|ss=StandardStream
;
MainSource:
src=Source (preWindowHandlers = BasicSourceStreamHandlers)? (window = Win)?
;
EveryPatternSourceChain:
EveryPatternSourceChain1 ({EveryPatternSourceChain.left=current} op= '->' right=EveryPatternSourceChain1)*
;
EveryPatternSourceChain1 returns EveryPatternSourceChain:
'('eps=EveryPatternSourceChain')' wt=WithinTime?
|psc=PatternSourceChain
//|EVERY psc1=PatternSourceChain1
|every=EVERY '('psc=PatternSourceChain ')' wt=WithinTime? //every error
|every=EVERY ps1=PatternSource wt=WithinTime?
;
PatternSource:
{PatternSource}lss=LogicalStatefulSource|{PatternSource}pss=PatternCollectionStatefulSource|{PatternSource}stdss=StandardStatefulSource
;
LogicalStatefulSource:
not=NOT stdSource+=StandardStatefulSource (and=AND stdSource+=StandardStatefulSource) //and error,not error
|stdSource+=StandardStatefulSource and=AND stdSource+=StandardStatefulSource //and error
|stdSource+=StandardStatefulSource or=OR stdSource+=StandardStatefulSource
;
SequenceSource:
LogicalStatefulSource|SequenceCollectionStatefulSource|StandardStatefulSource
;
PartitionWithStream:
attr=Attribute of=OF str_id1=Source //str_id1=StreamId ...
|ConditionRanges of=OF str_id2=Source //str_id2=StreamId
;
Can you provide a clue for error fixing for these ?
The grammar file is attached here.
-
Attachment: MyDsl.xtext
(Size: 18.14KB, Downloaded 183 times)
[Updated on: Mon, 10 July 2017 07:56] Report message to a moderator
|
|
|
|
|
|
|
Re: Content Assistant in a Xtext custom language [message #1767872 is a reply to message #1767869] |
Tue, 11 July 2017 19:50 |
|
sorry i have no idea on this.
i meant mainly to use antlrworks to find out where the ambiguities are if you are not able to find out with using more minimalized grammars and stuff.
doing so you would have find out that e.g.
SequenceSource | LogicalStatefulSource | SequenceCollectionStatefulSource
is one source of this pile
maybe something like
SequenceSource:
=>LogicalStatefulSource|=>SequenceCollectionStatefulSource|StandardStatefulSource
;
LogicalStatefulSource:
=>(not=NOT stdSource+=StandardStatefulSource (and=AND stdSource+=StandardStatefulSource)) //and error,not error
|=>(stdSource+=StandardStatefulSource and=AND stdSource+=StandardStatefulSource) //and error
|=>(stdSource+=StandardStatefulSource or=OR stdSource+=StandardStatefulSource)
;
SequenceCollectionStatefulSource:
=>(StandardStatefulSource ('<' coll=Collect '>'|zero_or_more='*'|zero_or_one='?'|one_or_more='+'))
;
helps
unfortunately your grammar is way way too big upfront to do a reasonable analysis without spending days or hard work and brain wiggeling
thus maybe backtracking is the way to go,
but then you have to deal with at other places.
the usualy way is:
start with a small grammar, make sure it works and add new stuff step by step
Model:
(elements += ExecutionPlan)*
;
ExecutionPlan:
(appAnn+=AppAnnotation)* ( //(defStream+=DefinitionStream| def_table+=DefinitionTable| def_window+=DefinitionWindow | defTrigger+=DefinitionTrigger | defFunction+=DefinitionFunction | err+=Error) (';' (defStream+=DefinitionStream| def_table+=DefinitionTable| def_window+=DefinitionWindow | defTrigger+=DefinitionTrigger | defFunction+=DefinitionFunction | err+=Error))* ';'?
((exElement+=ExecutionElement)
|(defStream+=DefinitionStream| def_table+=DefinitionTable| def_window+=DefinitionWindow | defTrigger+=DefinitionTrigger | defFunction+=DefinitionFunction)(';' (defStream+=DefinitionStream| def_table+=DefinitionTable| def_window+=DefinitionWindow | defTrigger+=DefinitionTrigger | defFunction+=DefinitionFunction))*) (';' (exElement+=ExecutionElement))* ';'?)
;
ExecutionElement:
que=Query|execPartition=ExecPartition
;
AppAnnotation:
'@' APP ':' na=Name ('(' ann5+=AnnotationElement (',' ann5+=AnnotationElement )* ')' )?
;
APP: (ap='app');
Query:
"query" name=ID
;
ExecPartition:
"execPart" name=ID
;
DefinitionStream:
{DefinitionStream} (ann += Annotation)* DEFINE STREAM src=Source1 '(' feature += Features (',' feature += Features )* ')'';'?
;
DefinitionTable:
(ann1 += Annotation)* DEFINE TABLE src=Source1 '(' feature += Features (',' feature += Features )* ')'';'?
;
DefinitionWindow:
(ann2 += Annotation)* DEFINE WINDOW src=Source1 '(' feature += Features (',' feature += Features )* ')' funcOp = FunctionOperation ( OUTPUT opEventType=OutputEventType )? ';'?
;
fragment OUTPUT: (output='output' );
OutputEventType:
{OutputEventType}ALL EVENTS |{OutputEventType} ALL RAW EVENTS |{OutputEventType} EXPIRED EVENTS |{OutputEventType} EXPIRED RAW EVENTS |{OutputEventType} CURRENT? EVENTS
;
fragment FALSE: (fals='false');
fragment TRUE: (tr='true');
fragment RAW: (raw='raw' );
fragment EVENTS: (events='events' );
fragment ALL: (all='all' );
fragment EXPIRED: (expired='expired' );
fragment CURRENT: (currt='current' );
AttributeList:
{AttributeList}((attr += Attribute) (',' attr += Attribute)* ) |{AttributeList}'*'
;
ConstantValue:
{ConstantValue}bv=BoolValue
;
BoolValue:
TRUE|FALSE
;
Attribute:
mathOp=ConstantValue
;
FunctionOperation:
{FunctionOperation}(funcNamespace=FunctionNamespace ':')? funcId=FunctionId '(' (attrList=AttributeList)? ')'
;
FunctionNamespace:
na=Name
;
FunctionId:
na=Name
;
Source1:
inner='#'? name = IdNew
;
Features:
(name = AttributeName) (type = AttributeType)
;
AttributeName:
name = IdNew
;
fragment STRINGS: (string='string');
fragment INTS: (int='int');
fragment LONG: (long='long');
fragment DOUBLE: (double='double');
fragment FLOAT: (float='float');
fragment BOOL: (bool='bool');
fragment OBJECT: (object='object');
fragment RETURN: (return='return');
AttributeType:
{AttributeType}STRINGS |{AttributeType} INTS|{AttributeType} LONG |{AttributeType} FLOAT |{AttributeType} DOUBLE|{AttributeType} BOOL|{AttributeType} OBJECT
;
DefinitionTrigger:
DEFINE TRIGGER tn=TriggerName AT (every=EVERY tv=TimeValue | sv=StringValue) ';'?
;
TimeValue:
v=INT "ms"
;
FunctionBody:
value=SCRIPT
;
terminal SCRIPT:
'{' -> '}'
;
DefinitionFunction:
DEFINE FUNCTION fn=FunctionName '[' ln=LanguageName ']' RETURN attr_type=AttributeType func_body=FunctionBody ';'?
;
FunctionName:
id=ID
;
LanguageName:
id=ID
;
TriggerName:
id=ID
;
EVERY: (every='every' );
fragment AT: (at='at' );
Annotation:
'@' na = Name ('(' (annElement += AnnotationElement | ann += Annotation)
( ',' (annElement += AnnotationElement | ann += Annotation))* ')' )
;
AnnotationElement:
(propName = PropertyName '=')? propVal = PropertyValue
;
PropertyValue:
sv=StringValue
;
PropertyName:
{PropertyName} na+=Name (ps+=PropertySeparator na += Name )*
;
StringValue:
sl=STRING_LITERAL
;
STRING_LITERAL:
STRING
;
PropertySeparator:
{PropertySeparator}DOT |{PropertySeparator} MINUS |{PropertySeparator} COL
;
COL : ':';
MINUS : '-';
DOT : '.';
IdNew: ID;
Name:
na=IdNew//k_word=Keyword |
;
fragment TRIGGER: (trigger='trigger' );
fragment FUNCTION: (function='function');
fragment STREAM: (str='stream');
fragment DEFINE: (define='define' );
fragment TABLE: (table='table' );
fragment WINDOW: (window='window' );
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Re: Content Assistant in a Xtext custom language [message #1767876 is a reply to message #1767872] |
Tue, 11 July 2017 20:02 |
|
you might to use predicates here as well. but i am not sure if it will do the right thing.
there is still the major issue of all that optional semiklon where where parser does not know where to put them.
ExecutionPlan:
(appAnn+=AppAnnotation)*
( //(defStream+=DefinitionStream| def_table+=DefinitionTable| def_window+=DefinitionWindow | defTrigger+=DefinitionTrigger | defFunction+=DefinitionFunction | err+=Error) (';' (defStream+=DefinitionStream| def_table+=DefinitionTable| def_window+=DefinitionWindow | defTrigger+=DefinitionTrigger | defFunction+=DefinitionFunction | err+=Error))* ';'?
(
(exElement+=ExecutionElement)
|
=>(defStream+=DefinitionStream
| def_table+=DefinitionTable
| def_window+=DefinitionWindow
| defTrigger+=DefinitionTrigger
| defFunction+=DefinitionFunction
)(';' =>(
defStream+=DefinitionStream|
def_table+=DefinitionTable|
def_window+=DefinitionWindow |
defTrigger+=DefinitionTrigger |
defFunction+=DefinitionFunction
))*) =>(';' (exElement+=ExecutionElement))* ';'?)
;
DefinitionStream:
=>({DefinitionStream} (ann += Annotation)* DEFINE STREAM) src=Source1 '(' feature += Features (',' feature += Features )* ')'';'?
;
DefinitionTable:
=>((ann1 += Annotation)* DEFINE TABLE) src=Source1 '(' feature += Features (',' feature += Features )* ')'';'?
;
DefinitionWindow:
=>((ann2 += Annotation)* DEFINE WINDOW) src=Source1 '(' feature += Features (',' feature += Features )* ')' funcOp = FunctionOperation ( OUTPUT opEventType=OutputEventType )? ';'?
;
DefinitionTrigger:
=>(DEFINE TRIGGER) tn=TriggerName AT (every=EVERY tv=TimeValue | sv=StringValue) ';'?
;
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Re: Content Assistant in a Xtext custom language [message #1767878 is a reply to message #1767876] |
Tue, 11 July 2017 20:04 |
|
(the semikolon is here:
DefinitionStream:
=>({DefinitionStream} (ann += Annotation)* DEFINE STREAM) src=Source1 '(' feature += Features (',' feature += Features )* ')'';'?
;
and is here
(';' (defStream+=DefinitionStream| def_table+=DefinitionTable| def_window+=DefinitionWindow | defTrigger+=DefinitionTrigger | defFunction+=DefinitionFunction | err+=Error))*
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Content Assistant in a Xtext custom language [message #1768769 is a reply to message #1768768] |
Sun, 23 July 2017 18:41 |
|
you can use debug menu in eclipse and setting breakpoints as i java to debug the xtend code.
the following work fine for me for the "table" reference
if (reference === MyDslPackage.eINSTANCE.source_StrId) {
println("b")
val execPlan = EcoreUtil2.getContainerOfType(context, ExecutionPlan)
if (!execPlan.defStream.empty) {
val x = execPlan.defStream.map[src]
return Scopes.scopeFor(x)
}
else if(!execPlan.def_table.empty){
val x = execPlan.def_table.map[src]
return Scopes.scopeFor(x)
}
}
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
Re: Content Assistant in a Xtext custom language [message #1768771 is a reply to message #1768770] |
Sun, 23 July 2017 18:47 |
|
so maybe you actually want to do a
if (reference === MyDslPackage.eINSTANCE.source_StrId) {
val execPlan = EcoreUtil2.getContainerOfType(context, ExecutionPlan)
val scope = <Source1>newArrayList()
scope.addAll(execPlan.defStream.map[src])
scope.addAll(execPlan.def_table.map[src])
return Scopes.scopeFor(scope)
}
bu i dont know i dont have a language spec for your dsl
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
|
|
|
|
Re: Content Assistant in a Xtext custom language [message #1769915 is a reply to message #1768868] |
Sat, 05 August 2017 15:24 |
Udeshika Sewwandi Messages: 118 Registered: March 2017 |
Senior Member |
|
|
Hi
The proposals are correctly shown in content assisting after scoping is done. I have removed almost all the ambiguities in grammar too. But I have one issue that is once I add a particular rule called QueryOutput as follows content assisting is not working as expected.
Query:
{Query}(ann3 += Annotation)* FROM (qInp = QueryInput ) (querySec = QuerySection)? outRate=OutputRate? (qOutput = QueryOutput)
;
But when I put (qOutput = QueryOutput)? like this no issue is coming. I have attached the grammar file below. I have added following in mwe2 file.
parserGenerator = {
debugGrammar=true
antlrParam = "-Xconversiontimeout"
antlrParam = "40000"
options = {
ignoreCase = true
backtrack=false
memoize = true
classSplitting=true
fieldsPerClass = "300"
methodsPerClass= "800"
}
}
Can you provide a clue why this is happenning?
[Updated on: Sat, 05 August 2017 15:26] Report message to a moderator
|
|
|
|
|