|
|
|
|
|
|
|
|
|
|
|
Re: Internal language parser is not found in xtext project [message #1764305 is a reply to message #1764265] |
Sat, 27 May 2017 19:20   |
Udeshika Sewwandi Messages: 118 Registered: March 2017 |
Senior Member |
|
|
Hi,
The issue was fixed by adding
parserGenerator = {
antlrParam = "-Xconversiontimeout"
antlrParam = "40000"
options = {
ignoreCase = true
backtrack=true
memoize = true
classSplitting=true
fieldsPerClass = "300"
methodsPerClass= "800"
}
}
Can you provide some examples where ll* problems are there? Since I am new to antlr and xtext I need some help to proceed. Except left recursive grammar I thought other rules are more like the same in xtext as well as antlr except minor changes. Appreciate your helpful response.
Thank you very much.
[Updated on: Sat, 27 May 2017 19:22] Report message to a moderator
|
|
|
|
|
|
|
|
Re: Internal language parser is not found in xtext project [message #1764315 is a reply to message #1764314] |
Sun, 28 May 2017 08:54   |
Udeshika Sewwandi Messages: 118 Registered: March 2017 |
Senior Member |
|
|
Hi
Another thing that I need to ask is I have converted a left recursive grammar in Antlr as follows and I want to clarify whether it is correct.
The Antlr grammar is :
math_operation
:'('math_operation')' #basic_math_operation
|null_check #basic_math_operation
|NOT math_operation #not_math_operation
|math_operation (multiply='*'|devide='/'|mod='%') math_operation #multiplication_math_operation
|math_operation (add='+'|substract='-') math_operation #addition_math_operation
|math_operation (gt_eq='>='|lt_eq='<='|gt='>'|lt='<') math_operation #greaterthan_lessthan_math_operation
|math_operation (eq='=='|not_eq='!=') math_operation #equality_math_operation
|math_operation IN name #in_math_operation
|math_operation AND math_operation #and_math_operation
|math_operation OR math_operation #or_math_operation
|function_operation #basic_math_operation
|constant_value #basic_math_operation
|attribute_reference #basic_math_operation
;
The converted Xtextgrammar is:
math_operation:
//name = name (gt_eq='>='|lt_eq='<='|gt='>'|lt='<') name1 = INT
{math_operation} fo=function_operation
|{math_operation} constant_value
|{math_operation}attribute_reference
|{math_operation} mlo=math_logical_operation
;
math_logical_operation returns math_operation:
{math_operation} gt_lt=math_gt_lt_operation ({math_logical_operation.left=current} (AND | OR) right=math_gt_lt_operation)*
;
math_gt_lt_operation returns math_operation:
{math_operation} equal=math_equal_operation ({math_gt_lt_operation.left=current} (gt_eq='>='|lt_eq='<='|gt='>'|lt='<') right=math_equal_operation)*
;
math_equal_operation returns math_operation:
{math_operation} add_sub=math_addsub_operation ({math_gt_lt_operation.left=current} (eq='=='|not_eq='!=') right=math_addsub_operation)*
;
math_addsub_operation returns math_operation:
{math_operation} divmul=math_divmul_operation ({math_addsub_operation.left=current} (add='+'|substract='-') right=math_divmul_operation)*
;
math_divmul_operation returns math_operation:
{math_operation} gt_lt=math_other_operations ({math_divmul_operation.left=current} (multiply='*'|devide='/'|mod='%') right=math_other_operations)*
;
math_other_operations returns math_operation:
//'math_op'
'('math_operation')'
|null_check
|NOT math_operation
;
[Updated on: Sun, 28 May 2017 08:56] Report message to a moderator
|
|
|
|
|
|
|
|
|
Re: Internal language parser is not found in xtext project [message #1764326 is a reply to message #1764323] |
Sun, 28 May 2017 11:20   |
|
p.s:
working on a simplifieed grammar might help
math_operation:
//name = name (gt_eq='>='|lt_eq='<='|gt='>'|lt='<') name1 = INT
mlo=math_logical_operation
;
math_logical_operation returns math_operation:
math_in_operation ({math_logical_operation.left=current} ("AND" | "OR") right=math_in_operation)*
;
math_in_operation returns math_operation:
math_gt_lt_operation ({math_in_operation.left=current} "IN" right=name)*
;
math_gt_lt_operation returns math_operation:
math_equal_operation ({math_gt_lt_operation.left=current} (gt_eq='>='|lt_eq='<='|gt='>'|lt='<') right=math_equal_operation)*
;
math_equal_operation returns math_operation:
math_addsub_operation ({math_gt_lt_operation.left=current} (eq='=='|not_eq='!=') right=math_addsub_operation)*
;
math_addsub_operation returns math_operation:
math_divmul_operation ({math_addsub_operation.left=current} (add='+'|substract='-') right=math_divmul_operation)*
;
math_divmul_operation returns math_operation:
math_other_operations ({math_divmul_operation.left=current} (multiply='*'|devide='/'|mod='%') right=math_other_operations)*
;
math_other_operations returns math_operation:
//'math_op'
=>({NotOperation} NOT op=math_operation)
|'('math_operation')'
|null_check
| literal
;
literal:
constant_value
|attribute_reference
;
null_check:
function_operation ({null_check.expr=current}IS NULL)?
;
function_operation:
{function_operation}(ns=function_namespace ':')? id=function_id '(' attr=attribute_list? ')'
;
function_namespace:
name
;
function_id:
name
;
attribute_list:
{attribute_list}( attr += attribute (',' attr += attribute)* ) |{attribute_list} isStar?='*'
;
attribute:
math_operation
;
name:
ID
;
constant_value:
value=STRING
;
attribute_reference:
value=name
;
NOT: "NOT";
fragment IS : ('is');
fragment NULL: ('null');
(reason for the warnings is inside not)
you can use this pattern for unary expressions:
UnitaryMinus returns Expression:
PrimaryExpression | ({UnitaryMinus} ('-'|"!"|"~") expr=UnitaryMinus);
PrimaryExpression returns Expression:
'(' Expression ')' | ...;
in your case
math_other_operations returns math_operation:
//'math_op'
PrimaryExpression
| =>({NotOperation} NOT op=math_other_operations)
;
PrimaryExpression returns math_operation:
'('math_operation')'
|null_check
| literal
;
and you should have a look at xtext naming conventions.
this makes grammar more readable for other Xtext Users
Rule: attr=SomeRule;
and you should asign stuff from the grammar so that it does not get lost
Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
|
|
|
|
|
|
Re: Internal language parser is not found in xtext project [message #1764439 is a reply to message #1764437] |
Mon, 29 May 2017 17:57   |
|
here is a grammar that i minified.
it should help you to understand and analyze the problem
pattern_stream:
every_pattern_source_chain
;
every_pattern_source_chain:
every_pattern_source_chain_1 ({every_pattern_source_chain.left=current} op= '->' right=every_pattern_source_chain_1)*
;
every_pattern_source_chain_1 returns every_pattern_source_chain:
{every_pattern_source_chain}'('eps=every_pattern_source_chain')' within_time?
|{every_pattern_source_chain} EVERY '('psc=pattern_source_chain ')' within_time?
|{every_pattern_source_chain} psc=pattern_source_chain
|{every_pattern_source_chain} EVERY ps=pattern_source within_time?
;
pattern_source_chain:
pattern_source_chain_1 ({pattern_source_chain.left=current} op='->' right=pattern_source_chain_1)* //pattern_source_chain '->' pattern_source_chain
;
pattern_source_chain_1 returns pattern_source_chain:
{pattern_source_chain}'('psc=pattern_source_chain')' within_time?
| {pattern_source_chain} ps=pattern_source within_time?
;
pattern_source:
name=ID
;
fragment SCRIPT_ATOM:
'abcd'
;
within_time:
WITHIN time_value
;
Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
Re: Internal language parser is not found in xtext project [message #1764441 is a reply to message #1764440] |
Mon, 29 May 2017 18:15   |
|
maybe you can ease that to something like
pattern_stream:
every_pattern_source_chain
;
every_pattern_source_chain:
every_pattern_source_chain_1 ({every_pattern_source_chain.left=current} op= '->' right=every_pattern_source_chain_1)*
;
every_pattern_source_chain_1 returns every_pattern_source_chain:
{every_pattern_source_chain} EVERY '('psc=pattern_source_chain ')' within_time?
|
{every_pattern_source_chain} psc=pattern_source_chain
|{every_pattern_source_chain} EVERY ps=pattern_source wt=within_time?
;
pattern_source_chain:
pattern_source_chain_1 ->({pattern_source_chain.left=current} op='->' right=pattern_source_chain_1)* //pattern_source_chain '->' pattern_source_chain
;
pattern_source_chain_1 returns pattern_source_chain:
{pattern_source_chain}'('psc=pattern_source_chain')' wt=within_time?
| {pattern_source_chain} ps=pattern_source wt=within_time?
;
but i am not sure (and dont have really time/money to digg)
Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
Re: Internal language parser is not found in xtext project [message #1764445 is a reply to message #1764443] |
Mon, 29 May 2017 20:55   |
|
once again. having a minimal grammar for the query part as well would help.
e.g
query_section:
{query_section}(SELECT ('*'| (out_att += output_attribute (',' out_att +=output_attribute)* )) (grp_by=group_by)? (having=having_expr)?)
;
output_attribute:
{output_attribute} attr=attribute INSERT (att_name +=attribute_name) | {output_attribute} attr_ref=attribute_reference
;
group_by:
GROUP BY attr_ref+=attribute_reference (',' attr_ref+=attribute_reference)*
;
having_expr:
HAVING expr=expression
;
attribute_index:
INT_LITERAL| LAST ('-' INT_LITERAL)?
;
expression:
literal
;
attribute:
literal
;
attribute_reference:
{attribute_reference} hash1='#'? name1=name ('['attribute_index1=attribute_index']')? (hash2='#' name2=name ('['attribute_index2=attribute_index']')?)? '.' attribute_name
|{attribute_reference} attribute_name
;
literal:
{function_operation} constant_value
|{function_operation} attr_ref=attribute_reference
;
constant_value:
string_value
| time_value
;
time_value:
year_value
;
year_value:
INT_LITERAL YEARS
;
string_value:
STRING_LITERAL
;
INT_LITERAL :
DIGIT
;
STRING_LITERAL:
STRING
;
fragment DIGIT:
INT
;
name:
keyword | ID
;
attribute_name:
name
;
which gives some warnings with an understandable message as well
warning(200): ../org.xtext.example.mydsl1/src-gen/org/xtext/example/mydsl1/parser/antlr/internal/InternalMyDsl.g:719:2: Decision can match input such as "RULE_STRING" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
warning(200): ../org.xtext.example.mydsl1.ide/src-gen/org/xtext/example/mydsl1/ide/contentassist/antlr/internal/InternalMyDsl.g:1363:1: Decision can match input such as "RULE_STRING" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
=> i can help you only if you help me to understand your problem based on a small example.
+ e.g. a bunch of unit tests
but if you have a look at
output_attribute:
{output_attribute} attr=attribute INSERT (att_name +=attribute_name) | {output_attribute} attr_ref=attribute_reference
you can see that after the INSERT can only come one attribute name but
insert all events into outputStream ;
are 4 things after insert
maybe that should be parsed as
query_output:
INSERT (out_event_type = output_event_type)? INTO (tar = target)
;
but i dont know
.....
so it might be ambigous in conj with
query:
(ann3 += annotation)* FROM (q_inp = query_input ) (query_sec = query_section)? (q_output = query_output)';'
;
..........
what should go into section and what into output.?
;
a grammar like
model:
s=query_section? (q_output = query_output)';'
;
query_output:
INSERT (out_event_type = output_event_type)? INTO (tar = target);
output_event_type:
ALL EVENTS | ALL RAW EVENTS | EXPIRED EVENTS | EXPIRED RAW EVENTS | CURRENT? EVENTS;
query_section:
{query_section}(SELECT ('*'| (out_att += output_attribute (',' out_att +=output_attribute)* ))
//(grp_by=group_by)? (having=having_expr)?
)
;
source:
inner='#'? (str_id = stream_id)
;
stream_id:
name
;
target:
source
;
output_attribute:
{output_attribute} attr=attribute INSERT (att_name +=attribute_name) | {output_attribute} attr_ref=attribute_reference
;
group_by:
GROUP BY attr_ref+=attribute_reference (',' attr_ref+=attribute_reference)*
;
having_expr:
HAVING expr=expression
;
attribute_index:
INT_LITERAL| LAST ('-' INT_LITERAL)?
;
expression:
literal
;
attribute:
literal
;
attribute_reference:
{attribute_reference} hash1='#'? name1=name ('['attribute_index1=attribute_index']')? (hash2='#' name2=name ('['attribute_index2=attribute_index']')?)? '.' attribute_name
|{attribute_reference} attribute_name
;
literal:
{function_operation} constant_value
|{function_operation} attr_ref=attribute_reference
;
constant_value:
string_value
| time_value
;
time_value:
year_value
;
year_value:
INT_LITERAL YEARS
;
string_value:
STRING_LITERAL
;
INT_LITERAL :
DIGIT
;
STRING_LITERAL:
STRING
;
fragment DIGIT:
INT
;
name:
keyword | ID
;
attribute_name:
name
;
looks ok but gives warnings as well
=>
i recommend to work with smaller grammars, avoid backtracking to nail down the issue
Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
|
|
|
|