Git Product home page Git Product logo

mostofashakib / lexical-analyzer Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 24 KB

A lexical analyzer that can identify lexemes and tokens found in a source code file provided by the user. Once the analyzer has identified the lexemes of the language and matched them to a token group, the program then prints each lexeme and token pair to the screen

License: GNU General Public License v3.0

Makefile 1.39% C++ 98.61%
compilers compiler-designs lexical-analyzer

lexical-analyzer's Introduction

Lexical-Analyzer

A lexical analyzer that can identify lexemes and tokens found in a source code file provided by the user. Once the analyzer has identified the lexemes of the language and matched them to a token group, the program then prints each lexeme and token pair to the screen

Author: Mostofa Adib Shakib

BNF Grammer Rule

P   ::=     S
S   ::=     V:=E | read(V) | write(V) | while C do S od | S;S
C   ::=     E < E | E > E | E = E | E <> E | E <= E | E >= E
E   ::=     T | E + T | E - T
T   ::=     F | T * F | T / F
F   ::=     (E) | N | V
V   ::=     a | b | … | y | z | aV | bV | … | yV | zV
N   ::=     0 | 1 | … | 8 | 9 | 0N | 1N | … | 8N | 9N

Lexeme & Token Pair

|      Lexeme      |     Token     |
| ---------------  | ------------- |
|       :=         |  ASSIGN_OP    |
|       +          |  ADD_OP       |
|       do         |  KEY_DO       |
|       <          |  LESSER_OP    |
|       -          |  SUB_OP       |
|       od         |  KEY_OD       |
|       >          |  GREATER_OP   |
|       *          |  MULT_OP      |
|   variable name  |  IDENT        |
|       =          |  EQUAL_OP     |
|       /          |  DIV_OP       |
|     integer      |  INT_LIT      |
|       <>         |  NEQUAL_OP    |
|      read        |  KEY_READ     |
|       (          |  LEFT_PAREN   |
|       <=         |  LEQUAL_OP    |
|     write        |  KEY_WRITE    |
|       )          |  RIGHT_PAREN  |
|      >=          |  GEQUAL_OP    |
|     while        |  KEY_WHILE    |
|       ;          |  SEMICOLON    |

lexical-analyzer's People

Contributors

mostofashakib avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

ferdousakash

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.