Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 56 additions & 12 deletions src/common/PeopleCodeParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,32 @@ options {
//* MAIN ENTRY POINTS FOR PARSER
//******************************************************************************

/**
* Entry point for an Application Class.
*/
appClass
: importDeclaration* classDeclaration (SEMI+ classExternalDeclaration)* (SEMI* classBody)? SEMI* EOF #AppClassProgram
| importDeclaration* interfaceDeclaration SEMI* EOF #InterfaceProgram
;

/**
* Entry point for a PeopleCode program.
*/
program
: importDeclaration* programPreambles? SEMI* statements? SEMI* EOF
: appClass
| importsBlock programPreambles? SEMI* statements? SEMI* EOF
;


//******************************************************************************
//* ADDITIONAL PARSER RULES
//******************************************************************************

importsBlock
: importDeclaration*
;

importDeclaration
: IMPORT (appPackageAll | appClassPath) SEMI+
;

appClass
: importsBlock classDeclaration (SEMI+ classExternalDeclaration)* (SEMI* classBody)? SEMI* EOF #AppClassProgram
| importsBlock interfaceDeclaration SEMI* EOF #InterfaceProgram
;

appPackageAll
: appPackagePath COLON STAR
;
Expand Down Expand Up @@ -135,6 +137,20 @@ typeT
| simpleType #SimpleTypeType
;

// Special type rule specifically for method annotations, which require Array2/Array3 notation
annotationType
: ARRAY2 OF typeT #AnnotationArray2Type
| ARRAY3 OF typeT #AnnotationArray3Type
| ARRAY4 OF typeT #AnnotationArray4Type
| ARRAY5 OF typeT #AnnotationArray5Type
| ARRAY6 OF typeT #AnnotationArray6Type
| ARRAY7 OF typeT #AnnotationArray7Type
| ARRAY8 OF typeT #AnnotationArray8Type
| ARRAY9 OF typeT #AnnotationArray9Type
| ARRAY OF typeT #AnnotationArray1Type // For single-dimension arrays
| typeT #AnnotationBaseType
;

propertyDeclaration
: PROPERTY typeT genericID GET SET? #PropertyGetSet
| PROPERTY typeT genericID ABSTRACT? READONLY? #PropertyDirect // abstract is sometimes featured before readonly in some delivered classes
Expand Down Expand Up @@ -220,15 +236,15 @@ classMember
;

method
: METHOD genericID SEMI* statements? END_METHOD
: METHOD genericID SEMI* methodAnnotations statements? END_METHOD
;

getter
: GET genericID SEMI* statements END_GET
: GET genericID methodReturnAnnotation SEMI* statements END_GET
;

setter
: SET genericID SEMI* statements? END_SET
: SET genericID methodParameterAnnotation SEMI* statements? END_SET
;

statements
Expand Down Expand Up @@ -361,6 +377,14 @@ dotAccess
allowableFunctionName
: ANY
| ARRAY
| ARRAY2
| ARRAY3
| ARRAY4
| ARRAY5
| ARRAY6
| ARRAY7
| ARRAY8
| ARRAY9
| BOOLEAN
| COMPONENT
| CONSTANT
Expand Down Expand Up @@ -437,3 +461,23 @@ functionArguments
functionArgument
: USER_VARIABLE (AS typeT)?
;

methodAnnotations
: methodParameterAnnotation* methodReturnAnnotation? methodExtendsAnnotation?
;

methodParameterAnnotation
: SLASH_PLUS methodAnnotationArgument COMMA? PLUS_SLASH
;

methodAnnotationArgument
: USER_VARIABLE AS annotationType OUT?
;

methodReturnAnnotation
: SLASH_PLUS RETURNS annotationType PLUS_SLASH
;

methodExtendsAnnotation
: SLASH_PLUS EXTENDS DIV IMPLEMENTS appClassPath DOT genericID PLUS_SLASH
;
Loading