Skip to content
basanders edited this page Apr 6, 2015 · 5 revisions

SIAL Grammar

Sial is not case sensitive, except for string literals. EOLs are significant white space.


Sial ::= EOLsopt ImportProgList Program

Program ::= sial Ident EOLs DecList StatementList endsial Ident EOLsopt

EOLsopt ::= %empty | EOLs

EOLs ::= SINGLE_LINE_COMMENT | EOL | EOLs EOL

ImportProgList ::= %empty | ImportProgList ImportProg

ImportProg ::= import STRINGLIT EOLs --use STRINGLIT for case sensitive file name, should have .sialx suffix

Declarations

Modifiersopt ::= %Empty | Modifiers

Modifiers ::= Modifier | Modifiers Modifier

Modifier ::= 'predefined' | 'contiguous' | 'sparse'

DecList ::= %empty | DecList Dec EOLs

Dec ::= ScalarDec | ArrayDec | IndexDec | SubIndexDec | IntDec | ProcDec | SpecialDec

ScalarDec ::= Modifiersopt scalar Ident ScalarInitializationOpt

ScalarInitializationOpt ::= %empty | '=' DOUBLELIT

IntDec ::= Modifiersopt int Ident IntInitializationOpt

IntInitializationOpt$IntInitialValue ::= %empty | '=' INTLIT

ArrayDec ::= Modifiersopt ArrayKind Ident '[' DimensionList ']'

ArrayKind$ArrayKind ::= static | temp | local | distributed | served

DimensionList ::= Dimension | DimensionList ',' Dimension

Dimension ::= Ident

IndexDec ::= Modifiersopt IndexKind Ident = Range

IndexKind ::= aoindex | moindex | moaindex | mobindex | index | laindex

SubIndexDec ::= subindex Ident of Ident

Range ::= RangeVal ':' RangeVal

RangeVal ::= INTLIT | '-' INTLIT | Ident

ProcDec ::= proc Ident EOLs StatementList endproc Ident

SpecialDec ::= special Ident IdentOpt
--the Signature isn't really an ident, but is a list made up of r (read) w(write) u(update) indicating the intent of each argument. There must be exactly one intent for each argument

IdentOpt ::= Ident | %empty

Statements

StatementList ::= %empty | StatementList Statement EOLs

WhereClause ::= where RelationalExpression

WhereClauseList ::= %empty | WhereClauseList WhereClause EOLs

Statement ::= call Ident

Statement ::= return

Statement ::= stop

Statement ::= server_barrier

Statement ::= sip_barrier

Statement ::= do Ident EOLs WhereClauseList StatementList enddo Ident

Statement ::= do Ident in Ident EOLs WhereClauseList StatementList enddo Ident in Ident

Statement ::= pardo Indices EOLs WhereClauseList StatementList endpardo Indices

Statement ::= section EOLs StatementList endsection

Statement ::= exit

Statement ::= cycle Ident

Statement ::= if RelationalExpression EOLs StatementList endif

Statement ::= if RelationalExpression EOLs StatementList else EOLs StatementList endif

Statement ::= allocate Ident AllocIndexListopt

Statement ::= deallocate Ident AllocIndexListopt

AllocIndex ::= Ident | '*'

AllocIndexList ::= AllocIndex | AllocIndexList ',' AllocIndex

AllocIndexListopt ::= %empty | '[' AllocIndexList ']'

Statement ::= allocate contiguous Ident '[' ContiguousIndexRangeExprList ']'

Statement ::= deallocate contiguous Ident '[' ContiguousIndexRangeExprList ']'

ContiguousIndexRangeExpr ::= Expression ':' Expression

ContiguousIndexRangeExprList ::= ContiguousIndexRangeExpr | ContiguousIndexRangeExprList ',' ContiguousIndexRangeExpr

Statement ::= create Ident

Statement ::= delete Ident

Statement ::= put DataBlock AssignOp Expression

Statement ::= get DataBlock

Statement ::= prepare DataBlock AssignOp Expression

Statement ::= request DataBlock

Statement ::= collective Ident AssignOp Expression

Statement::= destroy Ident

Statement ::= print Expression

Statement ::= println Expression

Arg ::= ContiguousDataBlock | DataBlock | IDENTIFIER | DOUBLELIT | INTLIT

ArgList ::= %empty | ArgList Arg

Statement ::= execute Ident ArgList

Statement ::= Ident AssignOp Expression

Statement ::= DataBlock AssignOp Expression

Statement ::= ContiguousDataBlock AssignOp Expression

Statement ::= gpu_on EOLs StatementList gpu_off

Statement ::= gpu_allocate Arg

Statement ::= gpu_free Arg

Statement ::= gpu_put Arg

Statement ::= gpu_get Arg

Statement ::= set_persistent Ident StringLiteral

Statement ::= restore_persistent Ident StringLiteral

Statement ::= assert_same Ident

Statement ::= broadcast_from Primary Ident

AssignOp ::= '=' | '+=' | '-=' | '*='

DataBlock ::= Ident '[' Indices ']'

Indices ::= Ident | Indices ',' Ident

ContiguousDataBlock ::= Ident '[' ContiguousIndexRangeExprList ']'

Expressions

RelOp ::= '<' | '>' | '<=' | '>=' | '==' | '!='

RelationalExpression ::= Expression RelOp Expression

Expression ::= Term | Expression '+' Term | Expression '-' Term

Term ::= ExponentExpression |= Term '*' ExponentExpression | Term '/' ExponentExpression | Term '^' ExponentExpression

ExponentExpression ::= CastExpression | ExponentExpression '**' CastExpression

CastExpression ::= UnaryExpression | '(' int ')' CastExpression | '(' scalar ')' CastExpression

UnaryExpression ::= Primary

UnaryExpression ::= '-' Primary | 'sqrt' Primary

Primary ::= '(' Expression ')'

Primary ::= INTLIT | DOUBLELIT | Ident | DataBlock | ContiguousDataBlock | StringLiteral

StringLiteral ::= STRINGLIT

Ident ::= IDENTIFIER

Clone this wiki locally