// Copyright (c) 2018 Vladimir Motylenko // // Licensed under the Apache License, Version 2.0 // or the MIT // license , 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) // 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)* }