JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html>
<head>
<title>test</title>
</head>
<body>
<textarea id="script" rows="24" cols="80" style="font-family: Monaco, Consolas, 'Courier New', monospace; color: white; background: #333333;"></textarea>
<br />
<input id="result" type="text" disabled="disabled"></input>
<button id="submit">Test</button>
<script>
// 2012-03-02
// Syntax checker setup
// From "Top Down Operator Precedence" by Douglas Crockford
// <javascript.crockford.com/tdop/index.html>
// Make a new object that inherits members from an existing object.
if (typeof Object.create !== 'function') {
Object.create = function(o) {
function F() {}
F.prototype = o;
return new F();
};
}
// Transform a token object into an exception object and throw it.
Object.prototype.error = function(message, t) {
t = t || this;
t.name = "SyntaxError";
t.message = message;
console.log(t);
throw t;
};
// 2012-03-01
// GS tokenizer
// Based off of a similar code (c) 2006 by Douglas Crockford
// <http://javascript.crockford.com/tdop/tokens.js>
// Multi-character operators.
String.prototype.tokenize = function() {
var c; // Current character
var from; // Token starting index
var i = 0; // Current index
var line = 1; // Current line
var length = this.length;
var n; // Numerical value
var q; // Terminal quote
var str; // Token string value
var mco = ['xor', 'NL', 'TAB', 'SPC',
'in', ':=', '+=', '-=', '@=',
'*=', '/=', '%=', '^=', '<=',
'>=', '==', '!=', '<>', '=<',
'=>', '&=', '|=', '&&', '||',
'<<', '>>', '++', '--', '::',
'new'];
var result = []; // An array of the resultant tokens
var make = function(type, value) {
// Make a token object.
return {
type: type,
value: value,
from: from,
to: i,
line: line
...