Parse an expression or a type name.
(parse-expression-or-type-name parstate) → (mv erp expr/tyname span new-parstate)
This is called when either an expression or a type name is allowed. As discussed in amb-expr/tyname, there is a complex syntactic overlap between expressions and type names, which cannot be disambiguated purely syntactically. Thus, this parsing function returns a possibly ambiguous expression or type name.
We try to parse both an expression and a type name, using the checkpointing and backtracking feature. If only one succeeds, there is no ambiguity, and we return either an expression or a type name (wrapped). If both succeed, there is an ambiguity, which we return as such. If none succeeds, it is an error.
A complication is that some type names are prefixes of expressions
(e.g.
The size of the input after backtracking should not exceed the size of the input before backtracking. For now we insert a run-time check without mbt, but we plan to revisit this to see if we can have an mbt.