Giter Site home page Giter Site logo

php_subset_compiler's Introduction

IFJ 2022

Makefile CI
This is a project for Formal Languages and Compilers class at FIT BUT.

Implementation of compiler for a given subset of the php language into a wannabe assembly language, which is given in the assingnment.

More about the compiler:

The four main parts of the compiler:

  • Lexical analysis
  • Syntactic analysis
  • Semantic analysis
  • Code generator

php_subset_compiler's People

Contributors

brezak avatar stolo93 avatar crookedcrayon avatar alarm-clock avatar

Watchers

 avatar  avatar

php_subset_compiler's Issues

vec_ _resize end of a non-void function

DEFINE_VEC_FUNCTIONS_WITH_DESTRUCTOR in vec_resize control reaches end of a non-void function
src/vector.c: In function ‘vec_token_ptr_resize’:
src/headers/vector.h:320:1: error: control reaches end of non-void function [-Werror=return-type]
320 | }
| ^
src/vector.c:22:1: note: in expansion of macro ‘DEFINE_VEC_FUNCTIONS_WITH_DESTRUCTOR’
22 | DEFINE_VEC_FUNCTIONS_WITH_DESTRUCTOR(token_ptr, token_ptr, free);

vec_push_back neuklada od nuli

Funkcia vec_push_back pri pushnuti prveho prvku ulozi prvok na index 1 nie nula co neviem ci je bug alebo to tak ma bit

vec_push_front stale segfaultuje

Pri volani funkcie new_vec_with_capacity(n) sa do premenej capacity_ ulozi sizeof(type)*n ( sizeof(type) moze bit vecsi nez 1 ).
https://github.com/stolo93/IFJ_2022/blob/314fa6acaf2f8f286ca7dd04911d80b46b76fa2e/src/headers/vector.h#L54
https://github.com/stolo93/IFJ_2022/blob/314fa6acaf2f8f286ca7dd04911d80b46b76fa2e/src/headers/vector.h#L168

Cize sa do kapacity ulozi velkost alokovaneho priestoru v pamati miesto max poctu prvkov na ulozenie co by sa tam asi malo ukladat.
Tim padom podmienka vo funkcii vec_push_front nema zmysel:
https://github.com/stolo93/IFJ_2022/blob/314fa6acaf2f8f286ca7dd04911d80b46b76fa2e/src/headers/vector.h#L97

lebo ak len_ bude max pocet prvkov kolko mozem ulozit do pola tak to bude vzdy mensie nez alokovany priestor (jedine ak robime s datovim typom char tak by to fungovalo, neskusal som). Dalej ked je tato funkcia volana prvi krat tak len_ bude nula pri volani:
https://github.com/stolo93/IFJ_2022/blob/314fa6acaf2f8f286ca7dd04911d80b46b76fa2e/src/headers/vector.h#L43

cize nastane (size_t)0-1 co podtecie a for loop segfaultne.

Interner may produce undefined behaviour if a new string is interned.

Details:
If the interner already has at least one string in it then interning a string which should be placed at the end of the backing array when sorting with strcmp, the intern function will produce a pointer one past the end of the backing array and then attempt to use it in a strcmp function. strcmp will then attempt to de-reference this pointer and if we're lucky segfault.

htab.c not included in Makefile src path

Hashing table can not be built

htab.c should either be placed in the src file or path to this file has to be given to Makefile explicitly in VPATH variable (I may not be correct about this).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.