all repos — NoPaste @ 3e3c433f026c49e04d0efa0f0f39fc688ed32bb1

Resurrected - The PussTheCat.org fork of NoPaste

scripts/CodeMirror/mode/pegjs/index.html (view raw)

 1<!doctype html>
 2<html>
 3  <head>
 4    <title>CodeMirror: PEG.js Mode</title>
 5    <meta charset="utf-8"/>
 6    <link rel=stylesheet href="../../doc/docs.css">
 7
 8    <link rel="stylesheet" href="../../lib/codemirror.css">
 9    <script src="../../lib/codemirror.js"></script>
10    <script src="../javascript/javascript.js"></script>
11    <script src="pegjs.js"></script>
12    <style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
13  </head>
14  <body>
15    <div id=nav>
16      <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></a>
17
18      <ul>
19        <li><a href="../../index.html">Home</a>
20        <li><a href="../../doc/manual.html">Manual</a>
21        <li><a href="https://github.com/codemirror/codemirror">Code</a>
22      </ul>
23      <ul>
24        <li><a href="../index.html">Language modes</a>
25        <li><a class=active href="#">PEG.js Mode</a>
26      </ul>
27    </div>
28
29    <article>
30      <h2>PEG.js Mode</h2>
31      <form><textarea id="code" name="code">
32/*
33 * Classic example grammar, which recognizes simple arithmetic expressions like
34 * "2*(3+4)". The parser generated from this grammar then computes their value.
35 */
36
37start
38  = additive
39
40additive
41  = left:multiplicative "+" right:additive { return left + right; }
42  / multiplicative
43
44multiplicative
45  = left:primary "*" right:multiplicative { return left * right; }
46  / primary
47
48primary
49  = integer
50  / "(" additive:additive ")" { return additive; }
51
52integer "integer"
53  = digits:[0-9]+ { return parseInt(digits.join(""), 10); }
54
55letter = [a-z]+</textarea></form>
56      <script>
57        var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
58          mode: {name: "pegjs"},
59          lineNumbers: true
60        });
61      </script>
62      <h3>The PEG.js Mode</h3>
63      <p> Created by Forbes Lindesay.</p>
64    </article>
65  </body>
66</html>