Skip to content

Commit

Permalink
parser: allow functions without parameters
Browse files Browse the repository at this point in the history
Fixes #55
  • Loading branch information
jkbz64 committed Sep 4, 2024
1 parent 2d35336 commit 15a4858
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ module.exports = grammar({
choice(kw("RETURNS"), kw("RETURN")),
field("return_type", choice($.primitive_type, $.identifier))
),
seq("(", optional(_list($.function_parameter, ",")), ")"),
optional(seq("(", optional(_list($.function_parameter, ",")), ")")),
choice(":", $._terminator),
optional($.body),
$._function_terminator
Expand Down
10 changes: 10 additions & 0 deletions test/corpus/basic.txt
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,10 @@ FUNCTION fn-no-mode RETURNS INTEGER (par1 AS INTEGER).
RETURN par1.
END.

FUNCTION fn-no-parameters RETURNS INTEGER:
RETURN 0.
END.

fn(INPUT somepar, OUTPUT otherpar).
fn-no-mode(somerpar).
fn-no-mode(somerpar) NO-ERROR.
Expand Down Expand Up @@ -799,6 +803,12 @@ PersonData:GetById(id, output table ttPerson by-reference).
(body
(return_statement
(identifier))))
(function_statement
name: (identifier)
return_type: (primitive_type)
(body
(return_statement
(number_literal))))
(function_call_statement
(function_call
function: (identifier)
Expand Down

0 comments on commit 15a4858

Please sign in to comment.