lutaml / expressir

Ruby parser for the ISO EXPRESS language
3 stars 3 forks source link

Potential eengine bug: Functions and procedures without parameters #23

Open ronaldtse opened 3 years ago

ronaldtse commented 3 years ago

Functions and procedures without parameters

Declaration:

PROCEDURE emptyProcedure; END_PROCEDURE;

Call:

emptyProcedure;

eengine throws Error: ASSIGNMENT_STMT expected ':COLON-EQUAL', got '#\;'

It seems that the spec doesn't explicitly disallow them, or at least I couldn't find where.

ISO 10303-11, 9.5.3 says:

A function or procedure can have formal parameters.

BNF syntax has parameters in [ ], which means optional

function_head = FUNCTION function_id [ ’(’ formal_parameter { ’;’ formal_parameter } ’)’ ] ’:’ parameter_type ’;’ .
procedure_head = PROCEDURE procedure_id [ ’(’ [ VAR ] formal_parameter { ’;’ [ VAR ] formal_parameter } ’)’ ] ’;’ .

actual_parameter_list = ’(’ parameter { ’,’ parameter } ’)’ .
function_call = ( built_in_function | function_ref ) [ actual_parameter_list ] .
procedure_call_stmt = ( built_in_procedure | procedure_ref ) [ actual_parameter_list ] ’;’ .

Are they valid or not?

Originally posted by @zakjan in https://github.com/lutaml/expressir/issues/11#issuecomment-729624529

ronaldtse commented 3 years ago

Screenshot for 9.5.2.

Screen Shot 2020-11-19 at 3 19 21 PM
ronaldtse commented 3 years ago

Reported at: http://bz.pdes-ch.org/show_bug.cgi?id=8482

ronaldtse commented 3 years ago

From Robert Swindells: http://bz.pdes-ch.org/show_bug.cgi?id=8482#c1

emptyProcedure;

The error is thrown by the call to the procedure, not the declaration of it.

ronaldtse commented 3 years ago

My response:

Thanks Robert! In this case, what should the correct "procedure call" format be?

According to ISO 10303-11, 13.8, the syntax given is:

270 procedure_call_stmt = ( built_in_procedure | procedure_ref )
    [ actual_parameter_list ] ’;’ .
167 actual_parameter_list = ’(’ parameter { ’,’ parameter } ’)’ .
264 parameter = expression .

"actual_parameter_list" is optional.

In 13.8 the example given is:

INSERT (point_list, this_point, here );
zakjan commented 3 years ago

Yes, a declaration without params is valid, a call without params throws.