root ::= { Block } end-of-script Block ::= | 'keep' FilterHeader | FilterBlock | IfElseBlock | AssignBlock | KeepBlock | ExprBlock | ImportBlock | LoopBlock | AssignCallBlock | TableBlock | ShowBlock | ReadBlock | ReturnBlock | YieldBlock | ExpectBlock | DeleteBlock | UserFunction | EnumDefBlock | StyleBlock | AutoDiffBlock | MonteCarloBlock | MatchBlock | SchemaDefinition | SchemaClone | WriteStmt FilterHeader ::= FilterKind ConditionKind end-of-line FilterKind ::= | 'where' | 'span' ConditionKind ::= | Expr,0,0,1,0,0,2,0,1,3,0,2,4,0,3,5,0,4,6,0,5,0,8,0,8,0,7,8,0,0 | Identifier '=' Expr | Identifier '=' '[' Expr '..' Expr ']' Expr ::= |0 |0 |0 |0 |0 unaryoperator Expr |1 Expr operator0 Expr |2 Expr operator1 Expr |3 Expr operator2 Expr |4 Expr operator3 Expr |5 Expr operator4 Expr |6 Expr operator5 Expr |7 'if' Expr 'then' Expr 'else' Expr |8 Expr 'into' Identifier Identifier ::= identifier { '.' identifier } FilterBlock ::= FilterHeader ChainedFilterBody ChainedFilterBody ::= | FilterBlock | indent { Block } dedent IfElseBlock ::= 'if' Expr end-of-line indent { Block } dedent ElseTail ElseTail ::= | | ElseBlock | 'else' IfElseBlock ElseBlock ::= 'else' end-of-line indent { Block } dedent AssignBlock ::= { AssignFlag } IdentifierOrUnderscore { ',' IdentifierOrUnderscore } '=' AssignedValue AssignFlag ::= | 'export' | 'const' | 'sample' | 'dash' IdentifierOrUnderscore ::= | Identifier | '_' AssignedValue ::= | LineExpr | Expr TailFilter end-of-line | SchemaPath end-of-line LineExpr ::= | Expr end-of-line | IfThenLineExpr | IfThenElseLineExpr IfThenLineExpr ::= 'if' Expr 'then' end-of-line IfThenLineExprBody IfThenLineExprBody ::= | indent LineExpr dedent 'else' ElseOrElif | indent indent LineExpr dedent 'else' ElseOrElif dedent ElseOrElif ::= | end-of-line indent LineExpr dedent | IfThenLineExpr IfThenElseLineExpr ::= IfThenElseLine indent MoreIfThenElseLine end-of-line dedent IfThenElseLine ::= 'if' Expr 'then' Expr 'else' end-of-line MoreIfThenElseLine ::= | IfThenElseLine MoreIfThenElseLine | Expr TailFilter ::= 'where' Expr SchemaPath ::= schema path enter { SchemaPathContent } schema path leave SchemaPathContent ::= | format | '\{' SchemaPathParam '}' SchemaPathParam ::= | Expr { ',' Expr } | '..' | Expr '..' Expr | '..' Expr | Expr '..' KeepBlock ::= | 'keep' Identifier end-of-line | 'keep' Identifier 'as' Identifier end-of-line | 'keep' Identifier '=' Expr end-of-line | 'keep' 'process' identifier '=' KeepSig end-of-line KeepSig ::= Identifier '(' TypeIdentifier { ',' TypeIdentifier } [ ';' Expr { ',' Expr } ] ')' TypeIdentifier ::= identifier ExprBlock ::= ExprBlockLeft ExprBlockPrelude indent { Block } dedent ExprBlockLeft ::= | | ExprBlockAssign | 'return' ExprBlockAssign ::= { AssignFlag } IdentifierOrUnderscore { ',' IdentifierOrUnderscore } '=' ExprBlockPrelude ::= | 'with' end-of-line | IterTarget [ EachWhen ] end-of-line | IterTarget 'scan' WithDesc`1 [ EachWhen ] end-of-line | IterTarget 'scan' '[' ExprTuple ']' [ EachWhen ] end-of-line | IterTarget 'scan' 'auto' [ EachWhen ] end-of-line IterTarget ::= | 'each' Identifier | 'for' Identifier 'in' ExprAtom { ',' Identifier 'in' ExprAtom } ExprAtom ::= | '(' ExprTuple ')' | Identifier | LiteralAtom`1 | LiteralAtom`1 | LiteralAtom`1 | text interpolation { FormatCell } ..." | markdown template start { FormatCell } markdown template end | StarLiteral | SchemaVarAtom ExprTuple ::= ExprTupleElem [ ExprTupleSep ExprTuple ] ExprTupleElem ::= | Expr | '...' Expr | identifier ':' Expr | Expr 'desc' ExprTupleSep ::= | ',' | ';' LiteralAtom`1 ::= { identifier '.' } number LiteralAtom`1 ::= { identifier '.' } boolean LiteralAtom`1 ::= { identifier '.' } text FormatCell ::= | format | '\{' Expr '}' | '\{' IdBeforeColon ':' format '}' IdBeforeColon ::= | identifier | identifier '.' IdBeforeColon StarLiteral ::= identifier { '.' identifier } '.*' SchemaVarAtom ::= 'schema' '.' identifier EachWhen ::= 'when' Expr WithDesc`1 ::= | ExprAtom | ExprAtom 'desc' ImportBlock ::= 'import' [ 'shared' ] text 'as' identifier ImportTail ImportTail ::= | end-of-line | NamedImports NamedImports ::= 'with' end-of-line indent { ImportColumn end-of-line } dedent ImportColumn ::= | identifier | identifier ':' TypeIdentifier LoopBlock ::= 'loop' LoopKind end-of-line indent { Block } dedent LoopKind ::= | ExprAtom 'in' Expr '..' Expr | ExprAtom | ExprAtom 'unsafe' | ExprAtom 'in' Expr | ExprAtom 'partitioned' 'table' Identifier AssignCallBlock ::= { AssignFlag } IdentifierOrUnderscore { ',' IdentifierOrUnderscore } '=' Identifier LabeledArgs LabeledArgs ::= '(' LabeledArg { ',' LabeledArg } ')' end-of-line LabeledArg ::= Label ':' Expr Label ::= | identifier | 'write' TableBlock ::= TableDecl TableDef TableDecl ::= [ 'export' ] 'table' identifier [ TablePrimary ] { TableSize } '=' TablePrimary ::= '[' identifier ']' TableSize ::= | 'max' TableSizeLimit | 'small' TableSizeLimit | 'small' | 'min' number TableSizeLimit ::= | number | number '..' number TableDef ::= | TableValue | 'with' end-of-line indent { Block } dedent | AutoDiffBlock TableValue ::= | Identifier '(' [ ExprTuple ] ')' [ 'schema' Identifier ] end-of-line | Identifier LabeledArgs | [ Identifier ] 'by' Expr { Label ':' Expr } end-of-line | [ Identifier ] 'by' '[' ExprTuple ']' { Label ':' Expr } end-of-line | 'where' Expr end-of-line | 'draw' Expr end-of-line | 'cross' '(' Identifier ',' Identifier ')' CallOption end-of-line CallOption ::= | | 'default' CallOptionExpr CallOption | 'default' ExprAtomOrCall | 'default' 'fail' CallOption | 'when' CallOptionExpr CallOption | 'when' ExprAtomOrCall | 'at' CallOptionExpr CallOption | 'at' ExprAtomOrCall | 'at' '[' [ ExprTuple ] ']' CallOption | 'by' CallOptionExpr CallOption | 'by' ExprAtomOrCall | 'by' '[' [ ExprTuple ] ']' CallOption | 'scan' CallOptionExpr CallOption | 'scan' ExprAtomOrCall | 'scan' 'auto' CallOption | 'scan' '[' [ ExprTuple ] ']' CallOption | 'sort' CallOptionExpr CallOption | 'sort' ExprAtomOrCall | 'sort' '[' [ ExprTuple ] ']' CallOption | CallOptionOver CallOption | CallOptionCross CallOption CallOptionExpr ::= | ExprAtom | unaryoperator CallOptionExpr ExprAtomOrCall ::= | ExprAtom | ExprCall | EnumCall | unaryoperator ExprAtomOrCall ExprCall ::= Identifier '(' [ ExprTuple ] ')' CallOption EnumCall ::= 'enum' '<<' Identifier '>>' '(' Expr ')' CallOptionOver ::= 'over' [ Identifier '=' ] '[' [ Expr ] '..' Expr ']' CallOptionCross ::= 'cross' '(' Identifier ',' Identifier [ 'as' identifier ] ')' AutoDiffBlock ::= 'autodiff' Identifier { Label ':' Expr } 'with' end-of-line indent { ParamsStmt } { Block } dedent ParamsStmt ::= 'params' Identifier [ ParamsRange ] [ 'abstract' ] ParamsInit end-of-line ParamsRange ::= 'in' '[' [ Expr ] '..' [ Expr ] ']' ParamsInit ::= | | '=' Expr | 'auto' '(' Expr ',' Expr ')' | 'auto' ShowBlock ::= | ShowBlock`2 | ShowBlock`2 | ShowBlock`2 ShowBlock`2 ::= { ScScope end-of-line } 'show' TileTypeWithColumns Expr ShowOptions [ ScScope ] end-of-line ScScope ::= | '{' [ ScEntry { ';' ScEntry } ] '}' ScEntry ::= | ScCoord ',' ScCoord [ 'in' ScRegion ] | property-name ':' ScValue | ScSelector ScScope ScCoord ::= | number '..' number | '..' number | number '..' | number | '..' ScRegion ::= | 'dash' | identifier ScValue ::= | text | boolean | identifier | [ '-' ] number | '#' ScColor | '#' '(' Expr ')' | '#' '[' Expr ']' | text interpolation { FormatCell } ..." ScColor ::= | color | colorId | colornum ScSelector ::= | identifier | '.' identifier | '>' identifier | '>' '.' identifier | '&' identifier | '&' '.' identifier TileTypeWithColumns ::= | tile-type | 'table' | 'upload' ShowOptions ::= | identifier ShowColor { Label ':' Expr } | identifier { Label ':' Expr } | { Label ':' Expr } ShowColor ::= | identifier | colorId | colornum | number ShowBlock`2 ::= { ScScope end-of-line } 'show' TileTypeWithColumns Expr ShowOptions [ ScScope ] ShowWithColumns ShowWithColumns ::= | ShowWithColumnsInline | ShowWithColumnsMultiLine ShowWithColumnsInline ::= 'with' ShowColumn { ',' ShowColumn } { ShowGroupOrder } end-of-line ShowColumn ::= Expr [ 'as' Expr ] { Label ':' Expr } [ ScScope ] ShowGroupOrder ::= | ShowGrouping | ShowOrdering ShowGrouping ::= | 'group' 'by' GroupColumns | 'group' 'into' Identifier GroupColumns ::= | '[' ExprTuple ']' | Expr { ',' Expr } ShowOrdering ::= | 'order' 'by' OrderColumns OrderColumns ::= | '[' ExprTuple ']' [ 'desc' ] | WithDesc`1 { ',' WithDesc`1 } WithDesc`1 ::= | Expr | Expr 'desc' ShowWithColumnsMultiLine ::= 'with' end-of-line indent { ShowColumn end-of-line } { ShowGroupOrder end-of-line } dedent ShowBlock`2 ::= { ScScope end-of-line } 'show' 'chart' Expr ShowOptions [ ScScope ] ShowWithBlocks ShowWithBlocks ::= 'with' end-of-line indent { ShowSubBlock } dedent ShowSubBlock ::= | ShowSubBlockLeaf | ShowSubBlockNode ShowSubBlockLeaf ::= TileBlockType [ ShowSubBlockPrelude ] end-of-line [ ShowSubBlockIndentedBody ] TileBlockType ::= | identifier ShowSubBlockPrelude ::= | ShowColumn | 'by' SubBlockGroupColumns { Label ':' Expr } | 'into' Identifier { Label ':' Expr } SubBlockGroupColumns ::= | '[' ExprTuple ']' | Expr ShowSubBlockIndentedBody ::= indent { ShowColumn end-of-line } [ ShowOrdering end-of-line ] dedent ShowSubBlockNode ::= TileBlockModifier end-of-line indent { ShowSubBlock } dedent TileBlockModifier ::= | FilterKind ConditionKind ReadBlock ::= 'read' ReadSource ReadSource ::= | [ ReadAggregatorType [ number ] ] ReadPattern ReadNamingAndDescriptor | 'upload' text ReadNamingAndDescriptor | 'form' ReadAsWith | [ ReadAggregatorType [ number ] ] SchemaPath ReadAs ReadTail | ReadAs ReadAsWith ReadAggregatorType ::= | 'min' | 'max' | 'latest' ReadPattern ::= | text | text interpolation { FormatCell } ..." | '(' Expr ')' ReadNamingAndDescriptor ::= { identifier ':' AnyLiteral } [ 'unsafe' ] ReadAs ReadTail AnyLiteral ::= | text | number | boolean ReadAs ::= 'as' IdentifierOrUnderscore [ ReadTablePrimary ] { TableSize } [ 'expect' Tuple`4 ] ReadTablePrimary ::= '[' TablePrimaryName TablePrimaryFlag`1 ']' TablePrimaryName ::= | identifier | identifier 'as' identifier | '(' identifier { ',' identifier } ')' 'as' identifier | identifier 'as' '_' | '(' identifier { ',' identifier } ')' 'as' '_' TablePrimaryFlag`1 ::= | 'unsafe' | Tuple`4 ::= '[' [ ExpectColumn { ',' ExpectColumn } ] ']' ExpectColumn ::= | identifier | identifier 'unsafe' ReadTail ::= | end-of-line | ReadAsWith ReadAsWith ::= 'with' ReadWithSpec ReadWithSpec ::= | ColumnBlock | InlineSchema ColumnBlock ::= end-of-line indent { ReadColumn } dedent ReadColumn ::= | 'schema' ReadSchemaInclude | ReadColumnBind | identifier ':' ReadType end-of-line | identifier ':' AnyLiteral { identifier ':' AnyLiteral } 'as' identifier ':' ReadType end-of-line | text { identifier ':' AnyLiteral } 'as' identifier end-of-line | text { identifier ':' AnyLiteral } 'as' identifier ':' ReadType end-of-line | 'const' '(' number ')' 'as' identifier end-of-line | 'const' '(' '-' number ')' 'as' identifier end-of-line | 'const' '(' boolean ')' 'as' identifier end-of-line | 'const' '(' number ',' number ',' number ')' 'as' identifier end-of-line | 'const' '(' text ')' 'as' identifier end-of-line | 'const' '(' text ')' 'as' identifier ':' ReadType end-of-line ReadSchemaInclude ::= Identifier SchemaTailOrEnd SchemaTailOrEnd ::= | ReadSchemaTail | end-of-line ReadSchemaTail ::= 'with' end-of-line indent { SchemaSpecialization end-of-line } dedent SchemaSpecialization ::= identifier '=' SchemaBinding SchemaBinding ::= | 'read' '(' AnyLiteral ')' { identifier ':' AnyLiteral } | Expr ReadColumnBind ::= identifier [ ':' TypeIdentifier ] '=' ReadBindExprOrTranspose end-of-line ReadBindExprOrTranspose ::= | Expr | 'read' '(' AnyLiteral { ',' AnyLiteral } ')' { identifier ':' AnyLiteral } ReadType ::= | TypeIdentifier | 'enum' Identifier | 'table' 'enum' [ identifier [ '[' identifier ']' ] ] InlineSchema ::= 'schema' Identifier end-of-line ReturnBlock ::= 'return' LineExpr YieldBlock ::= | '[|' 'as' identifier { ',' 'as' identifier } '|]' end-of-line | '[|' Expr [ 'as' identifier ] { ',' Expr [ 'as' identifier ] } '|]' end-of-line ExpectBlock ::= 'expect' ExpectDecl end-of-line ExpectDecl ::= | 'table' Identifier { TableSize } | Identifier '=' Expr DeleteBlock ::= 'delete' Identifier end-of-line UserFunction ::= [ 'export' ] 'def' FunctionFlags Identifier UserFunctionSig UserFunctionBody dedent FunctionFlags ::= | FunctionKind | 'assoc' FunctionFlags | 'autodiff' FunctionFlags | 'const' FunctionFlags FunctionKind ::= | 'pure' | 'process' UserFunctionSig ::= | UserFunctionOneLineSig | UserFunctionMultiLineSig UserFunctionOneLineSig ::= '(' [ UserFunctionArgument { ',' UserFunctionArgument } ] [ ';' UserFunctionArgument { ',' UserFunctionArgument } ] ')' TagAndDefaultWith end-of-line indent UserFunctionArgument ::= identifier ':' TypeIdentifier TagAndDefaultWith ::= [ 'as' text ] [ 'default' Expr ] 'with' UserFunctionMultiLineSig ::= '(' end-of-line indent indent UserFunctionArgument { UserFunctionMoreLineArg } ')' TagAndDefaultWith end-of-line dedent UserFunctionMoreLineArg ::= ',' end-of-line UserFunctionArgument UserFunctionBody ::= { Block } EnumDefBlock ::= [ 'export' ] 'table' 'enum' identifier [ TablePrimary ] '=' EnumDefList EnumDefList ::= | Expr { ',' Expr } end-of-line | Expr { ',' Expr } end-of-line indent { Expr { ',' Expr } end-of-line } dedent StyleBlock ::= '@' [ identifier ] ScScope end-of-line MonteCarloBlock ::= 'montecarlo' Expr 'with' end-of-line indent { Block } dedent MatchBlock ::= { AssignFlag } IdentifierOrUnderscore { ',' IdentifierOrUnderscore } '=' MatchExpression MatchExpression ::= 'match' Expr 'with' end-of-line indent { MatchLine } dedent MatchLine ::= MatchPattern '->' LineExpr MatchPattern ::= | Expr | Expr '..' [ Expr ] | '..' [ Expr ] | 'like' Expr SchemaDefinition ::= [ 'export' ] 'schema' SchemaDefName { TableSize } 'with' end-of-line indent { SchemaColumn } dedent SchemaDefName ::= | identifier | SchemaPath SchemaColumn ::= | SchemaColumnDef | 'schema' Identifier end-of-line SchemaColumnDef ::= identifier [ ':' SchemaType ] SchemaValue [ ScScope ] end-of-line SchemaType ::= | TypeIdentifier | 'enum' Identifier SchemaValue ::= | { identifier ':' AnyLiteral } | SchemaReadMapping { identifier ':' AnyLiteral } | '=' Expr SchemaReadMapping ::= '=' 'read' '(' text { ',' text } ')' SchemaClone ::= 'schema' SchemaDefName { TableSize } '=' SchemaPath end-of-line WriteStmt ::= 'write' Identifier [ 'partitioned' ] 'as' WritePath { Label ':' Expr } WriteWith WritePath ::= | Expr | SchemaPath WriteWith ::= | [ ShowOrdering ] end-of-line | 'with' 'schema' Identifier [ ShowOrdering ] end-of-line | 'with' end-of-line indent { WriteColumn } [ ShowOrdering end-of-line ] dedent WriteColumn ::= | WriteColumnData | 'schema' Identifier WriteSchemaTail WriteColumnData ::= identifier '=' Expr end-of-line WriteSchemaTail ::= | end-of-line | WriteSchemaSpecialization WriteSchemaSpecialization ::= 'with' end-of-line indent { WriteColumnData } dedent