4.6 Grammar for miniC

In Chapter 12, we shall discuss in detail, the development of a compiler for miniC language, which is a simplified version of C. We give here a slightly trimmed version of the yacc grammar for that language. This grammar is an extended and modified version of grammar for hoc6 put in public domain by AT&T. The copyright of the original hoc6 is held by AT&T.

%union { Symbol *sym; /* symbol table pointer */ util inst; /* machine instruction */ int narg; /* number of arguments */ } %token <sym>NUMBER STRING PRINT VAR BLTIN UNDEF WHILE FOR IF ELSE %token <sym>FUNCTION PROCEDURE RETURN FUNC PROC READ INT IVAR SVAR END %token <narg>ARG %type <sym> expr %type <inst> stmt asgn prlist stmtlist %type <inst>cond while for if begin end ...

Get Compilers: Principles and Practice now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.