Add lua parser

This commit is contained in:
Romain de Laage 2021-04-05 08:50:17 +02:00
parent 547d39d73b
commit 6fd1f6a46d
Signed by: rdelaage
GPG Key ID: 534845FADDF0C329
3 changed files with 42 additions and 0 deletions

8
lib/fengari-web.js Normal file

File diff suppressed because one or more lines are too long

1
lib/prism-lua.min.js vendored Normal file
View File

@ -0,0 +1 @@
Prism.languages.lua={comment:/^#!.+|--(?:\[(=*)\[[\s\S]*?\]\1\]|.*)/m,string:{pattern:/(["'])(?:(?!\1)[^\\\r\n]|\\z(?:\r\n|\s)|\\(?:\r\n|[^z]))*\1|\[(=*)\[[\s\S]*?\]\2\]/,greedy:!0},number:/\b0x[a-f\d]+(?:\.[a-f\d]*)?(?:p[+-]?\d+)?\b|\b\d+(?:\.\B|(?:\.\d*)?(?:e[+-]?\d+)?\b)|\B\.\d+(?:e[+-]?\d+)?\b/i,keyword:/\b(?:and|break|do|else|elseif|end|false|for|function|goto|if|in|local|nil|not|or|repeat|return|then|true|until|while)\b/,function:/(?!\d)\w+(?=\s*(?:[({]))/,operator:[/[-+*%^&|#]|\/\/?|<[<=]?|>[>=]?|[=~]=?/,{pattern:/(^|[^.])\.\.(?!\.)/,lookbehind:!0}],punctuation:/[\[\](){},;]|\.+|:+/};

33
lua.html Normal file
View File

@ -0,0 +1,33 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<title>Lua Playground</title>
<meta charset="utf-8" />
<script src="lib/codeflask.min.js"></script>
<script src="lib/prism-lua.min.js"></script>
<script src="lib/fengari-web.js"></script>
<link rel="stylesheet" href="assets/css/main.css" type="text/css" />
</head>
<body>
<header>
<h1>Lua Playground</h1>
</header>
<div id="container">
<div id="codeContainer"><div id="code"></div></div><!--
--><div id="console">
</div>
<input type="button" onclick="run()" value="Exécuter !" id="runBtn" />
</div>
<footer>
Romain de Laage - CC0
</footer>
<script src="assets/js/editor.js"></script>
<script>
const flask = getEditor("#code", "lua")
function run() {
fengari.load(flask.getCode())()
}
</script>
</body>
</html>