Skip to content

Commit

Permalink
parser: better define parameter definition
Browse files Browse the repository at this point in the history
Fixes #98
  • Loading branch information
jkbz64 committed Nov 18, 2024
1 parent bab31e2 commit b1dad3e
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 9 deletions.
24 changes: 21 additions & 3 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,14 +482,32 @@ module.exports = grammar({
choice($._block_terminator, $._procedure_terminator)
),

procedure_parameter_tuning: ($) =>
choice(kw("APPEND"), kw("BIND"), kw("BY-VALUE")),

procedure_parameter_definition: ($) =>
seq(
choice(kw("DEFINE"), kw("DEF")),
choice(kw("INPUT"), kw("OUTPUT"), kw("INPUT-OUTPUT"), kw("RETURN")),
optional(
choice(kw("INPUT"), kw("OUTPUT"), kw("INPUT-OUTPUT"), kw("RETURN"))
),
choice(kw("PARAMETER"), kw("PARAM")),
optional(
choice(
seq(kw("BUFFER"), field("buffer", $.identifier)),
choice(
kw("TABLE"),
kw("TABLE-HANDLE"),
seq(kw("DATASET"), optional(token.immediate(kw("-HANDLE"))))
)
)
),
optional(kw("FOR")),
field("name", $.identifier),
$.type_tuning,
repeat($.variable_tuning),
choice(
seq($.type_tuning, repeat($.variable_tuning)),
repeat($.procedure_parameter_tuning)
),
$._terminator
),

Expand Down
82 changes: 76 additions & 6 deletions test/corpus/basic.txt
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,27 @@ END PROCEDURE.
PROCEDURE another_procedure:
END.

DEFINE INPUT-OUTPUT PARAMETER TABLE-HANDLE hNode.
DEFINE OUTPUT PARAMETER TABLE-HANDLE hData.
DEFINE OUTPUT PARAMETER TABLE-HANDLE hSchema.
DEFINE INPUT PARAMETER DATASET-HANDLE hDset.
DEFINE OUTPUT PARAMETER TABLE-HANDLE ttHandle.

DEFINE INPUT PARAMETER TABLE FOR ttCustomer.
DEFINE OUTPUT PARAMETER TABLE FOR ttOrder APPEND.
DEFINE INPUT-OUTPUT PARAMETER TABLE FOR ttProduct BIND.
DEFINE INPUT PARAMETER TABLE-HANDLE hCustomer.
DEFINE OUTPUT PARAMETER TABLE-HANDLE hOrder BY-VALUE.
DEFINE INPUT-OUTPUT PARAMETER TABLE-HANDLE hProduct BIND BY-VALUE.
DEFINE INPUT PARAMETER DATASET FOR dsCustomer.
DEFINE OUTPUT PARAMETER DATASET FOR dsOrder APPEND.
DEFINE INPUT-OUTPUT PARAMETER DATASET FOR dsProduct BIND.
DEFINE INPUT PARAMETER DATASET-HANDLE hCustomer.
DEFINE OUTPUT PARAMETER DATASET-HANDLE hOrder BY-VALUE.
DEFINE INPUT-OUTPUT PARAMETER DATASET-HANDLE hProduct BIND BY-VALUE.
DEFINE PARAMETER BUFFER bBuf FOR field.
DEFINE INPUT PARAMETER DATASET FOR field.

--------------------------------------------------------------------------------

(source_code
Expand All @@ -826,7 +847,56 @@ END.
(comment))
(procedure_statement
(identifier)
(body)))
(body))
(procedure_parameter_definition
(identifier))
(procedure_parameter_definition
(identifier))
(procedure_parameter_definition
(identifier))
(procedure_parameter_definition
(identifier))
(procedure_parameter_definition
(identifier))
(procedure_parameter_definition
(identifier))
(procedure_parameter_definition
(identifier)
(procedure_parameter_tuning))
(procedure_parameter_definition
(identifier)
(procedure_parameter_tuning))
(procedure_parameter_definition
(identifier))
(procedure_parameter_definition
(identifier)
(procedure_parameter_tuning))
(procedure_parameter_definition
(identifier)
(procedure_parameter_tuning)
(procedure_parameter_tuning))
(procedure_parameter_definition
(identifier))
(procedure_parameter_definition
(identifier)
(procedure_parameter_tuning))
(procedure_parameter_definition
(identifier)
(procedure_parameter_tuning))
(procedure_parameter_definition
(identifier))
(procedure_parameter_definition
(identifier)
(procedure_parameter_tuning))
(procedure_parameter_definition
(identifier)
(procedure_parameter_tuning)
(procedure_parameter_tuning))
(procedure_parameter_definition
(identifier)
(identifier))
(procedure_parameter_definition
(identifier)))

================================================================================
FUNCTION statement
Expand Down Expand Up @@ -1995,7 +2065,7 @@ DISPLAY Order.CustNum Order.OrderDate Andsomething AndBug.
INTERFACE statement
================================================================================

INTERFACE r-ICustObj:
INTERFACE r-ICustObj:

/* Property prototypes to return basic values for the Customer
identified with the highest balance in the database */
Expand All @@ -2005,9 +2075,9 @@ INTERFACE r-ICustObj:
DEFINE PUBLIC PROPERTY HighCustNum AS INTEGER NO-UNDO
GET.
SET.

/* Event prototype to notify about Customers with Invoices */
DEFINE PUBLIC EVENT CustHasInvoices
DEFINE PUBLIC EVENT CustHasInvoices
SIGNATURE VOID ( piCustNum AS INTEGER ).

/* Temp-tables for the ProDataSet parameter */
Expand All @@ -2017,7 +2087,7 @@ INTERFACE r-ICustObj:
/* ProDataSet parameter for passing a single Customer with the highest
balance along with its related Invoices */
DEFINE DATASET dsHighCustData FOR ttCust, ttInv
DATA-RELATION FOR ttCust, ttInv
DATA-RELATION FOR ttCust, ttInv
RELATION-FIELDS (ttCust.CustNum, ttInv.CustNum).

/* Method prototype to get the current high Customer balance data */
Expand Down Expand Up @@ -2146,7 +2216,7 @@ VAR myclass myobj = NEW myclass().
VAR myclass myobj = NEW myclass("Progress", 2020,?).

/* Multiple instantiated object variables */
VAR myclass myobj1 = NEW myclass("MA"),
VAR myclass myobj1 = NEW myclass("MA"),
myobj2 = NEW myclass("VT"),
myobj3 = NEW myclass("NH").

Expand Down

0 comments on commit b1dad3e

Please sign in to comment.