Skip to content

EngFook/PythCparser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#-------------------------------------------------------------------------------
# Name:         PythCparser
# Purpose:      To parse and interpret C language by using Python.
#
# Author:       Tunku Abdul Rahman University College
#               Microelectronics and Physics Division 2014
#               Goh Eng Fook
#               Lim Bing Ran
#
# Supervise by: Dr. Poh Tze Ven
#
# Created:      07/03/2013
# Copyright:    (c) 2013-2014, Goh Eng Fook & Lim Bing Ran
# License:      GPLv3
#-------------------------------------------------------------------------------

PythCparser is used to parse C language program into Abstract Syntax Tree (AST) and implement an interpreter to execute the program statements on the AST by programmed in Python. C language expressions were tokenized by using Pratt Parser which is Top Down Operator Precedence algorithm to build the AST. AST of C language keywords were designed according to their behavior. Once the AST formed, the program statements were able to interpret.

PythCparser has ability:
1)	To parse any Expression included function definition, declaration and call:

                            expression = 2 + 3 * 4 ;
                            value = 2 * 3 + value / 3 % 7 << 1 ;
                            function ( a , b ) ;
                            -- value +  - 1 ;

2)	To parse keywords:
                            if else
                            while
                            do while
                            for loop
                            switch case
                            #define
                            struct
                            enum
                            typedef 
                            size of primitive types : e.g. int , double & float

Releases

No releases published

Packages

No packages published

Languages