Skip to content

ShringariV/programmingLanguage

Repository files navigation

PLC Project

Overview

This project is an implementation of a lexical analyzer (lexer) and parser for a programming language. It converts an input source code into a sequence of tokens and constructs an Abstract Syntax Tree (AST) for further processing.

Files

Lexer

  • Lexer.java – Tokenizes an input character stream based on predefined lexical rules.
  • LexException.java – Defines exceptions for lexical errors.
  • Token.java – Represents individual tokens identified by the lexer.

Parser

  • Parser.java – Parses the tokenized input into an AST following syntactic rules.
  • Ast.java – Defines the AST structure, including expressions and statements.

Features

  • Lexical Analysis: Identifies identifiers, numbers, strings, operators, and comments.
  • Parsing: Constructs an AST from a sequence of tokens.
  • Error Handling: Throws appropriate exceptions for invalid syntax or lexical errors.

Usage

  1. Lexing
    Lexer lexer = new Lexer("let x = 5;");
    List<Token> tokens = lexer.lex();
  2. Parsing
    Parser parser = new Parser(tokens);
    Ast.Source ast = parser.parseSource();

Dependencies

  • Guava (for checkState assertions)
  • Java SE 11+

Future Improvements

  • Support for additional language constructs.
  • Error reporting with line numbers.
  • Improved AST visualization tools.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published