comparison .cms/lib/codemirror/mode/pegjs/index.html @ 0:78edf6b517a0 draft

24.10
author Coffee CMS <info@coffee-cms.ru>
date Fri, 11 Oct 2024 22:40:23 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:78edf6b517a0
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/5"><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/codemirror5">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
37 start
38 = additive
39
40 additive
41 = left:multiplicative "+" right:additive { return left + right; }
42 / multiplicative
43
44 multiplicative
45 = left:primary "*" right:multiplicative { return left * right; }
46 / primary
47
48 primary
49 = integer
50 / "(" additive:additive ")" { return additive; }
51
52 integer "integer"
53 = digits:[0-9]+ { return parseInt(digits.join(""), 10); }
54
55 letter = [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>