From b174d5eae8063f2ccbe8f3aac573c0ca951ce169 Mon Sep 17 00:00:00 2001 From: Erez Sh Date: Thu, 6 Aug 2020 22:54:36 +0300 Subject: [PATCH] Documented regexp flags. Issue #230 --- docs/grammar.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/grammar.md b/docs/grammar.md index d6cc274..d4ecec5 100644 --- a/docs/grammar.md +++ b/docs/grammar.md @@ -112,6 +112,19 @@ Terminals can be assigned priority only when using a lexer (future versions may Priority can be either positive or negative. If not specified for a terminal, it defaults to 1. +### Regexp Flags + +You can use flags on regexps and strings. For example: + +```perl +SELECT: "select"i //# Will ignore case, and match SELECT or Select, etc. +MULTILINE_TEXT: /.+/s +``` + +Supported flags are one of: `imslu`. See Python's regex documentation for more details on each one. + +Regexps/strings of different flags can only be concatenated in Python 3.6+ + #### Notes for when using a lexer: When using a lexer (standard or contextual), it is the grammar-author's responsibility to make sure the literals don't collide, or that if they do, they are matched in the desired order. Literals are matched according to the following precedence: