hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit f90dd840ff569382052bbc5899a2256870b30903
parent ad84eab931d99e98b9c7492ba91f5429c0d1c72a
Author: Drew DeVault <sir@cmpwn.com>
Date:   Fri, 19 Feb 2021 14:18:22 -0500

hare::lex: lex keywords

Diffstat:
Mhare/lex/lex.ha | 13++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/hare/lex/lex.ha b/hare/lex/lex.ha @@ -2,6 +2,7 @@ use ascii; use encoding::utf8; use io; +use sort; use strings; // State associated with a lexer. @@ -118,7 +119,17 @@ fn lex_name(lex: *lexer, loc: location) ((token, location) | io::EOF | error) = }; let n = strings::from_utf8(chars); - return (n: name: token, loc); + return match (sort::search(bmap[..btoken::NAMED_LAST], + size(str), &n, &ncmp)) { + // TODO: Validate that names are ASCII + null => (n: name: token, loc), + v: *void => { + let tok = v: uintptr - &bmap[0]: uintptr; + tok /= size(str): uintptr; + (tok: btoken: token, loc); + }, + }; + }; fn lex2(