Skip to content

shivamyeshu/Mini-Lexer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

MiniLang Lexer

This project is a simple lexer (tokenizer) for a custom mini-language called MiniLang. It tokenizes an input string into keywords, identifiers, numbers, and operators, laying the foundation for building an interpreter or compiler. The lexer can be easily extended and enhanced as you explore more advanced language processing concepts.

Features

  • Tokenizes keywords (ye, bolo).
  • Recognizes identifiers (alphanumeric strings that aren't keywords).
  • Supports numbers (sequences of digits).
  • Handles basic operators (+, -, *, /, =).
  • Skips over whitespace (spaces and newlines).

How It Works

The lexer scans the input string character by character:

  1. Keywords: Recognizes the words ye (for variable declaration) and bolo (for output).
  2. Identifiers: Any alphanumeric string that isn't a keyword.
  3. Numbers: Any sequence of digits is tokenized as a number.
  4. Operators: Supports arithmetic and assignment operators (+, -, *, /, =).
  5. Whitespace: Ignores spaces and newlines during tokenization.

To run the lexer

compiler(ye x = 10 ye y = 20 ye sum = x + y bolo sum);

  • happy coding

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published