Repository navigation
How to use splparser.cmdrules.common
Although the syntax of SPL commands can be quite idiosyncratic, there is overlap in their rules. In order to avoid redundancy (each parser containing copies of the same rules), parsers can import rules from splparser.cmdparsers.common. Doing this is highly recommended. If you wish to use these rules (and you should), you need to be careful to define all the requisite tokens, which are noted below.
At a high-level, there are two types of common rules: those which can be used with search-style lexers, and those which can be used with eval-style lexers. The main difference between these two types of lexers is that the former is able to tokenize commonly occurring complex data types, such as email addresses, IP addresses, hostnames, etc., whereas the latter can't do that because characters which commonly occur in these data types (such as '.' and '-') are used as operators for arithmetic, string manipulation, and so on. Thus, these two types of lexers necessarily tokenize the same strings differently. For example, consider the string day-average. search-style lexers can and should tokenize this as:
ID
whereas eval-style lexers can and should tokenize this as:
WORD MINUS WORD
because subtraction is a valid eval operator.
If your command uses eval functions, then you should use eval-style lexers. Otherwise, please use search-style lexers. You should define a new lexer for each command, but almost all commands should be able to use either splparser.cmdparsers.searchregexes or splparser.cmdparsers.evalregexes, so think very hard if you are not doing this.
The modules within this package are as follows:
These are very simple rules for as, which is used by many SPL commands. These rules match both the uppercase and lowercase version of the word "as".
Required tokens
'ASLC''ASUC'
Lexer style: any
Similar to the previous module (splparser.cmdparsers.common.asrules).
Required tokens:
'BYLC''BYUC'
Lexer style: any
These rules are all those necessary to parse invocations of eval functions, which are functions that can be used with the eval command, and others. These are defined here.
Required tokens:
'EVAL_FN''COMMON_FN''LPAREN''RPAREN''COMMA''PERIOD''PLUS''MINUS''TIMES''DIVIDES''MODULUS''EQ''LT''LE''GE''GT''NE''DEQ''AND''OR''NOT''XOR''LIKE'- See: splparser.cmdparsers.common.simplevaluerules
Lexer style: eval
Required tokens:
- See: splparser.cmdparsers.common.fieldrules
Lexer style: search
Required tokens:
'WORD''ID''LITERAL''HOSTNAME''NBSTR''WILDCARD''BIN''OCT''HEX''INT''FLOAT'
Lexer style: search
Required tokens:
- See: splparser.cmdparsers.common.simplefieldrules
Lexer style: eval
Required tokens:
Lexer style: eval
Required tokens:
Lexer style: eval
Required tokens:
Lexer style: eval
Required tokens:
Lexer style: eval
Required tokens:
Lexer style: search