Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The line in question is the <em>first part</em> of an alternative expression, for the <code>primary</code> rule -- it is tested only if <code>integer</code> does not match.</p> <p>This alternate expression starts after the <code>/</code> and includes the corresponding action block: <code>{ return comma; }</code></p> <p>Note that "comma" is being used in two distinct ways here -- both as a rule name and also as a label identifier. See <a href="http://pegjs.majda.cz/documentation#grammar-syntax-and-semantics-parsing-expression-types" rel="nofollow">PEG.js - Parsing Expression Types</a>:</p> <blockquote> <p><em><strong>label</em> : <em>expression</em></strong></p> <p>Match the expression and remember its match result under given label. The label must be a JavaScript identifier. ...</p> </blockquote> <p>So, <code>integer / "(" comma:comma ")"</code> first attempts to match <code>integer</code>; if that fails it then attempts to match the entire second expression.</p> <p>The label could be any valid JavaScript identifier. Please consider the following snippet, which is functionally-equivalent to your example:</p> <pre><code>primary = integer / "(" result:comma ")" { return result; } </code></pre> <p>If parenthesis are not relevant then you could omit the <em>entire second expression</em>, leaving just:</p> <pre><code>primary = integer </code></pre> <p>As another quick example of labeling, this would also work (but is redundant):</p> <pre><code>primary = anumber:integer { return anumber; } </code></pre>
    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.
    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