I'm almost finishing my open-source language's verifier. It performs parsing and verification, which ensures a set of programs are valid both syntatically and semantically at compile-time. To start with, I've implemented it in C# (.NET Core).
The question is, is what I've usable by some, say, Visual Studio Code extension to provide type hints? I've never made an IDE extension, so I'm worried about how I'll make use of my language analysis made in C#.
The verifier that ensures a set of programs is valid and that derives an AST with semantic symbols attached to them can be used like follows:
// scripts hold diagnostics and basic source information,
// such as the file path and the source text.
// a script can be either valid or invalidated.
var scripts = gatherSuppliedScripts();
// parse each script with `new Parser(script).parseProgram()`, returning
// either a `Program` node or null.
// if a script is invalid, `parseProgram()` will invalidate it
// and return null.
var programNodes = toDo();
// the `Verifier` can be considered different things: a symbol solver,
// a type checker and a compile-time validator.
// its only public method is `VerifyPrograms(programList)`,
// which will validate the programs and attach symbol to AST nodes.
// in previous versions, I used to attach symbols through a hash map
// (from `Node` to `Symbol`);
// now I've decided to use AST fields instead, named 'SemanticN'.
// for example, the `Expression` node has a `SemanticSymbol` field that holds
// a `Symbol`.
// the verifier does expose the `ModelCore`, which holds
// references to static symbols and interns structural types
// and argumented definitions. every `Symbol` refers back to
// that same `ModelCore`.
var verifier = new Verifier();
verifier.VerifyPrograms(programList);
// note that every node, including `Program`, holds
// a `Span`. a `Span` holds the `Script` and source locations.
The way I've implemented that parser and verifier is very much like throwaway. You can't call VerifyPrograms(programList)
more than once for the same programs; I've not put any such restriction, but it should not work. An expression is not verified more than once if its internal verifier is called, but a statement is different.
My parser is not tolerant.
I guess that if I were to use my language core from an IDE like VS Code I'd have to perform some caching? Would I've to invoke the compiler multiple times everytime you change the program to reflect the user definitions?
So overall, I'm asking if it's fine to re-invoke the compiler whenever the user updates a script in their IDE?