diff --git a/src/name_analysis/gather.rs b/src/name_analysis/gather.rs index 87c42ec..8fbf08d 100644 --- a/src/name_analysis/gather.rs +++ b/src/name_analysis/gather.rs @@ -228,6 +228,9 @@ fn gather_node( AstNodeRef::IfElse(_) => {} AstNodeRef::WhileStatement(_) => {} AstNodeRef::ForStatement(_) => {} + AstNodeRef::LValue(_) => {}, + AstNodeRef::LValueSuffix(_) => {}, + AstNodeRef::VariableUse(_) => {}, AstNodeRef::Expression(_) => {} AstNodeRef::TernaryExpression(_) => {} AstNodeRef::TernaryRhs(_) => {} diff --git a/src/parser/ast.yaml b/src/parser/ast.yaml index df559fb..1f061b9 100644 --- a/src/parser/ast.yaml +++ b/src/parser/ast.yaml @@ -1,16 +1,16 @@ # $schema: ./ast.schema.yaml # Operators Operator: - struct: + struct: children: - inner: - member: + member: rule: OperatorInner - file_id: - special: + special: kind: file_id - range: - special: + special: kind: range OperatorInner: leaf_enum: @@ -442,24 +442,24 @@ PlatformFunction: - parameters - return_type PlatformOperatorFunction: - struct: + struct: children: - is_public: - member: + member: rule: Pub - build: - boolean: + build: + boolean: on: rule_present - platform_kw: - skip: + skip: rule: Platform - op_kw: skip: rule: Op - generics: - member: + member: rule: GenericParameters - build: + build: node: or_else_default: true - operator @@ -628,12 +628,8 @@ VariableDeclaration: AssignmentStatement: struct: children: - - left: - member: - rule: Expression - - right: - member: - rule: Expression + - l_value + - expression ExpressionStatement: struct: children: @@ -715,6 +711,26 @@ ForStatement: skip: rule: End +# LValue +LValue: + struct: + children: + - variable_use + - suffixes: + vec: + rule: LValueSuffix +LValueSuffix: + tree_enum: + rules: + - ObjectProperty + - ObjectIndex + +# VariableUse +VariableUse: + struct: + children: + - identifier + # Expressions Expression: polymorphic_type: @@ -749,6 +765,9 @@ Expression: - Literal: inner: kind: Literal + - VariableUse: + inner: + kind: VariableUse - Fqn: inner: kind: FullyQualifiedName @@ -1091,6 +1110,9 @@ PrimaryExpression: - Literal: inner: kind: Literal + - VariableUse: + inner: + kind: VariableUse - Fqn: inner: kind: FullyQualifiedName diff --git a/src/parser/deimos.pest b/src/parser/deimos.pest index 81cf3b8..4694984 100644 --- a/src/parser/deimos.pest +++ b/src/parser/deimos.pest @@ -542,7 +542,7 @@ VariableDeclaration = { } AssignmentStatement = { - Expression + LValue ~ "=" ~ Expression } @@ -593,6 +593,24 @@ ForStatement = { ~ End } +// LValue + +LValue = { + VariableUse + ~ LValueSuffix* +} + +LValueSuffix = { + ObjectProperty + | ObjectIndex +} + +// Variable Use + +VariableUse = { + Identifier +} + // Expressions Expression = { @@ -741,6 +759,7 @@ ObjectIndex = { PrimaryExpression = { Literal + | VariableUse | FullyQualifiedName | Closure | ListExpression