constexpr-macros 0.0.1-alpha1

Macros to define c++ like constexpr.
Documentation
// Copyright (c) 2018 Vladimir Motylenko
//
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT
// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. All files in the project carrying such notice may not be copied,
// modified, or distributed except according to those terms.
// TODO: Add generic in variable types arguments (support Vec<T>)
// TODO: Parse function body

function = _{ soi ~ signature ~ eoi}

signature = { "fn" ~  identifier ~
            "<"~ generics ~">" ~
            "("~ arguments  ~")" ~ ("->" ~ type_def)? }

generics = { identifier ~ ("," ~ identifier)* }

fn_keyword = _{ "fn" }

arguments = { argument ~ ("," ~ argument)* }

argument = { pat ~ ":" ~ type_def }

pat = {identifier | ("(" ~ pat ~ ("," ~ pat)* ~ ")") }

// TODO: add "," to support multiple types
type_def = {  ('a'..'z' | 'A'..'Z' | '0'..'9' | "_" | "<" | ">" | "{" | "}" )+ }

identifier = { ('a'..'z' | 'A'..'Z' | '0'..'9' | "_" )+ }

newline    = _{ "\n" | "\r\n" }
whitespace = _{ " " | "\t" }
comment    = _{ "//" ~ (!newline ~ any)* }