-export function matchRange(l : string, u : string) : (m: MatcheePair) => Maybe<MatcheePair> {
- let lCodepoint = charToCodepoint(l);
- let uCodepoint = charToCodepoint(u);
- if (l > u){
- throw new Error("Error: the codepoint of `"+l+"` is not smaller than `"+u+"`)");
- }
- return (m : MatcheePair)=>{
- if (m.remained.length < 1){
- return {_tag : "None"};
- }
- const charToBeMatched = m.remained[0];
- const codePointToBeMatched = charToCodepoint(charToBeMatched);
- if (codePointToBeMatched >= lCodepoint && codePointToBeMatched <= uCodepoint){
- return {_tag: "Some", value :{
- matched : m.matched + charToBeMatched,
- remained : m.remained.substring(1)}};
- }
- else{
- return {_tag: "None"};
- }
- }
-};
+const lexer = p.buildLexer([
+ [true, /^\d+(\.\d+)?/g, TokenKind.Number],
+ [true, /^\;/g, TokenKind.Semicolon],
+ [true, /^[-][-][-]/g, TokenKind.Seperator],
+ [true, /^[\+\-\*\/\&\|\!\^\<\>\~\=\?]+/g, TokenKind.Op],
+ [true, /^\@+/g, TokenKind.ExprMark],
+ [true, /^[()\[\]{}]/g, TokenKind.Paren],
+ [true, /^["]([\"]|[\\].)*["]/g, TokenKind.Str],
+ [true, /^[']([\']|[\\].)*[']/g, TokenKind.Str],
+ [true, /^[()\[\]{}]/g, TokenKind.Paren],
+ [true, /^[^\s\n\t\r;]+/g, TokenKind.Id],
+ [false, /^(\s|\n|\r|\t)+/g, TokenKind.SpaceNL]
+]);