For Students¶
Typical workflow¶
- Write a complete
.slprogram containingvoid main(). - Compile it with
./slangcc program.sl. - Fix the earliest lexer, syntax, or semantic diagnostic.
- Run the native output with
./program. - Add dump flags when an assignment asks you to inspect a compiler stage.
Language checklist¶
- Use typed declarations such as
int count = 0;. - Initialize every scalar variable.
- Put all statements and declarations inside functions.
- Use
#for a line comment andelseifas one word. - Put conditions in parentheses and bodies in braces.
- Match types exactly; use a supported explicit cast when necessary.
- Use an integer literal or identifier for array sizes and indices.
- End simple statements with a semicolon.
Useful command¶
./slangcc assignment1.sl \
--ast-dump \
--ast-semantic-dump \
--ir-dump \
--asm-dump
The native executable is written beside the source by default. Dumps are written to the current directory.
When compilation fails¶
Read the error category and line number. Lexer errors concern tokens, syntax errors concern program structure, and semantic errors concern names and types. Fix the first diagnostic before investigating later ones.