def-gthill / lexurgy

A high-powered sound change applier
GNU General Public License v3.0
47 stars 5 forks source link

confusing error: word boundary in one alternative #14

Closed GaryShelden closed 3 years ago

GaryShelden commented 3 years ago

This rule:

stress: [vowel] => [stressed] / {$ [cons]?, A [cons]?} _

(there are two spaces at the beginning of the line, though github may not display them)

causes this error:

extraneous input ' ' expecting {, NEWLINE} (Line 87, column 48)

The character at column 48 (one based) is '}' while the message is referencing a space. The character at column 48 (zero based) is ' ' .

At any rate, what is wrong with this rule?

It is intended to add the [stressed] feature to the first vowel in the word after word-initial consonants: "$ [cons]?" or after the suffix marker 'A' followed by potential consonants: "A [cons]?"

def-gthill commented 3 years ago

Currently, the word boundary marker $ isn't allowed to be nested inside other structures. This is a restriction that's supposed to help ensure that the $ is actually at the edge of the rule, but mostly it's just confusing and sometimes requires verbose workarounds. Fixing this will take a bit of rewriting, so I can't promise a quick turnaround, but it'll certainly be in place by the version 1.0 release.

Fortunately, in your case the workaround is pretty simple: just put the _ inside each alternative, like this:

[vowel] => [stressed] / {$ [cons]? _, A [cons]? _}

This works because Lexurgy treats each environment, $ [cons]? _ and A [cons]? _, separately, so it doesn't consider the word boundary to be nested.

Thanks for reporting!

def-gthill commented 3 years ago

This is fixed in commit b885cb19954e4e597f3da892b5d3c7c4b457f50e. Still need to do some more testing of the error conditions before I add this to the next release.