|
|
|
|
Re: Error after I run MWE2 [message #630102 is a reply to message #630099] |
Thu, 30 September 2010 16:13 |
pozer Messages: 32 Registered: August 2010 |
Member |
|
|
Do I need to add this new reference to scoping? How would I add it to what I currently have if that's the case.
/*
* generated by Xtext
*/
package org.xtext.querydef.scoping;
import org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.xtext.scoping.IScope;
import org.eclipse.xtext.scoping.Scopes;
import org.xtext.querydef.queryDef.QualifiedTableReference;
/**
* This class contains custom scoping description.
*
* see : http://www.eclipse.org/Xtext/documentation/latest/xtext.html#scoping
* on how and when to use it
*
*/
public class QueryDefScopeProvider extends AbstractDeclarativeScopeProvider {
public IScope scope_QualifiedTableReference_attribute(QualifiedTableReference qtf, EReference ref) {
return Scopes.scopeFor(qtf.getElement().getColumns());
}
}
Here is my grammar and the fragment reference is what is currently not included in my scoping. I just need to know what the appropriate syntax is for multiple items in the scoping.
grammar org.xtext.querydef.QueryDef with org.eclipse.xtext.common.Terminals
generate queryDef "http://www.xtext.org/querydef/QueryDef"
import "platform:/resource/org.xtext.DefTable/src-gen/org/xtext/example/deftable/DefTable.ecore" as deftable
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
import "platform:/resource/org.xtext.fragment/src-gen/org/xtext/Fragment.ecore" as fragment
NameSpaces:{NameSpaces}
(namespace+=NameSpace)*;
NameSpace:
'Namespace' name=ID "{"
(query+=Query)*
"}";
Query:
//question: is the order of the elements fixed (desc, query, filter,...)
//or can the order vary (in which case unordered groups could be used
//separate the namespace from the name of the query because
//when calculating the fully qualified name of Query, the
//container (NameSpace) is automatically added
'Query' namespace=[NameSpace] ("." name=QualifiedName)"{"
(
//a description is mandatory?
("[" 'Description:' description=MYSTRING"]")
("[" 'Set join_collapse_limit=' limit=INT"]")?
("[" 'Query:'queryName=[NameSpace]'.'query=[Query|QualifiedName]"]")?
("[" 'Filter:' filter+=Filter(',' filter+=Filter)*"]")?
("[" 'Return:' return+=ReturnElement (',' return+=ReturnElement)* "]")?
("[" 'From:' from=[deftable::Table]
joinexpression+=JoinExpression*
"]")?
("[" 'Where:' where+=Where(("And"|"Or")where+=Where)* "]")?
("[" 'Order:' order+=OrderExpression(',' order+=OrderExpression)*"]")?
"}");
//
//
Filter: column=(QualifiedTableReference)(multi?='*')?|(distance+=Distance) (multi?='*')?|('MIN_'|'MAX_'|'AVERAGE_'|'RANGE_')column3=QualifiedTableReference(multi?='*')?|fragment=[fragment::Fragments](multi?='*')?;
ReturnElement: column=QualifiedTableReference('As' asname=ID)?|(column2=QualifiedTableReference)'.'('MIN'|'MAX'|'AVERAGE'|'Range') ('As' asname=ID)?|fragment=[fragment::Fragments];
//JOINS
//assigned actions might be the better alternative to
//handle the joins
JoinExpression:InnerJoinExpression|OuterJoinExpression;
enum Distance: radiussearchdistance='RadiusSearchDistance'|radiussearchradius='RadiusSearchRadius'|RadiusSearchDistanceFromLatLon='RadiusSearchDistanceFromLatLon'|RadiusSearchLatLon='RadiusSearchLatLon'|RadiusSearchPostalCode='RadiusSearchPostalCode'|RadiusSearchDistanceFromPostalCode='RadiusSearchDistanceFromPostalCode';
InnerJoinExpression:
(optional?='Optional')? 'Inner' 'Join' jointablename+=[deftable::Table]
"On" equals+=ColumnRefEqualsExpression
("And" equals+=ColumnRefEqualsExpression)*
(("And"|"Or") equals+=JoinAndExpression)*;
OuterJoinExpression:
(optional?='Optional')? 'Left' 'Join' jointablename=[deftable::Table]
"On" equals+=ColumnRefEqualsExpression
(("And"|"Or") equals+=ColumnEqualsExpression)*
(("And"|"Or") equals+=JoinAndExpression)*
//
//
;
ColumnEqualsExpression:ColumnRefEqualsExpression|ColumnStringEqualsExpression;
ColumnRefEqualsExpression: left=QualifiedTableReference '='
right=QualifiedTableReference;
ColumnStringEqualsExpression: left=QualifiedTableReference '='
right=STRING;
JoinAndExpression:
IntCompareExpression|NullExpression|NotNullExpression|StringEqualsExpression;
Where: column=QualifiedTableReference (expression=WhereExpression);
//rather use references, same issue as in Filter
//Order: column=ID (direction=Direction)?;
OrderExpression: column= QualifiedTableReference(direction+=Direction)?;
//the first element is the default one used, when
//nothing is specified
enum Direction: ascending="asc"|descending="desc";
WhereExpression:
IntCompareExpression|NullExpression|NotNullExpression|StringEqualsExpression;
NullExpression: "is" "null"{NullExpression};
NotNullExpression: "is" "not" "null"{NotNullExpression};
IntCompareExpression: comparator=Comparator value=INT;
StringEqualsExpression: '=' value=STRING;
enum Comparator: equals = "="| greater=">"|less="<"|
lessequals="<="|greaterequals= ">=";
terminal ID : '^'?('a'..'z'|'A'..'Z') ('a'..'z'|'A'..'Z'|'0'..'9')*;
QualifiedTableReference hidden():element=[deftable::Table]'.'attribute=[deftable::Column];
QualifiedName hidden():ID('.'ID)*;
MYSTRING hidden(): (ID|WS|INT|STRING|'not'|','|ANY_OTHER|'null'|'.'|'Join'|'Inner'|'On'|'='|'or'|'keyword'|'Range'|'MIN'|'MAX'|'AVERAGE')*;
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.25518 seconds