punk_parser 0.0.0

Parser for Punk language.
Documentation
// Copyright (C) 2020 OTLab
//
// This file is part of Punklang.
//
// Punklang is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// Punklang is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Punklang.  If not, see <http://www.gnu.org/licenses/>.

#[allow(unused_imports)]
use crate::lexer::Lexer;

lalrpop_mod!(pub punk_syntax);

#[test]
fn punk_parser_test() {
    let e0 = punk_syntax::ExprParser::new().parse(Lexer::new(" (22 )"));
    assert!(e0.is_ok());
    println!("{:?}", e0);
    assert!(punk_syntax::ExprParser::new().parse(Lexer::new("(22)")).is_ok());
}

#[test]
fn punk_module_parser_test() {
    let case = "  def _foo (a:int, b:int): int { \"t\\\"mp\"; }";
    let e0 = punk_syntax::ModuleParser::new().parse(Lexer::new(case));
    println!("{:?}", e0);
    assert!(e0.is_ok());
}