[so] prioritatea operatorilor
Octavian Purdila
so@cursuri.cs.pub.ro
Sun, 31 Oct 2004 16:17:43 +0200
On Saturday 30 October 2004 21:40, andrei ion wrote:
>Care este prioritatea operatorilor?
Prioritatea operatorilor in ordine crescatoare:
SEQUENTIAL
PARALLEL
PIPE
CONDITIONAL_ZERO CONDITIONAL_NZERO
(deci CONDITIONAL_ZERO si CONDITIONAL_NZERO vor avea prioritatea cea mai mare,
iar SEQUENTIAL prioritatea cea mai mica)
Am modificat si parserul pentru a construi arborele sintactic cu prioritatile
precizate.
> Te rog exemplifica pe macar unul din urmatoarele:
> a) c0 ; c1 & c2 && c3 | c4
#c0 ; c1 & c2 && c3 | c4
1
shell: can't exec c0: No such file or directory
2
shell: can't exec c1: No such file or directory
5
3
shell: can't exec c2: No such file or directory
shell: can't exec c4: No such file or directory
> b) c1 & c2 && c3 & c4 || c5 || c6
#c1 & c2 && c3 & c4 || c5 || c6
2
2
shell: can't exec c1: No such file or directory
3
shell: can't exec c2: No such file or directory
4
4
shell: can't exec c4: No such file or directory
shell: can't exec c5: No such file or directory
shell: can't exec c6: No such file or directory
> Care va fi ordinea de executie a comenzilor?
>
In exemplele de mai sus sunt afisati operatorii conform definitiei lor din
parser.h, in ordinea in care sunt intalniti, si rezultatele executiei
comenzilor (c3 nu se executa datorita operatorului de conditionalitate)
tavi