From ef792116aa8c367ada28c1b6c14719473299980a Mon Sep 17 00:00:00 2001 From: yhirose Date: Thu, 1 Sep 2022 20:43:32 -0400 Subject: [PATCH] Update README --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index a1085ab..5e0b53e 100644 --- a/README.md +++ b/README.md @@ -597,6 +597,27 @@ sample.java:8:6: invalid statement As you can see, it can now show more than one error, and provide more meaningful error messages than the default messages. +### Custom error message for definitions + +We can associate custom error messages to definitions. + +```peg +# custom_message.peg +START <- CODE (',' CODE)* +CODE <- < '0x' [a-fA-F0-9]+ > { error_message 'code format error...' } +%whitespace <- [ \t]* +``` + +``` +> cat custom_message.txt +0x1234,0x@@@@,0xABCD + +> peglint custom_message.peg custom_message.txt +custom_message.txt:1:8: code format error... +``` + +NOTE: If there are more than one elements with error message instruction in a prioritized choice, this feature may not work as you expect. + peglint - PEG syntax lint utility ---------------------------------