IMCC - parsing
This document describes the basic parsing functionality of imcc.
Imcc parses and generates code in terms of compilation units. These are self-contained blocks of code very similar to subroutines.
Code for a compilation unit is created as soon (or not earlier) as the end of the unit is reached.
program: subs subs: statements ...
Comment start with # and end at line end.
Everything enclosed in POD markers is ignored.
=some_pod_marker in col 1 ... =cut
A POD starts with a = in columns 1 and ends with =cut on its own line.
.sub _name statements ... .end
defines a subroutine with the entry point _name. Subroutine entry points (as all global labels) have to start with an underscore. The statements may contain valid PIR or PASM statements.
.pcc_sub _name statements ... .end
Like above with parrot calling conventions. Subroutines according to Parrot Calling Conventions (PCC) are described in docs/calling_conventions.pod.
.emit _sub1: pasm_statements ... ret ... .eom
defines a compilation unit containing PASM statements only. Typical usage is for language initialization and builtins code.
Anything outside compilation units will be ignored in the near future.
Nested subroutines are deprecated and will be removed as well.
Compilation units maintain their own symbol table containing local labels and variable symbols. This symbol table hash is not visible to code in different units.
If you need global variables please use the global opcode.
Global labels and constants are kept in the global symbol table ghash.
This allows for global constant folding beyond subroutine scope.
Local labels in different compilation units with the same name are allowed, though assembling the generated PASM doesn't work. Running this code inside imcc is ok. This will probably change so that local labels are mangled to be unique.
docs/calling_conventions.pod
imcc.y, instructions.c, t/syn/sub.t, t/imcpasm/sub.t, t/syn/scope.t
Leopold Toetsch <lt@toetsch.at>
To install Make, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Make
CPAN shell
perl -MCPAN -e shell install Make
For more information on module installation, please visit the detailed CPAN module installation guide.