Compare commits
No commits in common. "fc463d38070f44da8c4d9173717f8412d932c72c" and "032fe5fed9370d497c94dc04a0fc8d90521b2f7a" have entirely different histories.
fc463d3807
...
032fe5fed9
@ -293,7 +293,8 @@ fn func_signature(input: Span) -> ParseResult<Signature> {
|
|||||||
"func-signature",
|
"func-signature",
|
||||||
preceded(
|
preceded(
|
||||||
kw("fn"),
|
kw("fn"),
|
||||||
cut(alt((
|
cut(verify(
|
||||||
|
alt((
|
||||||
map(normal_fn, |(name, params, type_anno)| Signature {
|
map(normal_fn, |(name, params, type_anno)| Signature {
|
||||||
name: rc_string(name.fragment()),
|
name: rc_string(name.fragment()),
|
||||||
operator: false,
|
operator: false,
|
||||||
@ -306,21 +307,18 @@ fn func_signature(input: Span) -> ParseResult<Signature> {
|
|||||||
params,
|
params,
|
||||||
type_anno,
|
type_anno,
|
||||||
}),
|
}),
|
||||||
))),
|
)),
|
||||||
|
|sig| sig.params.len() < 256,
|
||||||
|
)),
|
||||||
),
|
),
|
||||||
)(input)
|
)(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn formal_params(input: Span) -> ParseResult<Vec<FormalParam>> {
|
fn formal_params(input: Span) -> ParseResult<Vec<FormalParam>> {
|
||||||
context(
|
delimited(tok(char('(')), separated_list0(tok(char(',')), formal_param), tok(char(')')))(input)
|
||||||
"formal-params",
|
|
||||||
verify(
|
|
||||||
delimited(tok(char('(')), separated_list0(tok(char(',')), formal_param), tok(char(')'))),
|
|
||||||
|params: &Vec<_>| params.len() < 256,
|
|
||||||
),
|
|
||||||
)(input)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO support 256-limit
|
||||||
fn formal_param(input: Span) -> ParseResult<FormalParam> {
|
fn formal_param(input: Span) -> ParseResult<FormalParam> {
|
||||||
map(
|
map(
|
||||||
tuple((identifier, opt(type_anno), opt(preceded(tok(char('=')), expression)))),
|
tuple((identifier, opt(type_anno), opt(preceded(tok(char('=')), expression)))),
|
||||||
@ -580,6 +578,7 @@ fn extended_expr_part(input: Span) -> ParseResult<ExtendedPart> {
|
|||||||
))(input)
|
))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO this shouldn't be an expression b/c type annotations disallowed here
|
||||||
fn invocation_argument(input: Span) -> ParseResult<InvocationArgument> {
|
fn invocation_argument(input: Span) -> ParseResult<InvocationArgument> {
|
||||||
context(
|
context(
|
||||||
"invocation-argument",
|
"invocation-argument",
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use super::Parser;
|
use super::Parser;
|
||||||
|
//TODO make use of the format_parse_error function
|
||||||
|
//use crate::error::{SchalaError, format_parse_error};
|
||||||
use crate::ast::*;
|
use crate::ast::*;
|
||||||
|
|
||||||
fn rc_string(s: &str) -> Rc<String> {
|
fn rc_string(s: &str) -> Rc<String> {
|
||||||
@ -262,6 +264,7 @@ peg::parser! {
|
|||||||
rule call_part(parser: &mut Parser) -> Vec<InvocationArgument> =
|
rule call_part(parser: &mut Parser) -> Vec<InvocationArgument> =
|
||||||
"(" arguments:(invocation_argument(parser) ** ",") ")" { arguments }
|
"(" arguments:(invocation_argument(parser) ** ",") ")" { arguments }
|
||||||
|
|
||||||
|
//TODO this shouldn't be an expression b/c type annotations disallowed here
|
||||||
rule invocation_argument(parser: &mut Parser) -> InvocationArgument =
|
rule invocation_argument(parser: &mut Parser) -> InvocationArgument =
|
||||||
_ "_" _ { InvocationArgument::Ignored } /
|
_ "_" _ { InvocationArgument::Ignored } /
|
||||||
_ ident:identifier() _ "=" _ expr:expression(parser) { InvocationArgument::Keyword {
|
_ ident:identifier() _ "=" _ expr:expression(parser) { InvocationArgument::Keyword {
|
||||||
|
@ -886,14 +886,6 @@ fn max_function_params() {
|
|||||||
//TODO need to create a good, custom error message for this case
|
//TODO need to create a good, custom error message for this case
|
||||||
//assert_fail!(&buf, "A function cannot have more than 255 arguments");
|
//assert_fail!(&buf, "A function cannot have more than 255 arguments");
|
||||||
assert_fail!(&buf);
|
assert_fail!(&buf);
|
||||||
|
|
||||||
let mut buf = r#"\("#.to_string();
|
|
||||||
for n in 0..255 {
|
|
||||||
write!(buf, "a{}, ", n).unwrap();
|
|
||||||
}
|
|
||||||
write!(buf, " a256").unwrap();
|
|
||||||
write!(buf, ") {{ return 10 }}").unwrap();
|
|
||||||
assert_fail!(&buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
Loading…
Reference in New Issue
Block a user