-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpipeline.ebnf
More file actions
31 lines (22 loc) · 787 Bytes
/
pipeline.ebnf
File metadata and controls
31 lines (22 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Grammar for command pipeline.
# For our purposes it is enough to know boundaries of top-level commands
# in pipeline, their structure isn't interesting to us. However, in order
# to properly split pipeline it is needed to parse groups, strings, etc.
@no_skip_ws
Pipe = '|' !'|';
@export
Pipeline = first_command:TopLevelCommand { Pipe rest_commands:TopLevelCommand };
@position
TopLevelCommand = Command;
Command = {Segment};
Segment = @:Group | @:Subshell | @:String | @:Char;
Group = '{' Command '}';
Subshell = '(' Command ')';
String = SingleQuoteString | DoubleQuoteString;
Char = (!'|' char);
@no_skip_ws
DoubleQuoteString = '"' {('\\' char) | (!'"' char)} '"';
@no_skip_ws
SingleQuoteString = '\'' {!'\'' char} '\'';
@no_skip_ws
Whitespace = {' ' | '\t' | '\n' | '\r'};