summaryrefslogtreecommitdiff
path: root/src/llex.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2018-01-18 05:26:01 +1100
committerdaurnimator <quae@daurnimator.com>2018-01-18 07:07:55 +1100
commitd134ea20b0aa0d0c37664251656b3335a3d9bcfd (patch)
treec3be78f998359274bd90ca8dda8990a3baaebde5 /src/llex.js
parenta52a7105c5e858961217560dae47e7490bc0f2d7 (diff)
downloadfengari-d134ea20b0aa0d0c37664251656b3335a3d9bcfd.tar.gz
fengari-d134ea20b0aa0d0c37664251656b3335a3d9bcfd.tar.bz2
fengari-d134ea20b0aa0d0c37664251656b3335a3d9bcfd.zip
src/llex.js: Use lua_assert instead of assert
Diffstat (limited to 'src/llex.js')
-rw-r--r--src/llex.js17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/llex.js b/src/llex.js
index bd05aad..1e3f15b 100644
--- a/src/llex.js
+++ b/src/llex.js
@@ -1,8 +1,7 @@
"use strict";
-const assert = require('assert');
-
const defs = require('./defs.js');
+const { lua_assert } = require('./llimits.js');
const ldebug = require('./ldebug.js');
const ldo = require('./ldo.js');
const ljstype = require('./ljstype.js');
@@ -159,7 +158,7 @@ const luaX_newstring = function(ls, str) {
} else { /* string already present */
/* HACK: Workaround lack of ltable 'keyfromval' */
let tpair = ls.h.strong.get(lstring.luaS_hashlongstr(ts));
- assert(tpair.value == o);
+ lua_assert(tpair.value == o); /* fengari addition */
ts = tpair.key.tsvalue(); /* re-use value previously stored */
}
return ts;
@@ -171,7 +170,7 @@ const luaX_newstring = function(ls, str) {
*/
const inclinenumber = function(ls) {
let old = ls.current;
- assert(currIsNewline(ls));
+ lua_assert(currIsNewline(ls));
next(ls); /* skip '\n' or '\r' */
if (currIsNewline(ls) && ls.current !== old)
next(ls); /* skip '\n\r' or '\r\n' */
@@ -224,7 +223,7 @@ const check_next2 = function(ls, set) {
const read_numeral = function(ls, seminfo) {
let expo = "Ee";
let first = ls.current;
- assert(ljstype.lisdigit(ls.current));
+ lua_assert(ljstype.lisdigit(ls.current));
save_and_next(ls);
if (first === char['0'] && check_next2(ls, "xX")) /* hexadecimal? */
expo = "Pp";
@@ -248,7 +247,7 @@ const read_numeral = function(ls, seminfo) {
seminfo.i = obj.value;
return R.TK_INT;
} else {
- assert(obj.ttisfloat());
+ lua_assert(obj.ttisfloat());
seminfo.r = obj.value;
return R.TK_FLT;
}
@@ -284,7 +283,7 @@ const luaX_syntaxerror = function(ls, msg) {
const skip_sep = function(ls) {
let count = 0;
let s = ls.current;
- assert(s === char['['] || s === char[']']);
+ lua_assert(s === char['['] || s === char[']']);
save_and_next(ls);
while (ls.current === char['=']) {
save_and_next(ls);
@@ -469,7 +468,7 @@ const isreserved = function(w) {
const llex = function(ls, seminfo) {
lzio.luaZ_resetbuffer(ls.buff);
for (;;) {
- assert(typeof ls.current == "number");
+ lua_assert(typeof ls.current == "number"); /* fengari addition */
switch (ls.current) {
case char['\n']: case char['\r']: { /* line breaks */
inclinenumber(ls);
@@ -596,7 +595,7 @@ const luaX_next = function(ls) {
};
const luaX_lookahead = function(ls) {
- assert(ls.lookahead.token === R.TK_EOS);
+ lua_assert(ls.lookahead.token === R.TK_EOS);
ls.lookahead.token = llex(ls, ls.lookahead.seminfo);
return ls.lookahead.token;
};