Skip to content
This repository has been archived by the owner on Mar 29, 2022. It is now read-only.

Wandu/Compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wandu Compiler

Latest Stable Version Latest Unstable Version Total Downloads License

[EXPERIMENT] PHP Base Compiler(Lexical Analyzer).

Installation

composer require wandu/compiler

Useage

LexicalAnalyzer

Example.

$lexer = new \Wandu\Compiler\LexicalAnalyzer([
    '\\+' => function () {
        return 't_add';
    },
    '\\-' => function () {
        return 't_minus';
    },
    '\\*' => function () {
        return 't_multi';
    },
    '\\/' => function () {
        return 't_divide';
    },
    '\\=' => function () {
        return 't_equal';
    },
    '[1-9][0-9]*|0([0-7]+|(x|X)[0-9A-Fa-f]*)?' => function ($word) {
        return "t_number";
    },
    '\s' => null,
]);

$lexer->analyze('10 + 20 = 0')); // ['t_number', 't_add', 't_number', 't_equal', 't_number',]

References

About

[READ ONLY] [EXPERIMENT] PHP Base Compiler(Lexical Analyzer).

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages