GithubHelp home page GithubHelp logo

yang-rs's Introduction

yang-rs

Rust YANG parser. Supporting RFC7950.

Usage

Parse and dump a YANG file.

cargo run YANG-FILE

Code example to parse YANG string and get parsed Rust object.

use yang_rs::parser::Parser;
use yang_rs::config::Config;
use yang_rs::core::YangStmt;

let mut f = File::open(filename)?;
let mut s = String::new();

f.read_to_string(&mut s)?;

let yang = Parser::parse_yang_from_string(s, config)?;
match yang {
    YangStmt::ModuleStmt(module) => {
        println!("arg {:?}", module.arg());
        println!("arg {:?}", module.module_header().yang_version());
    }
    _ => {}
}

yang-rs's People

Contributors

amtelekom avatar sjtakada avatar

Watchers

 avatar  avatar

Forkers

amtelekom wastack

yang-rs's Issues

Parser: double-quoted multi-line string after multi-line block comment

Given the following input for the parser:

/*this is a multi
line comment */ "and this is a quoted multi
                              line string"

When calling parser.get_token():

  • Expected result: Token::QuotedString("and this is a quoted multi\nline string")
  • Actual result: Token::QuotedString("and this is a quoted multi\n line string")

It has two additional spaces.

Special characters not processed in double quoted string

rfc-6.1.3:

Within a double-quoted string (enclosed within " "), a backslash
character introduces a representation of a special character, which
depends on the character that immediately follows the backslash:

\n      newline
\t      a tab character
\"      a double quote
\\      a single backslash

The backslash MUST NOT be followed by any other character.

Expected
the following double quoted string: a\nb\nc should be translated to:

a
b
c

Actual
The contents of the token is: a\nb\nc

Parser: the parser defines Token::Identifier, whereas an identifier is not a token

RFC-7950 defines tokens here:
https://www.rfc-editor.org/rfc/rfc7950.html#section-6.1.2

And identifiers are defined here:
https://www.rfc-editor.org/rfc/rfc7950.html#section-6.2

The parser defines a token Token::Identifier that is not mentioned in the RFC as a token, only in the ABNF grammar.

This misconception does not lead to any errors, but confusing for the consumer of the Parser. For example, this way, the Token::Identifier may contain a prefix.

The following input:

"my extension" "my argument";

should throw an error, but not on tokenising (lexer) level, but on parser level.

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.