Skip to content

Commit

Permalink
grammar: Parse variable declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
obiwac committed Jul 4, 2024
1 parent c854441 commit b080c3d
Show file tree
Hide file tree
Showing 4 changed files with 3,053 additions and 2,597 deletions.
4 changes: 3 additions & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = grammar({
$.print,
$.assert,
$.assignment,
$.var_declaration,
$.import,
$.function_declaration,
$.class_declaration,
Expand Down Expand Up @@ -83,7 +84,8 @@ module.exports = grammar({

literal: $ => choice($.number, $.string, $.bool),

assignment: $ => seq(field("left", $.identifier), "=", field("right", $.expression)),
var_declaration: $ => seq($.identifier, ":", $.type),
assignment: $ => seq(field("left", choice($.var_declaration, $.identifier)), "=", field("right", $.expression)),

unary_expression: $ => choice(seq("-", $.expression), seq("!", $.expression)),

Expand Down
Loading

0 comments on commit b080c3d

Please sign in to comment.