GithubHelp home page GithubHelp logo

loquat-token's Introduction

loquat-token

Token parser extension for loquat.

Install

npm install --save loquat-token

Usage

Make sure loquat (or loquat-core) has already been installed.

const lq = require("loquat")();
// use extension
lq.use(require("loquat-token"));
// language definition
const def = new lq.LanguageDef({
    commentStart  : "/*",
    commentEnd    : "*/",
    commentLine   : "//",
    nestedComments: false,
    idStart       : lq.letter,
    idLetter      : lq.alphaNum,
    opStart       : lq.oneOf("+-*/%=<>!&|"),
    opLetter      : lq.oneOf("+-*/%=<>!&|"),
    reservedIds   : ["if", "else", "for"],
    reservedOps   : ["=", "=>"],
    caseSensitive : true
});
// make token parser from the definition
const tp = lq.makeTokenParser(def);
/*
 * { whiteSpace: Parser { _func: [Function] },
 *   lexeme: [Function: lexeme],
 *   symbol: [Function: symbol],
 *   parens: [Function: parens],
 *   braces: [Function: braces],
 *   angles: [Function: angles],
 *   brackets: [Function: brackets],
 *   semi: Parser { _func: [Function] },
 *   comma: Parser { _func: [Function] },
 *   colon: Parser { _func: [Function] },
 *   dot: Parser { _func: [Function] },
 *   semiSep: [Function: semiSep],
 *   semiSep1: [Function: semiSep1],
 *   commaSep: [Function: commaSep],
 *   commaSep1: [Function: commaSep1],
 *   decimal: Parser { _func: [Function] },
 *   hexadecimal: Parser { _func: [Function] },
 *   octal: Parser { _func: [Function] },
 *   natural: Parser { _func: [Function] },
 *   integer: Parser { _func: [Function] },
 *   float: Parser { _func: [Function] },
 *   naturalOrFloat: Parser { _func: [Function] },
 *   charLiteral: Parser { _func: [Function] },
 *   stringLiteral: Parser { _func: [Function] },
 *   identifier: Parser { _func: [Function] },
 *   reserved: [Function: reserved],
 *   operator: Parser { _func: [Function] },
 *   reservedOp: [Function: reservedOp] }
 */

License

MIT License

Author

Susisu (GitHub, Twitter)

loquat-token's People

Contributors

susisu avatar

Watchers

 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.