Skip to content

sheimi/tiny-lex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TINY-LEX(MyLex)

Overview

MyLex is a tiny lexical analyzer implemented in C++ and it is my home work of compiler.

STEPS

  1. parse .mylex file
  2. generate a list of NFA by the regex strings
  3. generate a large NFA by combining the NFAs
  4. convert the NFA to a DFA
  5. minimize the DFA
  6. generate the c code from DFA

Some Important Algorithms

  1. convert regex to postfix expression
  2. convert postfix expression to NFA, reference
  3. convert NFA to DFA
  4. minimize DFA

Compile And Run

Environment for MyLex

  1. OS: Linux , Unix or Mac OS
  2. Compiler: g++ or clang
  3. Library: Boost

Environment for c code generated by MyLex

  1. OS: Linux , Unix or Mac OS
  2. Compiler: gcc or clang, Must Use Compilers Which Support C99

Compiler MyLex

For Debug
  make DEBUG=1

Not For Debug
  make

How to use

mylex infile [outfile](default output to stdout)

Sample

make
./mylex sample/c_lex.mylex > c_lex.c
make c_lex

MyLex Syntax

File Format

[N] the number of entries
[Entry]
[Entry]
...

Entry Format

[Regex]
[Handler] with the param (shm_str)
========= (at least 4 '=')

About

My homework for compiler -- a tiny lexical analyzer generator

Resources

Stars

Watchers

Forks

Packages

No packages published