Skip to content

Latest commit

 

History

History
53 lines (35 loc) · 2.09 KB

README.md

File metadata and controls

53 lines (35 loc) · 2.09 KB

Author: Jakub Jaśków - 268416

Compiler manual

en en

Project compilation

Necessary programs

It's recommended to build the project with the same or newer program versions than the ones listed belowe.

  • Bison - 3.8.2
  • Flex - 2.6.4
  • g++ - 11.4.0
  • GNU Make - 4.3

Building the compiler

$ cd my_compiler/
$ make

After building the project, you will get a binary file called compiler.

Compiler usage

$ ./compiler [OPTION] [INPUT_FILE] [OUTPUT_FILE]

Options:

-v      verbose - will write all info/logs to standard output.

ATTENTION! Always remember to grant execution rights to the binary file (compiler). How it's done on LINUX:

$ chmod u+x [FILE_NAME]

Cleaning

Clean all build files:

$ make clean-all

Files

  • grammar.y, lexer.lex - definitions of lexical analyser and parser. Includes: grammar, keywords and functions from other files.

  • grammar.cpp, grammar.hpp, lexer.cpp - precompiled versions of files listed above. Generated by parser and lexer.

  • CodeBlock.hpp, AST.hpp, AST.cpp - headers and sources of various compiler elements. CodeBlock.hpp includes the definition of a code block and structures/elements used. AST.hpp and AST.cpp - define structures and classes used for construction of AST (Abstract Syntax Tree) and translation of tree nodes to pseudo assembler code.

  • handlers.hpp, handlers.cpp - definitions and declarations of functions responsible for handling the construction of an AST and semantic checks (variable initialization etc.).

  • definitions.hpp - macros and definitions used by multiple files.

  • types.hpp - mixed definition of an AST and a code block

  • main.cpp - definition and declaration of main, error and warning functions. Defines in what order the code compilation is done.

en en