linguaPhylo icon indicating copy to clipboard operation
linguaPhylo copied to clipboard

Improve the parser err message

Open walterxie opened this issue 1 year ago • 3 comments

Improve the parser err message for lphy grammar err.

E.g. https://github.com/LinguaPhylo/linguaPhylo/blob/973af6cc6ce0a5bbcc942063637fbfb9761e5f85/examples/simulation/jcCoal.lphy#L12-L13

If mis is mistyped to mi, where mi does not exist, it will throw Exception instead of a parsing err:

mis = get(key="mis", map=D);
l = length(mi);
Exception in thread "main" java.lang.RuntimeException: ERROR! No match in length constructor arguments, including vector match! 
	at lphy/lphy.parser.ParserUtils.constructGenerator(ParserUtils.java:183)
	at lphy/lphy.parser.ParserUtils.getFunctionByArguments(ParserUtils.java:150)
	at lphy/lphy.parser.ParserUtils.getMatchingFunctions(ParserUtils.java:53)
	at lphy/lphy.parser.SimulatorListenerImpl$SimulatorASTVisitor.visitMethodCall(SimulatorListenerImpl.java:852)
	at lphy/lphy.parser.SimulatorParser$MethodCallContext.accept(SimulatorParser.java:1125)

walterxie avatar Mar 06 '23 20:03 walterxie