Skip to content

Commit

Permalink
Add support for array access expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
ExcaliburZero committed Nov 5, 2023
1 parent c7a1ba3 commit b56b545
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
7 changes: 7 additions & 0 deletions tree-sitter-quickbms/grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,13 @@ module.exports = grammar({
$.string_literal,
$.integer_literal,
$.identifier,
$.array_access_expression,
),
array_access_expression: $ => seq(
field("array", $._expression),
"[",
field("index", $._expression),
"]",
),
array_size_expression: $ => seq(
field("length", $._expression),
Expand Down
11 changes: 10 additions & 1 deletion tree-sitter-quickbms/test/corpus/get.bms
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ get NAME filename
get EXT EXTENSION
get WIDTH short

get FILESTART[i] long

--------------------------------------------------------------------------------

(source_file
Expand Down Expand Up @@ -61,4 +63,11 @@ get WIDTH short
(get)
(identifier)
(type
(short))))
(short)))
(get_statement
(get)
(array_access_expression
(identifier)
(identifier))
(type
(long))))

0 comments on commit b56b545

Please sign in to comment.