Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » As a result, alternative(s) 2 were disabled for that input__ldscript(use xtext to design a gnu ldscript parser and editor, trouble has been happend)
icon9.gif  As a result, alternative(s) 2 were disabled for that input__ldscript [message #1272540] Tue, 18 March 2014 06:37 Go to next message
mao baolong is currently offline mao baolongFriend
Messages: 2
Registered: March 2014
Junior Member
Razz now i paste mydsl.xtext file here ! (also privode mydsl.xtext as attachment)


grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals



Model:
(
output_format+=OutputFormat
|provide+=Provide
|entry+=Entry
|assignmentExpression+=AssignmentExpression
|memory+=Memory
|sections+=Sections
)*

;
OutputFormat:
'OUTPUT_FORMAT' '(' name=STRING ')'
;
Provide:
'PROVIDE' '(' AssignmentExpressionConent ')' LINE_SPR_KW
;
Entry:
'ENTRY' '(' name=ID ')'
;

Memory:
name='MEMORY' '{' memoryBlock+=MemoryBlock* '}'
;
MemoryBlock:
name=ID ':' 'ORIGIN' '=' orgin =format_number_with_unit
',' 'LENGTH' '=' length=format_number_with_unit
;

Sections:
name = 'SECTIONS' '{'
(
assignment+=AssignmentExpression
|sectionList+=Section)*
'}'
;

Section:
name=(AssignmentLeftName)+
(addr= format_number_with_unit)?
(type='[' ('NOLOAD'|'DSECT'|'COPY'|'INFO'|'OVERLAY') ']')?
':'
('AT''(' lma=format_number_with_unit ')')?
'{'
sectionContent+=SectionContent*
'}'
('>' region=[MemoryBlock])?
('AT' '>' lma_region=ID)?
('=' fillexp=format_number_with_unit)?
;


SectionContent:

assignmentExpression=AssignmentExpression|
sectionPart =SectionPart|
sort=Sort|
keep=Keep|
provide+=Provide
;

Sort:
SORT_KW '(' filename_id_star ')' LINE_SPR_KW?
;
Keep:
KEEP_KW '(' (SectionPartBase) ')' LINE_SPR_KW?
;
SectionPart:
SectionPartBase LINE_SPR_KW
;
SectionPartBase:
filename_id_star
('(' ( (Exclude_file? filename_id_star)) ')')?
;
Exclude_file:
'EXCLUDE_FILE' '(' (filename_id_star)+ ')'
;
filename_id_star:
(AssignmentLeftName|'?'| '*'|'\\'|'/')+
;


TreeExpression:
Defined '?' expressionL = Expression ':' expressionR =Expression
;
Defined:
'DEFINED' '(' name=ID ')'
;

Align:
ALIGN_KW '(' name =format_number_with_unit ')'
;
Absolute:
ABSOLUTE_KW '(' name ='.' ')'
;

AssignmentExpression:
AssignmentExpressionConent LINE_SPR_KW;

AssignmentExpressionConent:
name=AssignmentLeftName(
"="
| "+="
| "-="
| "*="
| "/="
| "<<="
| ">>="
| "&="
| "|="
)expression=Expression
;



Expression:
Addition
| TreeExpression;

Addition returns Expression:
Multiplication (({Plus.left=current} name='+' | {Minus.left=current} name='-') right=Multiplication)*;

Multiplication returns Expression:
PrimaryExpression (({Multi.left=current} name='*' | {Div.left=current} name='/') right=PrimaryExpression)*;


PrimaryExpression returns Expression:
'(' Expression ')'
| valueStr=format_number_with_unit
| rname=('.'|ID)
| align=Align
| absolute=Absolute
;
AssignmentLeftName:
ID|'.'
;
format_number_with_unit:
FORMAT_NUMBER
( ('m'|'M'|'G'|'B'|'b'|'km'|'kM'|'kG'|'kB'|'kb'|'Km'|'KM'|'KG'|'KB'|'Kb') )?
;
terminal FORMAT_NUMBER returns ecore::EString:
('0'..'9')* ('.' ('0'..'9')+)?
| '0x' (('0'..'9')| ('a'..'f')|('A'..'F'))*
| '0b' ('0'..'1')*


;


terminal INT returns ecore::EInt:
'this one has been deactivated';

ALIGN_KW : 'ALIGN';
ABSOLUTE_KW : 'ABSOLUTE';
SORT_KW:'SORT';
KEEP_KW:'KEEP';
LINE_SPR_KW: ';';


  • Attachment: MyDsl.xtext
    (Size: 3.15KB, Downloaded 178 times)
Re: As a result, alternative(s) 2 were disabled for that input__ldscript [message #1272717 is a reply to message #1272540] Tue, 18 March 2014 15:26 Go to previous message
Salome Maro is currently offline Salome MaroFriend
Messages: 15
Registered: January 2014
Junior Member
I got this error before and it is usually due to ambigous grammar especially when you have the OR (|) operator for many options and Xtext does not know which one to pick.
Check the links below they explain how to get rid of that error.

http://zarnekow.blogspot.com/2012/10/xtext-corner-5-backtracking-vs.html
http://stackoverflow.com/questions/20831419/xtext-grammar-error-decision-can-match-input-using-multiple-alternatives-1

Hope this helps.
Previous Topic:As a result, alternative(s) 2 were disabled for that input__ldscript
Next Topic:Cross reference to data type
Goto Forum:
  


Current Time: Mon Sep 28 10:01:29 GMT 2020

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

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

Back to the top