Skip to content

Commit

Permalink
yeye
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanThatOneKid committed Nov 12, 2021
1 parent 5156a6c commit 7e50e1b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 15 deletions.
34 changes: 19 additions & 15 deletions lib/tokenize/lexicon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,26 @@ export enum Lexicon {
Modifier,
TextWrapper,
Comment,
CommentOpener,
CommentCloser,
Unknown,
EOF,
}

export const LEXICON = {
[Lexicon.Identifier]: null,
[Lexicon.StructOpener]: "{",
[Lexicon.StructCloser]: "}",
[Lexicon.TupleOpener]: "(",
[Lexicon.TupleCloser]: ")",
[Lexicon.TypeDefiner]: ["type", "struct", "interface"],
[Lexicon.PropertyDefiner]: ":",
[Lexicon.PropertyOptionalMarker]: "?",
[Lexicon.Modifier]: ["%", "mod"],
[Lexicon.TextWrapper]: ['"', "'", "`"],
[Lexicon.Comment]: [";", "//"],
[Lexicon.Unknown]: null,
[Lexicon.EOF]: null,
} as const;
export const LEXICON = new Map<Lexicon, string | string[] | null>([
[Lexicon.Identifier, null],
[Lexicon.StructOpener, "{"],
[Lexicon.StructCloser, "}"],
[Lexicon.TupleOpener, "("],
[Lexicon.TupleCloser, ")"],
[Lexicon.TypeDefiner, ["type", "struct", "interface"]],
[Lexicon.PropertyDefiner, ":"],
[Lexicon.PropertyOptionalMarker, "?"],
[Lexicon.Modifier, ["%", "mod"]],
[Lexicon.TextWrapper, ['"', "'", "`"]],
[Lexicon.Comment, [";", "//"]],
[Lexicon.CommentOpener, "/*"],
[Lexicon.CommentCloser, "*/"],
[Lexicon.Unknown, null],
[Lexicon.EOF, null],
};
21 changes: 21 additions & 0 deletions lib/tokenize/token.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { LEXICON, Lexicon } from "./lexicon.ts";

export class Token {
public kind: Lexicon | null = null;
public line: number = -1;
public column: number = -1;

constructor(
private raw: string,
line: number,
column: number,
noCheck = false,
) {
this.line = line;
this.column = column;
this.kind = noCheck ? Lexicon.Identifier : Token.getKindOf(raw);
}

// https://github.com/EthanThatOneKid/fart/blob/c43f2333458b2cbc40d167610d87e2a2e3f89885/lib/tokenize/token.ts?_pjax=%23js-repo-pjax-container%2C%20div%5Bitemtype%3D%22http%3A%2F%2Fschema.org%2FSoftwareSourceCode%22%5D%20main%2C%20%5Bdata-pjax-container%5D#L48
static getKindOf(raw: string): Lexicon | null {}
}

1 comment on commit 7e50e1b

@deno-deploy
Copy link

@deno-deploy deno-deploy bot commented on 7e50e1b Nov 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failed to deploy:

failed to fetch 'https://raw.githubusercontent.com/EthanThatOneKid/fart/7e50e1b30226f50c2f2a1032772c87befcc9ccf4/std/server/worker.ts': HTTP status client error (404 Not Found) for url (https://raw.githubusercontent.com/EthanThatOneKid/fart/7e50e1b30226f50c2f2a1032772c87befcc9ccf4/std/server/worker.ts)

Please sign in to comment.