Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext 2.9 BETA - attribute is not a token, parameter, or return value
Xtext 2.9 BETA - attribute is not a token, parameter, or return value [message #1710784] Fri, 09 October 2015 10:02 Go to next message
Ian Warwick is currently offline Ian WarwickFriend
Messages: 44
Registered: April 2012
Member
I have a grammar and when I try to generate using the MWE workflow, I get an error which looks like its to do with the generated PSI grammar file:

attribute is not a token, parameter, or return value: Keyword_9_1ElementType

Full MWE output with error here:

0    [main] INFO  text.xtext.generator.XtextGenerator  - Initializing Xtext generator
8    [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Adding generated EPackage 'org.eclipse.xtext.common.types.TypesPackage'
116  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project com.justeat.mickeydb at 'file:/sandbox-mars-04/com.justeat.mickeydb.parent/com.justeat.mickeydb/'
117  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project com.justeat.mickeydb.tests at 'file:/sandbox-mars-04/com.justeat.mickeydb.parent/com.justeat.mickeydb.tests/'
117  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project com.justeat.mickeydb.ide at 'file:/sandbox-mars-04/com.justeat.mickeydb.parent/com.justeat.mickeydb.ide/'
117  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project com.justeat.mickeydb.ui at 'file:/sandbox-mars-04/com.justeat.mickeydb.parent/com.justeat.mickeydb.ui/'
117  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project com.justeat.mickeydb.ui.tests at 'file:/sandbox-mars-04/com.justeat.mickeydb.parent/com.justeat.mickeydb.ui.tests/'
117  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project com.justeat.mickeydb.idea at 'file:/sandbox-mars-04/com.justeat.mickeydb.parent/com.justeat.mickeydb.idea/'
127  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Using resourceSet registry. The registered Packages will not be registered in the global EPackage.Registry.INSTANCE!
575  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/Xtext/Xbase/XAnnotations' from 'platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel'
590  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/xtext/xbase/Xtype' from 'platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel'
647  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/xtext/xbase/Xbase' from 'platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel'
647  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/xtext/common/JavaVMTypes' from 'platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.genmodel'
1907 [main] INFO  text.xtext.generator.XtextGenerator  - Generating com.justeat.mickeydb.MickeyLang
5695 [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.justeat.com/mickeydb/MickeyLang' from 'platform:/resource/com.justeat.mickeydb/model/generated/MickeyLang.genmodel'
18740 [main] INFO  i.generator.compare.CompareFragment  - generating Compare Framework infrastructure
error(114): ../com.justeat.mickeydb.idea/src-gen/com/justeat/mickeydb/idea/parser/antlr/internal/PsiInternalMickeyLang.g:1929:4: attribute is not a token, parameter, or return value: Keyword_9_1ElementType
28038 [main] INFO  text.xtext.generator.XtextGenerator  - Generating common infrastructure
28064 [main] INFO  .emf.mwe2.runtime.workflow.Workflow  - Done.



Here is the grammar in question.
grammar com.justeat.mickeydb.MickeyLang with org.eclipse.xtext.common.Terminals hidden(WS, ML_COMMENT, SL_COMMENT)

import "http://www.eclipse.org/emf/2002/Ecore" as ecore
generate mickeyLang "http://www.justeat.com/mickeydb/MickeyLang"

/***********************************************************************
 *                                                                     *
 * CORE                                                                *
 *                                                                     *
 ***********************************************************************/
MickeyFile:
	'database' databaseName=QualifiedName
	 blocks+=MickeyBlock*;

MickeyBlock:
	MickeyFunction | ActionStatement | DDLStatement | MigrationBlock
;

MickeyFunction: 'function' name=ID '(' (args+=FunctionArg (',' args+=FunctionArg)*)? ')' (':' type=[TableDefinition|QualifiedName])? '{'
	(statements+=DMLStatement ';')*
'}' ;

ActionStatement: 'action' name=ID uri=ContentUri 'on' type=[TableDefinition|QualifiedName] unique?='unique'?
		('{' params+=ContentUriQueryParam* notifications+=ContentNotificationUri* '}')?
;

ContentNotificationUri:
	'notify' uri=NotifyContentUri
;

FunctionArg:
	type=ColumnType name=ID
;

NotifyContentUri:
	{NotifyContentUri}
	segments+=NotifyContentUriSegment? ('/' segments+=NotifyContentUriSegment)*
;

NotifyContentUriSegment:
	name=ID |
	{NotifyContentUriParamSegment} '{'name=ID'}'
;

ContentUri:
	{ContentUri}
	segments+=ContentUriSegment? ('/' segments+=ContentUriSegment)*
;

ContentUriQueryParam:
	'param' like?='like'? column=[ColumnSource]
;

ContentUriSegment:
	name=ID |
	{ContentUriParamSegment} '{'param=[ColumnSource]'}'
;

MigrationBlock:
	{MigrationBlock}
	'migrate' name=ID ('from' from=[MigrationBlock|QualifiedName])? '{' (statements+=DDLStatement ';')* '}';
	
/***********************************************************************
 *                                                                     *
 * EXPRESSIONS                                                         *
 *                                                                     *
 ***********************************************************************/
SqlExpression returns Expression:
	ExprConcat
;

ExprConcat returns Expression:
	ExprMult ({ExprConcat.left=current} op='||' right=ExprMult)*
;

ExprMult returns Expression:
	ExprAdd ({ExprMult.left=current} op=('*'|'/'|'%') right=ExprAdd)*
;

ExprAdd returns Expression:
	ExprBit ({ExprAdd.left=current} op=('+'|'-') right=ExprBit)*
;

ExprBit returns Expression:
	ExprRelate ({ExprBit.left=current} op=('<<'|'>>'|'&'|'|') right=ExprRelate)*
;

ExprRelate returns Expression:
	ExprEqual ({ExprRelate.left=current} op=('<'|'<='|'>'|'>=') right=ExprEqual)*
;

ExprEqual returns Expression:
	ExprAnd ({ExprEqual.left=current} 
		op=('='|'=='|'!='|'<>'|'is'|'is not'|'in'|'not in'|'like'|'glob'|'match'|'regexp') 
		right=ExprAnd
	)*
;

ExprAnd returns Expression:
	ExprOr ({ExprAnd.left=current} op='and' right=ExprOr)*
;

ExprOr returns Expression:
	NullCheckExpression ({ExprOr.left=current} op='or' right=NullCheckExpression)*
;

NullCheckExpression returns Expression:
	PrimaryExpression ({NullCheckExpression.left=current} right=NullExpression)?
;

NullExpression returns Expression:
	{IsNull} 'is null' |
	{NotNull} ('not null'|'notnull')
;

PrimaryExpression returns Expression:
	{NewColumn} 'new.' column=[ColumnSource] |
	{OldColumn} 'old.' column=[ColumnSource] |
	{ColumnSourceRef} (=>source=[SelectSource]'.'|source=[SelectSource]'.'(all?='*'|column=[ColumnSource])|column=[ColumnSource]) |
	{Literal} literalValue=LiteralValue|
	{NestedExpression} '(' expression=SqlExpression ')'|
	{SelectStatementExpression} not?='not'? exists?='exists'? '(' select=SelectStatement ')' |
	{CaseExpression} 'case' caseExpression=SqlExpression? 
			cases+=Case+
			('else' elseExpression=SqlExpression)? 'end' |
	{Function} name=ID '(' (all?='*'|arguments+=SqlExpression (',' arguments+=SqlExpression)*) ')' |
	{CastExpression} 'cast' '(' expression=SqlExpression 'as' type=SqliteDataType ')' |
	{FunctionArgument} '$' arg=[FunctionArg]
;

Case:
'when' whenExpression=SqlExpression 'then' thenExpression=SqlExpression
;

SelectStatement:
	core=SelectCore
	('order by'  orderby=OrderingTermList)?
	('limit' limit=SqlExpression ( ('offset'|',') limitOffset=SqlExpression)?)?
;

OrderingTermList:
	orderingTerms+=OrderingTerm (',' orderingTerms+=OrderingTerm)*
;


SelectCore returns SelectCoreExpression:
	SelectExpression ({SelectCore.left = current} op=CompoundOperator right=SelectExpression)*
;

SelectExpression returns SelectCoreExpression:
	{SelectExpression}
	'select' (distinct?='distinct'|all?='all')? (allColumns?='*'|selectList=SelectList)
	('from' source=JoinSource)?
	('where' where=WhereExpressions)?
	('group by' groupBy=GroupByExpressions)?
	('having' having=HavingExpressions)?
;

SelectList:
	resultColumns+=ResultColumn (',' resultColumns+=ResultColumn)*
;

WhereExpressions:
	expression=SqlExpression
;

GroupByExpressions:
	groupByExpressions+=SqlExpression (',' groupByExpressions+=SqlExpression)*
;

HavingExpressions:
	expression=SqlExpression
;


enum CompoundOperator:
	unionall='union all' | union='union' | intersect='intersect' | except='except'
;

OrderingTerm:
	expression=SqlExpression (asc?='asc'|desc?='desc')?
;

JoinSource:
	source=SingleSource joinStatements+=JoinStatement*
;

SingleSource:
	SingleSourceTable | SingleSourceSelectStatement | SingleSourceJoin
;

SingleSourceTable returns SelectSource:
	 {SingleSourceTable} 
	 tableReference=[TableDefinition|QualifiedName] ('as' name=ID)?;
	 
SingleSourceSelectStatement returns SelectSource: 
	{SingleSourceSelectStatement} 
	'(' selectStatement=SelectStatement ')' ('as' name=ID)?
;

SingleSourceJoin: 
	'(' joinSource=JoinSource ')';

JoinStatement:
	{JoinStatement}
	natural?='natural'? ((left?='left' outer?='outer'?) | inner?='inner' | cross?='cross')? 'join' singleSource=SingleSource 'on' expression=SqlExpression;
	

ResultColumn returns ColumnSource:
	{ResultColumn}
	expression=SqlExpression ('as' name=ID)?
;
	
LiteralValue:
	{NumericLiteral} number=SignedNumber |
	{StringLiteral} literal=STRING |
	{NullLiteral} literal='null' |
	{CurrentTimeLiteral} literal='current_time' |
	{CurrentDateLiteral} literal='current_date' |
	{CurrentTimeStampLiteral} literal='current_timestamp'
;

enum SqliteDataType:
	text | integer | real | blob | none | numeric;

/***********************************************************************
 *                                                                     *
 * DDL                                                                 *
 *                                                                     *
 ***********************************************************************/

DDLStatement:
	CreateTableStatement
	| CreateViewStatement
	| CreateTriggerStatement
	| CreateIndexStatement
	| AlterTableRenameStatement
	| AlterTableAddColumnStatement
	| DropTableStatement
	| DropTriggerStatement
	| DropViewStatement
	| DropIndexStatement
;

CreateTableStatement returns TableDefinition: 
	{CreateTableStatement} 'create' temporary?='temp'? 'table' name=ID '(' 
		columnDefs+=ColumnDef (',' columnDefs+=ColumnDef)* 
		(',' constraints+=TableConstraint)* 
	')';

CreateViewStatement returns TableDefinition: 
	{CreateViewStatement}
	'create' temporary?='temp'? 'view' name=ID 'as' selectStatement=SelectStatement;
	
CreateTriggerStatement: 
	'create' temporary?='temp'? 'trigger' name=ID when=('before'|'after'|'instead of')?
	  (eventType='delete'|eventType='insert'|eventType='update' ('of' updateColumnNames+=ID (',' updateColumnNames+=ID)*)?)
	  'on' table=[TableDefinition|ID] forEachRow=('for each row')? ('when' whenExpression=SqlExpression)?
	  'begin' (statements+=DMLStatement ';' (statements+=DMLStatement ';')*)? 'end';
	  
AlterTableRenameStatement returns TableDefinition:
	{AlterTableRenameStatement} 
	'alter' 'table' table=[TableDefinition|ID] 'rename to' name=ID
;

AlterTableAddColumnStatement: 
	'alter' 'table' table=[TableDefinition|ID] 'add column' columnDef=ColumnDef
;

DropTableStatement: 
	'drop' 'table' ifExists?=('if exists')? table=[TableDefinition|ID];
	
DropTriggerStatement: 
	'drop' 'trigger' ifExists?=('if exists')? trigger=[CreateTriggerStatement|ID];

DropViewStatement: 
	'drop' 'view' ifExists?=('if exists')? view=[CreateViewStatement|ID];
	
CreateIndexStatement:
	'create' unique?=('unique')? 'index' name=ID 'on' table=[TableDefinition|ID]
	'(' columns+=IndexedColumn (',' columns+=IndexedColumn)* ')'
;

DropIndexStatement: 
	'drop' 'index' ifExists?=('if exists')? index=[CreateIndexStatement|ID];
	

ColumnDef returns ColumnSource:
	{ColumnDef}
	name=ID type=ColumnType constraints+=ColumnConstraint*;

ColumnConstraint:
	{PrimaryKeyColumnConstraint} 'primary key' (asc?='asc'|desc?='desc')? autoincrement?='autoincrement'? |
	{NotNullConstraint} 'not null' conflictClause=ConflictClause? |
	{UniqueConstraint} 'unique' conflictClause=ConflictClause? |
	{DefaultConstraint} 'default' defaultValue=DefaultValue |
	{CheckConstraint} 'check' '(' expression=SqlExpression ')'
;

TableConstraint:
	UniqueTableConstraint | PrimaryConstraint | CheckTableConstraint
;

UniqueTableConstraint: 
	('constraint' name=ID)? 'unique' '(' columns+=IndexedColumn (',' columns+=IndexedColumn)* ')' conflictClause=ConflictClause
;

PrimaryConstraint: 
	('constraint' name=ID)? 'primary key' '(' columns+=IndexedColumn (',' columns+=IndexedColumn)* ')' conflictClause=ConflictClause
;

CheckTableConstraint: 
	('constraint' name=ID)? 'check' '(' expression=SqlExpression ')'
;

IndexedColumn:
	columnReference=[ColumnDef] ('collate' collationName=ID)? (asc?='asc'|desc?='desc')?;

DefaultValue:
	{LiteralDefaultValue} literal=LiteralValue |
	{ExpressionDefaultValue} '(' expression=SqlExpression ')'
;

ConflictClause:
	'on' 'conflict' resolution=ConflictResolution;

enum ColumnType:
	text | integer | real | blob | boolean;
	
enum ConflictResolution:
	rollback | abort | fail | ignore | replace;
	
/***********************************************************************
 *                                                                     *
 * DML                                                                 *
 *                                                                     *
 ***********************************************************************/

DMLStatement:
	SelectStatement 
	| InsertStatement 
	| UpdateStatement 
	| DeleteStatement
;

DeleteStatement:
	'delete' 'from' table=[TableDefinition|ID] ('where' expression=SqlExpression)?	
;

InsertStatement:
	('insert' ('or' (conflictResolution=ConflictResolution))?|'replace') 'into' table=[TableDefinition|ID]
	('(' columnNames+=[ColumnDef] (',' columnNames+=[ColumnDef])* ')')? 
	(('values' 
		'(' expressions+=SqlExpression (',' expressions+=SqlExpression)* ')'
		| selectStatement=SelectStatement
	)|'default' 'values')
;

UpdateStatement:
	'update' ('or' (conflictResolution=ConflictResolution))? table=[TableDefinition|ID]
	'set' updateColumnExpressions+=UpdateColumnExpression (',' updateColumnExpressions+=UpdateColumnExpression)*
	('where' whereExpression=SqlExpression)?
;

UpdateColumnExpression:
	columnName=[ColumnDef] '=' expression=SqlExpression
;

/***********************************************************************
 *                                                                     *
 * DATATYPE & TERMINAL RULES                                           *
 *                                                                     *
 ***********************************************************************/
 
SignedNumber returns ecore::EBigDecimal:
	'-'?NUMBER
;	

QualifiedName:
	ID ("." ID)*;

terminal NUMBER returns ecore::EBigDecimal:
	('0'..'9')* ('.' ('0'..'9')+)?;
	
terminal INT returns ecore::EInt: 
	"$$$don't use this anymore$$$";
	
terminal STRING	: 
			'"' ( '\\' ('b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'\\') | !('\\'|'"') )* '"' |
			"'" ( '\\' ('b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'\\') | !('\\'|"'") )* "'"
		; 
	


Any help would be greatly appreciated! Smile

[Updated on: Fri, 09 October 2015 10:06]

Report message to a moderator

Re: Xtext 2.9 BETA - attribute is not a token, parameter, or return value [message #1710813 is a reply to message #1710784] Fri, 09 October 2015 13:34 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

i can you please file a ticket



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext 2.9 BETA - attribute is not a token, parameter, or return value [message #1710816 is a reply to message #1710813] Fri, 09 October 2015 13:49 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
As a workaround you may move dollar sign to a terminal rule

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext 2.9 BETA - attribute is not a token, parameter, or return value [message #1710995 is a reply to message #1710816] Mon, 12 October 2015 08:24 Go to previous message
Ian Warwick is currently offline Ian WarwickFriend
Messages: 44
Registered: April 2012
Member
Cheers! yes seems to be that dollar sign, I can create a ticket
Previous Topic:Xtext 2.9 Beta 5
Next Topic:Building current Xtext master branch locally fails
Goto Forum:
  


Current Time: Wed Apr 24 19:19:38 GMT 2024

Powered by FUDForum. Page generated in 0.03271 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top