@@ -60,11 +60,8 @@ moduleBody:
6060 moduleBodyElement (endOfLine+ moduleBodyElement)* endOfLine*;
6161
6262moduleBodyElement :
63- functionStmt
64- | propertyGetStmt
65- | propertySetStmt
66- | propertyLetStmt
67- | subStmt
63+ methodStmt
64+ | propertyStmt
6865 | macroStmt;
6966
7067// block ----------------------------------
@@ -240,12 +237,6 @@ forNextStmt:
240237 WS STEP WS valueStmt
241238 )? endOfStatement block? NEXT (WS ambiguousIdentifier)?;
242239
243- functionStmt :
244- (visibility WS )? (STATIC WS )? FUNCTION WS ? ambiguousIdentifier typeHint? (
245- WS ? argList )? (WS ? asTypeClause)?
246- methodBlock
247- END_FUNCTION ;
248-
249240getStmt :
250241 GET WS fileNumber WS ? ' ,' WS ? valueStmt? WS ? ' ,' WS ? valueStmt;
251242
@@ -361,33 +352,45 @@ outputList_Expression:
361352
362353printStmt : PRINT WS fileNumber WS ? ' ,' (WS ? outputList)?;
363354
364- methodBlock : (comment | remComment)? NEWLINE
365- (attributeStmt endOfLine)?
366- (docstringStmt endOfLine)?
367- block?;
368-
369- // TODO: endOfStatement is consuming multiple endOfLines, including comments.
370- // If there are no attributes, the docstring is parsed in endOfLines.
371- propertyGetStmt :
372- (visibility WS )? (STATIC WS )? PROPERTY_GET WS ambiguousIdentifier typeHint? (
373- WS ? argList
374- )? (WS asTypeClause)?
375- methodBlock
376- END_PROPERTY ;
377-
378- propertySetStmt :
379- (visibility WS )? (STATIC WS )? PROPERTY_SET WS ambiguousIdentifier (
380- WS ? argList
381- )?
355+ methodStmt :
356+ methodSignatureStmt
382357 methodBlock
383- END_PROPERTY ;
358+ methodEndStmt
359+ ;
384360
385- propertyLetStmt :
386- (visibility WS )? (STATIC WS )? PROPERTY_LET WS ambiguousIdentifier (
387- WS ? argList
388- )?
361+ propertyStmt :
362+ propertySignatureStmt
389363 methodBlock
390- END_PROPERTY ;
364+ methodEndStmt
365+ ;
366+
367+ methodSignatureStmt :
368+ (visibility WS )?
369+ (STATIC WS )?
370+ (SUB |FUNCTION ) WS ?
371+ ambiguousIdentifier typeHint?
372+ (WS ? argList)
373+ (WS ? asTypeClause)?
374+ ;
375+
376+ propertySignatureStmt :
377+ (visibility WS )?
378+ (STATIC WS )?
379+ (PROPERTY_GET |PROPERTY_LET |PROPERTY_SET ) WS ?
380+ ambiguousIdentifier typeHint?
381+ (WS ? argList)
382+ (WS ? asTypeClause)?
383+ ;
384+
385+ methodBlock : endOfStatement
386+ (attributeStmt endOfLine)? // Optional attribute statement
387+ (docstringStmt endOfLine)? // Optional docstring statement
388+ block? // Optional method body
389+ ;
390+
391+ methodEndStmt :
392+ (END_SUB | END_FUNCTION | END_PROPERTY )
393+ ;
391394
392395putStmt :
393396 PUT WS fileNumber WS ? ' ,' WS ? valueStmt? WS ? ' ,' WS ? valueStmt;
@@ -449,13 +452,6 @@ setStmt: SET WS implicitCallStmt_InStmt WS? EQ WS? valueStmt;
449452
450453stopStmt : STOP ;
451454
452- subStmt :
453- (visibility WS )? (STATIC WS )? SUB WS ? ambiguousIdentifier (
454- WS ? argList
455- )?
456- methodBlock
457- END_SUB ;
458-
459455timeStmt : TIME WS ? EQ WS ? valueStmt;
460456
461457typeStmt :
0 commit comments