#18 "CALL func(A B)" fails to parse

closed
5
2002-10-27
2002-02-22
Alan Insley
No

The statement "CALL func(A B)" fails to parse.
But, the following are ok:
"CALL func (A B)"
"CALL func(A||' '||B)"
"CALL func('A' 'B')"

This funny expression was valid in uniRexx, but not in
Regina .08f, 2.2, or 3.0.

Best Regards!
Alan Insley

Discussion

  • Robert A "Bob" Cruz

    Logged In: YES
    user_id=371416

    You may have fallen prey to a common REXX mistake.
    Here is the "gotchya":

    A function is recognized by REXX when a left parenthesis
    *immediately* follows a valid symbol (i.e. "a = f( x )" is
    a function reference, whereas "a = f ( x )" is a
    concatenation of the value of <f> followed by a space,
    followed by the value of <x>; this is due to the space
    which separates "f" from "(" in the latter example).

    You invoke a function wherever an expression is permitted,
    whereas a subroutine is invoked by the CALL instruction,
    and the subroutine name must NOT have a left-parenthesis
    immediately following it.

    Thus:
    CALL func ( x )
    calls subroutine "func" with a single argument whose value
    is the result of evaluating the expression "( x )".
    CALL func( x )
    is illegal.

    When I run a test with the invalid form, I get the message:
    Error 19 running "<program-file-name", line <##>: String or
    symbol expected

    While this does not explain the situation, it is a
    reasonable response to this type of user error.

    Please go back and inspect your tests with this in mind.

    P.S. The construct "CALL func(x)" would be interpreted
    as "call the subroutine whose name is returned by the
    expression "func(x)". This is not permitted. (Trying to
    support this would introduce a nasty ambiguity into the
    CALL instruction.)

    My test shows that "CALL func(A||' '||B)" invokes func()!!
    I beleive that this should not work at all, and that this
    is the true bug here!

     
  • Alan Insley

    Alan Insley - 2002-08-14

    Logged In: YES
    user_id=269097

    While I can see your point that no form of CALL func()
    should work, if CALL variable or function return is not
    allowed CALL func() is not ambiguous and could be
    supported.

    >The construct "CALL func(x)" would be interpreted
    >as "call the subroutine whose name is returned by the
    >expression "func(x)".
    The above in Rexx could be managed with an Interpret
    statement.

    uniRexx allowed all three forms and interpreted them to
    mean "call the function and ignore the result"

     
  • Alan Insley

    Alan Insley - 2002-08-14
    • summary: "CALL func(A B)" fails to parse --> "CALL func(A B)" fails to parse
     
  • Ross Patterson

    Ross Patterson - 2002-09-06

    Logged In: YES
    user_id=326519

    According to the ANSI spec, the syntax for CALL is "CALL
    <taken_constant> <expr>, <expr>, ...". There isn't any
    restriction on placement of parentheses, because the
    routine-name is a constant, not an expression.

    So "CALL func(A B)" should parse as "CALL func (A B)" and
    result in a call to the routine "func" with arg(1) set to the result
    of evaluating the expression "(A B)". While I'm not in a
    position to test it, this is also how I remember Mike
    Cowlishaw's VM/CMS Rexx working.

    FYI, there is no facility in Rexx for calling a variably-named
    routine (as bob_cruz suggested would be correct in his
    postscript).

     
  • Florian Grosse-Coosmann

    Logged In: YES
    user_id=262734

    The bug has been fixed. The solution will be available in the
    next official release.

     
  • Mark Hessling

    Mark Hessling - 2002-10-27

    Logged In: YES
    user_id=86185

    Call func(a,b,c) now correctly gives a syntax error, however
    it gives error 19; symbol or string expected. Looking at
    the ANSI standard (6.3.2.97) and testing with Object Rexx,
    it probably should give error 37.1

     
  • Mark Hessling

    Mark Hessling - 2002-10-27
    • assigned_to: rexx --> fgc
    • summary: "CALL func(A B)" fails to parse --> "CALL func(A B)" fails to parse
     
  • Florian Grosse-Coosmann

    • summary: "CALL func(A B)" fails to parse --> "CALL func(A B)" fails to parse
    • status: open --> closed
     
  • Florian Grosse-Coosmann

    Logged In: YES
    user_id=262734

    OK, I applied a change for this. There are many, many errors
    of this
    kind in Regina. We have to rewrite the whole parser to be
    ANSI compatible in error messages. That's a good job for much
    spare time.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks