Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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 @@ -337,6 +337,24 @@ public void visit(ASTConcept srcNode) {
map(srcNode, targetNode);
}

@Override
public void visit(ASTSplitRule srcNode) {
Log.debug("Visiting " + srcNode.toString(), LOG);
tfLang.addSplitRule(srcNode.deepClone());
}

@Override
public void visit(ASTKeywordRule srcNode) {
Log.debug("Visiting " + srcNode.toString(), LOG);
tfLang.addKeywordRule(srcNode.deepClone());
}

@Override
public void visit(ASTReplaceRule srcNode) {
Log.debug("Visiting " + srcNode.toString(), LOG);
tfLang.addReplaceRule(srcNode.deepClone());
}

public ASTMCGrammar getTfLang() {
return tfLang;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@ grammar ExpressionDSL extends
Foo = "expr" Expression;

CDAttribute = Modifier MCType Name ("=" initial:Expression)? ";";

// a production introducing a keyword
MyFancyKeywordP = "MyFancyKeyword";
// which is then turned into no keyword
nokeyword "MyFancyKeyword";
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ public void testAssigns() throws IOException {
Assert.assertEquals("string", ((ASTStringLiteral)((ASTLiteralExpression)((ASTPlusExpression)ast.getValue()).getRight()).getLiteral()).getValue());
}

@Test
public void testNoKeyword() throws IOException {
// Test if (no)keywords rules apply
test("MyFancyKeyword", ExpressionDSLTRParser::parse_StringITFMyFancyKeywordP);
test("MyFancyKeyword", ExpressionDSLTRParser::parse_StringITFNameExpression);
test("42<=42", ExpressionDSLTRParser::parse_StringITFExpression);
test("42 <42", ExpressionDSLTRParser::parse_StringITFExpression);
}

protected <A> A test(String exp, ParserFunction<A> parserFunction) throws IOException {
ExpressionDSLTRParser parser = ExpressionDSLTRMill.parser();
Optional<A> typeOptional = parserFunction.parse(parser, exp);
Expand Down
Loading