Question: / * * * * * * * * * * * * * * * * * * * * * * * *
Principles of Programming Languages
Fall
Authors: Sheryl D'Mello
CFG for tinyL LANGUAGE
::
::
:: ;
::
::
::
::
::
&
:: a b c d e f
::
NOTE: tokens are exactly a single character long
Example expressions:
a;a
a&;a
#include
#include
#include
#include "Instr.h
#include "InstrUtils.h
#include "Utils.h
#define MAXBUFFERSIZE
#define EMPTYFIELD xFFFFF
#define token buffer
GLOBALS
static char buffer NULL; read buffer
static int regnum ; for next free virtual register number
static FILE outfile NULL; output of code generation
Utilities
static void CodeGenOpCode opcode, int field int field int field;
static inline void nexttoken;
static inline int nextregister;
static inline int isdigitchar c;
static inline int todigitchar c;
static inline int isidentifierchar c;
static char readinputFILE f;
Routines for recursive descending parser LL
static void program;
static void stmtlist;
static void morestmts;
static void stmt;
static void assign;
static void read;
static void print;
static int expr;
static int variable;
static int digit;
Definitions for recursive descending parser LL
static int digit
int reg;
if isdigittoken
ERRORExpected digit
;
exitEXITFAILURE;
reg nextregister;
CodeGenLOADI reg, todigittoken EMPTYFIELD;
nexttoken;
return reg;
static int variable
YOUR CODE GOES HERE
int reg;
if isidentifiertoken
ERRORExpected variable
;
exitEXITFAILURE;
reg nextregister;
CodeGenLOAD reg, token, EMPTYFIELD;
nexttoken;
return reg;
static int expr
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
