Re: [jison] Issues with CSS Grammar
- From:
- Zachary Carter
- Date:
- 2011-03-05 @ 03:04
The syntax they use for that grammar is "optimized for human
consumption and some shorthand notation beyond Yacc," so you won't be
able to use it directly.
On Thu, Mar 3, 2011 at 9:41 PM, Peter Wagenet <peter.wagenet@gmail.com> wrote:
> I'm trying to convert the CSS grammar defined
> here http://www.w3.org/TR/CSS2/grammar.html
> into JISON and I've been running into the following issues:
> 1. %option case-insensitive isn't recognized, not a big deal. I can remove
> it.
Interesting. I'll see about implementing that option.
> 2. Issues with single quotes in definitions:
>
> string2 \'([^\n\r\f\\']|\\{nl}|{escape})*\'
>
> The above code fails to parse and causes errors on subsequent lines.
Philippe is correct here. Surround them with double quotes.
> 3. When I attempt to correct by wrapping in double quotes (which may be
> incorrect). I get errors r elating to:
>
> simple_selector
> : element_name [ HASH | class | attrib | pseudo ]*
> | [ HASH | class | attrib | pseudo ]+
> ;
>
> If I change this section to:
>
> simple_selector
> : element_name [ HASH ]*
> | [ HASH | class | attrib | pseudo ]+
> ;
>
> Then it works, but obviously this has changed the behavior.
> Is there anything obviously wrong with what I'm doing. Am I trying to do
> things that aren't supported?
The regex-like syntax is not supported. You can use separate rules
though; something like this:
simple_selector
: element_name simple_selector_parts
| element_name
| simple_selector_parts
;
simple_selector_parts
: simple_selector_parts simple_selector_part
| simple_selector_part
;
simple_selector_part
: HASH | class | attrib | pseudo
;
More info on Bison style grammar syntax:
http://dinosaur.compilertools.net/bison/bison_6.html#SEC41
> Let me know if more precise error messages would help.
> Thanks,
> Peter
--
Zach Carter
Re: [jison] Issues with CSS Grammar
- From:
- Philippe Rathe
- Date:
- 2011-03-04 @ 03:03
Hello,
for the single quote, maybe try putting it between double quotes without
backslash: "'"
On 2011-03-03, at 9:41 PM, Peter Wagenet wrote:
> I'm trying to convert the CSS grammar defined here
http://www.w3.org/TR/CSS2/grammar.html
> into JISON and I've been running into the following issues:
>
> 1. %option case-insensitive isn't recognized, not a big deal. I can remove it.
>
> 2. Issues with single quotes
> in definitions:
>
>> string2 \'([^\n\r\f\\']|\\{nl}|{escape})*\'
>>>
>>
>
> The above code fails to parse and causes errors on subsequent lines.
>
> 3. When I attempt to correct by wrapping in double quotes (which may be
incorrect). I get errors r elating to:
>> simple_selector
>> : element_name [ HASH | class | attrib | pseudo ]*
>> | [ HASH | class | attrib | pseudo ]+
>> ;
> If I change this section to:
>> simple_selector
>> : element_name [ HASH ]*
>> | [ HASH | class | attrib | pseudo ]+
>> ;
>
> Then it works, but obviously this has changed the behavior.
>
> Is there anything obviously wrong with what I'm doing. Am I trying to do
things that aren't supported?
> Let me know if more precise error messages would help.
>
> Thanks,
> Peter