diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 83a1d30..ce254c8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,7 +22,7 @@ jobs: artifact: name: Publish - Nexus - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest needs: unit-test steps: diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 16230fa..e7314fc 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -25,7 +25,7 @@ jobs: artifact: name: Publish - Nexus - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest needs: unit-test steps: diff --git a/pom.xml b/pom.xml index f9bb11a..b20bd1d 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ jar DHIS Antlr Expression Parser org.hisp.dhis.parser - 1.0.33 + 1.0.34-SNAPSHOT Antlr Expression Parser diff --git a/src/main/antlr4/org/hisp/dhis/parser/expression/antlr/Expression.g4 b/src/main/antlr4/org/hisp/dhis/parser/expression/antlr/Expression.g4 index dc4a143..426e322 100644 --- a/src/main/antlr4/org/hisp/dhis/parser/expression/antlr/Expression.g4 +++ b/src/main/antlr4/org/hisp/dhis/parser/expression/antlr/Expression.g4 @@ -170,6 +170,7 @@ expr | numericLiteral | stringLiteral | booleanLiteral + | comments ; programVariable // (alphabtical) @@ -241,6 +242,10 @@ programRuleVariablePart | '.' ; +comments + : COMMENT + ; + // ----------------------------------------------------------------------------- // Assign token names to parser symbols // ----------------------------------------------------------------------------- @@ -498,6 +503,12 @@ EMPTY WS : [ \t\n\r]+ ; +// Comments + +COMMENT + : ('/*' .*? '*/') -> skip + ; + // Lexer fragments fragment Exponent diff --git a/src/test/java/org/hisp/dhis/antlr/ValidExpressionTest.java b/src/test/java/org/hisp/dhis/antlr/ValidExpressionTest.java index a7cdf6f..6f4ba11 100644 --- a/src/test/java/org/hisp/dhis/antlr/ValidExpressionTest.java +++ b/src/test/java/org/hisp/dhis/antlr/ValidExpressionTest.java @@ -65,6 +65,12 @@ public void testExpressionWithValidSyntaxAndNotSupportedVariable() evaluate( "2 > V{not_supported}" ); } + @Test + public void testMultiLineComments() + { + assertEquals( true, evaluate( "true and true || 1 /* this is multi \n line comment \r */" ) ); + } + @Test(expected = ParserExceptionWithoutContext.class) public void testExpressionWithValidSyntaxAndNotSupportedAttribute() {