compilers-project

command module
v0.0.0-...-9af731a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 30, 2023 License: MIT Imports: 3 Imported by: 0

README

Simple Parser in Go

This repository contains a simple lexer and parser written in Go. The parser can handle basic assignments and if statements.

Lexer (Lexical Analysis)

The lexer (lexer.go) tokenizes input strings into a sequence of tokens. The supported token types include:

  • INTEGER: Integer literals
  • PLUS, MINUS, MULTIPLY, DIVIDE: Arithmetic operators
  • LPAREN, RPAREN: Left and right parentheses
  • ASSIGN: Assignment operator
  • ID: Identifier (variable name)
  • IF, ELSE: If statement and else keyword
  • GREATER_THAN: Greater than operator
  • LBRACE, RBRACE: Left and right curly braces

Parser (Syntax Analysis)

The parser (parser.go) processes a list of tokens produced by the lexer. It can handle simple assignments and if statements. The grammar includes:

  • Statements: Assignments and if statements
  • Expressions: Arithmetic expressions and comparisons
  • Terms and factors: Components of expressions

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL