Decaf Compiler
Functions | Variables
main.c File Reference

Compiler driver. More...

#include "p1-lexer.h"
#include "p2-parser.h"
#include "p3-analysis.h"
#include "p4-codegen.h"

Functions

void Error_throw_printf (const char *format,...)
 Throw an exception with an error message using printf syntax. More...
 
bool read_file (const char *filename, char *text)
 Read all text data from a file. More...
 
int main (int argc, char **argv)
 Compiler entry point. More...
 

Variables

char decaf_error_msg [MAX_ERROR_LEN]
 Error message buffer.
 
jmp_buf decaf_error
 Data structure used by setjmp / longjmp for exception handling.
 

Detailed Description

Compiler driver.

Function Documentation

◆ Error_throw_printf()

void Error_throw_printf ( const char *  format,
  ... 
)

Throw an exception with an error message using printf syntax.

Throw an exception with an error message using printf syntax.

This function is declared in common.h but must be defined here in main.c because that's where the jmp_buf declaration is.

◆ main()

int main ( int  argc,
char **  argv 
)

Compiler entry point.

Parameters
argcNumber of command-line arguments
argvArray of command-line argument strings
Returns
EXIT_SUCCESS if the compilation succeeds and EXIT_FAILURE otherwise

◆ read_file()

bool read_file ( const char *  filename,
char *  text 
)

Read all text data from a file.

Parameters
filenameName of file to read
textString buffer destination (must be MAX_FILE_SIZE characters long)
Returns
True if and only if the file read was successful.