Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » XTEXT - Problems with my grammar(XTEXT . grammar)
XTEXT - Problems with my grammar [message #670524] Sat, 14 May 2011 17:37 Go to next message
Eclipse User is currently offline Eclipse UserFriend
Messages: 5
Registered: February 2011
Junior Member
Hi,
I have errors with my grammar in XTEXT: the rule .... Accion is left recursive
the rule .... Condicion is left recursive
the rule .... propiedad is left recursive

This is my grammar:
Program:
(reglas += Regla)*;



Regla:
Condicion Accion;

Condicion:
Propiedad OpComparacion Propiedad |
Propiedad OpComparacion Valor |
Condicion OpLogico Condicion;

Accion:
propiedad=Propiedad OpAccion valor=Valor | accion=Accion "AND" accion=Accion;

OpAccion:
"=" | "+" |"-"| "*" | "/";

OpComparacion:
"==" | "<" | ">";

OpLogico:
"AND" | "OR";

Propiedad:
Identificador:Valor | Identificador.Propiedad;

Valor:
Type;




Type: intType|booleanType|StringType|NullType;

intType:
{intType} "int";
booleanType:
{booleanType} "boolean";
StringType:
{StringType} "String";
NullType:
{NullType} "Null";


Please, any can help me. What´s the correct form to correct my grammar?
Re: XTEXT - Problems with my grammar [message #670541 is a reply to message #670524] Sat, 14 May 2011 19:22 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
The documentation shows how to left factor an expression grammar. Also look
at the expression example.

- henrik
<forums-noreply@eclipse.org> wrote:
> Hi,
> I have errors with my grammar in XTEXT: the rulle .... Accion
> is left recursive
> the rule .... Condicion is left recursive
> the rule .... propiedad is left recursive
>
> This is my grammar:
> Program: (reglas += Regla)*;
>
>
> Regla:
> Condicion Accion;
>
> Condicion:
> Propiedad OpComparacion Propiedad |
> Propiedad OpComparacion Valor |
> Condicion OpLogico Condicion;
>
> Accion:
> propiedad=Propiedad OpAccion valor=Valor | accion=Accion
> "AND" accion=Accion;
>
> OpAccion:
> "=" | "+" |"-"| "*" | "/";
>
> OpComparacion:
> "==" | "<" | ">";
>
> OpLogico:
> "AND" | "OR";
>
> Propiedad:
> Identificador:Valor | Identificador.Propiedad;
>
> Valor:
> Type;
>
>
>
>
> Type: intType|booleanType|StringType|NullType;
>
> intType:
> {intType} "int";
> booleanType:
> {booleanType} "boolean";
> StringType:
> {StringType} "String";
> NullType:
> {NullType} "Null";
>
>
> Please, any can help me. What´s the correct form to correct
> my grammar?


--
- henrik
Previous Topic:Shadowing with ImportedNamespaceAwareSP
Next Topic:Define a grammar to parse Java-Code
Goto Forum:
  


Current Time: Thu Apr 25 10:10:30 GMT 2024

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

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

Back to the top