-
Notifications
You must be signed in to change notification settings - Fork 0
Code
EpicPix edited this page May 30, 2022
·
14 revisions
Grammar is in Zld format
There are a couple built-in types in zProl, which are:
void
uint8, ubyte
uint16, ushort
uint32, uint
uint64, ulong
int8, byte
int16, short
int32, int
int64, long
def Boolean:
true
false
def inline Integer:
[$Whitespace] $DecimalInteger
def chars DecimalInteger:
0
$NonZeroDecimalDigit { $DecimalDigits }
def chars NonZeroDecimalDigit <1-9>
def chars DecimalDigits <0-9>
There is a String type in the zprol.lang namespace. To use it you have to do using zprol.lang; at the beginning of the file.
Grammar
def chars AddOperator [$Whitespace] <+>
def chars SubtractOperator [$Whitespace] <->
def chars MultiplyOperator [$Whitespace] <*>
def chars DivideOperator [$Whitespace] </>
def chars ModuloOperator [$Whitespace] <%>
def chars InclusiveOrOperator [$Whitespace] <|>
def chars AndOperator [$Whitespace] <&>
def chars ShiftLeftOperator [$Whitespace] <\<><\<>
def chars ShiftRightOperator [$Whitespace] <\>><\>>
def chars EqualOperator [$Whitespace] <=><=>
def chars NotEqualOperator [$Whitespace] <!><=>
def inline chars HardCastIndicatorOperator <!>
def CastOperator ( $Type )
def HardCastOperator ( $Type $HardCastIndicatorOperator )
def inline AdditiveOperators:
$AddOperator
$SubtractOperator
def inline EqualityOperators:
$EqualOperator
$NotEqualOperator
def inline ShiftOperators:
$ShiftLeftOperator
$ShiftRightOperator
def inline MultiplicativeOperators:
$MultiplyOperator
$DivideOperator
$ModuloOperator
def inline CastOperators:
$CastOperator
$HardCastOperator
Grammar
def inline PostExpression:
( $Expression )
$Integer
$Boolean
$String
$FunctionCall
$Accessor
def CastExpression $CastOperators $CastExpression
def inline CastExpression $PostExpression
def merge MultiplicativeExpression $CastExpression [ $MultiplicativeOperators $MultiplicativeExpression ]
def merge AdditiveExpression $MultiplicativeExpression [ $AdditiveOperators $AdditiveExpression ]
def merge EqualsExpression $AdditiveExpression [ $EqualityOperators $EqualsExpression ]
def merge EqualsExpression $InclusiveOrExpression [ $EqualityOperators $EqualsExpression ]
def merge ShiftExpression $EqualsExpression [ $ShiftOperators $ShiftExpression ]
def merge InclusiveOrExpression $ShiftExpression [ $InclusiveOrOperator $InclusiveOrExpression ]
def merge InclusiveAndExpression $InclusiveOrExpression [ $AndOperator $InclusiveAndExpression ]
def Expression $EqualsExpression
def Expression $InclusiveAndExpression
def inline chars ArrayAccessorOpenCharacter [$Whitespace] <[>
def inline chars ArrayAccessorOpenCharacter [$Whitespace] <[>
def inline chars ArrayAccessorCloseCharacter [$Whitespace] <]>
def inline chars ArrayAccessorCloseCharacter [$Whitespace] <]>
def ArrayAccessor $ArrayAccessorOpenCharacter $Expression $ArrayAccessorCloseCharacter
def ArrayAccessor $ArrayAccessorOpenCharacter $Expression $ArrayAccessorCloseCharacter
def Accessor $Identifier { . $Identifier } { $ArrayAccessor }
def AccessorElement:
. $Identifier
$ArrayAccessor
def Accessor $Identifier { $AccessorElement }
Example
1 + 1 * 2
1
9 | 7
Grammar
tok Using:
using $DotWord ;
Example
using zprol.lang.amd64.syscalls;
using something;
Grammar
tok Namespace:
namespace $DotWord ;
Example
namespace something;
Grammar
def Parameter:
$Type $Identifier
def ParameterList:
$Parameter {, $Parameter}
def inline keyword FunctionModifier:
native
inline
def Statement:
$ReturnStatement
$FunctionCallStatement
$AssignmentStatement
$CreateAssignmentStatement
$IfStatement
$WhileStatement
def FunctionModifiers:
{ $FunctionModifier $Whitespace }
def inline chars LineCodeChars [$Whitespace] <=> <\>>
def Code:
\{ {$Statement} \}
$LineCodeChars $Statement
tok Function:
$FunctionModifiers $Type $Identifier ( [$ParameterList] ) $Code
$FunctionModifiers $Type $Identifier ( [$ParameterList] ) ;
Example
native void test(int test);
inline void test(int test, int abc) {}
void test(int test) {}
Grammar
def ReturnStatement:
return $Expression ;
return ;
Example
return;
return 1 * 1;
Grammar
def Argument:
$Expression
def ArgumentList:
$Argument {, $Argument}
def FunctionCallStatement:
$Identifier ( [$ArgumentList] ) ;
Example
test();
test(1, 2, 3);
Grammar
def Accessor $Identifier { . $Identifier }
def AssignmentStatement:
$Accessor = $Expression ;
Example
test = 1;
test.example = 2 + 2;
Grammar
def CreateAssignmentStatement:
$Type $Identifier = $Expression ;
Example
long abc = 123;
int def = 2;
Grammar
def IfStatement:
if ( $Expression ) $Code
Example
if(1 + 1 == 2) {}
if(1 | 2 == 3) => something();
Grammar
def WhileStatement:
while ( $Expression ) $Code
Example
while(1 != 2) {
stdout("thing\n");
}
Grammar
def inline ClassElement:
$ClassField
$ClassMethod
tok Class:
class $Identifier \{ {$ClassElement} \}
Example
class test {}
Grammar
def ClassField:
$Type $Identifier ;
Example
uint64 abc;
byte test;
Grammar
def ClassMethod:
$FunctionModifiers $Type $Identifier ( [$ParameterList] ) $Code
$FunctionModifiers $Type $Identifier ( [$ParameterList] ) ;
Example
void test();
uint8 test1(int a);