Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make DSL locations more deterministic #291

Open
JonathanAldrich opened this issue Jan 5, 2019 · 1 comment
Open

make DSL locations more deterministic #291

JonathanAldrich opened this issue Jan 5, 2019 · 1 comment

Comments

@JonathanAldrich
Copy link
Member

The goal of this would be to simplify the spec of Wyvern, with benefits for implementation, for the understandability of error messages, and for learning the language. The cost is a slightly higher annotation burden.

Right now, anytime there is a random indent, we assume it is a DSL unless a keyword like "type" or "def" or "match" leads us to expect an indent for something else.

Sometimes this leads to weird error messages, where the user indented and hears something about a DSL but they never intended that. There are also strange interactions with comments, particularly /* / style. If you indent and add a comment, the lexer infers a DSL, which then must be heuristically stripped out (see DSLLines() in WyvernParser.jj). Since / / may wrap lines, and DSLs can wrap lines but require indentation (which / */ does not), there are weird error cases, like indenting, starting a comment, and continuing the comment without indentation.

It would be better if you can always determine if line X+1 is a DSL by looking at line X. That would require some signal. We could always require a ~, so that if would look like

if (x > 0) ~
    something
  else
    something else

Or we could be pythonic:

if (x > 0):
    something
  else:
    something else

@potanin
Copy link
Member

potanin commented Jan 9, 2019

In my head this is related to the lambdas issue, it is all about what language makes explicit and what it makes implicit as you add more features. The original goal with TSL's was to make them everywhere and thus it is "normal" to expect DSL errors everywhere because everything is TSL of some sort - almost every kind of expression. Surely making DSL's explicit will detract from this goal of Wyvern (the goal of composable language)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants