mirror of
https://github.com/inexorabletash/jsbasic.git
synced 2025-01-04 16:32:07 +00:00
Use RegExp literals where possible
This commit is contained in:
parent
60d2025d4b
commit
73802c7eb7
26
basic.js
26
basic.js
@ -358,10 +358,10 @@ var basic = (function() {
|
|||||||
// the substring consumed.
|
// the substring consumed.
|
||||||
var parseDataInput = (function() {
|
var parseDataInput = (function() {
|
||||||
|
|
||||||
var regexWhitespace = new RegExp('^[ \\t]+'),
|
var regexWhitespace = /^[ \t]+/,
|
||||||
regexQuotedString = new RegExp('^"([^"]*?)"'),
|
regexQuotedString = /^"([^"]*?)"/,
|
||||||
regexUnquotedString = new RegExp('^([^:,\\r\\n]*)'),
|
regexUnquotedString = /^([^:,\r\n]*)/,
|
||||||
regexComma = new RegExp('^,');
|
regexComma = /^,/;
|
||||||
|
|
||||||
return function _parseDataInput(stream, items) {
|
return function _parseDataInput(stream, items) {
|
||||||
|
|
||||||
@ -1236,19 +1236,19 @@ var basic = (function() {
|
|||||||
RESERVED_WORDS.reverse();
|
RESERVED_WORDS.reverse();
|
||||||
|
|
||||||
var regexReservedWords = new RegExp("^(" + RESERVED_WORDS.map(munge).join("|") + ")", "i"),
|
var regexReservedWords = new RegExp("^(" + RESERVED_WORDS.map(munge).join("|") + ")", "i"),
|
||||||
regexIdentifier = new RegExp('^([A-Za-z][A-Za-z0-9]?)[A-Za-z0-9]*(\\$|%)?'),
|
regexIdentifier = /^([A-Za-z][A-Za-z0-9]?)[A-Za-z0-9]*(\$|%)?/,
|
||||||
regexStringLiteral = new RegExp('^"([^"]*?)(?:"|(?=\\n|\\r|$))'),
|
regexStringLiteral = /^"([^"]*?)(?:"|(?=\n|\r|$))/,
|
||||||
regexNumberLiteral = new RegExp('^([0-9]*\\.?[0-9]+(?:[eE]\\s*[\\-+]?\\s*[0-9]+)?)'),
|
regexNumberLiteral = /^([0-9]*\.?[0-9]+(?:[eE]\s*[\-+]?\s*[0-9]+)?)/,
|
||||||
regexOperator = new RegExp('^(;|<[ \t]*=|=[ \t]*<|>[ \t]*=|=[ \t]*>|=[ \t]*=|<[ \t]*>|>[ \t]*<|=|<|>|\\+|-|\\*|/|\\^|\\(|\\)|,)'),
|
regexOperator = /^(;|<[ \t]*=|=[ \t]*<|>[ \t]*=|=[ \t]*>|=[ \t]*=|<[ \t]*>|>[ \t]*<|=|<|>|\+|-|\*|\/|\^|\(|\)|,)/,
|
||||||
|
|
||||||
regexLineNumber = new RegExp('^([0-9]+)'),
|
regexLineNumber = /^([0-9]+)/,
|
||||||
regexSeparator = new RegExp('^(:)'),
|
regexSeparator = /^(:)/,
|
||||||
|
|
||||||
regexRemark = new RegExp('^(' + munge(kws.REM) + '([^\r\n]*))', 'i'),
|
regexRemark = new RegExp('^(' + munge(kws.REM) + '([^\r\n]*))', 'i'),
|
||||||
regexData = new RegExp('^(' + munge(kws.DATA) + ')', 'i'),
|
regexData = new RegExp('^(' + munge(kws.DATA) + ')', 'i'),
|
||||||
|
|
||||||
regexLinearWhitespace = new RegExp('^[ \t]+'),
|
regexLinearWhitespace = /^[ \t]+/,
|
||||||
regexNewline = new RegExp('^\r?\n');
|
regexNewline = /^\r?\n/;
|
||||||
|
|
||||||
// Token types:
|
// Token types:
|
||||||
// lineNumber - start of a new line
|
// lineNumber - start of a new line
|
||||||
@ -1383,7 +1383,7 @@ var basic = (function() {
|
|||||||
|
|
||||||
function quote(string) {
|
function quote(string) {
|
||||||
// From json2.js (http://www.json.org/js.html)
|
// From json2.js (http://www.json.org/js.html)
|
||||||
var escapable = new RegExp('[\\\\"\\x00-\\x1f\\x7f-\\x9f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]', 'g'),
|
var escapable = /[\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
|
||||||
meta = { // table of character substitutions
|
meta = { // table of character substitutions
|
||||||
'\b': '\\b',
|
'\b': '\\b',
|
||||||
'\t': '\\t',
|
'\t': '\\t',
|
||||||
|
@ -131,7 +131,7 @@ This is intended as a quick reference for the <a href="index.htm">Applesoft BASI
|
|||||||
<h3>Hi-Res Graphics</h3>
|
<h3>Hi-Res Graphics</h3>
|
||||||
<dl>
|
<dl>
|
||||||
<dt>HGR<dd>Set display to mixed/high resolution ("hires") graphics mode, clear screen to black
|
<dt>HGR<dd>Set display to mixed/high resolution ("hires") graphics mode, clear screen to black
|
||||||
<dt>HGR2<dd>Set display to full hires mode (page 2), clear screen
|
<dt>HGR2<dd>Set display to full hires mode (page 2), clear screen to black
|
||||||
<dt>HPLOT [TO] <var>expr</var>, <var>expr</var> [ TO <var>expr</var>, <var>expr</var> ] ... <dd>Plot hires point/line (x=0...279, y=0...191)
|
<dt>HPLOT [TO] <var>expr</var>, <var>expr</var> [ TO <var>expr</var>, <var>expr</var> ] ... <dd>Plot hires point/line (x=0...279, y=0...191)
|
||||||
<dt>HCOLOR= <var>expr</var><dd>Set hires color (0...7)
|
<dt>HCOLOR= <var>expr</var><dd>Set hires color (0...7)
|
||||||
</dl>
|
</dl>
|
||||||
|
Loading…
Reference in New Issue
Block a user