/pld-comp

Projet de compilateur C en C++

Primary LanguageC++MIT LicenseMIT

Projet compilateur

doc x86

Choices

Here we put the non-programming choices we made

  • variables can be only constitued of letters, _ and numbers
  • for the moment we can do multiple affectations
  • we choose to change the memory_offset and the tmp_index before the actions
  • the char have size 4

TODO

Mandatory

  • Data type char
  • Data type int
  • Variables
  • Integer constants
  • Basic arithmetic operations: +,-, *
  • Division and modulo (in IR)
  • Bit-by-bit logical operations: |, &,ˆ
  • Comparison operations: ==, !=, <, >
  • Unary operations: ! and - and ~ (bonus)
  • Declaration of variables anywhere
  • Assignment (which, in C, also returns a value)
  • Possibility of initializing a variable when declaring it
  • Use of standard putchar and getchar functions for I/O
  • Define functions with parameters, and int, char or void return type : James
  • Check consistency of function calls and parameters (reserved names)
  • Block structure using { and }
  • Support for variable scopes and shadowing
  • If, else, while control structures
  • Support for return expression anywhere
  • Check that a variable used in an expression has been declared
  • Check that a variable is not declared more than once
  • Check that a declared variable is used at least once: I don't think this has been implemented ~James

Optional

  • Retargeting to multiple architectures: x86, MSP430, ARM
  • Double support with all implicit conversions
  • Simple constant propagation
  • Propagation of constant variables (with data-flow analysis)
  • Arrays (one-dimensional)
  • Pointers
  • Break and continue : Mathieu
  • Char data type width support (8-bit integer)
  • Character strings represented by char arrays
  • Switch...case : Bachir
  • Lazy operators ||, &&
  • Assignment operators +=, -= etc., increment ++ and decrement --

Bonus

  • Data type void
  • Data type pointer address

Ressources

  • see example of c.g4

operator priority