Skip to content

arhamchopra/almost-c-compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is the README for our C compiler implemented in Python

Source language : C, Platform : Intel X86, Implementation : Python.

Usage instructions

For running standalone lexer for

./src/lexer <input file>

For running the parser,

./src/parser <input file name>

The output produced will be in the file ParseTree.png by default.

Usage Options

Lexer

To start lexer in command line mode, the command is

./lexer.py

To pass the input files to lexer, the command is

./lexer.py <filename> <filename> <more files>

Parser

To find the usage information, the command is

./parser.py -h

To find the version, the command is

./parser.py -v

To produce output in user defined file name, the command is

./parser.py -o <output file name> <input file name>

For removing the extra files generated, the command is

make clean

##Libraries used

  1. python2 or python3
  2. Python Lex/Yacc (ply) by David Beazley
  3. Pydot Library

##Additional features ##Error reporting ###If there is an error in the source code the parser reports most (and more) errors in the file but does not generate the graph.

References Grammar lex and yacc files : https://github.com/eliben/pycparser

Test Code References Code1.c: https://www.programiz.com/c-programming/examples/prime-number-intervals

Code2.c: https://www.programiz.com/c-programming/examples/quadratic-roots

Code3.c:https://www.programiz.com/c-programming/examples/product-numbers

Code4.c https://www.tutorialspoint.com/data_structures_algorithms/merge_sort_program_in_c.htm

Code5.c https://www.programiz.com/c-programming/examples/remainder-quotient

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published