Xtext grammar : mismatched input '0' expecting RULE_INT

cartman

I'm new to Xtext and I'm trying to create a simple DSL for railway systems, here's my grammar :

grammar org.xtext.railway.RailWay with org.eclipse.xtext.common.Terminals

generate railWay "http://www.xtext.org/railway/RailWay"

Model:
    (trains+=Train)*
    | (paths+=Path)*
    | (sections+=Section)*
;

Train:
    'Train' name=ID ':'
    'Path'  path=[Path]
    'Speed' speed=INT
    'end'
;

Path:
    'Path'      name=ID ':'
    'Sections'  ('{' sections+=[Section] (',' sections+=[Section] )+ '}' ) | sections+=[Section]
    'end'
;

Section:
    'Section'   name=ID ':'
    'Start'     start=INT
    'End'       end=INT
    ('SpeedMax' speedMax=INT)?
    'end'
;

But when I put this code at the Eclipse instance :

Section brestStBrieux :
    Start 0
    End 5
end

Section StBrieuxLeMan :
    Start 5
    End 10
end

Section leManParis :
    Start 1
    End 12
end

Path brestParis :
    Sections  { brestStBrieux, StBrieuxLeMan, leManParis}
end

Train tgv :
    Path  brestParis
    Speed  23
end

I got this error three times:

mismatched input '0' expecting RULE_INT mismatched input '1' expecting RULE_INT mismatched input '5' expecting RULE_INT

I can't see where those errors come from, what can I do to fix them. Any idea?

Sebastian Zarnekow

Christian is right, since the FLOAT terminal is no longer defined, the original problem is resolved. Anyway, a remaining issue is the rule

Path:
    'Path'      name=ID ':'
    'Sections'  ('{' sections+=[Section] (',' sections+=[Section] )+ '}' ) | sections+=[Section]
    'end'
;

which currently has this precedence:

Path:
    (
       'Path' name=ID ':' 'Sections'
       ('{' sections+=[Section] (',' sections+=[Section] )+ '}' )
    ) 
    |
    (sections+=[Section] 'end')
;

You may want to rewrite it to

Path:
    'Path'      name=ID ':'
    'Sections'  
    ( 
       ('{' sections+=[Section] (',' sections+=[Section] )+ '}' )
    |  sections+=[Section]
    ) 'end'
;

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Xtext grammar : mismatched input '0' expecting RULE_INT

From Dev

ANTLR Grammar line 1:6 mismatched input '<EOF>' expecting '.'

From Dev

Mismatched input ',' expecting ')'

From Dev

mismatched input ')' expecting EOF in CQL

From Dev

mismatched input ')' expecting EOF in CQL

From Dev

Jython @property SyntaxError: mismatched input '' expecting CLASS

From Dev

Antlr : beginner 's mismatched input expecting ID

From Dev

ANTLR 4.5 - Mismatched Input 'x' expecting 'x'

From Dev

"Mismatched input <EOF>" with very simple grammar

From Dev

"Mismatched input <EOF>" with very simple grammar

From Dev

mismatched input '.' in rule

From Dev

Mismatched input 'STRING' expecting : near 'name' in column specification

From Dev

Why am I getting "mismatched input 'addr' expecting {<EOF>, 'addr'}"

From Dev

Pig: Failed to parse: mismatched input 'id' expecting set null

From Dev

Pig: Failed to parse: mismatched input 'id' expecting set null

From Dev

ANTLR 4.5: line 1:22 mismatched input 'randomly' expecting DIRECTION

From Dev

ANTLR4 Grammar extraneous / mismatched input error

From Dev

Drools decision table, "mismatched input '>' in rule "

From Dev

Is there a java grammar file for Xtext?

From Dev

XText grammar for markdown

From Dev

Xtext grammar QualifiedName ambiguity

From Dev

Bad Request: line 1:115 mismatched input ';' expecting K_VALUES in cassandra

From Dev

FAILED: Parse Error: line 7:19 mismatched input '(' expecting FROM in from clause

From Dev

How to share values for different tokens - mismatched input 'COMMAND1' expecting FUNCTIONNAME2" -

From Dev

Mismatched types `[int]` vs `[int, .. 0]`

From Dev

Xtext grammar error "Decision can match input ... using multiple alternatives: 1, 3, 4, 5"

From Dev

Defining Primitives within xtext Grammar

From Dev

Eclipse XText Object Oriented Grammar

From Dev

Defining Primitives within xtext Grammar

Related Related

  1. 1

    Xtext grammar : mismatched input '0' expecting RULE_INT

  2. 2

    ANTLR Grammar line 1:6 mismatched input '<EOF>' expecting '.'

  3. 3

    Mismatched input ',' expecting ')'

  4. 4

    mismatched input ')' expecting EOF in CQL

  5. 5

    mismatched input ')' expecting EOF in CQL

  6. 6

    Jython @property SyntaxError: mismatched input '' expecting CLASS

  7. 7

    Antlr : beginner 's mismatched input expecting ID

  8. 8

    ANTLR 4.5 - Mismatched Input 'x' expecting 'x'

  9. 9

    "Mismatched input <EOF>" with very simple grammar

  10. 10

    "Mismatched input <EOF>" with very simple grammar

  11. 11

    mismatched input '.' in rule

  12. 12

    Mismatched input 'STRING' expecting : near 'name' in column specification

  13. 13

    Why am I getting "mismatched input 'addr' expecting {<EOF>, 'addr'}"

  14. 14

    Pig: Failed to parse: mismatched input 'id' expecting set null

  15. 15

    Pig: Failed to parse: mismatched input 'id' expecting set null

  16. 16

    ANTLR 4.5: line 1:22 mismatched input 'randomly' expecting DIRECTION

  17. 17

    ANTLR4 Grammar extraneous / mismatched input error

  18. 18

    Drools decision table, "mismatched input '>' in rule "

  19. 19

    Is there a java grammar file for Xtext?

  20. 20

    XText grammar for markdown

  21. 21

    Xtext grammar QualifiedName ambiguity

  22. 22

    Bad Request: line 1:115 mismatched input ';' expecting K_VALUES in cassandra

  23. 23

    FAILED: Parse Error: line 7:19 mismatched input '(' expecting FROM in from clause

  24. 24

    How to share values for different tokens - mismatched input 'COMMAND1' expecting FUNCTIONNAME2" -

  25. 25

    Mismatched types `[int]` vs `[int, .. 0]`

  26. 26

    Xtext grammar error "Decision can match input ... using multiple alternatives: 1, 3, 4, 5"

  27. 27

    Defining Primitives within xtext Grammar

  28. 28

    Eclipse XText Object Oriented Grammar

  29. 29

    Defining Primitives within xtext Grammar

HotTag

Archive