This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 233038 - SASS parser issues
Summary: SASS parser issues
Status: RESOLVED DUPLICATE of bug 238988
Alias: None
Product: web
Classification: Unclassified
Component: CSS Preprocessors (SASS, LESS, ...) (show other bugs)
Version: 7.4
Hardware: PC Linux
: P3 normal with 5 votes (vote)
Assignee: Milutin Kristofic
URL:
Keywords:
: 233051 233216 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-07-19 07:28 UTC by Vladimir Riha
Modified: 2015-04-17 10:42 UTC (History)
7 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Unexpected token RPAREN found (148.35 KB, image/jpeg)
2013-10-12 10:01 UTC, PavelCibulka
Details
Unexpected token HASH_SYMBOL found (126.09 KB, image/jpeg)
2013-10-12 10:02 UTC, PavelCibulka
Details
Unexpected token LESS_AND found (59.61 KB, image/jpeg)
2013-10-12 10:03 UTC, PavelCibulka
Details
Unexpected token COMMA found (88.91 KB, image/jpeg)
2013-10-12 10:05 UTC, PavelCibulka
Details
Variable interpolation with ID hash (42.95 KB, image/png)
2013-12-10 14:39 UTC, cautionbug
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Riha 2013-07-19 07:28:07 UTC
Please try this in sass file:

@function composeURL($a, $b)
{
    @return url($a + $b);
}

=> line with url(..) is underlined, with unexpected token ERROR, SEMI and RPAREN. If I remove white spaces to

@function composeURL($a, $b)
{
    @return url($a+$b);
}

then error is gone but it is not recognized as variables (different color of $a and $b in braces, mark occurrences does not work



Product Version: NetBeans IDE Dev (Build web-main-11111-on-20130719)
Java: 1.7.0_40-ea; Java HotSpot(TM) Client VM 24.0-b52
Runtime: Java(TM) SE Runtime Environment 1.7.0_40-ea-b33
System: Linux version 3.2.0-48-generic-pae running on i386; UTF-8; en_US (nb)
Comment 1 Vladimir Riha 2013-07-19 07:32:27 UTC
Marku I didn't realize this is another "Sass parser error", I have one more case with false error. Should I reopen the original issue
Comment 2 Vladimir Riha 2013-07-19 07:35:58 UTC
Please ignore comment #1, I've submitted by accident.


#2 Formula inside media query

@media only tv and (resolution: 120 * 3 + "dpi"){

}

=> unexpected token star and number
Comment 3 Marek Fukala 2013-07-19 09:24:05 UTC
(In reply to comment #1)
> Marku I didn't realize this is another "Sass parser error", I have one more
> case with false error. Should I reopen the original issue
Keep the current state. Use this one for possible upcoming parsing issues. Thanks.
Comment 4 Marek Fukala 2013-07-19 09:33:55 UTC
changeset:   258935:f66878b45532
summary:     #233038#c2 - CP expression in media query
Comment 5 Marek Fukala 2013-07-19 14:10:20 UTC
I'm afraid comment#0 ("url($a + $b)" issue) is very tricky to fix.

Normally the CSS grammar creates an URI token for the content of the parens: uri(alink). 

In the described case the content of the parens does not conform the set of allowed chars inside the URI.  

However as the lexer already started to consume the input an error token is created for the whole expressin instead of creating IDENT(url), LPAREN('('), SASS_VAR($a), ...

I tried to remove the URI token completely and replace it by 'uri' parser rule, but then I run into problems in the grammar when the content of the uri is a generic non-quoted URL (like: http://nazdar.org/soubor.txt) in such case it looks like I'd have to introduce a complete grammar for the URI content or create some custom parser which handles this.

Opposite approach - extend the URI token to contain anything doesn't work well either. I may rewrite the rule to:

URI: 'url(' ~')'* ')'; 

but this will work only for the case where the content doesn't contain the rparen, like url(add($a,$b)). 

Moreover such solution wouldn't make the SASS features work inside the URI, it would just relax the errors.

So ...  spent almost whole day on that and still have nothing reliable :-) 

As the issue doesn't seem to be very common, I'll either live with that for 7.4 or if I had some more time I'd create the custom parser (predicate) for the URI rule as mentioned above.
Comment 6 Vladimir Riha 2013-07-19 14:23:13 UTC
Thank you for evaluation. I can't comment on how common it is as I really don't know. I've seen it once.
Comment 7 Quality Engineering 2013-07-23 02:39:11 UTC
Integrated into 'main-silver', will be available in build *201307222300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/f66878b45532
User: Marek Fukala <mfukala@netbeans.org>
Log: #233038#c2 - CP expression in media query
Comment 8 Vladimir Riha 2013-07-23 06:25:54 UTC
*** Bug 233216 has been marked as a duplicate of this bug. ***
Comment 9 Vladimir Riha 2013-07-23 06:27:12 UTC
To be thorough, another instance of #1:

$path: '/test/';
div{
    background: url($path+'nic');
}
Comment 10 Petr Jiricka 2013-07-26 13:21:49 UTC
Next: "Unexpected token LBRACE found" after 'before'

#3: 
@mixin m ( $selector, $hiResIcon)
{

    @media only screen and (min-resolution: 1000) {

      #{$selector}:before {
        content: $hiResIcon;
      }
    }
}
Comment 11 Marek Fukala 2013-08-01 09:27:02 UTC
fixed Petr's case (#3):

changeset:   259995:616739c71f65
summary:     #233038#c10 - fixed parsing of selector w/ interpolation expression in media body
Comment 12 Quality Engineering 2013-08-02 02:33:39 UTC
Integrated into 'main-silver', will be available in build *201308012300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/616739c71f65
User: Marek Fukala <mfukala@netbeans.org>
Log: #233038#c10 - fixed parsing of selector w/ interpolation expression in media body
Comment 13 Marek Fukala 2013-08-21 11:07:36 UTC
#4 -- the parent reference in selector:

@mixin block() {
    @if $var {
        &>li {
            width: 100%/$var;
            &:nth-of-type(#{var}n+1) { clear: both }
        }
    }
}
Comment 14 Marek Fukala 2013-08-26 11:31:00 UTC
*** Bug 233051 has been marked as a duplicate of this bug. ***
Comment 15 PavelCibulka 2013-10-12 10:01:23 UTC
Created attachment 141026 [details]
Unexpected token RPAREN found
Comment 16 PavelCibulka 2013-10-12 10:02:47 UTC
Created attachment 141027 [details]
Unexpected token HASH_SYMBOL found
Comment 17 PavelCibulka 2013-10-12 10:03:41 UTC
Created attachment 141028 [details]
Unexpected token LESS_AND found
Comment 18 PavelCibulka 2013-10-12 10:05:51 UTC
Created attachment 141029 [details]
Unexpected token COMMA found
Comment 19 PavelCibulka 2013-10-12 10:07:44 UTC
This four are from Bourbone mixin library (http://bourbon.io/). Reproduced on 7.4 RC2 and 201310120001.
Comment 20 hon2a 2013-11-18 15:02:10 UTC
For me the parser breaks on:

&:nth-child(#{$step + 'n+' + $start}) {
	border-left-style: dotted;
}

with multiple reported errors, among many other things.

---

Side note: I downloaded and installed NetBeans 7.4 just for the native SASS support and I've been forced to go back to http://plugins.netbeans.org/plugin/34929/ plugin to have the files highlighted. Furthermore, even with the plugin the .scss file icons in 'Projects' have those "parser errors" exclamation marks, which I have no idea how to get rid of. It'd seem adequate to remove SASS support from declared "new features" in 7.4 until these issues are fixed.
Comment 21 cautionbug 2013-12-10 14:39:50 UTC
Created attachment 143014 [details]
Variable interpolation with ID hash

Further variable interpolation problems.

Hope to see an update for this soon. Can't use Netbeans for my newer projects without this. Agree with comment 20 that S[A/C]SS support should be dropped from feature list until fix is implemented. Especially given all these perfectly legal structures that are making the parser puke.
Comment 22 Sladex 2014-02-13 07:52:59 UTC
Have the same issue.

background-image: url(../images/icons/#{$name}.svg);
Unexpected token COLON found.
Comment 23 Brewal 2014-11-04 09:40:17 UTC
Exact same problem of comment #20 under NetBeans 8.0.1

    &:nth-child(#{$nbMenuTab / 2}) {
        border-right: none;
    }

 > Unexpected token LESS_AND found
Comment 24 Milutin Kristofic 2015-04-17 10:42:20 UTC
The only one unresolved issue from this is url($a + $b)

*** This bug has been marked as a duplicate of bug 238988 ***