Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix comments and add math constant names #36

Merged
merged 2 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,16 @@ export class Resolver implements StmtNS.Visitor<void>, ExprNS.Visitor<void> {
["None", new Token(TokenType.NAME, "None", 0, 0, 0)],
["NaN", new Token(TokenType.NAME, "NaN", 0, 0, 0)],
["Infinity", new Token(TokenType.NAME, "Infinity", 0, 0, 0)],


// math constants
["math_pi", new Token(TokenType.NAME, "math_pi", 0, 0, 0)],
["math_e", new Token(TokenType.NAME, "math_e", 0, 0, 0)],
["math_ln10", new Token(TokenType.NAME, "math_ln10", 0, 0, 0)],
["math_ln2", new Token(TokenType.NAME, "math_ln2", 0, 0, 0)],
["math_log10e", new Token(TokenType.NAME, "math_log10e", 0, 0, 0)],
["math_sqrt1_2", new Token(TokenType.NAME, "math_sqrt1_2", 0, 0, 0)],
["math_sqrt2", new Token(TokenType.NAME, "math_sqrt2", 0, 0, 0)],

// math library
["math_abs", new Token(TokenType.NAME, "math_abs", 0, 0, 0)],
["math_acos", new Token(TokenType.NAME, "math_acos", 0, 0, 0)],
Expand Down
6 changes: 6 additions & 0 deletions src/tokenizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,12 @@ export class Tokenizer {
// Consume the rest of the line's leading whitespace.
this.advance();
}
// Handles comments
if (this.peek() === "#") {
while ((this.peek() !== '\n' && this.peek() !== '\r') && !this.isAtEnd()) {
this.advance();
}
}
// The following block handles things like
/*
def foo():
Expand Down
Loading