Skip to content

Commit

Permalink
lib.xsd_regexp: implement unicode ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
eugeneia committed Jan 11, 2018
1 parent b6cc1a6 commit 5fd0198
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lib/xsd_regexp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
module(..., package.seeall)
local maxpc = require("lib.maxpc")
local match, capture, combine = maxpc.import()
local codepoint = maxpc.codepoint

-- Implementation of regular expressions (ASCII only) as defined in Appendix G
-- of "W3C XML Schema Definition Language (XSD) 1.1 Part 2: Datatypes", see:
Expand Down Expand Up @@ -435,9 +436,9 @@ function compile_group (group)
end

function compile_range (start, stop)
start, stop = start:byte(), stop:byte()
start, stop = codepoint(start), codepoint(stop)
local function in_range (s)
s = s:byte()
s = codepoint(s)
return start <= s and s <= stop
end
return match.satisfies(in_range)
Expand Down

0 comments on commit 5fd0198

Please sign in to comment.