Skip to content

Commit c9095a7

Browse files
Update README.md
1 parent a41e3d0 commit c9095a7

File tree

1 file changed

+42
-69
lines changed

1 file changed

+42
-69
lines changed

README.md

+42-69
Original file line numberDiff line numberDiff line change
@@ -41,80 +41,65 @@ parseResult.Placeholders[0].Offset // Start 5, End 17
4141
```
4242

4343
# Grammar
44-
### Core Expressions
45-
46-
```ebnf
47-
expression = logical_expr | term
48-
49-
logical_expr =
50-
logic_expr
51-
| comparison_expr
52-
| is_operation
53-
| match_operation
54-
| in_operation
55-
| not_operation
56-
57-
comparison_expr = string_argument ('Equals' | 'Contains' | 'StartsWith' | 'EndsWith') string_argument
58-
59-
logic_expr = logical_expr ('And' | 'Or' | 'NAND' | 'NOR' | 'XOR' | 'XNOR') logical_expr
60-
61-
not_operation = 'Not' logical_term
62-
63-
match_operation = string_argument 'Match' '"' <any valid regex> '"'
64-
65-
in_operation = string_argument 'In' [ '(' ] string_argument { ',' string_argument } [ ')' ]
66-
67-
is_operation = string_argument 'Is' ('Var' | 'Int' | 'Double' | 'DateTime' | 'Guid')
68-
69-
logical_term = '(' expression ')' | term
70-
```
71-
72-
### Values and Properties
73-
7444
```ebnf
75-
string_argument = term | property_operation
76-
77-
property_operation =
45+
logic_expr =
46+
binary_op
47+
| not_expr
48+
| string_cmp_op
49+
| is_op
50+
| match_op
51+
| in_op
52+
| '(' logic_expr ')'
53+
54+
binary_op =
55+
logic_expr ('And' | 'Or' | 'NAND' | 'NOR' | 'XOR' | 'XNOR') logic_expr
56+
57+
string_cmp_op =
58+
string_expr ('Equals' | 'Contains' | 'StartsWith' | 'EndsWith') string_expr
59+
60+
not_expr = 'Not' logic_expr
61+
is_op = string_expr 'Is' ('Var' | 'Int' | 'Double' | 'DateTime' | 'Guid')
62+
match_op = string_expr 'Match' '"' <regex> '"'
63+
in_op = string_expr 'In' [ '(' ] string_expr { ',' string_expr } [ ')' ]
64+
65+
string_expr =
66+
grouped_string
67+
| property_access
68+
| atomic_token
69+
70+
grouped_string =
71+
'(' string_expr ')'
72+
| '{' string_expr '}'
73+
| '[' string_expr ']'
74+
75+
property_access =
7876
placeholder '.' (
7977
'Length'
8078
| complex_property
81-
| input_property [ string_property_chain ]
79+
| input_property [ chainable_string_ops ]
8280
)
83-
| placeholder [ string_property_chain ]
81+
| placeholder [ chainable_string_ops ]
8482

85-
string_property_chain = { '.' chainable_operation }
83+
chainable_string_ops = { '.' chainable_operation }
8684

8785
chainable_operation = 'Trim' | 'TrimEnd' | 'TrimStart' | 'ToUpper' | 'ToLower'
88-
8986
input_property = 'Input.' identifier
90-
9187
complex_property = ('Offset' | 'Line' | 'Column') '.' ('Start' | 'End')
92-
```
93-
94-
### Terms and Tokens
95-
96-
```ebnf
97-
term =
98-
'(' expression ')'
99-
| '{' expression '}'
100-
| '[' expression ']'
101-
| term '+'
102-
| token
103-
104-
token = placeholder | string_literal | whitespace | comment
10588

89+
atomic_token = placeholder | string_literal | whitespace | comment
10690
placeholder = '$' identifier '$'
107-
10891
string_literal = <escaped string>
109-
11092
whitespace = (' ' | '\n' | '\r')+
111-
11293
comment = <single or multiline comment>
113-
```
11494

115-
### Template Matching
95+
find_rule = logic_expr
96+
97+
replace_rule =
98+
'if' logic_expr 'then' assignment
99+
| assignment
100+
101+
assignment = placeholder '=>' string_expr
116102

117-
```ebnf
118103
template_component = placeholder | string_literal | whitespace
119104

120105
template =
@@ -124,18 +109,6 @@ template =
124109
| template_component+
125110
```
126111

127-
### Rule Definitions
128-
129-
```ebnf
130-
find_rule = expression
131-
132-
replace_rule =
133-
'if' expression 'then' placeholder_should
134-
| placeholder_should
135-
136-
placeholder_should = placeholder '=>' string_argument
137-
```
138-
139112
## Getting Started📂
140113
Install from Nuget:
141114
```sh

0 commit comments

Comments
 (0)