first commit
This commit is contained in:
73
js/codemirror-5.54.0/mode/wast/index.html
Normal file
73
js/codemirror-5.54.0/mode/wast/index.html
Normal file
@@ -0,0 +1,73 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<title>CodeMirror: Rust mode</title>
|
||||
<meta charset="utf-8" />
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/mode/simple.js"></script>
|
||||
<script src="wast.js"></script>
|
||||
<style>
|
||||
.CodeMirror {
|
||||
border-top: 1px solid black;
|
||||
border-bottom: 1px solid black;
|
||||
}
|
||||
</style>
|
||||
<div id=nav>
|
||||
<a href="https://codemirror.net">
|
||||
<h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt="">
|
||||
</a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">WebAssembly</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>WebAssembly mode</h2>
|
||||
|
||||
|
||||
<div><textarea id="code" name="code">
|
||||
/* Example WebAssembly */
|
||||
(module $foo
|
||||
(export "fac" (func $fac))
|
||||
(export "plus" (func $plus))
|
||||
|
||||
(func $fac (type $t0) (param $p0 i64) (result i64)
|
||||
(if $I0 (result i64)
|
||||
(i64.lt_s
|
||||
(local.get $p0)
|
||||
(i64.const 1))
|
||||
(then
|
||||
(i64.const 1))
|
||||
(else
|
||||
(i64.mul
|
||||
(local.get $p0)
|
||||
(call $fac
|
||||
(i64.sub
|
||||
(local.get $p0)
|
||||
(i64.const 1)))))))
|
||||
|
||||
(func $plus (param $x i32) (param $y i32) (result i32)
|
||||
(i32.add
|
||||
(local.get $x)
|
||||
(local.get $y))))</textarea></div>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
lineWrapping: true,
|
||||
indentUnit: 4,
|
||||
mode: "wast"
|
||||
});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/webassembly</code>.</p>
|
||||
</article>
|
||||
35
js/codemirror-5.54.0/mode/wast/test.js
Normal file
35
js/codemirror-5.54.0/mode/wast/test.js
Normal file
@@ -0,0 +1,35 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
||||
|
||||
(function() {
|
||||
var mode = CodeMirror.getMode({indentUnit: 4}, "wast");
|
||||
function MT(name) {test.mode(name, mode, Array.prototype.slice.call(arguments, 1));}
|
||||
|
||||
MT('number-test',
|
||||
'[number 0]',
|
||||
'[number 123]',
|
||||
'[number nan]',
|
||||
'[number inf]',
|
||||
'[number infinity]',
|
||||
'[number 0.1]',
|
||||
'[number 123.0]',
|
||||
'[number 12E+99]');
|
||||
|
||||
MT('string-literals-test',
|
||||
'[string "foo"]',
|
||||
'[string "\\"foo\\""]',
|
||||
'[string "foo #\\"# bar"]');
|
||||
|
||||
MT('atom-test',
|
||||
'[atom i32]',
|
||||
'[atom i64]',
|
||||
'[atom f32]',
|
||||
'[atom f64]');
|
||||
|
||||
MT('keyword-test',
|
||||
'[keyword br]',
|
||||
'[keyword if]',
|
||||
'[keyword loop]',
|
||||
'[keyword i32.add]',
|
||||
'[keyword local.get]')
|
||||
})();
|
||||
41
js/codemirror-5.54.0/mode/wast/wast.js
Normal file
41
js/codemirror-5.54.0/mode/wast/wast.js
Normal file
@@ -0,0 +1,41 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"), require("../../addon/mode/simple"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror", "../../addon/mode/simple"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineSimpleMode('wast', {
|
||||
start: [
|
||||
{regex: /[+\-]?(?:nan(?::0x[0-9a-fA-F]+)?|infinity|inf|0x[0-9a-fA-F]+\.?[0-9a-fA-F]*p[+\/-]?\d+|\d+(?:\.\d*)?[eE][+\-]?\d*|\d+\.\d*|0x[0-9a-fA-F]+|\d+)/, token: "number"},
|
||||
{regex: /anyfunc|mut|nop|block|if|then|else|loop|br|br_if|br_table|call|call_indirect|drop|end|return|local\.get|local\.set|tee_local|global\.get|global\.set|i32\.load|i64\.load|f32\.load|f64\.load|i32\.store|i64\.store|f32\.store|f64\.store|i32\.load8_s|i64\.load8_s|i32\.load8_u|i64\.load8_u|i32\.load16_s|i64\.load16_s|i32\.load16_u|i64\.load16_u|i64\.load32_s|i64\.load32_u|i32\.store8|i64\.store8|i32\.store16|i64\.store16|i32\.const|i64\.const|f32\.const|f64\.const|i32\.eqz|i64\.eqz|i32\.clz|i64\.clz|i32\.ctz|i64\.ctz|i32\.popcnt|i64\.popcnt|f32\.neg|f64\.neg|f32\.abs|f64\.abs|f32\.sqrt|f64\.sqrt|f32\.ceil|f64\.ceil|f32\.floor|f64\.floor|f32\.trunc|f64\.trunc|f32\.nearest|f64\.nearest|i32\.add|i64\.add|i32\.sub|i64\.sub|i32\.mul|i64\.mul|i32\.div_s|i64\.div_s|i32\.div_u|i64\.div_u|i32\.rem_s|i64\.rem_s|i32\.rem_u|i64\.rem_u|i32\.and|i64\.and|i32\.or|i64\.or|i32\.xor|i64\.xor|i32\.shl|i64\.shl|i32\.shr_s|i64\.shr_s|i32\.shr_u|i64\.shr_u|i32\.rotl|i64\.rotl|i32\.rotr|i64\.rotr|f32\.add|f64\.add|f32\.sub|f64\.sub|f32\.mul|f64\.mul|f32\.div|f64\.div|f32\.min|f64\.min|f32\.max|f64\.max|f32\.copysign|f64\.copysign|i32\.eq|i64\.eq|i32\.ne|i64\.ne|i32\.lt_s|i64\.lt_s|i32\.lt_u|i64\.lt_u|i32\.le_s|i64\.le_s|i32\.le_u|i64\.le_u|i32\.gt_s|i64\.gt_s|i32\.gt_u|i64\.gt_u|i32\.ge_s|i64\.ge_s|i32\.ge_u|i64\.ge_u|f32\.eq|f64\.eq|f32\.ne|f64\.ne|f32\.lt|f64\.lt|f32\.le|f64\.le|f32\.gt|f64\.gt|f32\.ge|f64\.ge|i64\.extend_s\/i32|i64\.extend_u\/i32|i32\.wrap\/i64|i32\.trunc_s\/f32|i64\.trunc_s\/f32|i32\.trunc_s\/f64|i64\.trunc_s\/f64|i32\.trunc_u\/f32|i64\.trunc_u\/f32|i32\.trunc_u\/f64|i64\.trunc_u\/f64|f32\.convert_s\/i32|f64\.convert_s\/i32|f32\.convert_s\/i64|f64\.convert_s\/i64|f32\.convert_u\/i32|f64\.convert_u\/i32|f32\.convert_u\/i64|f64\.convert_u\/i64|f64\.promote\/f32|f32\.demote\/f64|f32\.reinterpret\/i32|i32\.reinterpret\/f32|f64\.reinterpret\/i64|i64\.reinterpret\/f64|select|unreachable|current_memory|memory.size|grow_memory|memory.grow|type|func|param|result|local|global|module|table|memory|start|elem|data|offset|import|export/, token: "keyword"},
|
||||
{regex: /\b(i32|i64|f32|f64)\b/, token: "atom"},
|
||||
{regex: /\$([a-zA-Z0-9_`\+\-\*\/\\\^~=<>!\?@#$%&|:\.]+)/, token: "variable-2"},
|
||||
{regex: /"(?:[^"\\\x00-\x1f\x7f]|\\[nt\\'"]|\\[0-9a-fA-F][0-9a-fA-F])*"/, token: "string"},
|
||||
{regex: /\(;.*?/, token: "comment", next: "comment"},
|
||||
{regex: /;;.*$/, token: "comment"},
|
||||
{regex: /\(/, indent: true},
|
||||
{regex: /\)/, dedent: true},
|
||||
],
|
||||
|
||||
comment: [
|
||||
{regex: /.*?;\)/, token: "comment", next: "start"},
|
||||
{regex: /.*/, token: "comment"},
|
||||
],
|
||||
|
||||
meta: {
|
||||
dontIndentStates: ['comment'],
|
||||
},
|
||||
});
|
||||
|
||||
// https://github.com/WebAssembly/design/issues/981 mentions text/webassembly,
|
||||
// which seems like a reasonable choice, although it's not standard right now.
|
||||
CodeMirror.defineMIME("text/webassembly", "wast");
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user