diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-07-24 20:11:04 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-07-24 20:11:14 -0700 |
| commit | e491a5838a45d083346a30ae457ebfe0d8dfe7c4 (patch) | |
| tree | 5a5f95e78879999c671eb3b8f0417951fc45266d /parser.lua | |
| parent | d7e297844c88022cf10ebeb14759a8df7dd539c4 (diff) | |
Fix for source being too long.
Diffstat (limited to 'parser.lua')
| -rw-r--r-- | parser.lua | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -144,6 +144,7 @@ do Parser.patterns[version] = re.compile(nomsu_peg, NOMSU_DEFS) end end +local _anon_chunk = 0 Parser.parse = function(nomsu_code, source, version) if source == nil then source = nil @@ -153,7 +154,10 @@ Parser.parse = function(nomsu_code, source, version) end source = source or nomsu_code.source nomsu_code = tostring(nomsu_code) - source = source or Source("string: " .. nomsu_code, 1, #nomsu_code) + if not (source) then + source = Source("anonymous chunk #" .. tostring(_anon_chunk), 1, #nomsu_code) + _anon_chunk = _anon_chunk + 1 + end version = version or nomsu_code:match("^#![^\n]*nomsu[ ]+-V[ ]*([0-9.]+)") local syntax_version = version and tonumber(version:match("^[0-9]+")) or Parser.version local userdata = { |
