Closed jurgenvinju closed 3 years ago
Additional benefit: if parse functions do not need to call rascal functions then the IFunction which is generated by IRascalValueFactory.parser
does not have to lock the interpreter anymore. This is beneficial for the code complexity of the parser function and also for parallel calls to the parser (which happens in Eclipse and the LSP a lot while typing).
reminder: we do need post-parse filtering during tree construction to bring tree construction for ambiguous-grammars-which are-disambiguated-by-post-parse-filtering down to O(n^3)
as opposed to in O(n^p)
. (p the length of the longest production minus 1). Namely, we can apply disambiguations on the binarized SPPF level like this instead of on the non-binarized Rascal Tree representation.
I'm fine with moving it to a parameter of parse.
The only place where I know it's used is in the standard libraries java8
grammar. It's used to disambiguate actually ambigu type-aliases in java, but also for some left-overs from the sdf source.
This was done. Filtering is no longer an implicit side-by-side effect but a parameter of the parse function.
This is a proposal to change the behavior of the Rascal
parse
function inParseTree
. Not enough for a complete amendment proposal in my view. But perhaps we can escalate this later if others deem this necessary.Please help in this discussion @PaulKlint @tvdstorm @DavyLandman
parse
function a parser is generated from thetype[Tree] grammar
parameter. So first the grammar is reified from the current declaration scope (all relevant rules are collected) and then the grammar is passed to the parser generator.#
is a static compile-time operator.amb
andappl
constructors. The overloaded functions are collected from the calling context of theparse
function. Thefilter
statement also plays a big role ere.This latter feature is highly problematic:
parse
plugin deeply queries into the interpreters implementation details to recover the right overloaded functions to call.An optimal solution would be that the
#
operator produces also a reified set of normalizing functions which are applicable in the given compile-time scope, but that would require serializable functions to work, and some other features which Rascal does not have yet. Also it is questionable if these functions are logically belonging to a "reified grammar".An intermediate solution is to add a keyword parameter to each
parse
function, which contains a set of references to normalization functions. That way the user can "reifiy" the normalizations functions and pass them to the parser explicitly. The same normalizing functionality would be obtained at a slight cost of changing all calls to parser functions:parse(input, src, normalizers={amb, \ifStatement, \whileStatement})
parse
built-in queries into the interpreterYour thoughts pls.