Skip to content

Instantly share code, notes, and snippets.

@otac0n
Forked from chomwitt/test-pegjs-inline.html
Created December 19, 2012 17:02
Show Gist options
  • Save otac0n/4338312 to your computer and use it in GitHub Desktop.
Save otac0n/4338312 to your computer and use it in GitHub Desktop.
<!DOCTYPE HTML>
<html>
<head>
<title>WebTurtle/Parser tests</title>
<meta charset="utf-8">
<script language="javascript" SRC="js/peg-0.7.0.js"></script>
<script language="peg" id="grammar">
start = wt program wt
program = front / back
front = 'μπροστά' wt integer
back = 'πίσω' integer
integer = digits:[0-9]+ { return parseInt(digits.join(''), 10); }
wt = [ \t\r\n]*
</script>
</head>
<body>
<script>
var parser = PEG.buildParser(document.getElementById("grammar").innerText);
result = parser.parse("μπροστά 10");
document.write("<h1>Out with the old - in with the new!</h1>" );
document.write(result);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment