diff --git a/src/resolver.ts b/src/resolver.ts index 17758fe..7d56d2b 100644 --- a/src/resolver.ts +++ b/src/resolver.ts @@ -151,7 +151,16 @@ export class Resolver implements StmtNS.Visitor, ExprNS.Visitor { ["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)], diff --git a/src/tokenizer.ts b/src/tokenizer.ts index 3d69cfb..41f4bf8 100644 --- a/src/tokenizer.ts +++ b/src/tokenizer.ts @@ -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():