/************************************************* * AUTHOR : Jatin Bhateja * jatin_bhateja@indiatimes.com **************************************************/ jlang Complier ============== jlang is a small and easy to learn language designed by Jatin Bhateja. It chiefly does mathematical operations on data variables.Languge is easy to unterstand and is basically develoved for educational purpose. jlang complier is small and tidy complier written by the language designer to translate the source language to machine language. Compiler has a LR(1) parser constructed using bison. Compiler Working ================ Complier initialy creates an AST for jlang source program. Once complete AST is constructed then semantic checks are performed on the tree.Along with semantic checking constant folding optimization is performed on the AST. Before semantic checking symbol resolving is done so that symbols in AST point to their symbol table entry. After doing semantic checking AST is translated to intermediate code (iCode).After this stage CSE , constant/copy propogation optimization ,dead code elemination and some algebraic optimization is performed on the iCode. Finally optimized iCode is converted to MACHINE language by backend. About the Assembly ================== Machine language constitutes of simple and self explanatory instruction set. Assembly is generated in AT&T Format. This directory contains following files: ======================================== a. laxer.l : Lexical Analyzer b. parser.y : Parser + symantic analyzer + iCode generator + Optimization passes. c. Makefile Building the jlang complier: ============================ Execute the following command to build the compiler. "make all" To clean the directory execute the following command "make clean" Build process generates the following files "comp" : Compiler frontend "parser.output" : This file contains the gramatical specification of the lanuage. HOW To generate the AST & iCode ============================== A. comp B. During compilation output after each phase is dumped on the console. Example. var : a,b,c; start a = b * c; c = a / b; end C. Usage can be seen by invoking following command comp -h Bug Reporting: ============== Report bug along with following information to jatin_bhateja@indiatimes.com a. Test Case. b. Compiler Version. c. Severity. SAMPLE PROGRAMS: ================ TestCase 001 : var:a,b,c,d,e; start a=1+3; b= a * c + d; d = 1; e = d + a; end TestCase 002: var : a,b; start a = 1 + 4 * 3 + b; end TestCase 003: var : a,b,c; start a = b/c; a = 1+5*a; end TestCase 004: var: a,b,c,d,i; start a=b; b=a; end