Browse Source

Implement parenthesis-handling fixes for Sass in Vaadin 7.1 (#12834)

These are the same changes that were done for the master-branch in
(#12833).

Change-Id: I397028c7b0ba06567adaad9f0f0095157f7ae8f9
Merge: no
tags/7.1.12
Mika Murtojarvi 10 years ago
parent
commit
b008768b93

+ 30
- 4
theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java View File

@@ -2667,7 +2667,7 @@ boolean isPseudoElement = false;
}
jj_consume_token(S);
}
d = skipStatementUntilRightParan();
d = skipStatementUntilMatchingRightParan();
jj_consume_token(RPARAN);
// accept anything between function and a right parenthesis
String f = convertIdent(n.image);
@@ -6202,9 +6202,35 @@ LexicalUnitImpl result = null;
return skipStatementUntil(lBrace);
}

String skipStatementUntilRightParan() throws ParseException {
int[] rParan = {RPARAN};
return skipStatementUntil(rParan);
String skipStatementUntilMatchingRightParan() throws ParseException {
int[] leftTokens = {LPARAN, FUNCTION}; // a FUNCTION also contains "("
int[] rightTokens = {RPARAN};
StringBuffer s = new StringBuffer();
int difference = 1;
Token tok;
while(difference != 0){
tok = getToken(1);
if(tok.kind == EOF) {
return null;
}
for(int sym : leftTokens){
if(tok.kind == sym){
difference++;
}
}
for(int sym : rightTokens){
if(tok.kind == sym){
difference--;
}
}
if(difference != 0){
if (tok.image != null) {
s.append(tok.image);
}
getNextToken();
}
}
return s.toString().trim();
}

String skipStatementUntil(int[] symbols) throws ParseException {

+ 30
- 4
theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj View File

@@ -1445,7 +1445,7 @@ boolean isPseudoElement = false;
}
}
}
| ( n=<FUNCTION> ( <S> )* d=skipStatementUntilRightParan() <RPARAN>
| ( n=<FUNCTION> ( <S> )* d=skipStatementUntilMatchingRightParan() <RPARAN>
{
// accept anything between function and a right parenthesis
String f = convertIdent(n.image);
@@ -2842,9 +2842,35 @@ String skipStatementUntilLeftBrace(){
}

JAVACODE
String skipStatementUntilRightParan(){
int[] rParan = {RPARAN};
return skipStatementUntil(rParan);
String skipStatementUntilMatchingRightParan(){
int[] leftTokens = {LPARAN, FUNCTION}; // a FUNCTION also contains "("
int[] rightTokens = {RPARAN};
StringBuffer s = new StringBuffer();
int difference = 1;
Token tok;
while(difference != 0){
tok = getToken(1);
if(tok.kind == EOF) {
return null;
}
for(int sym : leftTokens){
if(tok.kind == sym){
difference++;
}
}
for(int sym : rightTokens){
if(tok.kind == sym){
difference--;
}
}
if(difference != 0){
if (tok.image != null) {
s.append(tok.image);
}
getNextToken();
}
}
return s.toString().trim();
}

JAVACODE

+ 3
- 0
theme-compiler/tests/resources/w3ctests/scss/css3-modsel-67.0.scss View File

@@ -0,0 +1,3 @@
/* Source: http://www.w3.org/Style/CSS/Test/CSS3/Selectors/current/html/tests/css3-modsel-67.html */
div.stub * { background-color : red }
div.stub *:not(:lang(fr)) { background-color : green }

Loading…
Cancel
Save