npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mandel59/lemon-js

v0.1.0

Published

Lemon.JS is an LALR(1) parser generator for JavaScript based on Lemon parser generator for C included in SQLite package distribution.

Downloads

8

Readme

LEMON.JS - LALR(1) Parser Generator for JavaScript

Lemon.JS is an LALR(1) parser generator for JavaScript based on Lemon parser generator for C included in SQLite package distribution.

Parser Code Base

Files lemon.c, lempar.c, lemon.html are extracted from SQLite v3.17.0. Original parser generator code is slightly fixed to produce JavaScript compatible statements. Parser template translated from C to JavaScript. Source comments mostly not touched to keep it easy diff against original file.

Both original C version and patched JS version are included for side by side comparison for reference.

Installation

Compile lenon-js.c with any C compiler and place in anywhere with lempar.js side by side.

Compilation

Prerequisites: C compiler, for example GCC.

gcc -o lemon-js -O2 lemon-js.c

Usage

lemon-js <filename>.y

See http://www.hwaci.com/sw/lemon/lemon.html for more details.

Special Directives

See lemon.html for additional documentation.

  • %name - Set parser class name (default is "Parse")
  • %include - Include code in the beginning of file (usefull for imports)
  • %code - Include code in the end of file (usefull for exports or main code)
  • %token_destructor - Define code which will be executed on token destruction.
  • %default_destructor
  • %token_prefix - Define token name prefix.
  • %syntax_error - Define custom error handler for syntax erorrs.
  • %parse_accept - Define handler for all accepted tokens.
  • %parse_failure - Define handler for parse errors.
  • %stack_overflow - Define handler for stack overflow.
  • %extra_argument - NOT SUPPORTED
  • %token_type - NOT SUPPORTED
  • %default_type - NOT SUPPORTED
  • %stack_size - Set default stack size.
  • %start_symbol
  • %left - Set left associative tokens.
  • %right - Set right associative tokens.
  • %nonassoc - Set non associative tokens.
  • %destructor - Define custom parser destructor.
  • %type - NOT SUPPORTED
  • %fallback - Define fallback logic for tokens.
  • %wildcard - Define WILDCARD token.
  • %token_class - NOT SUPPORTED

Notes:

  • some expressions, for example, regular expression /\*/ could break lemon parser in %code or %include sections.
  • the best place to put something like module.exports = ParserName; or export default ParserName; is in %code section.

TODO

  • add some tests for different options
  • document variables
  • YYNOERRORRECOVERY ?
  • YYERRORSYMBOL ?
  • rename methods, variables, get rid of YY prefixes?
  • enable asserts, could be usefull for testing

Alternative Lexers

  • https://github.com/tantaman/lexed.js
  • https://github.com/aaditmshah/lexer
  • https://github.com/YuhangGe/jslex

Alternative Parsers

  • https://github.com/sormy/flex-js
  • http://jscc.brobston.com
  • http://zaach.github.io/jison/
  • https://pegjs.org