This repository contains a simple Lexical Analyzer implemented in JavaScript for JavaScript code. The purpose of this tool is to break down the input JavaScript code into individual tokens, providing a foundational step in the process of building a compiler or interpreter.
Additionally, the project includes HTML and CSS components for a user-friendly interface to visualize the output of the Lexical Analyzer.
-
Lexical Tokenization: The analyzer breaks down the input JavaScript code into tokens, such as keywords, identifiers, literals, and operators.
-
Configurable: Easily configure the analyzer to include or exclude specific types of tokens based on your needs.
-
Output Formatting: The tool produces a structured output, making it easier to understand and work with the generated tokens.
-
User Interface: The project includes HTML and CSS components for a table-based interface to display the token information.
Follow these steps to use the JavaScript Lexical Analyzer in your project:
-
Clone the Repository:
git clone https://github.com/pardis-mdd/lexical-analyzer.git
-
Include the Analyzer and UI files:
- Copy the
lexicalAnalyzer.js
,index.html
, andstyles.css
files into your project. - Include the files in your HTML file.
<script src="path/to/lexicalAnalyzer.js"></script> <link rel="stylesheet" type="text/css" href="path/to/styles.css">
- Copy the
The Lexical Analyzer recognizes the following token types:
Keyword
Identifier
Literal
Operator
Punctuation
The output table is designed to present the analyzed tokens in a clear and organized manner. It includes the following columns:
Type
Value
Line
Index
Block
Included in this repository is a sample JavaScript file, test.js
, that you can use to test the Lexical Analyzer. Modify and experiment with the contents of test.js
to observe how the analyzer processes different JavaScript code structures. Use this testing script to ensure the correct functionality of the lexical analysis process in various scenarios.