The fix in
BLZG-1151 made the parser DB aware in the sense that it throws exceptions for, e.g., GRAPH keyword queries when parsing a query with underlying DB in triples mode.
In general, it seems that making the parser db-mode aware is problematic (this problem popped up during benchmarking, e.g., in the NanoSparqlClient). It is already a problem that it requires the AbstractTripleStore reference. It should be able to run stateless. We could have an AST traversal that marks the top-level as using quads or other constructs that might not be legal in all db modes (such as RDR syntax). We could then flag illegal queries after the parse. We would also need to do RDF Value => IV resolution after the parse. This would make it much easier to support the syntax extensions on the client side.