-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
parse PEG/BNF in pre_proces method as well fix nodejs loading
- Loading branch information
Nikos M
committed
Oct 30, 2015
1 parent
181f264
commit 7b7746a
Showing
9 changed files
with
264 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
|
||
<meta charset="utf-8"> | ||
|
||
<link rel="stylesheet" href="prism/themes/prism-coy.css" data-noprefix /> | ||
<link rel="stylesheet" href="prism/plugins/line-numbers/prism-line-numbers.css" data-noprefix /> | ||
<script src="prism/prefixfree.min.js"></script> | ||
<style type="text/css"> | ||
body { | ||
position: relative; | ||
} | ||
pre { | ||
max-height: 30em; | ||
overflow: auto; | ||
} | ||
pre > code.highlight { | ||
outline: .4em solid red; | ||
outline-offset: .4em; | ||
} | ||
code[class*="language"] { | ||
overflow: visible; | ||
} | ||
pre[class*="language"] { | ||
overflow: scroll; | ||
max-height: 50em; | ||
} | ||
</style> | ||
<script src="prism/prism.js" data-manual ></script> | ||
<script src="prism/plugins/line-numbers/prism-line-numbers.min.js"></script> | ||
<script src="../build/prism_grammar.js"></script> | ||
<script src="grammars/json.js"></script> | ||
<script src="./demo.js"></script> | ||
|
||
<title>Prism: Dynamic JSON Recursive Grammar Demo</title> | ||
</head> | ||
<body> | ||
|
||
<h3>Prism (v.<span id="editor-version">0</span>) Grammar (v.<span id="grammar-version">0</span>): Dynamic JSON Recursive Grammar</h3> | ||
|
||
|
||
<pre class="language-javascript line-numbers"><code id="code"> | ||
// 1. a complete json grammar in simple JSON format | ||
{ | ||
|
||
// prefix ID for regular expressions used in the grammar | ||
"RegExpID" : "RE::", | ||
|
||
"Extra" : { | ||
|
||
"fold" : "brace" | ||
|
||
}, | ||
|
||
// Style model | ||
"Style" : { | ||
|
||
"comment" : "comment" | ||
,"atom" : "entity" | ||
,"number" : "number" | ||
,"string" : "string" | ||
,"error" : "" | ||
|
||
}, | ||
|
||
// Lexical model | ||
"Lex" : { | ||
|
||
"comment:comment" : {"interleave":true,"tokens":[["//", null],["/*", "*/"]]} | ||
,"string:escaped-block" : ["\"", "\""] | ||
,"atom" : {"autocomplete":true,"tokens":["true","false","null"]} | ||
,"number" : [ | ||
// floats | ||
"RE::/\\d*\\.\\d+(e[\\+\\-]?\\d+)?/", | ||
"RE::/\\d+\\.\\d*/", | ||
"RE::/\\.\\d+/", | ||
// integers | ||
// hex | ||
"RE::/0x[0-9a-fA-F]+L?/", | ||
// binary | ||
"RE::/0b[01]+L?/", | ||
// octal | ||
"RE::/0o[0-7]+L?/", | ||
// decimal | ||
"RE::/[1-9]\\d*(e[\\+\\-]?\\d+)?L?/", | ||
// just zero | ||
"RE::/0(?![\\dx])/" | ||
] | ||
,"other" : "RE::/\\S+/" | ||
|
||
,"ctx:action" : {"context":true} | ||
,"\\ctx:action" : {"context":false} | ||
,"unique:action" : {"unique":["prop","$1"],"msg":"Duplicate object property \"$0\"","in-context":true} | ||
,"invalid_json:error" : "Invalid JSON" | ||
|
||
}, | ||
|
||
// Syntax model (optional) | ||
"Syntax" : { | ||
|
||
"literal_object" : "'{' ctx (literal_property_value (',' literal_property_value)*)? '}' \\ctx" | ||
,"literal_array" : "'[' (literal_value (',' literal_value)*)? ']'" | ||
// grammar recursion here | ||
,"literal_value" : "atom | string | number | literal_array | literal_object" | ||
,"literal_property_value" : "string unique ':' literal_value" | ||
,"json" : "literal_value | other.error invalid_json" | ||
|
||
}, | ||
|
||
// what to parse and in what order | ||
// allow comments in json ;) | ||
"Parser" : [ "comment", [ "json" ] ] | ||
|
||
} | ||
</code></pre> | ||
|
||
<p></p> | ||
|
||
<script> | ||
// <![CDATA[ | ||
prism_grammar_demo(document.getElementById('code'), "json", json_grammar); | ||
// ]]> | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.