[ Pobierz całość w formacie PDF ]
.By inspecting the grammarrules, we see that the other tokens must be taken from { EOP , COP ,;,end,then,do,else,)}.We confirm that all the tokens defined by this set are differentfrom the tokens defined by TOP.There are two kinds of symbols in Table 3.2: nonterminals and terminals.A nonterminal symbol is one that is further expanded according to a grammarrule.A terminal symbol corresponds directly to a token in the input.It isnot expanded.The nonterminal symbols are Prog (complete program), Stat(statement), Comp (comparison), Expr (expression), Term (term), Fact(factor), COP (comparison operator), EOP (expression operator), and TOP(term operator).To parse a program, start with Prog and expand until findinga sequence of tokens that matches the input.The parser output is a tree (i.e., a nested record) with syntax given in Ta-ble 3.3.Superficially, Tables 3.2 and 3.3 have very similar content, but they areactually quite different: the first defines a sequence of tokens and the seconddefines a tree.The first does not show the structure of the input program wesay it is flat.The second exposes this structure we say it is nested.Becauseit exposes the program s structure, we call the nested record an abstract syntaxCopyright © 2001-3 by P.Van Roy and S.Haridi.All rights reserved. 166 Declarative Programming TechniquesProg ::= program Id ; Stat endStat ::= begin{ Stat ;} Stat end| Id := Expr| if Comp then Stat else Stat| while Comp do Stat| read Id| write ExprComp ::= { Expr COP } ExprExpr ::= { Term EOP } TermTerm ::= { Fact TOP } FactFact ::= Integer | Id |( Expr )COP ::= ´==´ | ´!=´ | ´>´ | ´0 then {LoopUp A} endif S0: as long as A+n*S=0 then {LoopUp A In Out} endif S0: as long as A+n*S= [ Pobierz caÅ‚ość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • czarkowski.pev.pl
  •