question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Goal

Make it easier to extend the syntax and make compiler easier to work with.

Overview

This should unblock #28

Currently, the individual node parsing methods perform in-place validation on the syntax. For example, the identifier parser may throw an undefined variable syntax error if it cannot identify the variable.

https://github.com/ballercat/walt/blob/296f1cb1d19188c29e63ea96b6873df94781ba20/src/parser/maybe-identifier.js#L48

This is OK, but the more syntax is extended the harder it is to extend the behavior. In the above code, the undefined variable handler is overwritten to silence the error while parsing function arguments(while parsing the parent node). Instead of doing the above, let’s have another step before the generator, a static type/validator checker.

The final pipeline will look like this:

Tokenizer -> tokens -> Parser -> ast -> Static Checker -> ast/dag -> Generator -> ir -> Emitter -> bytecode

Initial implementation would only handle Identifier nodes. This means the static checker would do the following:

  • Ensure the identifier is valid/in-scope
  • Patch nodes to attach correct metadata, like global/local indexes, type definitions, function indexes and table pointers
  • throw syntax errors if the identifier is undefined and only do so in correct context. For example, it should be fine for an identifier to be undefined in a function definition because that is the first node it’s defined in.
  • Code generation needs to be moved entirely to its own step. Currently, functions generate IR in-place but this will need to change.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ballercatcommented, Dec 27, 2017

I think once the project is mature and stable enough something like that should be possible. Right now I’d like to keep the discussion focused on implementing the changes outlined in the issue.

0reactions
ballercatcommented, Jan 4, 2018

I’ve unblocked this with #56 and implemented a basic validation step.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Validation Definition & Meaning - Merriam-Webster
The meaning of VALIDATION is an act, process, or instance of validating; especially : the determination of the degree of validity of a ......
Read more >
What is Validation and Why Do I Need to Know? - Psych Central
Validation is the recognition and acceptance of another persons internal experience as being valid. Emotional validation is distinguished from ...
Read more >
Validation Definition & Meaning - Dictionary.com
the act of confirming something as true or correct: The new method is very promising but requires validation through further testing.
Read more >
Validation - Wikipedia
Data validation, in computer science, ensuring that data inserted into an application satisfies defined formats and other input criteria · Forecast verification, ...
Read more >
Validation - Laravel - The PHP Framework For Web Artisans
Laravel includes a wide variety of convenient validation rules that you may apply to data, even providing the ability to validate if values...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found