|
|
|
|
|
by javcasas
614 days ago
|
|
How do you debug DCGs? I get "false." instead of "syntax error at line 23", which is unacceptable for bigger inputs. Also DCGs for high level operations? Do you mean "use DCGs to parse strings that contain instructions" or do you parse things other than strings with DCGs? I'm assuming you take the parsed instructions and run them through some kind of interpreter that does the execution and audit trail. |
|
>> How do you debug DCGs? I get "false." instead of "syntax error at line 23", which is unacceptable for bigger inputs.
You need to include exception handling in your DCG rules. For example, in Prolog-like pseudocode:
Called from a source file the error output will list the line in the source file where the exception was raised. There are more tools to debug the error:https://www.swi-prolog.org/pldoc/man?section=exception
DCGs parse lists, not strings, as such. So the input can be anything you can put in the form of a list.