From c6a107d54f20a57dff4b8e26b07d8eac15982c91 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 1 Jul 2017 17:36:17 -0400 Subject: - Lexers now carry an offset which they use to figure out where to extract parts of the whole input, instead of having to clip the input as they lex. thereby doing a lot of unnecessary text allocations. - Some refactoring. --- stdlib/test/test/lux/data/text/lexer.lux | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'stdlib/test') diff --git a/stdlib/test/test/lux/data/text/lexer.lux b/stdlib/test/test/lux/data/text/lexer.lux index 76eadfbb0..8752d4b96 100644 --- a/stdlib/test/test/lux/data/text/lexer.lux +++ b/stdlib/test/test/lux/data/text/lexer.lux @@ -94,9 +94,9 @@ (test "Can lex characters ranges." (and (should-passT "Y" (&;run "Y" - (&;char-range #"X" #"Z"))) + (&;range #"X" #"Z"))) (should-fail (&;run "M" - (&;char-range #"X" #"Z"))))) + (&;range #"X" #"Z"))))) (test "Can lex upper-case and &;lower-case letters." (and (should-passT "Y" (&;run "Y" @@ -111,23 +111,23 @@ (test "Can lex numbers." (and (should-passT "1" (&;run "1" - &;digit)) + &;decimal)) (should-fail (&;run " " - &;digit)) + &;decimal)) (should-passT "7" (&;run "7" - &;oct-digit)) + &;octal)) (should-fail (&;run "8" - &;oct-digit)) + &;octal)) (should-passT "1" (&;run "1" - &;hex-digit)) + &;hexadecimal)) (should-passT "a" (&;run "a" - &;hex-digit)) + &;hexadecimal)) (should-passT "A" (&;run "A" - &;hex-digit)) + &;hexadecimal)) (should-fail (&;run " " - &;hex-digit)) + &;hexadecimal)) )) (test "Can lex alphabetic characters." @@ -167,9 +167,9 @@ (test "Can create the opposite of a lexer." (and (should-passT "a" (&;run "a" - (&;not (p;alt &;digit &;upper)))) + (&;not (p;alt &;decimal &;upper)))) (should-fail (&;run "A" - (&;not (p;alt &;digit &;upper)))))) + (&;not (p;alt &;decimal &;upper)))))) (test "Can select from among a set of characters." (and (should-passT "C" (&;run "C" @@ -191,10 +191,10 @@ (test "Can apply a lexer multiple times." (and (should-passT "0123456789ABCDEF" (&;run "0123456789ABCDEF" - (&;many &;hex-digit))) + (&;many &;hexadecimal))) (should-fail (&;run "yolo" - (&;many &;hex-digit))) + (&;many &;hexadecimal))) (should-passT "" (&;run "" - (&;some &;hex-digit))))) + (&;some &;hexadecimal))))) )) -- cgit v1.2.3