stjude-rust-labs / wdl

Rust crates for working with Workflow Description Language (WDL) documents.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improve diagnostic for unexpected strings

peterhuene opened this issue · comments

The following WDL:

version 1.1

workflow test {
    "wrong"
}

Fails to parse with:

error: expected input section, output section, runtime section, metadata section, parameter metadata section, conditional statement, scatter statement, task call statement, or private declaration, but found `"`
  ┌─ source.wdl:4:5
  │
4 │     "wrong"
  │     ^ unexpected `"`

But users will expect:

error: expected input section, output section, runtime section, metadata section, parameter metadata section, conditional statement, scatter statement, task call statement, or private declaration, but found string
  ┌─ foo.wdl:4:5
  │
4 │     "wrong"
  │     ^^^^^^^ unexpected string

To fix this, we will need to calculate the span of the string when we encounter an unexpected quote token; this should be possible by cloning the lexer, recovering it past the string (i.e. with interpolation), and then getting the cloned lexer's span for the ending ".

I have a fix ready for this once #85 merges.