alda-lang / alda-core

The core machinery of Alda
80 stars 26 forks source link

Parse error involving variables within variable definitions #64

Closed elydpg closed 6 years ago

elydpg commented 6 years ago

Consider the following code:

soprano = >c< b >c<
alto = g g g
tenor = e d e
bass = c <b> c
piano: V1: soprano V2: alto V3: tenor V4: bass

Plays normally However,

soprano = >c< b >c<
alto = g g g
tenor = e d e
bass = c <b> c

melody = V1: soprano V2: alto V3: tenor V4: bass

piano: melody

Throws the error [27713] ERROR Unrecognized event: :name (this happens regardless of whether or not the variable melody is actually used or not). However,

soprano = >c< b >c<
alto = g g g
tenor = e d e
bass = c <b> c

melody = [V1: soprano V2: alto V3: tenor V4: bass]

piano: melody

Plays normally.

daveyarwood commented 6 years ago

Another nice catch @elyisgreat -- I've found the cause* and am working on a fix.

*Don't ask, it's a really weird edge case!

daveyarwood commented 6 years ago

...OK, I'll explain :)

Voices ended up actually being a red herring. It turns out that there's a bug in the parser that has to do with ending a variable definition with another variable reference.

This works because the foo = line ends with f (not a variable):

bar = c d e
foo = bar f

piano: foo

But this fails with Unrecognized event: :name because the reference to bar isn't getting disambiguated from a "name" token into a "get variable" token.

bar = c d e
foo = bar

piano: foo

Should have a fix out shortly!

daveyarwood commented 6 years ago

Fixed in 1.0.0-rc80.