rusty icon indicating copy to clipboard operation
rusty copied to clipboard

Support array indexing in VAR_CONFIG blocks

Open volsa opened this issue 1 year ago • 1 comments

Describe the bug Indexing any array variable within a VAR_CONFIG block currently reports a parsing error, e.g.

VAR_CONFIG
    main.foo[1].bar AT %IX1.0 : BOOL;
END_VAR

will report

error[E006]: Missing expected Token AT
  ┌─ target/demo.st:2:12
  │
2 │     foo.bar[1] AT %IX1.0 : BOOL;
  │            ^ Missing expected Token AT

error[E006]: Missing expected Token hardware access
  ┌─ target/demo.st:2:12
  │
2 │     foo.bar[1] AT %IX1.0 : BOOL;
  │            ^ Missing expected Token hardware access

error[E007]: Unexpected token: expected KeywordSemicolon but found '[1] AT %IX1.0 : BOOL'
  ┌─ target/demo.st:2:12
  │
2 │     foo.bar[1] AT %IX1.0 : BOOL;
  │            ^^^^^^^^^^^^^^^^^^^^ Unexpected token: expected KeywordSemicolon but found '[1] AT %IX1.0 : BOOL'

volsa avatar Sep 12 '24 12:09 volsa

In a similar vein, declaring a custom string type, e.g.

VAR_CONFIG
    main.foo.bar AT %IX1.0 : STRING[100];
END_VAR

currently leads to a panic in index::visitor::visit_global_var_block, src/index/visitor.rs:313:50 due to the custom string type not having a name. Not yet sure if this is also a parser issue (might be in the pre-processor), if not I'll open a separate issue once I've investigated further.

mhasel avatar Sep 23 '24 12:09 mhasel

Since parsing arrays is no longer an issue, I'm closing this issue. Custom string type panic tracked in #1331

mhasel avatar Oct 08 '24 06:10 mhasel