Tool for semantic actions on any language or file format driven by PEG grammars.
- Get search file definition for SemGrep/OpenGrep.
- Define a set of keywords/rules.
- Implement parser for search files with comb.
- Refine own PEG grammar parser.
- Implement AST comparison.
- Implement repacements with Go text templates.
=is used for rule assignment./is used for alternatives (FirstSuccessful).- Separating multiple rules with space is used for sequences (
Sequence). *and+are used for repetitions (Many0andMany1).,*and,+are used for lists (Separated0andSeparated1) withOUT parsing a separator at the end.;*and;+are used for lists (Separated0andSeparated1) WITH optional parsing of a separator at the end.?is used for optional parsers (Optional).->is used for parsing until another parser matches (Until)..is used for any character or byte in case of a binary parser (eitherAnyCharorAnyByte).'and"are used for string literals.(and)are used for grouping.!is used for negative lookahead.&is used for positive lookahead.[and]are used for character classes.- In string literals ANSI escape sequences are supported and so are
\377,\xabcdefand\u00abcdeffor octal, hex and Unicode. - Comments start with
#and continue to the end of the line. - Whitespace is ignored.
EOFparses the end of the input.EOLparses the end of a line ('\r\n','\n'or'\r``).FLOATparses a floating point number (without a sign).INTEGERparses an integer number (without a sign).SPACEparses any amount of Unicode whitespace (including none).MUST_SPACEparses Unicode whitespace (at least one character).NAMEparses a name (a Unicode letter followed by zero or more Unicode letters, Unicode digits or underscores).
ALPHAparses a Unicode letter.DIGITparses a Unicode digit or number.WORDOisALPHAandDIGITplus_combined into a single class.
The names of these character classes are deliberately chosen to contain a double vowel.
So they aren't reasonable character classes
(for example [WORD] is a reasonable character class but [WORDO] isn't).
GRAMMARis the root rule of a grammar.VARIABLEparses a variable name (e.g.'$' NAME) in code snippets for searching or replacing. A variable can stand for any syntactically valid subtree of the current parse tree (AST).PLACEHOLDERparses a placeholder (e.g.'_'or'$PLACEHOLDER') in code snippets for searching. Like a variable, a placeholder can stand for any syntactically valid subtree of the current parse tree (AST). But a placeholder can't be referenced later. So it can't be used in replacements.BINARYis more a variable than a rule. It can only be set totrueorfalse.falseis the default value. So it can be omitted.