ProgramSursa | program identificator; Bloc. |
Bloc | SectiuneConstSectiuneVar SectiuneDeclSubprog InstrComp |
SectiuneConst | Epsilon | const ListaDeclConst |
ListaDeclConst | DeclarConst | ListaDeclConst DeclarConst |
SectiuneVar | Epsilon | var ListaDeclVar |
ListaDeclVar | DeclarVar | ListaDeclVar DeclarVar |
SectiuneDeclSubprog | Epsilon | ListaDeclSubprog |
ListaDeclSubprog | DeclSubprog | ListaDeclSubprog DeclSubprog |
DeclSubprog | DeclarFunctie | DeclarProcedura |
DeclarConst | identificator=ExpresieStatica; |
DeclarVar | ListaId :Tip; |
ListaId | identificator| ListaId,identificator |
Tip | TipSimplu | TipTablou | TipStruct |
TipSimplu | integer | real | char |
TipTablou | array[ ExpresieStatica ..ExpresieStatica ]of TipSimplu |
TipStruct | record ListaCampend |
ListaCamp | DeclSimpla| ListaCamp;DeclSimpla |
DeclSimpla | ListaId:TipSimplu |
DeclarFunctie | function AntetSubprog :TipSimplu;Bloc; |
DeclarProcedura | procedure AntetSubprog;Bloc; |
AntetSubprog | identificatorParamForm |
ParamForm | Epsilon | (ListaParamForm) |
ListaParamForm | DeclarPar | ListaParamForm ;DeclarPar |
DeclarPar | DeclarSimpla| varDeclarSimpla |
ExpresieStatica | TermenStatic | ExpresieStatica OpAd TermenStatic |
TermenStatic | FactorStatic | TermenStatic OpMul FactorStatic |
FactorStatic | identificator | Constanta | (ExpresieStatica) |
OpAd | + | - |
OpMul | * | / | div | mod |
Constanta | constNum|constCar |
InstrComp | begin ListaInstrend | begin ListaInstr ;end |
ListaInstr | Instr | ListaInstr;Instr |
Instr | InstrAtrib
| InstrIf | InstrWhile | InstrRepeat
| InstrFor | InstrCase |
InstrComp | ApelProc | InstrRead | InstrPrint |
InstrAtrib | Variabila :=Expresie |
Variabila | identificator | identificator [Expresie] | identificator .identificator |
Expresie | Termen | Expresie OpAd Termen |
Termen | Factor | TermenOpMulFactor |
Factor | identificator|
Constanta|
(Expresie)
|
identificator(ListaExpresii) | identificator[Expresie] | identificator .identificator |
ListaExpresii | Expresie | ListaExpresii,Expresie |
InstrIf | if Conditiethen InstrRamuraElse |
RamuraElse | Epsilon | else Instr |
Conditie | ExprLogica| notExprLogica |
ExprLogica | ExprRel | ExprLogica OpLogExprRel |
OpLog | and | or |
ExprRel | Expresie OpRelExpresie | (Conditie) |
OpRel | < | > | <= | >= | = | <> |
InstrWhile | while Conditiedo Instr |
InstrRepeat | repeat Instruntil Conditie |
InstrFor | forVariabila:=ExpresieSensExpresie Pas do Instr |
Sens | to | downto |
Pas | Epsilon | step Expresie |
InstrCase | case Expresieof ListaAltern end |
ListaAltern | ListaRamuri | ListaRamuri otherwise: Instr |
ListaRamuri | Ramura| ListaRamuriRamura |
Ramura | ListaVal :Instr; |
ListaVal | Constanta| ListaVal,Constanta |
InstrPrint | print(ListaElem) |
ListaElem | Element | ListaElem,Element |
Element | Expresie | constSir |
InstrRead | read(ListaVariab) |
ListaVariab | Variabila| ListaVariab,Variabila |
ApelProc | identificator | identificator (ListaExpresii) |
Legenda:
- Font drept, bold, rosu = cuvinte cheie, operatori si semne de punctuatie (atomi care apar ca atare in textul sursa).
- Font italic, bold, verde = alte terminale, definite prin expresii regulate (v. Atomi ).
- Epsilon = simbolul sirului vid.
- Font italic, bold, turcoaz = neterminalul radacina al gramaticii.
- Font italic, bold, negru = celelalte neterminale.
- Font drept, non-bold, negru = operatorii metalimbajului de descriere a productiilor (notatia BNF in acest caz).