Grammar

Program :

{ set_Program($1);}

Stmts :

';'
{ $$ = make_Empty_Stmts($1);}
{ $$ = make_Stmts(0,$1);}
{ $$ = make_Stmts($1,$2);}

Stmt :

PreProcStmt :

'#' BIGINT STRING BIGINT
{ $$ = make_PreProcStmt($1,$2,$3,$4);}

ProcessStmt :

PROCESS NAME BlockStmt
{ $$ = make_ProcessStmt($1,$2,$3);}
| PROCESS NAME ':' NameList BlockStmt
{ $$ = make_ProcessStmt($1,$2,$3,$4,$5);}
| PROCESS '[' Expr ']' NAME BlockStmt
{ $$ = make_ProcessArrayStmt($1,$2,$3,$4,$5,$6);}

NamespaceStmt :

NAMESPACE NAME BlockStmt
{ $$ = make_NamespaceStmt($1,$2,$3);}

UsingStmt :

USING DottedName ';'
{ $$ = make_UsingStmt($1,$2,$3);}
| USING DottedName '.' ';'
{ $$ = make_UsingStmt($1,$2,$3,$4);}

NameList :

NAME
| NameList ',' NAME
{ $$ = make_TokenList($1,remove_1st($2,$3));}

StructPrefix :

STRUCT
| StaticDynamic STRUCT
{ $$ = make_StructPrefix($1,$2);}
| TYPE
| ARCHETYPE

StructDefStmt :

{ $$ = make_StructDefStmt($1,$2);}

ForStmt :

FOR NAME IN OrExpr WhereBody
{ $$ = make_ForStmt1($1,$2,$3,$4,$5);}
| FOR NAME IN OrExpr STEP OrExpr WhereBody
{ $$ = make_ForStmt2($1,$2,$3,$4,$5,$6,$7);}
{ $$ = make_ForStmt3($1,$2,$3,$4,$5,$6,$7);}

OptDefStmt :

| ';'
{ $$ = remove_1st($1,0);}

OptExprStmt :

| ';'
{ $$ = remove_1st($1,0);}

OptOrExpr :

|
{ $$ = 0;}

OptTemplateArgList :

|
{ $$ = 0;}

IfStmt :

IF '(' OrExpr ')' IfExpr
{ $$ = make_IfStmt($1,$2,$3,$4,$5);}

IfExpr :

{ $$ = make_AltIfStmt($1,$2);}

IfBody :

{ $$ = make_IfBody($1);}
{ $$ = make_IfBody($1);}
{ $$ = make_IfBody($1);}

AltIfStmt :

ELIF '(' OrExpr ')' IfExpr
{ $$ = make_ElifStmt($1,$2,$3,$4,$5);}
| ELSE IfBody
{ $$ = make_ElseStmt($1,$2);}

ReturnStmt :

RETURN Expr ';'
{ $$ = make_ReturnStmt($1,$2,$3);}

KeywordStmt :

KEYWORD NAME ';'
{ $$ = make_Keyword($1,$2,$3);}
| KEYWORD NAME '=' DottedName ';'
{ $$ = make_Keyword($1,$2,$3,$4,$5);}

ExprStmt :

Expr ';'
{ $$ = remove_2nd($1,$2);}

DefStmt :

SymDefStmt :

{ $$ = make_SymDefStmt($1,$2);}
{ $$ = make_OperatorSymDefStmt($1,$2);}

TemplateDefStmt :

{ $$ = make_TemplateDefStmt($1,$2,$3,$4,$5);}
| TEMPLATE TemplateInstReq
{ $$ = remove_1st($1,$2);}

TemplateOrStructPrefix :

TEMPLATE

TemplateDefDecl :

{ $$ = make_TemplateDef($1);}
{ $$ = make_TemplateDecl($1,$2);}
{ $$ = make_TemplateSpesh($1,$2,$3,$4,$5);}
| NAME '[' OptTemplateArgList ']' ';'
{ $$ = make_TemplateSpeshDecl($1,$2,$3,$4,$5);}

TemplateInstReq :

NAME '[' OptTemplateArgList ']' ';'
{ $$ = make_TemplateInstReq($1,$2,$3,$4,$5);}
| NAME '[' OptTemplateArgList ']' FUN '(' ArgList ')' ';'
{ $$ = make_TemplateFunInstReq($1,$2,$3,$4,$5,$6,$7,$8,$9);}
| StructPrefix NAME '[' OptTemplateArgList ']' ';'
{ $$ = make_TemplateStructInstReq($1,$2,$3,$4,$5,$6);}

DefinitionBody :

{ $$ = make_WhereDefinitionBody($1);}
{ $$ = make_FunDefDeclDefinitionBody($1);}

TypenameSymDefStmt :

TYPENAME NAME DefinitionBody
{ $$ = make_TypenameSymDefStmt($1,$2);}

MemberDefStmt :

DynamicMemberStmt :

{ $$ = remove_2nd($1,$2);}

StaticMemberStmt :

STATIC SymDefStmt ';'
{ $$ = remove_1st($1,remove_2nd($2,$3));}

PowExpr :

| Prim '^' Prim
{ $$ = make_BinaryOp($1,$2,$3);}

BitXorExpr :

{ $$ = make_BinaryOp($1,$2,$3);}

BitAndExpr :

{ $$ = make_BinaryOp($1,$2,$3);}

BitOrExpr :

{ $$ = make_BinaryOp($1,$2,$3);}

MulExpr :

{ $$ = make_BinaryOp($1,$2,$3);}

AddExpr :

{ $$ = make_BinaryOp($1,$2,$3);}

LessExpr :

{ $$ = make_BinaryOp($1,$2,$3);}

EqualityExpr :

{ $$ = make_BinaryOp($1,$2,$3);}

XorlExpr :

{ $$ = make_BinaryOp($1,$2,$3);}

AndExpr :

| AndExpr AND_AND XorlExpr
{ $$ = make_BinaryOp($1,$2,$3);}

OrExpr :

| OrExpr OR_OR AndExpr
{ $$ = make_BinaryOp($1,$2,$3);}

Expr :

{ $$ = make_BinaryOp($1,$2,$3);}

RangeExpr :

OrExpr DOT_DOT OrExpr
{ $$ = make_RangeExpr($1,$2,$3);}
{ $$ = make_RangeExpr($1,$2,$3,$4);}

ArgListExpr :

ArgList :

{ $$ = make_ArgList($1);}
{ $$ = make_ArgList($1,$2,$3);}

NonLiteralPrim :

THIS
| '(' Expr ')'
{ $$ = remove_1st($1,remove_2nd($2,$3));}
| TypeParam ':'
{ $$ = make_RhsTypeParam($1,$2);}
{ $$ = make_Constructor($1,$2,$3,$4);}
| TypeParam '=' '{' Expr '}'
{ $$ = make_Constructor($1,$2,$3,$4,$5);}
| TypeParam '=' '[' ArgList ']'
{ $$ = make_Constructor($1,$2,$3,$4,$5);}
| STRING '(' ArgListOrEmpty ')'
{ $$ = make_StringFunction($1,$2,$3,$4);}
| AT_LIB '{' ArgList '}'
{ $$ = make_NonLiteralPrim_Lib($1,$2,$3,$4);}
{ $$ = make_NonLiteralFunCall($1,$2,$3,$4);}
{ $$ = make_NonLiteralArray($1,$2,$3,$4);}
{ $$ = make_NonLiteralPrimDottedName($1,$2,$3);}

ArgListOrEmpty :

|
{ $$ = 0;}

DirectPrim :

| '[' ArgList ']'
{ $$ = make_Tuple($1,$2,$3);}
| '!' Prim
{ $$ = make_UnaryPreOp($1,$2);}
| '+' Prim
{ $$ = make_UnaryPreOp($1,$2);}
| '-' Prim
{ $$ = make_UnaryPreOp($1,$2);}
| '~' Prim
{ $$ = make_UnaryPreOp($1,$2);}

Prim :

| INLINE DirectPrim
{ $$ = make_Prim($1,$2);}
| CALL DirectPrim
{ $$ = make_Prim($1,$2);}
| '?'

AnonFun :

{ $$ = make_AnonFun1($1,$2,$3);}
{ $$ = make_AnonFun2($1,$2,$3,$4);}

CastLiteral :

{ $$ = make_CastLiteral1($1,$2,$3,$4);}
{ $$ = make_CastLiteral2($1,$2);}
| Literal STRING
{ $$ = make_CastLiteral2($1,$2);}

Literal :

BIGINT
{ $$ = make_BigInt($1);}
| REAL
{ $$ = make_Real($1);}
| STRING
{ $$ = make_String($1);}
| TRUE
{ $$ = make_Bool($1);}
| FALSE
{ $$ = make_Bool($1);}

BlockStmt :

'{' '}'
{ $$ = make_BlockStmt($1,0,$2);}
| '{' Stmts '}'
{ $$ = make_BlockStmt($1,$2,$3);}

NameOrOperatorName :

NAME

OperatorName :

OPERATOR Operator
{ $$ = make_Operator($1,$2);}

Operator :

'='
| LESS_TILDE
| '<'
| '>'
| LESS_EQUAL
| EQUAL_EQUAL
| NOT_EQUAL
| GREATER_EQUAL
| '+'
| '-'
| '*'
| '/'
| '~'
| '&'
| '|'
| DIV
| MOD
| AND_AND
| XORL
| XORB
| OR_OR
| '[' ']'
{ $$ = make_OperatorTok($1,$2,OP_ARRAY);}
| '(' ')'
{ $$ = make_OperatorTok($1,$2,OP_FUN_CALL);}
| '{' '}'
{ $$ = make_OperatorTok($1,$2,OP_BRACES);}
| '!'
| PLUS_EQUAL
| MINUS_EQUAL
| STAR_EQUAL
| SLASH_EQUAL
| GREATER_GREATER
| LESS_LESS
| GREATER_GREATER_EQUAL
| LESS_LESS_EQUAL
| OR_EQUAL
| AND_EQUAL
| CONVERT

FunDefDecl :

{ $$ = make_FunDefDecl($1,$2);}

FunctionPrefix :

FUN
| STATIC FUN
{ $$ = make_FunctionPrefix($1,$2);}
| DYNAMIC FUN
{ $$ = make_FunctionPrefix($1,$2);}
| TYPE FUN
{ $$ = make_FunctionPrefix($1,$2);}

FunctionSig :

{ $$ = make_FunctionSig1($1,$2);}
{ $$ = make_FunctionSig2($1,$2,$3);}
{ $$ = make_FunctionSig3($1,$2,$3);}
{ $$ = make_FunctionSig4($1,$2,$3,$4);}

FunctionTail :

{ $$ = make_FunctionTail1($1,$2);}
{ $$ = make_FunctionTail2($1,$2,$3);}
{ $$ = make_FunctionTail3($1,$2);}

WhereBody :

{ $$ = make_SimpleWhereBody($1);}
{ $$ = make_BlocksWhereBody($1);}

WhereBlocks :

{ $$ = make_TokenList($1,$2);}

WhereBlock :

{ $$ = make_WhereBlock($1,$2);}

OptTypeParamAssignBody :

{ $$ = make_OptTypeParamAssignBody(0,$1);}
{ $$ = make_OptTypeParamAssignBody($1,$2);}

WhereCondition :

WHERE '(' OrExpr ')'
{ $$ = make_WhereCondition($1,$2,$3,$4);}
| DEFAULT

WhereClause :

{ $$ = make_WhereClause($1,$2);}

Scratch :

SCRATCH BlockStmt
{ $$ = make_Scratch($1,$2);}

AssignBody :

'=' ArgList ';'
{ $$ = make_AssignBody1($1,$2,$3);}
{ $$ = $1;}
{ $$ = $1;}

NestedWhereBlocks :

'{' WhereBlocks '}'
{ $$ = make_NestedWhereBlocks($1,$2,$3);}

FunParams :

'(' ParamList ')'
{ $$ = make_FunParams1($1,$2,$3);}
| '(' ')'
{ $$ = make_FunParams2($1,$2);}

ParamList :

{ $$ = make_TokenList($1,remove_1st($2,$3));}

Param :

| NAME
| THIS TypeParam
{ $$ = make_Param1($1,$2);}

TypeParam :

{ $$ = make_TypeParam1($1,$2);}
{ $$ = make_TypeParam2($1,$2);}
{ $$ = make_TypeParam3($1,$2,$3);}

Constraint :

'?'
{ $$ = make_Constraint($1,$2);}

PrefixedDirectConstraint :

{ $$ = make_PrefixedDirectConstraint3($1,$2);}

OptNamedDirectConstraint :

{ $$ = make_OptNamedDirectConstraint($1,$2);}

DirectConstraint :

{ $$ = make_DirectConstraint1($1);}
{ $$ = make_DirectConstraint2($1,$2);}

VariadicPostfix :

ELLIPSIS
| ELLIPSIS '[' OrExpr ']'
{ $$ = make_VariadicPostfix($1,$2,$3,$4);}

PrimDirectConstraint :

{ $$ = make_PrimDirectConstraint1($1);}
{ $$ = make_PrimDirectConstraint2($1,$2,$3,$4);}
{ $$ = make_PrimDirectConstraint3($1,$2,$3,$4);}
{ $$ = make_PrimDirectConstraint4($1,$2,$3);}
{ $$ = make_UnaryOpDirectConstraint($1,$2);}

NestedDirectConstraint :

AndDirectConstraint :

{ $$ = make_BinaryOpDirectConstraint($1,$2,$3);}

OrDirectConstraint :

{ $$ = make_BinaryOpDirectConstraint($1,$2,$3);}

TemplateArgList :

{ $$ = make_TokenList($1,remove_1st($2,$3));}

TemplateArg :

RptConstraintPrefix :

{ $$ = make_TokenList($1,$2);}

ConstraintPrefix :

{ $$ = make_ConstraintPrefix(0,$1);}
{ $$ = make_ConstraintPrefix($1,$2);}

IndirSym :

'*'
| '[' ']'
{ $$ = make_IndirSym2($1,$2);}
| '[' Expr ']'
{ $$ = make_IndirSym3($1,$2,$3);}

RefValAccess :

{ $$ = make_RefValAccessSym($1,$2);}

Access :

CONST
| MUTABLE
| WRITEONLY

RefVal :

'$'
| '&'

StaticDynamic :

STATIC
| DYNAMIC

MulOp :

'*'
| '/'
| DIV
| MOD

AddOp :

'+'
| '-'

LessOp :

'<'
| LESS_EQUAL
| GREATER_EQUAL
| '>'

EqualityOp :

EQUAL_EQUAL
| NOT_EQUAL

AssignOp :

QUESTION_EQUAL
| LESS_TILDE
| PLUS_EQUAL
| MINUS_EQUAL

DottedName :

NAME
{ $$ = make_DottedName($1);}
| THIS
{ $$ = make_DottedName($1);}
| '.' NAME
{ $$ = make_DottedName(make_TokenList($1,$2));}
| DottedName '.' NAME
{ $$ = make_DottedName(make_TokenList($1,remove_1st($2,$3)));}

NameTypeParam :

{ $$ = make_NameTypeParam($1,$2);}