Coder Social home page Coder Social logo

syntax-analyser's Introduction

Syntax Analyser

Feature Set

  • A basic syntax and semantic analyser of C-based programs supporting following features:
    • Data types - int, char
    • Assignments to the variables can be done at the time of declaration.
    • IO get x;(taking x as input from stdin)
      put x;(printing x at stdout)
    • Conditional statement syntax: id = expression ? expression:expression;
    • Relational Operators supported: {>, <, ~}
    • Arithmetic Operators supported: {+, -, *}
    • Only main() function is supported. The function may definition may contain arguments and return statement.
    • White-spaces and new lines within statements are ignored.
    • Statements end with ;
  • Steps involved in the construction of the Compiler -
    • Construction of CFG for the language.
    • Building Lexical Analyser to scan the stream of characters from a program written in above language and generate a stream of tokens to pass to the parser.
    • Building a Bottom-up parser for this language using SLR(1) parsing technique.

File Description

CFG

  • mod.txt: Map from symbols of the language to letters of CFG
  • LetterCFG.txt: CFG grammar productions
  • augCFG.txt: Human readable CFG grammar production

INPUT

  • input.cpp: Input file to analyse
  • keywords.txt: File for keywords

OUTPUT

  • tokens.txt: Output from Lexical Analyser
  • DFA_for_Lexical.txt: DFA states
  • StatesFile.txt: Item set created
  • GoToTransitions.txt: Goto (I,a) for all item set
  • Parsing Table.csv: SLR parsing table

Steps to run

  • Put the file to be analysed in input.cpp
  • Open a terminal and go to the project's directory
  • Run command g++ -o compile driver.cpp -w
  • Run command ./compile input_file

Output Screenshot

Output

syntax-analyser's People

Contributors

vaibhavjoe101 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.