sasstools / scss-tokenizer

A tokenzier for Sass' SCSS syntax
MIT License
24 stars 22 forks source link

Curly bracket detected as endInterpolant #27

Open nisalikularatne opened 5 years ago

nisalikularatne commented 5 years ago

Hi,

When we tokenize the following example

@mixin bg-variant($parent,$color){
  a#{$parent},
  button#{$parent} {
  }
}

the output returned is

[ [ '@', '@', 1, 1 ],
  [ 'ident', 'mixin', 1, 2, 1, 6 ],
  [ 'space', ' ' ],
  [ 'ident', 'bg-variant', 1, 8, 1, 17 ],
  [ '(', '(', 1, 18 ],
  [ '$', '$', 1, 19 ],
  [ 'ident', 'parent', 1, 20, 1, 25 ],
  [ ',', ',', 1, 26 ],
  [ '$', '$', 1, 27 ],
  [ 'ident', 'color', 1, 28, 1, 32 ],
  [ ')', ')', 1, 33 ],
  [ '{', '{', 1, 34 ],
  [ 'newline', '\n', 2, 0 ],
  [ 'space', '  ' ],
  [ 'ident', 'a', 2, 3, 2, 3 ],
  [ 'startInterpolant', '#{', 2, 5 ],
  [ '$', '$', 2, 6 ],
  [ 'ident', 'parent', 2, 7, 2, 12 ],
  [ 'endInterpolant', '}', 2, 13 ],
  [ ',', ',', 2, 14 ],
  [ 'newline', '\n', 3, 0 ],
  [ 'space', '  ' ],
  [ 'ident', 'button', 3, 3, 3, 8 ],
  [ 'startInterpolant', '#{', 3, 10 ],
  [ '$', '$', 3, 11 ],
  [ 'ident', 'parent', 3, 12, 3, 17 ],
  [ 'endInterpolant', '}', 3, 18 ],
  [ 'space', ' ' ],
  [ '{', '{', 3, 20 ],
  [ 'newline', '\n', 4, 0 ],
  [ 'space', '  ' ],
  [ 'endInterpolant', '}', 4, 3 ],
  [ 'newline', '\n', 5, 0 ],
  [ '}', '}', 5, 1 ] ]

The tokenizer detects the second last curly bracket '}' as an endInterpolant token. Any idea on how it can be solved ?

Thank you

xzyfer commented 5 years ago

Sounds like a bug. I can take a look next week.

I'm curious to know what your use case for this library?

On Fri., 15 Feb. 2019, 12:33 pm Nisali Sanara Kularatne < notifications@github.com wrote:

Hi,

When we tokenize the following example

@mixin bg-variant($parent,$color){ a#{$parent}, button#{$parent} { } }

the output returned is

[ [ '@', '@', 1, 1 ], [ 'ident', 'mixin', 1, 2, 1, 6 ], [ 'space', ' ' ], [ 'ident', 'bg-variant', 1, 8, 1, 17 ], [ '(', '(', 1, 18 ], [ '$', '$', 1, 19 ], [ 'ident', 'parent', 1, 20, 1, 25 ], [ ',', ',', 1, 26 ], [ '$', '$', 1, 27 ], [ 'ident', 'color', 1, 28, 1, 32 ], [ ')', ')', 1, 33 ], [ '{', '{', 1, 34 ], [ 'newline', '\n', 2, 0 ], [ 'space', ' ' ], [ 'ident', 'a', 2, 3, 2, 3 ], [ 'startInterpolant', '#{', 2, 5 ], [ '$', '$', 2, 6 ], [ 'ident', 'parent', 2, 7, 2, 12 ], [ 'endInterpolant', '}', 2, 13 ], [ ',', ',', 2, 14 ], [ 'newline', '\n', 3, 0 ], [ 'space', ' ' ], [ 'ident', 'button', 3, 3, 3, 8 ], [ 'startInterpolant', '#{', 3, 10 ], [ '$', '$', 3, 11 ], [ 'ident', 'parent', 3, 12, 3, 17 ], [ 'endInterpolant', '}', 3, 18 ], [ 'space', ' ' ], [ '{', '{', 3, 20 ], [ 'newline', '\n', 4, 0 ], [ 'space', ' ' ], [ 'endInterpolant', '}', 4, 3 ], [ 'newline', '\n', 5, 0 ], [ '}', '}', 5, 1 ] ]

The tokenizer detects the send last curly bracket '}' as an endInterpolant token. Any idea on how it can be solved ?

Thank you

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sasstools/scss-tokenizer/issues/27, or mute the thread https://github.com/notifications/unsubscribe-auth/AAjZWJ_atVAcWzJ2UrLv6Fm3Zp4_E2F4ks5vNg6BgaJpZM4a8xC- .