Giter Site home page Giter Site logo

sblex's Introduction

SBLex

Latest PyPI version Latest Travis CI build status Latest CodeCov status

A simple library for tokenizing text with additional functionalities. (NOT MAINTAINED ANYMORE)

Overview

SBLex is a lexer that is capable to tokenize text with only a few lines of code, it includes as well other extra functions.

Features

  • Dependent Tokens
  • Custom Errors
  • Custom functions when a token is found
  • Custom capture groups
  • Support of multiple regular expressions

Planned Features

  • Ignore patterns
  • Documentation (Please use a IDE that supports autocomplete for docs)

Installation

PyPi

You can easily install SBLex through pip like this:

pip install SBLex

If you get an environment error, you can also try using the --user option:

pip install SBLex --user

Usage

Starting using SBLex is as easy as importing the SBLex and declaring the lexer, here you have a working example lexing the world Hello World!:

from SBLex import lex

lexer = lex.lex()

lexer.add("Hello World", r'Hello World\!')

lexer.evaluate("Hello World!")

"""
Returns:
    >>> [token(type: 'Hello World', value: 'Hello World!', line: 0)]
"""

Here is another example using a custom capturing_group.

from SBLex import lex

lexer = lex.lex()

# Try to lex: The weather today is {weather}
lexer.add(
    "The weather today is",
    r'The weather today is ([a-zA-Z]+)',
    capturing_group=1
)

lexer.evaluate("The weather today is rainy")

"""
Returns:
    >>> [token(type: 'The weather today is', value: 'rainy', line: 0)]
"""

Compatibility

SBLex is compatible with Python2 & Python3.

Licence

SBLex is under the MIT License.

Authors

SBLex was written by KadMuffin.

sblex's People

Contributors

kadmuffin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.