@@ -41,16 +41,101 @@ parseResult.Placeholders[0].Offset // Start 5, End 17
41
41
```
42
42
43
43
# Grammar
44
- ```C #
45
- grammar = term EOF
46
- term = '(' term ')' | '{' term '}' | '[' term ']' | term + | token
47
- token = placeholder | string_literal | whitespaces | comment
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
+
74
+ ```ebnf
75
+ string_argument = term | property_operation
76
+
77
+ property_operation =
78
+ placeholder '.' (
79
+ 'Length'
80
+ | complex_property
81
+ | input_property [ string_property_chain ]
82
+ )
83
+ | placeholder [ string_property_chain ]
84
+
85
+ string_property_chain = { '.' chainable_operation }
86
+
87
+ chainable_operation = 'Trim' | 'TrimEnd' | 'TrimStart' | 'ToUpper' | 'ToLower'
88
+
89
+ input_property = 'Input.' identifier
90
+
91
+ 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
105
+
48
106
placeholder = '$' identifier '$'
107
+
49
108
string_literal = < escaped string >
50
- whitespace = [“\n \r ” | '\n ' | ' ' ] +
109
+
110
+ whitespace = (' ' | '\n ' | '\r ' )+
111
+
51
112
comment = < single or multiline comment >
52
113
```
53
114
115
+ ### Template Matching
116
+
117
+ ```ebnf
118
+ template_component = placeholder | string_literal | whitespace
119
+
120
+ template =
121
+ '(' template ')'
122
+ | '{' template '}'
123
+ | '[' template ']'
124
+ | template_component +
125
+ ```
126
+
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
+
54
139
## Getting Started📂
55
140
Install from Nuget :
56
141
```sh
0 commit comments