[heycam/webidl] Check Grammar bison format? (#591)

https://github.com/heycam/webidl/blob/c2f8e96836ce6fa1638320240002162ab013f658/check-grammar.js#L12


Hi @tobie
Digging this up from the vaults but wondering.  This seems to produce rules with one colon on the first line of the rule, and one leading the second line.  The bison format seems to expect only one.
I get this result with this version,  adding a colon to the first regex term and the second test predicate:

function processRules(rules) {
    const REGEXP = /(\s*::\n\s*)|\b(integer|float|identifier|string|whitespace|comment|other)\b|(\s*\n\s*)|(ε)/g;
    return rules.map(rule => {
        return rule.trim().replace(REGEXP, m => {
            if (/^(integer|float|identifier|string|whitespace|comment|other)$/.test(m)) {
              return m.toUpperCase();
            }
            if (/::\n/.test(m)) { return "\n  : "; }
            if (/\n/.test(m)) { return "\n  | "; }
            if (/ε/.test(m)) { return "/* epsilon */"; }
        }) + "\n  ;";
    });
}

HTH!
Alex

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/issues/591

Received on Tuesday, 4 December 2018 05:37:19 UTC