![]() |
|
Главная Терминология Хоора 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 [ 118 ] 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 procedure statemmt% var i: integer; procedure expression; procedure term; procedure factor; var i: integer; begin if sym = ident tlien begin i := positionQd); if / = 0 then error (11) else iltabk[i] .kind = procedure then error (21); getsym end else if sym - number then 15egin getsym end else it sym Iparenthen begin getsym;. expressionist sym - rparen then getsym else error (22) end else ewr (23) end {factor} ; begin [term] factor; while jyw in [й/ийу, л/да/г] do begin geisytn; factor end end [term] ; begin [expression) it sym m [plus, minus] then begin getsym; term end else term; while Jj/w in [plus, minus] do begin /еш end [expression] ; procedure condition; begin it sym =3 oc&y/Mthen be getsym; expression end else begin expression; ,it->(sym in [e/, ие, lss,kq, gtr, geq]) then W(?r (20) else begin gefsymi expression end end {condition} ; begin {statement} ifsym - ident then begin i := positionQd); if i = 0 then error (11) else if table [i].kind Ф variable thm error (12); getsym; ifsym ~ becomes tbea getsym еЫ error (IS); expression end else if лгут = callsym then begra getsym; ifsym Ф ident thea error (14) dse begin i := position(id); if г - 0 then e/Tor (11) else if table[i] .kind Ф procedure then-error (15); getsym end end else if sym = ifsym then \>&gm.getsym; condition; if sym = thensym then getsym else error (16); statement; end else ifsym ~ beginsym then begin getsym; statement; while sym = semicolon do begin getsym; statement end; ifsym - endsym then getsym else error (17) end else sym ~ whilesymtbm begin getsym; condition; ifsym = (foiirvm then getyjm else error (18); л/й/етеиг end end (statement) ; Ъефа {block} ifsym ~ constsym then begin getsym; constdeclaration; fvTiile sym comma do begin getsym; constdeclaration end ; \isym s= semicolon then efjr/n else error (5) ad; iisym = vcrjym then begin getsym; vardeclaration; yiiaiesym - comma begax getsym; vardeclaratioit end ; if sym =e semicolon then getsym else ото/* (5) end ; while sym procsym do begin getojm; if sym = We nhen begin enter (procedure); getsym end else error (4); if-sym = semicolon then else erw (5); block (tx); iisym => semicolon theagetsym iUse error (S); end; end {i/ocfc} ; begin {основная программа) for ch := A to ; do ssymlch] :*= nul; v/ord[ 1] := begin ; word[ 2]: call wo/d[ 3] := const; worJ[ 4] := do wordl 5] := end ; word[ 6] :== if word{ 7] := odd ; wor 8] := procedure Twri 9] then ; vfort/lioj := var vvordlll] := -while; wsym[ 1] := beginsym; wsym[ 2] ;= .callsym; wsyml 3} ;== constsym; wsym[ 4] : = dosym; wsyml 5] := endsym; wsynl 6\ := (jm; 7] oddsym; wsyni, S] := procsym] yvsymi 9] := thensym; wsym[lG\ := v ;w; mwLll] r: whilesym; ssym-\-1 := wj; JJiywI-l := minus; ssyn*\ := /иел'; ssymll} у/й'УА; JSywrC] := Iparen; ssymlji jpcew; |