正在加载图片...
Decllist - Decl Program -> Decllist Here is another simple program with a bit more complex expression void main()( main nt a Print (a)i t1 t0+ a 1, Pushpa LCall PrintInti Endfunc Here is the derivation. Again, consider where the instructions above must be emitted relative to the parsing Formals - Stmtlist - int Variable - Type identifier VariableDecl-> variable Stmt - variableDecl Stmtlist - stmtlist stmt OptReceiver -> iver identif Value ->OptReceiver identi p了 Simplestmt-> tmt - Simplestmt titlist - stmtlist stmt Recei LVal iver identifi Expr - LValue ExprLlst - Expr intstmt - Print( ExprList Stmt - Prints stmtlist - StmtBlock - Stmtlist tionDefn - Type identifier( Formals StmtBlock tion def cIList - Decl4 Decl -> FunctionDefn DeclList -> Decl Program -> DeclList Here is another simple program with a bit more complex expression: void main() { int a; a = 2 + a; Print(a); } main: BeginFunc; _t0 = 2; _t1 = _t0 + a; a = _t1; PushParam a; LCall _PrintInt; EndFunc; Here is the derivation. Again, consider where the instructions above must be emitted relative to the parsing activity: Type -> void Formals -> StmtList -> Type -> int Variable -> Type identifier VariableDecl -> Variable ; Stmt -> VariableDecl StmtList -> StmtList Stmt OptReceiver -> LValue -> OptReceiver identifier Constant -> intConstant Expr -> Constant OptReceiver -> LValue -> OptReceiver identifier Expr -> LValue Expr -> Expr + Expr SimpleStmt -> LValue = Expr Stmt -> SimpleStmt ; StmtList -> StmtList Stmt OptReceiver -> LValue -> OptReceiver identifier Expr -> LValue ExprList -> Expr PrintStmt -> Print ( ExprList ) Stmt -> PrintStmt ; StmtList -> StmtList Stmt StmtBlock -> { StmtList } FunctionDefn -> Type identifier ( Formals ) StmtBlock Decl -> FunctionDefn DeclList -> Decl Program -> DeclList
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有