diff --git a/css-checks/src/test/resources/checks/less/unknownFunctions.less b/css-checks/src/test/resources/checks/less/unknownFunctions.less index 6c034f72..786519d3 100644 --- a/css-checks/src/test/resources/checks/less/unknownFunctions.less +++ b/css-checks/src/test/resources/checks/less/unknownFunctions.less @@ -7,4 +7,5 @@ filter: alpha(opacity=50); filter: color("#123"); filter: desaturate("#123"); + top: -(@timeline-h-size-step/2)-(@timeline-h-size-line/2); } diff --git a/css-frontend/src/main/java/org/sonar/css/parser/LexicalGrammar.java b/css-frontend/src/main/java/org/sonar/css/parser/LexicalGrammar.java index 0f6effd3..775d8e11 100644 --- a/css-frontend/src/main/java/org/sonar/css/parser/LexicalGrammar.java +++ b/css-frontend/src/main/java/org/sonar/css/parser/LexicalGrammar.java @@ -514,11 +514,12 @@ private static void macros(LexerlessGrammarBuilder b) { b.rule(_IDENT).is( b.firstOf( b.regexp("(?i)(progid:DXImageTransform\\.Microsoft\\.[a-z]+)"), + b.sequence("-", b.oneOrMore(_NMCHAR)), b.sequence(_NMSTART, b.zeroOrMore(_NMCHAR)))) .skip(); b.rule(_NMSTART).is( - b.firstOf(b.regexp("(?i)[_a-z]"), "-", "*", _NONASCII, _ESCAPE)).skip(); + b.firstOf(b.regexp("(?i)[_a-z]"), "*", _NONASCII, _ESCAPE)).skip(); b.rule(_NONASCII).is(b.regexp("[^\\x00-\\xED]")).skip(); diff --git a/css-frontend/src/test/java/org/sonar/css/parser/css/IdentifierTreeTest.java b/css-frontend/src/test/java/org/sonar/css/parser/css/IdentifierTreeTest.java index c716ea6c..7eb2112c 100644 --- a/css-frontend/src/test/java/org/sonar/css/parser/css/IdentifierTreeTest.java +++ b/css-frontend/src/test/java/org/sonar/css/parser/css/IdentifierTreeTest.java @@ -63,6 +63,8 @@ public void notIdent() { checkNotParsed("123"); checkNotParsed("123px"); checkNotParsed("@{abc}"); + checkNotParsed("-"); + checkNotParsed("-("); } private IdentifierTree checkParsed(String toParse, String expectedIdent) { diff --git a/its/ruling/projects/custom/less/unknownFunctions.less b/its/ruling/projects/custom/less/unknownFunctions.less index 6c034f72..786519d3 100644 --- a/its/ruling/projects/custom/less/unknownFunctions.less +++ b/its/ruling/projects/custom/less/unknownFunctions.less @@ -7,4 +7,5 @@ filter: alpha(opacity=50); filter: color("#123"); filter: desaturate("#123"); + top: -(@timeline-h-size-step/2)-(@timeline-h-size-line/2); }