Skip to content

Commit

Permalink
fix(syntax): Removed token for keywords we don't use
Browse files Browse the repository at this point in the history
  • Loading branch information
giann committed May 16, 2024
1 parent d85ebb2 commit f814a45
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
21 changes: 12 additions & 9 deletions src/Parser.zig
Original file line number Diff line number Diff line change
Expand Up @@ -433,10 +433,8 @@ const rules = [_]ParseRule{
.{ .prefix = null, .infix = null, .precedence = .None }, // While
.{ .prefix = null, .infix = null, .precedence = .None }, // For
.{ .prefix = null, .infix = null, .precedence = .None }, // ForEach
.{ .prefix = null, .infix = null, .precedence = .None }, // Switch
.{ .prefix = null, .infix = null, .precedence = .None }, // Break
.{ .prefix = null, .infix = null, .precedence = .None }, // Continue
.{ .prefix = null, .infix = null, .precedence = .None }, // Default
.{ .prefix = null, .infix = null, .precedence = .None }, // In
.{ .prefix = null, .infix = is, .precedence = .IsAs }, // Is
.{ .prefix = literal, .infix = null, .precedence = .None }, // Integer
Expand Down Expand Up @@ -513,7 +511,7 @@ pub fn init(
imported: bool,
flavor: RunFlavor,
) Self {
var self = Self{
return .{
.gc = gc,
.imports = imports,
.script_imports = std.StringHashMap(LocalScriptImport).init(gc.allocator),
Expand All @@ -524,13 +522,9 @@ pub fn init(
.allocator = gc.allocator,
.error_prefix = "Syntax",
},
.ffi = undefined,
.ffi = FFI.init(gc),
.ast = Ast.init(gc.allocator),
};

self.ffi = FFI.init(gc);

return self;
}

pub fn deinit(self: *Self) void {
Expand Down Expand Up @@ -747,13 +741,22 @@ fn synchronize(self: *Self) !void {
.For,
.ForEach,
.Return,
.Switch,
.Throw,
.Break,
.Continue,
.Export,
.Import,
.Zdef,
.From,
.Var,
.Yield,
.Resume,
.Resolve,
.Protocol,
.Try,
.Static,
.Extern,
.Namespace,
=> return,
else => {},
}
Expand Down
2 changes: 0 additions & 2 deletions src/Scanner.zig
Original file line number Diff line number Diff line change
Expand Up @@ -626,10 +626,8 @@ pub fn highlight(self: *Self, out: anytype, true_color: bool) void {
.While,
.For,
.ForEach,
.Switch,
.Break,
.Continue,
.Default,
.Const,
.Fun,
.In,
Expand Down
4 changes: 0 additions & 4 deletions src/Token.zig
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,8 @@ pub const Type = enum {
While, // while
For, // for
ForEach, // foreach
Switch, // switch
Break, // break
Continue, // continue
Default, // default
In, // in
Is, // is
IntegerValue, // 123
Expand Down Expand Up @@ -191,7 +189,6 @@ pub const keywords = std.StaticStringMap(Type).initComptime(
.{ "catch", .Catch },
.{ "const", .Const },
.{ "continue", .Continue },
.{ "default", .Default },
.{ "do", .Do },
.{ "else", .Else },
.{ "enum", .Enum },
Expand Down Expand Up @@ -224,7 +221,6 @@ pub const keywords = std.StaticStringMap(Type).initComptime(
.{ "return", .Return },
.{ "static", .Static },
.{ "str", .Str },
.{ "switch", .Switch },
.{ "test", .Test },
.{ "throw", .Throw },
.{ "true", .True },
Expand Down

0 comments on commit f814a45

Please sign in to comment.