eclipse-langium / langium

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

Grammar generation logs error with imports and types #1366

Open cdietrich opened 5 months ago

cdietrich commented 5 months ago

Create a new hello world grammar

change the hello-world.langium to

grammar HelloWorld

import './hello-metadata'

interface FieldValidation {
    field: @Field;
}

entry Validation: 
    'validate' name=ID '{'
        content+=FieldValidation*
    '}'
;

FieldValidation returns FieldValidation: 
    'on' field=[Field] '{' 
    '}';

create following additional grammars

hello-terminals.langium

hidden terminal WS: /\s+/;
terminal ID: /[_a-zA-Z][\w_-]*/;

hello-metadata.langium

grammar HelloMetadata

import './hello-terminals'

TextType infers DataType:
    name='Text';

BuiltInType:
    TextType;

Type:
    BuiltInType
;

interface Field {
    name: string;
    type: Type;
}

entry Field returns Field:
    'field' name=ID (type=Type) ('{' '}')?;

run langium:generate the following error is logged to command line

Error: Token "Text" not found."

=> looks like there is something broken in the lexer building

cdietrich commented 5 months ago

might be another wired variant of https://github.com/eclipse-langium/langium/issues/1151