Documente Academic
Documente Profesional
Documente Cultură
Cod sursa
Translator
Cod obiect
Analiza lexical
secven de atomi lexicali
Analiza sintactic
Analiza semantic
Translatare n cod
intermediar
Program n cod intermediar neoptimizat
Optimizarea codului
intermediar
Program n cod intermediar optimizat
Opiune 1:
Generarea de cod:
Codul intermediar -> cod
main sau limbaj de
asamblare
Program n cod main sau limbaj
de asamblare
Opiune 2:
Interpretare:
Simularea execuiei codului
intermediar de ctre un
interpretor
6
Eminescu este un
sriicotr.
Eminescu scriitor un
este.
Scriitor este un
Eminescu.
Eminescu este un
scriitor.
NU
DA
NU
DA
DA
NU
DA
DA
DA
10
11
12
13
In the PHP language, which was largely inspired by Perl, $ precedes any variable name.
Names not prefixed by this are considered constants or functions.
In Ruby, ordinary variables lack sigils, but $ is prefixed to global variables, @ is
prefixed to instance variables, and @@ is prefixed to class variables (the second @
cannot be considered a twigil, so @@ is just a longer sigil).
In Windows PowerShell, which was partly inspired by Unix shells and Perl, variable names
are prefixed by the $ sigil.
In Transact-SQL, @ precedes a local variable or parameter name. System variables
(known as global variables) are distinguished by a @@ prefix.
In mIRC script, identifiers have a $ sigil, while all variables have a % prefixed (regardless
of local or global variables or data type). Binary variables are prefixed by an &.
In Fortran, sigils are not used, but all variables starting with the letters I, J, K, L, M and N
are integers by default. Fortran documentation refers to this as "implicit typing", though
explicit typing is always available to allow any variable to be declared with any type. (The
range I-N was chosen to be mnemonic with the first two characters of "integer").
In CLIPS, scalar variables are prefixed with a ? sigil while multifield (i.e. a 1-level list)
variables are prefixed with $?.
In C#, any variable names may be prefixed with @. This is mainly used to allow the use
of variable names that would otherwise conflict with keywords. The @ sigil can also be
applied to string literals, which changes the way they are interpreted (character escapes
are not used and strings can extend over multiple lines). The same is achieved in VB.Net
by enclosing the name in square brackets, as in [end].
14
15
16
Pentru un atom lexical de tip numr trebuie s se memoreze att tipul numrului, ct i valoarea
acestuia.
Pentru un atom lexical de tip nume de variabil trebuie s se memoreze tipul, domeniul de
valabilitate (scope) i valoarea.
Pentru un atom lexical de tip nume de funcie trebuie s se memoreze numrul de parametrii, tipul
fiecrui parametru i modul de transfer al acestora.
Pentru atomul lexical corespunztor unei constante exist mai multe iruri de intrare (n exemplul
anterior 0 i 25)
17
18
controlled text
#endif /* expression */
19
20
21
22
23
25
26
27
28
29
30
Inline expansion
Dead code elimination
Constant propagation
Loop transformation
Register allocation
Automatic parallelization
31
Ex:
// alte calcule
float pi = 4 * arctan(1);
aria = pi * r * r;
este
32
33
34
35
"String literal too long (I let you have 512 characters; that's 3
more than ANSI said I should)
"...And the lord said, 'lo, there shall only be case or default
labels inside a switch statement'
"A typedef name was a complete surprise to me at this point in
your program
"You can't modify a constant, float upstream, win an argument
with the IRS, or satisfy this compiler
"This struct already has a perfectly good definition
"type in (cast) must be scalar; ANSI 3.3.4; page 39, lines 10-11 (I
know you don't care, I'm just trying to annoy you)"
36
"Can't cast a void type to type void (because the ANSI spec. says
so, that's why)
"Huh?
"Can't go mucking with a 'void *'
"We already did this function
"This label is the target of a goto from outside of the block
containing this label AND this block has an automatic variable
with an initializer AND your window wasn't wide enough to read
this
whole
error message
"Call me paranoid but finding '/*' inside this comment makes me
suspicious
"Too many errors on one line (make fewer)
"Symbol table full - fatal heap error; please go buy a RAM
upgrade from your local Apple dealer
37
http://academic.udayton.edu/saverioperugini/co
urses/cps343/lecture_notes/grammars.html
http://homedir.jct.ac.il/~rafi/formcomp.pdf
Umberto Eco, Cinci sensuri ale cuvntului semantic, De la
arbore la labirint, edit. POLIROM, 2009.
38