-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsyntatic_grammar.txt
94 lines (71 loc) · 2.38 KB
/
syntatic_grammar.txt
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<command_line> : <and_or> ; <command_line>
| <and_or> ;
| <and_or>
;
<and_or> : <task> && <and_or>
| <task> || <and_or>
| <task>
;
<task> : <exec> | <task>
| <exec>
;
<exec> : <command> <redir>
| <command>
| NULL
;
<command> : [name] <argument_list>
| [name]
;
<argument_list> : <argument> <argument>
| NULL
;
<argument> : //Peliculas, aspas variables expands.
<redir> : <redir_in> <redir_out>
| <redir_out> <redir_in>
| <redir_out>
;
<redir_in> : < [filename]
| << [filename]
;
<redir_out> : > [filename]
| >> [filename]
;
NOTE(03/04/2023)
Goal implement these (1):
• Handle ’ (single quote) which should prevent the shell from interpreting the meta-
characters in the quoted sequence.
• Handle " (double quote) which should prevent the shell from interpreting the meta-
characters in the quoted sequence except for $ (dollar sign).
List:
The semicolon (;), ampersand (&), and bar ampersand (|&) have a lower priority than the double ampersand (&&) and double bar (||).
The ;, &, and |& symbols have equal priority among themselves.
The && and || symbols are equal in priority. One or more newline characters can be used instead of a semicolon to delimit two commands in a list.
Metacharacters:
Each metacharacter has a special meaning to the shell and causes termination of a word unless it is quoted.
Metacharacters are: pipe (|), ampersand (&), semicolon (;), less-than sign (<), greater-than sign (>),
left parenthesis ((), right parenthesis ()), dollar sign ($), backquote (`), backslash (\), right quote ('),
double quotation marks ("), newline character, space character, and tab character.
All characters enclosed between single quotation marks are considered quoted and are interpreted literally by the shell.
The special meaning of metacharacters is retained if not quoted. (Metacharacters are also known as parser metacharacters in the C shell.)
| & ; < > ( ) $ ` \ ' "
Observation:
ex1:
echo '"$t'"" -> "$t
ex2:
echo "$t$PATH" -> it is string side by side
ex3:
"""echo""" """hello""" -> hello
ex4:
export t=l
"$t"s -> ls
ex5:
"e"c"h""o" teste
ex6:
"l"$s -> ls
Goal implement the correct pipe separator (2);
Goal implemente these (3):
◦ ctrl-C displays a new prompt on a new line.
◦ ctrl-D exits the shell.
◦ ctrl-\ does nothing.
Metacharacters:
> >> < * ? [ ] | ; [ ] || && ( ) & # $ << " '