aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rwxr-xr-xexample.tsl2
-rw-r--r--src/parser.c8
3 files changed, 8 insertions, 4 deletions
diff --git a/README.md b/README.md
index df43dc2..cbb907c 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
A tiny scripting language that is designed to be a replacement for small shell/python scripts.\
Written in ANSI C to allow embedding everywhere and a WTFPL license that allows it to be used anywhere without any restrictions.\
See example.tsl for an example of what tsl looks like.\
-The language and implementation is designed to be very simple.
+The language and implementation is designed to be very simple and not use much memory.
** Note: tsl is not usable yet **
# Installation
diff --git a/example.tsl b/example.tsl
index 861db41..756f246 100755
--- a/example.tsl
+++ b/example.tsl
@@ -90,7 +90,7 @@ value8 = fn (value) {}
# setv "value9"
value9 = {
"hello": "world",
- "sayHello": fn() {
+ "sayHello": fn {
result = $(echo hello)
}
}
diff --git a/src/parser.c b/src/parser.c
index 0c46f42..8d23888 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -167,9 +167,13 @@ static TslParseResult tsl_parser_parse_fn_body(TslParser *self) {
return tsl_parser_parse_expressions(self, TSL_TOKEN_RBRACE);
}
-/* FN = '(' (IDENTIFIER ',')* ')' FN_BODY */
+/* FN = ( '(' (IDENTIFIER ',')* ')' )? FN_BODY */
static TslParseResult tsl_parser_parse_fn(TslParser *self) {
- return_if_error(tsl_tokenizer_accept(&self->tokenizer, TSL_TOKEN_LPAREN));
+ TslToken token = tsl_tokenizer_next(&self->tokenizer);
+ /* FN_BODY */
+ if(token == TSL_TOKEN_LBRACE)
+ return tsl_parser_parse_expressions(self, TSL_TOKEN_RBRACE);
+
for(;;) {
TslToken token = tsl_tokenizer_next(&self->tokenizer);
if(token == TSL_TOKEN_RPAREN) {