From 7460d5c29b8f3e49e9ac18f49f8207a0bea051f5 Mon Sep 17 00:00:00 2001 From: Evin Sellin Date: Mon, 14 Jan 2019 19:27:31 -0800 Subject: [PATCH] add a lot of new characters, idk exactly why --- src/lib/lambda/lexer.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lib/lambda/lexer.ts b/src/lib/lambda/lexer.ts index c60b3a9..14682a1 100644 --- a/src/lib/lambda/lexer.ts +++ b/src/lib/lambda/lexer.ts @@ -1,5 +1,9 @@ import { LambdaToken } from './types'; +// idk i'm just guessing here. If you want something, just add it and i'll probs approve it +const validSingleChars = /[a-zα-κμ-ω+\!\-\|\&]/; +const validMultiChars = /[A-Z_]/; + function tokenize(str: string) : LambdaToken[] { let tokenStream : LambdaToken[] = []; for(let pos = 0; pos < str.length; pos++){ @@ -22,7 +26,7 @@ function tokenize(str: string) : LambdaToken[] { tokenStream.push({ type: 'closeParen', }); - } else if(/[a-z]/.test(nextChar)){ + } else if(validSingleChars.test(nextChar)){ // scan ahead to read the whole identifier let name = nextChar; while(/[₀-₉]/.test(str[pos + 1])){ @@ -33,9 +37,9 @@ function tokenize(str: string) : LambdaToken[] { type: 'identifier', value: name, }); - } else if(/[A-Z]/.test(nextChar)) { + } else if(validMultiChars.test(nextChar)) { let name = nextChar; - while(/[A-Z]/.test(str[pos + 1])) { + while(validMultiChars.test(str[pos + 1])) { pos++; name += str[pos]; }