Q2 done?! maybe

This commit is contained in:
bobbert committed 2026-04-28 20:06:29 +01:00
1 parent d20c595e0f
commit c76af24421
6 files changed
+116 -55

No files matched your search

+27 -27
View File
@@ -1,62 +1,62 @@
grammar fspow;
// workshop 4 version
prog: stat+ ;
// labelling alternatives creates extra visitor methods
// the labels migh clash with rule names, so I make them unique
stat:
assignment # statAssignment
// the labels might clash with rule names, so I make them unique
stat: assignment # statAssignment
| fcList # statFcList
| fcApplySelector # statFcApplySelector
| message # statMessage
;
assignment :
ID '=' expression ;
ID '=' expression;
// when alternatives are introduced, try using labels to distinguish
expression :
ID # exprID
|
selCreation # exprSelCreation
|
fcCreation # exprFcCreation
expression : ID # exprID
| selCreation # exprSelCreation
| fcCreation # exprFcCreation
;
// -------
// filecollection statements
// filecollection statements
// -------
fcCreation: fcCreationName '(' rootSpecifier ')' ;
fcCreationName: 'FileCollection' ;
rootSpecifier: STRING ;
// -------
// selector statements
// selector statements
// -------
selCreation : selCreationName '(' filterSpecifier ')' ;
selCreation : selCreationName '(' testexpression ')' ;
selCreationName: 'Selector' ;
selCreationName: 'Selector' ;
filterSpecifier: selfilter '(' STRING ')' ;
selfilter: 'name' ;
testexpression : testunit (testoperator testunit)* ;
testoperator: 'intersect' #testoperatorIntersect ;
testunit: 'name' '(' STRING ')' #testunitname
| 'size' '(' STRING ')' #testunitsize
| 'type' '(' STRING ')' #testunittype
| 'date' '(' STRING ')' #testunitdate
| '(' testexpression ')' #testunittestexpression
| 'not' '(' testexpression ')' #testunitnottestexpression ;
// -------
// apply statement
// apply statement
// -------
fcApplySelector: ID '.' applyName '(' expression ')' ;
applyName: 'apply' ;
// -------
// print statement
// print statement
// -------
fcList: ID '.' printName ;
fcList: ID '.' printName ; // fc.print()
printName: 'print()' ;
// -------
// message statement
// message statement
// -------
message: 'message' STRING ;
ID: [a-zA-Z][a-zA-Z0-9]* ;
STRING: '"'.*?'"'
{self.text = self.text[1:-1]} ;
STRING: '"'.*?'"' {self.text = self.text[1:-1]} ;
WS : [ \t\r\n]+ -> skip ;
COMMENT : '//' ~[\r\n]* -> channel(HIDDEN) ;
COMMENT : '//' ~[\r\n]* -> channel(HIDDEN) ;