eclipse-langium / langium

Next-gen language engineering / DSL framework
https://langium.org/
MIT License
740 stars 66 forks source link

Incorrect AST generation with actions #297

Closed pluralia closed 2 years ago

pluralia commented 2 years ago

An AST, generated from the grammar bellow, doesn't contain an interface StaticAccessExpression. Also, interfaces StaticSymbolReference and StaticMemberAccess are generated incorrectly.

Model:
    elements+=Element*;

Element:
    StaticAccessExpression;

StaticAccessExpression:
    {StaticSymbolReference} ref=ID
    ({StaticMemberAccess.receiver=current} '.' member=ID)*;

StaticSymbolReference:
    {StaticSymbolReference} ref=ID;

StaticMemberAccess:
    {StaticMemberAccess} '.' member=ID;

terminal ID: /\$?[_a-zA-Z][\w_]*/;

Langium version: 0.2.1

Steps To Reproduce

  1. Generate an AST with the grammar above
  2. Check out the StaticAccessExpression, StaticSymbolReference and StaticMemberAccess interfaces in the AST

The current behavior

The generated AST doesn't contain the StaticAccessExpression interface. StaticSymbolReference and StaticMemberAccess interfaces don't extend StaticAccessExpression.

export interface StaticSymbolReference extends AstNode {
    member: string
    receiver: StaticAccessExpression
    ref: string
}

export interface StaticMemberAccess extends StaticSymbolReference {}

The expected behavior

A correctly generated AST:

export interface StaticAccessExpression extends Element {}

export interface StaticSymbolReference extends StaticAccessExpression {
    ref: string
}

export interface StaticMemberAccess extends StaticAccessExpression {
    member: string
    receiver: StaticAccessExpression
}
pluralia commented 2 years ago

@jbicker Should I close this issue? The PR is merged.

jbicker commented 2 years ago

Closed :-)