Note that there are some explanatory texts on larger screens.

plurals
  1. POCan explain what is necesariy the extra rule on this PEG
    primarykey
    data
    text
    <p>I'm playing with <a href="http://pegjs.majda.cz/" rel="nofollow">PEG.js</a> and reading and in the <a href="http://nathansuniversity.com/pegs6.html" rel="nofollow">Nathans University</a> i found a good "explain" how to build my own languaje but i'm stuck with this step</p> <p>i dont understand the <code>primary</code> can explain me please</p> <pre><code>start = comma comma = left: additive "," right:comma { return {tag: ",", left:left, right:right}; } / additive additive = left:multiplicative "+" right:additive { return {tag: "+", left:left, right:right}; } / multiplicative multiplicative = left:primary "*" right:multiplicative { return {tag: "*", left:left, right:right}; } / primary primary = integer / "(" comma:comma ")" # Can explain me why is necesary "(" and ")" { return comma; } integer = digits:[0-9]+ { return parseInt(digits.join(""), 10); } </code></pre> <h2>test</h2> <pre><code>var parse = wrapExceptions(PEG.buildParser(answer).parse); assert_eq(parse("1+2"), {tag:"+", left:1, right:2}, "parse 1+2"); assert_eq(parse("1+2*3"), {tag:"+", left:1, right:{tag:"*", left:2, right:3}}, "parse 1+2*3"); assert_eq(parse("1,2"), {tag:",", left:1, right:2}, "parse 1,2"); assert_eq(parse("1,2+3"), {tag:",", left:1, right:{tag:"+", left:2, right:3}}, "parse 1,2+3"); assert_eq(parse("1*2,3"), {tag:",", left:{tag:"*", left:1, right:2}, right:3}, "parse 1*2,3"); </code></pre> <p>my question is why is necesary the <code>/ "(" comma:comma ")"</code> if the entry does not have parenthesis, if remove that line the last test fails</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload