- table.insert(res, next)
- end
- if next[1] == 10 then next = nil end
- return true, next
- end
-
- local function grab_hexa(next, res)
- local ok = false
- table.insert(res, next)
- while true do
- next = get_expd_next()
- if not ((next[1] == 12 and (0x30 <= next[2] and next[2] <= 0x39)) or
- ((next[1] == 12 or next[1] == 11) and
- (0x41 <= next[2] and next[2] <= 0x46))) then
- break
- end
- ok = true
- table.insert(res, next)
- end
- if next[1] == 10 then next = nil end
- return ok, next
- end
-
- local function grab_octal(next, res)
- local ok = false
- table.insert(res, next)
- while true do
- next = get_expd_next()
- if not (next[1] == 12 and (0x30 <= next[2] and next[2] <= 0x37)) then
- break
- end
- ok = true
- table.insert(res, next)
- end
- if next[1] == 10 then next = nil end
- return ok, next
- end
-
- local function grab_charnum(next, res)
- table.insert(res, next)
- next = token.get_next()
- table.insert(res, next)
- next = get_expd_next()
- if next[1] == 10 then next = nil end
- return true, next
- end
-
- local function scan_with(delay, scanner)
- local function proc()
- if delay ~= 0 then
- if delay > 0 then delay = delay - 1 end
- return token.get_next()
- else
- local cont, back = scanner()
- if not cont then
- ltb.remove_from_callback("token_filter", "ltj@grab@num")
- end
- return back
- end
- end
- ltb.add_to_callback("token_filter", proc, "ltj@grab@num", 1)
- end
-
- scan_brace = function ()
- scan_with(1, function()
- local next = token.get_next()
- if next[1] == 1 then
- return false, { tok_escape, next }
- elseif next[1] == 10 then
- return true, { next }
- else
- return false, { next }
- end
- end)
- end
-
- scan_number = function ()
- scan_with(1, function()
- local next = get_expd_next()
- local res, ok = { tok_num }, false
- while true do
- if next[1] == 12 and (next[2] == 0x2B or next[2] == 0x2D) then
- table.insert(res, next)
- elseif next[1] ~= 10 then
- break
- end
- next = get_expd_next()
- end
- if next[1] == 12 and 0x30 <= next[2] and next[2] <= 0x39 then
- ok, next = grab_decimal(next, res)
- elseif next[1] == 12 and next[2] == 0x22 then
- ok, next = grab_hexa(next, res)
- elseif next[1] == 12 and next[2] == 0x27 then
- ok, next = grab_octal(next, res)
- elseif next[1] == 12 and next[2] == 0x60 then
- ok, next = grab_charnum(next, res)
- elseif next[1] == c_id_assign_int or next[1] == c_id_char_given then
- table.insert(res, next)
- ok, next = true, nil
- end
- if ok then
- table.insert(res, tok_num)
- else
- error_scan()
- res = { tok_escape }
- end
- if next then table.insert(res, next) end
- return false, res
- end)
- end
-
-end
--------------------- TeX register allocation
-local const_number, count_number, attribute_number, dimen_number, skip_number
-
-do
- local cmod_base_count = token.create('ltj@@count@zero')[2]
- local cmod_base_attr = token.create('ltj@@attr@zero')[2]
- local cmod_base_dimen = token.create('ltj@@dimen@zero')[2]
- local cmod_base_skip = token.create('ltj@@skip@zero')[2]
-
- const_number = function (name)
- if name:sub(1, 1) == '\\' then name = name:sub(2) end
- return token.create(name)[2]
- end
-
- count_number = function (name)
- if name:sub(1, 1) == '\\' then name = name:sub(2) end
- return token.create(name)[2] - cmod_base_count
- end
-
- attribute_number = function (name)
- if name:sub(1, 1) == '\\' then name = name:sub(2) end
- return token.create(name)[2] - cmod_base_attr
- end
-
- dimen_number = function (name)
- if name:sub(1, 1) == '\\' then name = name:sub(2) end
- return token.create(name)[2] - cmod_base_dimen
- end
-
- skip_number = function (name)
- if name:sub(1, 1) == '\\' then name = name:sub(2) end
- return token.create(name)[2] - cmod_base_skip
- end
-
-end
--------------------- mock of debug logger
-
-if not debug or debug == _G.debug then
- local function no_op() end
- debug = no_op
- package_debug = no_op
- show_term = no_op
- show_log = no_op
- function debug_logger()
- return no_op
- end
-end
-
--------------------- getting next token
-local cstemp = nil
-local function get_cs(s)
- cstemp = token.csname_name(token.get_next())
- tex.sprint(cat_lp,'\\' .. s)