How to use the parsimmon.eof function in parsimmon

To help you get started, we’ve selected a few parsimmon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yorkie / node-orgmode / lib / parser.js View on Github external
'use strict';

const Parsimmon = require('parsimmon');
const tagsParser = require('./tags-parser')
const string = Parsimmon.string;
const regex = Parsimmon.regex;
const succeed = Parsimmon.succeed;
const alt = Parsimmon.alt;
const seq = Parsimmon.seq;
const seqMap = Parsimmon.seqMap;
const lazy = Parsimmon.lazy;
const eof = Parsimmon.eof;
const ignore = regex(/\s*/m);
function lexeme(p) {
  return p.skip(ignore);
}

// Base context-free grammar
const colon = lexeme(string(':'));
const flag = lexeme(string('#+'));
const startOfLine = lexeme(regex(/\n*/));
const identifier = lexeme(regex(/[a-z]+/i));
const singleLineText = lexeme(regex(/[^\n]+/));
const multiline = lexeme(regex(/[^\*]*/));

// Complex context-free grammar
const blockOption = seq(
  startOfLine, flag, identifier, colon, singleLineText
github squiggle-lang / squiggle-lang / src / parse / comment.js View on Github external
module.exports = function(ps) {
  return P.string("#")
    .then(NotNewlines)
    .skip(Newline.or(P.eof));
};
github hydux / hydux-mutator / lib / parser.js View on Github external
    function: function (r) { return P.seqObj(r.fnKeyword, r.lparen, ['args', r.arg.sepBy(r.comma).desc('args')], r.rparen, r.lbrace, r.return, ['obj', r.letters], ['keyPath', r.field.sepBy(r._)], r.semi.or(r._), r.rbrace, P.eof); },
    lambda: function (r) { return P.seqObj(r.lparen.or(r._), ['args', r.arg.sepBy(r.comma).desc('args')], r.rparen.or(r._), r.arrow, r.lbrace.or(r._), r.return.or(r._), ['obj', r.letters], ['keyPath', r.field.sepBy(r._)], r.semi.or(r._), r.rbrace.or(r._), P.eof); },
github hydux / hydux-mutator / src / parser.ts View on Github external
lambda: r => P.seqObj(
    r.lparen.or(r._),
    ['args', r.arg.sepBy(r.comma).desc('args')],
    r.rparen.or(r._),
    r.arrow,
    r.lbrace.or(r._),
    r.return.or(r._),
    ['obj', r.letters],
    ['keyPath', r.field.sepBy(r._)],
    r.semi.or(r._),
    r.rbrace.or(r._),
    P.eof,
  ),
github hydux / hydux-mutator / src / parser.ts View on Github external
function: r => P.seqObj(
    r.fnKeyword,
    r.lparen,
    ['args', r.arg.sepBy(r.comma).desc('args')],
    r.rparen,
    r.lbrace,
    r.return,
    ['obj', r.letters],
    ['keyPath', r.field.sepBy(r._)],
    r.semi.or(r._),
    r.rbrace,
    P.eof,
  ),
  lambda: r => P.seqObj(
github hydux / hydux-mutator / lib / parser.js View on Github external
    lambda: function (r) { return P.seqObj(r.lparen.or(r._), ['args', r.arg.sepBy(r.comma).desc('args')], r.rparen.or(r._), r.arrow, r.lbrace.or(r._), r.return.or(r._), ['obj', r.letters], ['keyPath', r.field.sepBy(r._)], r.semi.or(r._), r.rbrace.or(r._), P.eof); },
    accessor: function (r) { return r.function.or(r.lambda); }
github youknowriad / averroes / scripts / editor / api / parser.js View on Github external
return P.alt(
      P.seqMap(
        P.string("{%")
          .then(P.whitespace)
          .then(P.string("name=" + blockType.name))
          .then(JSONParser.value.trim(P.optWhitespace))
          .skip(P.string("%}")),
        innerBlockParser.trim(r.newline),
        P.string("{% end %}"),
        (attributes, block) => {
          return Object.assign({}, block, {
            attributes: Object.assign(attributes, block.attributes)
          });
        }
      ),
      innerBlockParser.lookahead(P.alt(r.newline, P.eof))
    ).map(({ name, attributes }) => createBlock(name, attributes));
  };
};