GithubHelp home page GithubHelp logo

aleksamcode / bnf-parser Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 71 KB

BNF (Backus-Naur Form) LL(k) parser.

C# 100.00%
bnf top-down-parser parsing context-free-language ll-grammar backus-naur-form regex regular-expression bnf-parser

bnf-parser's Introduction

BNF parser

Parser reads a grammar definition expressed in BNF (Backus-Naur Form) at runtime after which it parses inputed strings.

Description

The project idea was to create a text parser that would parse the contents of the input file, as specified by the grammar in the modified Backus-Naur form. The grammar is given in a .bnf file.

The modified BNF form is written based on the rules for the standard BNF form, with the following appendices:

  • <a> ::= regex(regular_expression)

    Denotes a node that is determined on the basis of a regular expression specified in parentheses. In a given case, <a> represents any expression that matches the given regex.

  • <a> ::= standard_expression

    Denotes a node that is determined based on tables of standard regular expressions, where in place of standard_expression can be any of the items from the following table.

standard_expression Meaning
phone_number Phone number with or without international and country call codes, with different delimiters
mail_address Properly formatted e-mail address
web_link Properly formatted absolute URL
number_constant Integer or floating-point constant
big_city Any city from a parsers list

Implementation specifications

  • The grammar (configuration) file, must contain, in a modified BNF form, a specification of the parsing method.

  • XML tags of an output file must be named based on the token name in the BNF form, so that the resulting parsing tree is clear and equivalent to the specified BNF form.

  • In case the BNF grammar is incorrect, throw an exception describing where the error occurred (i.e. the line from the BNF grammar on which the error occurred).

  • In case a string from an input file cannot be parsed according to the BNF form, skip that input line.

Dependencies

Projects that BNF parser uses and/or is dependent on:

References

  • Peter Linz - An Introduction to Formal Languages and Automata

  • Peter Sestoft, Ken Friis Larsen - Grammars and parsing with C# 2.0

  • Anil Maheshwari, Michiel Smid - Introduction to Theory of Computation

  • Dick Grune, Ceriel J. H. Jacobs - Parsing Techniques: A Practical Guide (Monographs in Computer Science)

To-Do List

  • Implement download of city names from a web API instead of using hard-coded city names in code.
  • Create a GUI for BNF parser.

bnf-parser's People

Contributors

aleksamcode avatar

Stargazers

 avatar

Watchers

 avatar  avatar

bnf-parser's Issues

Missing Test Sources

Hi,
I'm interested in your project and would like to learn sth about BFN parsing.
I downloaded the source code and tried to open it in MS VisualStudio 2023 and got an error, that sub-project 'test' is missing. Would it be possible to check in the missing source files into github?
Best Regards
Marcel

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.