GslCore icon indicating copy to clipboard operation
GslCore copied to clipboard

FEA parameterless functions

Open daz10000 opened this issue 7 years ago • 3 comments

This almost feels like a bug. The following code gives an error. Basically you can't have a function that just expands into code. Of course you can get around this with part definitions but it seems like an omission.

#refgenome cenpk

#platform stitch
let foo() =
    uADH1 ; dADH1
end

foo()
syntax error; found ')', expected one of ['identifier'].
=================================================================
#platform stitch
let foo() =
        ^
    uADH1 ; dADH1
end

foo()

daz10000 avatar May 29 '18 06:05 daz10000

Seems like this should be an "easy" fix to add to the parser; offhand altering the function declaration pattern to add another line should probably just fix it.

FunctionDeclaration:
    | LET ID LPAREN FunctionDefArgs RPAREN EQUALS CodeSection END { createFunctionDeclaration $2 $4 $7 }
    | LET ID LPAREN RPAREN EQUALS CodeSection END { createFunctionDeclaration $2 [] $6 }

chrismacklin avatar May 29 '18 22:05 chrismacklin

Good point - I'll add this while I'm doing the function line number patch. I wrote a test for this case already and then discovered the base case didn't compile :(

daz10000 avatar May 30 '18 22:05 daz10000

Hopefully it works! Scare quotes around "easy" definitely necessary when the parser is involved...

chrismacklin avatar May 30 '18 22:05 chrismacklin