Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"LeftCurlyBracket is expected" error when using parseSelector: false #56

davidkudera opened this issue Sep 10, 2017 · 4 comments


Copy link

@davidkudera davidkudera commented Sep 10, 2017

Hi, I wanted to parse some styles with parseSelector: false, but when I do that I see following error:

Parse error: LeftCurlyBracket is expected
    1 |div {}

Steps to reproduce:

$ mkdir css-test && cd css-test
$ npm install css-tree

Create index.js file with this code:

var parse = require('css-tree').parse;

try {
	var ast = parse('div {}', {
		parseSelector: false

} catch (e) {

and run

$ node index.js

Interesting is that when I clone this repository and try to write the code above as test, it works just fine.

Versions: both 1.0.0-alpha22 and 171664a.

Copy link

@peterbe peterbe commented Sep 10, 2017

I get this too

> const csstree = require('css-tree')
> const text = `body, p { font-weight: bold; }
... body { border: 1px solid red; }
... `
> const ast =csstree.parse(text, {parseValue: false, parseSelector: false})
CssSyntaxError: LeftCurlyBracket is expected

> csstree.parse(text.trim(), {parseValue: false, parseSelector: true})
{ type: 'StyleSheet',
  loc: null,
   List {
     cursor: null,
     head: { prev: null, next: [Object], data: [Object] },
     tail: { prev: [Object], next: null, data: [Object] } } }

@lahmatiy lahmatiy closed this in 97b4920 Sep 10, 2017
Copy link

@lahmatiy lahmatiy commented Sep 10, 2017

Your case let me to confirm a problem that I could not reproduce in the tests. It's a bit complicated and all around balance finding in tokenizer (can be reproduced only when token count less that input length; my test case was ? { } – input length equal to token count).
You could not reproduce the problem it in the tests because parser re-use tokenizer and last one re-use buffers. Therefore previous tests "fix" up your test by data left in the buffer.
Never mind... now it fixed, release is coming.
Good finding. Thank you!

Copy link

@davidkudera davidkudera commented Sep 10, 2017

awesome, thank you 👏

Copy link

@lahmatiy lahmatiy commented Sep 10, 2017

1.0.0-alpha23 with fix is out :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.