Superior University Lahore: Compiler Construction
Superior University Lahore: Compiler Construction
Project Team
Student Name Program Rool number Email Address
M. Wasal BSCS BCSM-F16-324 Bcsm-f16-324@superior.edu.pk
M. Ihsan BSCS BCSM-F16-352 Bcsm-f16-352@superior.edu.pk
Bilal Rasool BSCS BCSM-F16-314 Bcsm-f16-314@superior.edu.pk
Miss Maryam
Syntax analyzer for PHP
Syntax analyzer for PHP
Project Scope:
The purpose of this project to develop a compiler that is find any type(missing tag, syntax mistake)
of error in PHP . We are using different tools to build this project. We will build a Syntax analyzer
for PHP using flex code in this project.
Introduction:
PHP syntax analyzer analyze the code for language and then show what does it really means and
find out if there is any type of syntax error(missing tag, function error) in code that the user
provide at run time. So for all these purpose we use lex tools. That will helpful for new and
inexperienced users.
Lexical Analyzer
Regular Expression:
DFA:
Lexical Code:
%{
int total =0 ;
%}
%option noyywrap
%%
("echo")|("function")|("if")|("else")|("while")|("do")|("break")|("continue")|("double")|("float")|("re
turn") { fprintf(yyout,"This is Keyword: %s\n\n",yytext);}
("php")|("case")|("sizeof")|("typedef")|("switch")|("goto") {fprintf(yyout,"This is
Keyword:%s\n",yytext);}
. {fprintf(yyout,"",yytext);}
[\t\n]+
%%
main()
{
extern FILE *yyin, *yyout;
yylex();
return 0;
}
Input File:
Output File:
Syntax Analysis
CFG(un-ambiguous and Right Recursive):
CFG(Deterministic):
First() & Follow():
Algorithm:
LL(1)
Parsing Table:
Stack Implementation:
Semantic Analysis(S attributes):