Skip to content

GiannisProkopiou/Python4.0-Compiler-1

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 

Repository files navigation

Python4.0 Compiler

This is an attempt to implement a truncated version of a Python3 Compiler. It's a Lexical, Syntax and Sematic Analyzer mix.

Team 👪

Apostolos Kontarinis
Agisilaos Kounelis
Ioannis Prokopiou
Ioannis Sina

Supported Features ✊

Semantic analysis:

  • Variables: initialization (int, float, string), overriding variables with the same name, execution of arithmetic operations (* / - +), support order of operations.
  • Dictionaries: initialization(keys: primitive types, values: everything), implementation of items() and setdefault(keyname, value=None) functions.
  • print(): implementation of the function. Fully compatible with variables and dictionaries.

Syntax & Lexical analysis:

  • Comments
  • Modules Import
  • Classes: definition, constructor definition, object creation.
  • Functions: definiction, call.
  • Conditional Statements: if, elif, else.
  • For Loops
  • Lambda Functions

Compile & Run - Classic Way 😐

$ flex calc.l
$ bison -y -d calc.y
$ gcc -c y.tab.c lex.yy.c
$ gcc linked_list.c -c
$ gcc linked_list.c y.tab.c lex.yy.c -o calc -lm
$ ./calc input.py

Compile & Run - Alias Way 😉

$ alias python4='clear && flex calc.l && bison -y -d calc.y && gcc -c y.tab.c lex.yy.c && gcc linked_list.c -c && gcc y.tab.c lex.yy.c linked_list.c -o calc -lm && ./calc'
$ python4 input.py

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Yacc 67.4%
  • C 12.3%
  • Lex 12.1%
  • Python 8.2%