emu_r060's Introduction
README ------ The project deals with development of a lexer and parser for our language The following are the files and corresponding use 1. lexemes.h - has definition of various tokens 2. lexer.c - The lexer code 3. parse_table.h - The parse table and rule list 4. parser.c - The parser code 5. symbol_table.h - The symbol table code which is populated with requisite data Data flow --------- The lexer takes in the input of a source code written in the language, it scans it character by character in order to detect lexemes which are listed as an enum in the lexemes.h file. Once it does, it writes it to a .lexer file which can be read during later processing stages, it also writes into a symbol table (as defined in symbol_table.h) the necessary details when it scans a identifier. The parser now reads this file and derives a top-down Left most derivation with one lookup. The LL(1) parse table is available in the parse_table.h file and is used to look up which rule to use for expansion from an list of rules also available in parse_table.h. If any errors are detected, it is thrown with appropriate error messages. As this is done, a parse tree is simultaneously generated which is used to generate AST later on. The AST generation phase converts the parse tree generated in the parser phase into an Abstract Syntax Tree. It does this by first removing unecessary tokens without children in a depth first manner (such as tokens corresponding to punctuators like braces, or tokens that were not expanded or whose children were all in turn removed). It next "folds" the tree by removing nodes with only one child, significantly compressing it. Finally, it "elevates symbols", pushing up operations into the parent node, compressing the tree further. The AST is extremely compact at this stage, and is fairly human readable. The semantic analysis phase comprises of two sub-phases: the type checking phase, which examines the AST to make sure that the program conforms to the type rules, and the function checking phase, which ensures that the functions definitons and the assignment of the return values has been done as expected in the program. How to use? ----------- run "make" in the directory Pass the input program as a command line argument to the necessary executable Note: "make clean" removes all system generated files in the current directory
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.