Adding spread operator. starting to build a stdlib. omg
This commit is contained in:
parent
216fe6bd30
commit
9edee10508
7 changed files with 102 additions and 14 deletions
19
src/lexer.ts
19
src/lexer.ts
|
|
@ -33,6 +33,7 @@ export type Token =
|
|||
| { kind: 'ampersand' }
|
||||
| { kind: 'underscore' }
|
||||
| { kind: 'dot' }
|
||||
| { kind: 'dot-dot-dot' }
|
||||
| { kind: 'at' }
|
||||
|
||||
// Anithmetic
|
||||
|
|
@ -148,7 +149,7 @@ export function tokenize(source: string): Token[] {
|
|||
|
||||
switch (char) {
|
||||
case '>': {
|
||||
if (source[i + 1] == '=') {
|
||||
if (source[i + 1] === '=') {
|
||||
tokens.push({ kind: 'greater-equals' });
|
||||
i++;
|
||||
} else {
|
||||
|
|
@ -157,7 +158,7 @@ export function tokenize(source: string): Token[] {
|
|||
break;
|
||||
}
|
||||
case '<': {
|
||||
if (source[i + 1] == '=') {
|
||||
if (source[i + 1] === '=') {
|
||||
tokens.push({ kind: 'less-equals' });
|
||||
i++;
|
||||
} else {
|
||||
|
|
@ -166,7 +167,7 @@ export function tokenize(source: string): Token[] {
|
|||
break;
|
||||
}
|
||||
case '=': {
|
||||
if (source[i + 1] == '=') {
|
||||
if (source[i + 1] === '=') {
|
||||
tokens.push({ kind: 'equals-equals' });
|
||||
i++;
|
||||
} else {
|
||||
|
|
@ -175,7 +176,7 @@ export function tokenize(source: string): Token[] {
|
|||
break;
|
||||
}
|
||||
case '!': {
|
||||
if (source[i + 1] == '=') {
|
||||
if (source[i + 1] === '=') {
|
||||
tokens.push({ kind: 'not-equals' });
|
||||
i++;
|
||||
} else {
|
||||
|
|
@ -183,6 +184,15 @@ export function tokenize(source: string): Token[] {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case '.': {
|
||||
if (source[i + 1] === '.' && source[i + 2] === '.') {
|
||||
tokens.push({ kind: 'dot-dot-dot' })
|
||||
i += 2;
|
||||
} else {
|
||||
tokens.push({ kind: 'dot' });
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ':': tokens.push({ kind: 'colon' }); break;
|
||||
case ';': tokens.push({ kind: 'semicolon' }); break;
|
||||
case '\\': tokens.push({ kind: 'backslash' }); break;
|
||||
|
|
@ -190,7 +200,6 @@ export function tokenize(source: string): Token[] {
|
|||
case '|': tokens.push({ kind: 'pipe' }); break;
|
||||
case ',': tokens.push({ kind: 'comma' }); break;
|
||||
case '&': tokens.push({ kind: 'ampersand' }); break;
|
||||
case '.': tokens.push({ kind: 'dot' }); break;
|
||||
case '@': tokens.push({ kind: 'at' }); break;
|
||||
|
||||
// Arithmetic
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue