Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[incubator-kie-drools-5911] [new-parser] Support optional type keywor… #5977

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5304,4 +5304,17 @@ void accumulateWithEmptyActionAndReverse() {
});
});
}

@Test
void typeDeclarationWithTypeToken() {
final String drl = "declare type Foo\n" + // "type" is just optional
" id : int\n" +
"end";
final PackageDescr pkg = parseAndGetPackageDescr(drl);

TypeDeclarationDescr typeDeclarationDescr = pkg.getTypeDeclarations().get(0);
assertThat(typeDeclarationDescr.getTypeName()).isEqualTo("Foo");
TypeFieldDescr typeFieldDescr = typeDeclarationDescr.getFields().get("id");
assertThat(typeFieldDescr.getPattern().getObjectType()).isEqualTo("int");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ drlKeywords returns [Token token]
| DRL_GLOBAL
| DRL_DECLARE
| DRL_TRAIT
| DRL_TYPE
| DRL_RULE
| DRL_QUERY
| DRL_WHEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ DRL_FUNCTION : 'function';
DRL_GLOBAL : 'global';
DRL_DECLARE : 'declare';
DRL_TRAIT : 'trait';
DRL_TYPE : 'type';
DRL_RULE : 'rule';
DRL_QUERY : 'query';
DRL_WHEN : 'when';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ declaredef : DRL_DECLARE (
* END
*/

typeDeclaration : DRL_TRAIT? name=drlQualifiedName (EXTENDS superTypes+=drlQualifiedName (COMMA superTypes+=drlQualifiedName)* )? drlAnnotation* field* DRL_END ;
typeDeclaration : DRL_TRAIT? DRL_TYPE? name=drlQualifiedName (EXTENDS superTypes+=drlQualifiedName (COMMA superTypes+=drlQualifiedName)* )? drlAnnotation* field* DRL_END ;

// entryPointDeclaration := ENTRY-POINT stringId annotation* END

Expand Down
Loading