?? readme
字號(hào):
The LanguageThe language is based on the fragments in Chapter 6: expressions, arrays,boolean expressions, statements, declarations, blocks:P -> { DD SS }DD -> e | DD D | DD -> T id ;T -> T [ num ] | int | float | char | boolSS -> e | SS S | SS -> L = E ; | if ( B ) S | if ( B ) S else S | while ( B ) S | do S while ( B ) ; | break ; | { DD SS }B -> B or B | B and B | ! B | ( B ) | E rel E | true | falseE -> E + E | E - E | E * E | E / E | L | ( B ) | numL -> L [ B ] | idPackage lexerclass Tag. Tags distinguish tokens.class Token with subclasses Num, Real, and Wordclass Lexer, with procedure scanPackage symbolsclass Type. Put types here.class Id. Could have put Id's with expressions; in fact Id extends Exprclas Env. Linked symbol tables.Package inter for intermediate codeFor simplicity, the front end builds syntax trees. Three-address code isemitted during a subsequent pass. We generate short-circuit code forboolean expressions.An optimizing compiler would presumably create intermediate-code objectsrather than emitting strings. Further, Chapter 9 has examples with codethat might be produced by backpatching -- that's a variant to be exploredseparately.Package parserAt one point, I had the parser and lexer in one package, called syntax.The parser is kept separate for readability. We can present the lexerearly -- the parser "touches" the other packages, so it's best presentedlater.Directories tests and tmpThe makefile automatically runs a compiled front end on tests, presumedto be in files ending in ".t"; for example, prog0.t is the quicksortfragment from the running example in Chapter 9. The expected output isin a file ending in ".i"; for example, prog0.i.To distinguish between multiple declarations of the same name, uncommentthe line// public String toString() {return "" + op.toString() + offset;}in class Id in package inter. The intermediate code will then print theoffset as a suffix to an identifier.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -