123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <meta http-equiv="content-type" content="text/html; charset=UTF-8">
- </head>
- <body>
- <!--
- #
- # /*
- # * This program is free software: you can redistribute it and/or modify
- # * it under the terms of the GNU General Public License as published by
- # * the Free Software Foundation, either version 3 of the License, or
- # * (at your option) any later version.
- # *
- # * This program is distributed in the hope that it will be useful,
- # * but WITHOUT ANY WARRANTY; without even the implied warranty of
- # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # * GNU General Public License for more details.
- # *
- # * You should have received a copy of the GNU General Public License
- # * along with this program. If not, see <http://www.gnu.org/licenses/>.
- # *
- # * SPDX-License-Identifier: GPL-3.0+
- # * License-Filename: LICENSE
- # *
- # */
- #
- -->
- <script src="gmlpeg-parser.js"></script>
- <script>
- function checkgml() {
- var text = document.getElementById("textin").value;
- try {
- var g=gmlpeg.parse(text);
- strOut2 = "<b>Syntax oke</b>";
- } catch (err) {
- /* console.log(err.message); */
- /* console.log(err.location.start.line); */
- strOut2 = '<b>Syntax error at line ' + err.location.start.line + ' ' + err.message + '</b>';
- }
- var resultselement2 = document.getElementById("results2");
- resultselement2.innerHTML = strOut2;
- }
- </script><br>
- <b> check gml graph for syntax errors</b><br>
- <br>
- <form>
- <p> <textarea rows="20" cols="80" id="textin" wrap="off"># this is a comment line
- # colors in nodes/edges using 'fill'
- # background color of a node is set using `fill'
- # border color of a node is set using `outline'
- # edge line color is set using `fill'
- graph [
- directed 1
- node [ id 0 label "n0" graphics [ fill "#f00000" ] ]
- node [ id 1 label "n1" graphics [ outline "#ff0000" fill "#00ff00" ] ]
- node [ id 2 label "n2" graphics [ outline "#00ff00" fill "#f0ff00" ] ]
- node [ id 3 label "n3" graphics [ outline "#0000ff" fill "#f08000" ] ]
- node [ id 4 label "n4" graphics [ fill "#f0000f" ] ]
- node [ id 5 label "n5" graphics [ outline "#f0000f" fill "#ffffff" ] ]
- edge [ source 4 target 0 graphics [ fill "#f000ff" ] ]
- edge [ source 0 target 1 label "foo" graphics [ fill "#0f0ff0" ] ]
- edge [ source 1 target 2 graphics [ fill "#abf000" ] ]
- edge [ source 2 target 3 graphics [ fill "#f0f000" ] ]
- edge [ source 3 target 0 graphics [ fill "#f000f0" ] ]
- edge [ source 3 target 0 graphics [ fill "#ff000b" ] ]
- edge [ source 5 target 0 graphics [ fill "#ff000b" ] ]
- ]
- </textarea><br>
- <table>
- <tbody>
- <tr>
- <td><button onclick="checkgml()" type="button">Check GML
- Graph syntax</button></td>
- </tr>
- </tbody>
- </table>
- </p>
- <p> </p>
- <br>
- <div id="results2"> </div>
- <br>
- The syntax parser is a javascript parser made with pegjs at <a
- href="https://pegjs.org/">https://pegjs.org/</a><br>
- <br>
- This is the gml.pegjs gml grammar<br>
- <br>
- <br>
- file = _ head _ id _ list _<br>
- <br>
- head = (pair)*<br>
- <br>
- list = "[" _ some_items* _ "]" _<br>
- <br>
- some_items = id list2 / pair<br>
- <br>
- list2 = _ "[" _ some_items* _ "]" _<br>
- <br>
- pair = (id string) / (id id) / (id fpnum) / (id digit)<br>
- <br>
- digit = (("-"[0-9]+ _ ) / ("+"[0-9]+ _ ) / ([0-9]+ _ ))<br>
- <br>
- fpnum = (("-"[0-9]*["."][0-9]* _ ) / ("+"[0-9]*["."][0-9]* _ ) /
- ([0-9]*["."][0-9]* _ ))<br>
- <br>
- id = [a-zA-Z_]+[a-zA-Z_0-9]* _<br>
- <br>
- string = '"' char* '"' _<br>
- <br>
- char =<br>
- "\\" "\""<br>
- / "\\" "\\"<br>
- / "\\" "b"<br>
- / "\\" "f"<br>
- / "\\" "n"<br>
- / "\\" "r"<br>
- / "\\" "t"<br>
- / (!"\"" .)<br>
- <br>
- _ = (space
- / comment / endofline)*<br>
- <br>
- space = (" " / "\t" /
- endofline)<br>
- <br>
- comment = "#" (!endofline .)*<br>
- <br>
- endofline = ( "\r\n" / "\n" /
- "\r" / "\n\r" )<br>
- <br>
- <br>
- </form>
- </body>
- </html>
|