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/>.

#[derive(Debug)]
pub struct SrcModule(pub Vec<SrcItem>);

#[derive(Debug)]
pub struct SrcIdent(pub String);

#[derive(Debug)]
pub enum SrcItem {
    Def(SrcIdent, Option<SrcType>, Option<SrcExpr>),
}

#[derive(Debug)]
pub enum SrcStmt {
    BlockStmt(Vec<Box<SrcStmt>>),
    ExprStmt(Box<SrcExpr>),
}

#[derive(Debug)]
pub enum SrcExpr {
    IntegerLiteral(i64),
    StringLiteral(String),
    ParenExpr(Box<SrcExpr>),
    FunctionExpr(Vec<(SrcIdent, SrcType)>, SrcType, SrcStmt),
}

#[derive(Debug)]
pub enum SrcType {
    NamedType(SrcIdent),
    ArraowType(Vec<Box<SrcType>>, Box<SrcType>),
}