diff options
Diffstat (limited to 'theme-compiler/src')
-rw-r--r-- | theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj | 106 |
1 files changed, 76 insertions, 30 deletions
diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj index f4752a502a..17373532a7 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj @@ -1671,13 +1671,20 @@ ArrayList<VariableNode> arglist() : } JAVACODE -boolean checkMixinForNonOptionalArguments(VariableNode arg, boolean hasNonOptionalArguments)
{ +boolean checkMixinForNonOptionalArguments(VariableNode arg, boolean hasNonOptionalArguments) +{ boolean currentArgHasArguments = arg.getExpr() != null && arg.getExpr().getLexicalUnitType() == LexicalUnitImpl.SCSS_VARIABLE && arg.getExpr().getNextLexicalUnit() != null; -
if(currentArgHasArguments)
{ - if(hasNonOptionalArguments)
{
throw new ParseException("Sass Error: Required argument $"+ arg.getName() +" must come before any optional arguments."); + + if(currentArgHasArguments) + { + if(hasNonOptionalArguments) + { + throw new ParseException("Sass Error: Required argument $"+ arg.getName() +" must come before any optional arguments."); } return hasNonOptionalArguments; - }else
{
return true; + }else + { + return true; } } @@ -1692,9 +1699,13 @@ VariableNode mixinArg() : { name=variableName() (< COLON > (< S >)* - (
first = nonVariableTerm(null)
{ - prev = first;
} - (LOOKAHEAD(3)(< COMMA >(< S >)*)? prev = nonVariableTerm(prev))*
) + ( + first = nonVariableTerm(null) + { + prev = first; + } + (LOOKAHEAD(3)(< COMMA >(< S >)*)? prev = nonVariableTerm(prev))* + ) | (variable = < VARIABLE >{ first = LexicalUnitImpl.createVariable(token.beginLine, token.beginColumn, prev, variable.image);} @@ -1881,39 +1892,66 @@ String listModifyDirectiveArgs(int nest) { t = getToken(1); String s = t.image; - if(t.kind == VARIABLE||t.kind == IDENT)
{ + if(t.kind == VARIABLE||t.kind == IDENT) + { list += s; - }else if(s.toLowerCase().equals("auto")||s.toLowerCase().equals("space")||s.toLowerCase().equals("comma"))
{ + }else if(s.toLowerCase().equals("auto")||s.toLowerCase().equals("space")||s.toLowerCase().equals("comma")) + { int i = 2; Token temp = getToken(i); boolean isLast = true; while(temp.kind != SEMICOLON) - {
if(temp.kind != RPARAN || temp.kind != S) - {
isLast = false;
} + { + if(temp.kind != RPARAN || temp.kind != S) + { + isLast = false; + } i++; temp = getToken(i); } - if(isLast)
{
return list; + if(isLast) + { + return list; } - }
else if(t.kind == STRING)
{
list += s.substring(1,s.length()).substring(0,s.length()-2); + } + else if(t.kind == STRING) + { + list += s.substring(1,s.length()).substring(0,s.length()-2); - }else if(t.kind == LPARAN)
{
nesting++; - if(nesting > nest+1)
{
throw new CSSParseException("Only one ( ) pair per parameter allowed", getLocator()); + }else if(t.kind == LPARAN) + { + nesting++; + if(nesting > nest+1) + { + throw new CSSParseException("Only one ( ) pair per parameter allowed", getLocator()); } - }else if(t.kind == RPARAN)
{
nesting--; - if(nesting == 0)
{ + }else if(t.kind == RPARAN) + { + nesting--; + if(nesting == 0) + { return list; } - } else if(t.kind == COMMA)
{ - if(nesting == nest)
{ - return list;
}else
{ - list += ",";
} + } else if(t.kind == COMMA) + { + if(nesting == nest) + { + return list; + }else + { + list += ","; + } - }else if(t.kind == S)
{ - list += " ";
} else if(t.kind == LBRACE)
{ - throw new CSSParseException("Invalid token,'{' found", getLocator());
} -
getNextToken(); + }else if(t.kind == S) + { + list += " "; + } else if(t.kind == LBRACE) + { + throw new CSSParseException("Invalid token,'{' found", getLocator()); + } + + getNextToken(); } } @@ -2305,14 +2343,20 @@ LexicalUnitImpl term(LexicalUnitImpl prev) : } } -LexicalUnitImpl variableTerm(LexicalUnitImpl prev) :
{ +LexicalUnitImpl variableTerm(LexicalUnitImpl prev) : +{ LexicalUnitImpl result = null; - String varName = "";
}
{ + String varName = ""; +} +{ varName = variableName() {result = LexicalUnitImpl.createVariable(token.beginLine, token.beginColumn, - prev, varName); return result;}
} + prev, varName); return result;} +} -LexicalUnitImpl nonVariableTerm(LexicalUnitImpl prev) :
{
LexicalUnitImpl result = null; +LexicalUnitImpl nonVariableTerm(LexicalUnitImpl prev) : +{ +LexicalUnitImpl result = null; Token n = null; char op = ' '; String varName; @@ -2435,7 +2479,9 @@ LexicalUnitImpl nonVariableTerm(LexicalUnitImpl prev) :
{
LexicalUnitImpl result | result=unicode(prev) ) ) ( <S> )* { - return result;
}
} + return result; + } +} /** * Handle all CSS2 functions. |