Giter Club home page Giter Club logo

bnf's Introduction

The BNF(EBNF) Parser

version 0.0.0.1 (using C++17)

Lexical

parse input ( string or file ) to tokens

Syntax

using lexcial parse output as input, setup first and follow set and parse tokens according to BNF(EBNF) rules.

Note

since without left recursion check, eliminate left recursion rule before you parse it

Demo

  • seque, alter and terminal ( implemented by functions )

seque as: T==> A B C

bnf::Nseque<uchar> S{ "S" };
S( A, B, C );

alter as: T==> A|B|C

bnf::Nalter<uchar> S{ "S" };
S( A, B, C );

string as: T==> "something"

bnf::Nliteral<uchar> T{ "name of something", "something", nid_something };

state machine funcions as: T==> 'a'|'b'|...'z'

bnf::Nfunc<uchar> f{ "lowletter", _f, _frs, nid_something };
_f = [ Nfunc<uchar> &node ]->roadmap {
  ...
  return (ch>='a' && ch<='z')?matched:unmatched;
}
_frs = [ char ch ]->roadmap {
  return (ch>='a' && ch<='z')?matched:unmatched;
}

with range as: T==> 'a'{1,4}, min value is zero means allow match nothing, when max equal -1 match any number input

bnf::Nliteral<uchar> T{ "name", "a", nid_a, 1, 4 };
  • lua syntax parser ( match hexical number not implemented yet! ) in file llua.h and llua.cpp

Output

output text format is Lua string, include success or fail, stack and result size used, matched or unmatched count, if fail should print the information of match cursor

Support

[email protected]

License

Licensed under the MIT License.

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.