Skip to content
/ ft_lex Public

Lex is a program that generates lexical analyzers. This is a POSIX compliant lex clone in Rust.

Notifications You must be signed in to change notification settings

0xEDU/ft_lex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ft_lex

If I have seen further it is by standing on the shoulders of Giants.

What is this?

This is an École 42 project about recreating the lex utility, keeping it POSIX compliant. This version is being built in Rust, for no specific reason, I just thought it would be a good project for learning Rust.

How it works?

Basically lex will parse a lexer.l source file, which is divided into 3 sections: Definitions, Rules and UserSubroutines:

  1. Definitions will be copied to the final file as is (if they are as described in the specification), dunno what to do with substitution strings yet;
  2. Rules will be treated somewhat similarly, code in the prelude will be copied to a yylex() function, the regex rules will go through a regex engine and the output will be written to yylex() in a sort of if rule then action;
  3. UserSubroutines will be copied to the final file as is.

Project Design

  • The design for this project is heavily inspired on DOOM's engine, each step of the lexer should be in a self-contained Rust module that expose only an invoke() function and it's I/O types, the logic of the module should be private to the module.
  • Error handling should be done by bubbling up a value from LexError enum.

Modules

  1. Input Loader.
    • Description: Should be responsible for handling options, opening and parsing (POSIX-compliant) input file(s) and generating a data structure containing relevant information about the file.
    • Input: Command line arguments.
    • Output: An Intermediate Representation of the parsed lex source.
  2. ...

Reference

About

Lex is a program that generates lexical analyzers. This is a POSIX compliant lex clone in Rust.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages