Skip to content

yy945635407/PL-0-Compiler

Repository files navigation

PL-0-Compiler

A Compiler for PL/0

Grammer for this language(Expanded Backus paradigm):

<prog> → program <id>;<block>
<block> → [<condecl>][<vardecl>][<proc>]<body>
<condecl> → const <const>{,<const>};
<const> → <id>:=<integer>
<vardecl> → var <id>{,<id>};
<proc> → procedure <id>([<id>{,<id>}]);<block>{;<proc>}
<body> → begin <statement>{;<statement>}end
<statement> → <id> := <exp>               
|if <lexp> then <statement>[else <statement>]
           |while <lexp> do <statement>
           |call <id>([<exp>{,<exp>}])
           |<body>
           |read (<id>{,<id>})
           |write (<exp>{,<exp>})
<lexp> → <exp> <lop> <exp>|odd <exp>
<exp> → [+|-]<term>{<aop><term>}
<term> → <factor>{<mop><factor>}
<factor>→<id>|<integer>|(<exp>)
<lop> → =|<>|<|<=|>|>=
<aop> → +|-
<mop> → *|/
<id> → l{l|d}   (ps:l for letters)
<integer> → d{d}

File Organization:

lexical.py: lexical analyzer
parser.py: grammer analyzer, semantic analyzer combined with code generater.It's also the main procedure
Pcodes.py: class for PseudoCode and class for its table
symbols.py: class for symbol and class for symbol table

About

A Compiler for PL/0

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages