Coder Social home page Coder Social logo

etymu's Introduction

etymu

Build Status Godoc

Generates lexers from language-agnostic lexer files. All the good stuff from flex/lex, none of the bad decisions.

Why not flex/lex?

flex and lex implement the ".l" file format, which suffers from the notable problem of combining data with code - that is, C code is written inline with the definition of the language's tokenization. It's impossible to use an ".l" file to generate code for any language other than C. Therefore, if you have a lex-able format and want to distribute parsers for more than one languages, you will have to write one lex file for each language - and find a program which will translate that file into the desired language correctly (hint: it's not easy).

Instead of all that, this program takes one format and can create multiple languages worth of lexer implementations for that format.

This came out of the author's frustration trying to even tokenize a bash file - because bash's tokenization is so closely coupled with its implementation.

How does the format and usage differ from lex?

  • Lex files have three parts; definition, rules, and code. "el" files have no code section, and no ability for inline code.
  • Regex are Go, not the original C regex used by lex.
  • If any syntax is not specified, it is an error. Lex will usually just print unused sections of the file.
  • Lex uses logic that involves matching a token to the longest rule. etymu prefers rule precedence - top to bottom, the first rule that matches the token string will be used.

What languages does this support?

Right now, in this earliest phase, only Go. However, the entire system is set up for anyone to write a generator for any language. The author simply hasn't needed anything but Go yet, but isn't under the impression that only Go users want to write tokenizers.

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.