Skip to content

Commit

Permalink
parser: add array_access
Browse files Browse the repository at this point in the history
Fixes #66
  • Loading branch information
jkbz64 committed Sep 13, 2024
1 parent 986f95f commit b21aff0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
12 changes: 12 additions & 0 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,17 @@ module.exports = grammar({
$.logical_expression
),

array_access: ($) =>
prec.right(
1,
seq(
field("array", choice($.identifier, $.object_access)),
"[",
$._expression,
"]"
)
),

/// Includes
include_argument: ($) =>
choice(
Expand Down Expand Up @@ -1235,6 +1246,7 @@ module.exports = grammar({
$._binary_expression,
$.qualified_name,
$.object_access,
$.array_access,
$.function_call,
$.ternary_expression,
$.available_expression,
Expand Down
11 changes: 10 additions & 1 deletion test/corpus/basic.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1124,6 +1124,8 @@ OBJECT ACCESSORS statement
DISPLAY some_object:root.
DISPLAY some_object:chained_property:chained_another:method().

PUT some_object:array[5].

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

(source_code
Expand All @@ -1139,7 +1141,14 @@ DISPLAY some_object:chained_property:chained_another:method().
object: (identifier)
property: (identifier)
property: (identifier)
property: (identifier)))))
property: (identifier))))
(abl_statement
statement: (identifier)
(array_access
array: (object_access
object: (identifier)
property: (identifier))
(number_literal))))

================================================================================
TERNARY EXPRESSION statement
Expand Down

0 comments on commit b21aff0

Please sign in to comment.