PL0编译器(pascal).doc

  1. 1、本文档共28页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
PL0编译器(pascal)

program pl0(fa,fa1,fa2); (* PL0 compile with code generation *) label 99; (* Turbo Pascal do not support goto between different blocks so, the goto command in getch are replaced by procedure exitp !! in another way, label 99 do not work !! Lin Wei 2001 *) const norw=13; (* of reserved words *) txmax=100; (* length of identifier table *) nmax=14; (* max number of digits in numbers *) al=10; (* length of identifiers *) amax=2047; (* maximum address *) levmax=3; (* max depth of block nesting *) cxmax=200; (* size of code array *) type symbol=(nul,ident,number,plus,minus,times,slash,oddsym, eql,neq,lss,leq,gtr,geq,lparen,rparen,comma, semicolon,period,becomes,beginsym,endsym,ifsym, thensym,whilesym,writesym,readsym,dosym,callsym, constsym,varsym,procsym); alfa=packed array[1..al] of char; objects=(constant,variable,procedur); (* wirth used the word procedureandobject there, which wont work! *) symset=set of symbol; fct=(lit,opr,lod,sto,cal,int,jmp,jpc); instruction=packed record f:fct; (* function code *) l:0..levmax; (* level *) a:0..amax; (* displacement addr *) end; (* lit 0,a load constant a opr 0,a execute opr a lod 1,a load variable 1,a sto 1,a store variable 1,a cal 1,a call procedure at level 1 int 0,a increment t -register by a jmp 0,a jump to a jpc 0,a jump conditional to a *) var fa:text; fa1,fa2:text; listswitch:boolean; (* true set list object code *) ch:char; (* last char read *) sym:symbol; (* last symbol read *) id:alfa; (* last identifier read *) num:integer; (* last number read *) cc:integer; (* character count *) ll:integer; (* line length *) kk:integer; cx:integer; (* code allocation index *) line:array[1..81] of char; a:alfa; code:array[0..cxmax] of instruction; word:array[1..norw] of alfa; wsym:array[1..norw] of symbol; ssym:array[ ..^] of symbol; (* wirth uses array[char] here *) mnemonic:array[fct] of packed array[1..5] of char; declbegsys, statbegsys, facbegsys:symset; table:array[0..txmax] of record name:alfa; case kind:objects of constant:(val

文档评论(0)

xy88118 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档