Renamed various productions and nodes
This commit is contained in:
parent
909a5bbf38
commit
1ecf0ed2bd
4 changed files with 125 additions and 125 deletions
|
@ -18,191 +18,191 @@ namespace arookas {
|
||||||
}
|
}
|
||||||
|
|
||||||
// precedence 0
|
// precedence 0
|
||||||
class sunLogOR : sunOperator {
|
class sunLogicalOrOperator : sunOperator {
|
||||||
public override int Precedence { get { return 0; } }
|
public override int Precedence { get { return 0; } }
|
||||||
|
|
||||||
public sunLogOR(sunSourceLocation location)
|
public sunLogicalOrOperator(sunSourceLocation location)
|
||||||
: base(location) { }
|
: base(location) { }
|
||||||
|
|
||||||
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteOR(); }
|
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteOR(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// precedence 1
|
// precedence 1
|
||||||
class sunLogAND : sunOperator {
|
class sunLogicalAndOperator : sunOperator {
|
||||||
public override int Precedence { get { return 1; } }
|
public override int Precedence { get { return 1; } }
|
||||||
|
|
||||||
public sunLogAND(sunSourceLocation location)
|
public sunLogicalAndOperator(sunSourceLocation location)
|
||||||
: base(location) { }
|
: base(location) { }
|
||||||
|
|
||||||
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteAND(); }
|
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteAND(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// precedence 2
|
// precedence 2
|
||||||
class sunBitOR : sunOperator {
|
class sunBitwiseOrOperator : sunOperator {
|
||||||
public override int Precedence { get { return 2; } }
|
public override int Precedence { get { return 2; } }
|
||||||
|
|
||||||
public sunBitOR(sunSourceLocation location)
|
public sunBitwiseOrOperator(sunSourceLocation location)
|
||||||
: base(location) { }
|
: base(location) { }
|
||||||
|
|
||||||
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteBOR(); }
|
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteBOR(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// precedence 3
|
// precedence 3
|
||||||
class sunBitAND : sunOperator {
|
class sunBitwiseAndOperator : sunOperator {
|
||||||
public override int Precedence { get { return 3; } }
|
public override int Precedence { get { return 3; } }
|
||||||
|
|
||||||
public sunBitAND(sunSourceLocation location)
|
public sunBitwiseAndOperator(sunSourceLocation location)
|
||||||
: base(location) { }
|
: base(location) { }
|
||||||
|
|
||||||
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteBAND(); }
|
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteBAND(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// precedence 4
|
// precedence 4
|
||||||
class sunEq : sunOperator {
|
class sunEqualOperator : sunOperator {
|
||||||
public override int Precedence { get { return 4; } }
|
public override int Precedence { get { return 4; } }
|
||||||
|
|
||||||
public sunEq(sunSourceLocation location)
|
public sunEqualOperator(sunSourceLocation location)
|
||||||
: base(location) { }
|
: base(location) { }
|
||||||
|
|
||||||
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteEQ(); }
|
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteEQ(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class sunNtEq : sunOperator {
|
class sunNotEqualOperator : sunOperator {
|
||||||
public override int Precedence { get { return 4; } }
|
public override int Precedence { get { return 4; } }
|
||||||
|
|
||||||
public sunNtEq(sunSourceLocation location)
|
public sunNotEqualOperator(sunSourceLocation location)
|
||||||
: base(location) { }
|
: base(location) { }
|
||||||
|
|
||||||
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteNE(); }
|
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteNE(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// precedence 5
|
// precedence 5
|
||||||
class sunLt : sunOperator {
|
class sunLessThanOperator : sunOperator {
|
||||||
public override int Precedence { get { return 5; } }
|
public override int Precedence { get { return 5; } }
|
||||||
|
|
||||||
public sunLt(sunSourceLocation location)
|
public sunLessThanOperator(sunSourceLocation location)
|
||||||
: base(location) { }
|
: base(location) { }
|
||||||
|
|
||||||
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteLT(); }
|
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteLT(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class sunLtEq : sunOperator {
|
class sunLessEqualOperator : sunOperator {
|
||||||
public override int Precedence { get { return 5; } }
|
public override int Precedence { get { return 5; } }
|
||||||
|
|
||||||
public sunLtEq(sunSourceLocation location)
|
public sunLessEqualOperator(sunSourceLocation location)
|
||||||
: base(location) { }
|
: base(location) { }
|
||||||
|
|
||||||
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteLE(); }
|
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteLE(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class sunGt : sunOperator {
|
class sunGreaterThanOperator : sunOperator {
|
||||||
public override int Precedence { get { return 5; } }
|
public override int Precedence { get { return 5; } }
|
||||||
|
|
||||||
public sunGt(sunSourceLocation location)
|
public sunGreaterThanOperator(sunSourceLocation location)
|
||||||
: base(location) { }
|
: base(location) { }
|
||||||
|
|
||||||
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteGT(); }
|
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteGT(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class sunGtEq : sunOperator {
|
class sunGreaterEqualOperator : sunOperator {
|
||||||
public override int Precedence { get { return 5; } }
|
public override int Precedence { get { return 5; } }
|
||||||
|
|
||||||
public sunGtEq(sunSourceLocation location)
|
public sunGreaterEqualOperator(sunSourceLocation location)
|
||||||
: base(location) { }
|
: base(location) { }
|
||||||
|
|
||||||
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteGE(); }
|
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteGE(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// precedence 6
|
// precedence 6
|
||||||
class sunBitLsh : sunOperator {
|
class sunShiftLeftOperator : sunOperator {
|
||||||
public override int Precedence { get { return 6; } }
|
public override int Precedence { get { return 6; } }
|
||||||
|
|
||||||
public sunBitLsh(sunSourceLocation location)
|
public sunShiftLeftOperator(sunSourceLocation location)
|
||||||
: base(location) { }
|
: base(location) { }
|
||||||
|
|
||||||
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteSHL(); }
|
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteSHL(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class sunBitRsh : sunOperator {
|
class sunShiftRightOperator : sunOperator {
|
||||||
public override int Precedence { get { return 6; } }
|
public override int Precedence { get { return 6; } }
|
||||||
|
|
||||||
public sunBitRsh(sunSourceLocation location)
|
public sunShiftRightOperator(sunSourceLocation location)
|
||||||
: base(location) { }
|
: base(location) { }
|
||||||
|
|
||||||
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteSHR(); }
|
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteSHR(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// precedence 7
|
// precedence 7
|
||||||
class sunAdd : sunOperator {
|
class sunAddOperator : sunOperator {
|
||||||
public override int Precedence { get { return 7; } }
|
public override int Precedence { get { return 7; } }
|
||||||
|
|
||||||
public sunAdd(sunSourceLocation location)
|
public sunAddOperator(sunSourceLocation location)
|
||||||
: base(location) { }
|
: base(location) { }
|
||||||
|
|
||||||
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteADD(); }
|
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteADD(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class sunSub : sunOperator {
|
class sunSubtractOperator : sunOperator {
|
||||||
public override int Precedence { get { return 7; } }
|
public override int Precedence { get { return 7; } }
|
||||||
|
|
||||||
public sunSub(sunSourceLocation location)
|
public sunSubtractOperator(sunSourceLocation location)
|
||||||
: base(location) { }
|
: base(location) { }
|
||||||
|
|
||||||
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteSUB(); }
|
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteSUB(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// precedence 8
|
// precedence 8
|
||||||
class sunMul : sunOperator {
|
class sunMultiplyOperator : sunOperator {
|
||||||
public override int Precedence { get { return 8; } }
|
public override int Precedence { get { return 8; } }
|
||||||
|
|
||||||
public sunMul(sunSourceLocation location)
|
public sunMultiplyOperator(sunSourceLocation location)
|
||||||
: base(location) { }
|
: base(location) { }
|
||||||
|
|
||||||
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteMUL(); }
|
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteMUL(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class sunDiv : sunOperator {
|
class sunDivideOperator : sunOperator {
|
||||||
public override int Precedence { get { return 8; } }
|
public override int Precedence { get { return 8; } }
|
||||||
|
|
||||||
public sunDiv(sunSourceLocation location)
|
public sunDivideOperator(sunSourceLocation location)
|
||||||
: base(location) { }
|
: base(location) { }
|
||||||
|
|
||||||
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteDIV(); }
|
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteDIV(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class sunMod : sunOperator {
|
class sunModuloOperator : sunOperator {
|
||||||
public override int Precedence { get { return 8; } }
|
public override int Precedence { get { return 8; } }
|
||||||
|
|
||||||
public sunMod(sunSourceLocation location)
|
public sunModuloOperator(sunSourceLocation location)
|
||||||
: base(location) { }
|
: base(location) { }
|
||||||
|
|
||||||
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteMOD(); }
|
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteMOD(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// precedence 9
|
// precedence 9
|
||||||
class sunLogNOT : sunOperator {
|
class sunLogicalNotOperator : sunOperator {
|
||||||
public override int Precedence { get { return 9; } }
|
public override int Precedence { get { return 9; } }
|
||||||
|
|
||||||
public sunLogNOT(sunSourceLocation location)
|
public sunLogicalNotOperator(sunSourceLocation location)
|
||||||
: base(location) { }
|
: base(location) { }
|
||||||
|
|
||||||
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteNOT(); }
|
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteNOT(); }
|
||||||
}
|
}
|
||||||
class sunNeg : sunOperator {
|
class sunNegateOperator : sunOperator {
|
||||||
public override int Precedence { get { return 9; } }
|
public override int Precedence { get { return 9; } }
|
||||||
|
|
||||||
public sunNeg(sunSourceLocation location)
|
public sunNegateOperator(sunSourceLocation location)
|
||||||
: base(location) { }
|
: base(location) { }
|
||||||
|
|
||||||
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteNEG(); }
|
public override void Compile(sunCompiler compiler) { compiler.Binary.WriteNEG(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// assignment operators
|
// assignment operators
|
||||||
class sunAssign : sunOperator {
|
class sunAssignOperator : sunOperator {
|
||||||
public override Associativity Associativity { get { return Associativity.Right; } }
|
public override Associativity Associativity { get { return Associativity.Right; } }
|
||||||
public override int Precedence { get { return -1; } }
|
public override int Precedence { get { return -1; } }
|
||||||
|
|
||||||
public sunAssign(sunSourceLocation location)
|
public sunAssignOperator(sunSourceLocation location)
|
||||||
: base(location) { }
|
: base(location) { }
|
||||||
|
|
||||||
public virtual void Compile(sunCompiler compiler, sunStorableSymbol symbol, sunExpression expression) {
|
public virtual void Compile(sunCompiler compiler, sunStorableSymbol symbol, sunExpression expression) {
|
||||||
|
@ -211,8 +211,8 @@ namespace arookas {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class sunAssignAdd : sunAssign {
|
class sunAssignAddOperator : sunAssignOperator {
|
||||||
public sunAssignAdd(sunSourceLocation location)
|
public sunAssignAddOperator(sunSourceLocation location)
|
||||||
: base(location) { }
|
: base(location) { }
|
||||||
|
|
||||||
public override void Compile(sunCompiler compiler, sunStorableSymbol symbol, sunExpression expression) {
|
public override void Compile(sunCompiler compiler, sunStorableSymbol symbol, sunExpression expression) {
|
||||||
|
@ -223,8 +223,8 @@ namespace arookas {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class sunAssignSub : sunAssign {
|
class sunAssignSubtractOperator : sunAssignOperator {
|
||||||
public sunAssignSub(sunSourceLocation location)
|
public sunAssignSubtractOperator(sunSourceLocation location)
|
||||||
: base(location) { }
|
: base(location) { }
|
||||||
|
|
||||||
public override void Compile(sunCompiler compiler, sunStorableSymbol symbol, sunExpression expression) {
|
public override void Compile(sunCompiler compiler, sunStorableSymbol symbol, sunExpression expression) {
|
||||||
|
@ -235,8 +235,8 @@ namespace arookas {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class sunAssignMul : sunAssign {
|
class sunAssignMultiplyOperator : sunAssignOperator {
|
||||||
public sunAssignMul(sunSourceLocation location)
|
public sunAssignMultiplyOperator(sunSourceLocation location)
|
||||||
: base(location) { }
|
: base(location) { }
|
||||||
|
|
||||||
public override void Compile(sunCompiler compiler, sunStorableSymbol symbol, sunExpression expression) {
|
public override void Compile(sunCompiler compiler, sunStorableSymbol symbol, sunExpression expression) {
|
||||||
|
@ -247,8 +247,8 @@ namespace arookas {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class sunAssignDiv : sunAssign {
|
class sunAssignDivideOperator : sunAssignOperator {
|
||||||
public sunAssignDiv(sunSourceLocation location)
|
public sunAssignDivideOperator(sunSourceLocation location)
|
||||||
: base(location) { }
|
: base(location) { }
|
||||||
|
|
||||||
public override void Compile(sunCompiler compiler, sunStorableSymbol symbol, sunExpression expression) {
|
public override void Compile(sunCompiler compiler, sunStorableSymbol symbol, sunExpression expression) {
|
||||||
|
@ -259,8 +259,8 @@ namespace arookas {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class sunAssignMod : sunAssign {
|
class sunAssignModuloOperator : sunAssignOperator {
|
||||||
public sunAssignMod(sunSourceLocation location)
|
public sunAssignModuloOperator(sunSourceLocation location)
|
||||||
: base(location) { }
|
: base(location) { }
|
||||||
|
|
||||||
public override void Compile(sunCompiler compiler, sunStorableSymbol symbol, sunExpression expression) {
|
public override void Compile(sunCompiler compiler, sunStorableSymbol symbol, sunExpression expression) {
|
||||||
|
@ -271,8 +271,8 @@ namespace arookas {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class sunAssignBitAND : sunAssign {
|
class sunAssignBitwiseAndOperator : sunAssignOperator {
|
||||||
public sunAssignBitAND(sunSourceLocation location)
|
public sunAssignBitwiseAndOperator(sunSourceLocation location)
|
||||||
: base(location) { }
|
: base(location) { }
|
||||||
|
|
||||||
public override void Compile(sunCompiler compiler, sunStorableSymbol symbol, sunExpression expression) {
|
public override void Compile(sunCompiler compiler, sunStorableSymbol symbol, sunExpression expression) {
|
||||||
|
@ -283,8 +283,8 @@ namespace arookas {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class sunAssignBitOR : sunAssign {
|
class sunAssignBitwiseOrOperator : sunAssignOperator {
|
||||||
public sunAssignBitOR(sunSourceLocation location)
|
public sunAssignBitwiseOrOperator(sunSourceLocation location)
|
||||||
: base(location) { }
|
: base(location) { }
|
||||||
|
|
||||||
public override void Compile(sunCompiler compiler, sunStorableSymbol symbol, sunExpression expression) {
|
public override void Compile(sunCompiler compiler, sunStorableSymbol symbol, sunExpression expression) {
|
||||||
|
@ -295,8 +295,8 @@ namespace arookas {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class sunAssignBitLsh : sunAssign {
|
class sunAssignShiftLeftOperator : sunAssignOperator {
|
||||||
public sunAssignBitLsh(sunSourceLocation location)
|
public sunAssignShiftLeftOperator(sunSourceLocation location)
|
||||||
: base(location) { }
|
: base(location) { }
|
||||||
|
|
||||||
public override void Compile(sunCompiler compiler, sunStorableSymbol symbol, sunExpression expression) {
|
public override void Compile(sunCompiler compiler, sunStorableSymbol symbol, sunExpression expression) {
|
||||||
|
@ -307,8 +307,8 @@ namespace arookas {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class sunAssignBitRsh : sunAssign {
|
class sunAssignShiftRightOperator : sunAssignOperator {
|
||||||
public sunAssignBitRsh(sunSourceLocation location)
|
public sunAssignShiftRightOperator(sunSourceLocation location)
|
||||||
: base(location) { }
|
: base(location) { }
|
||||||
|
|
||||||
public override void Compile(sunCompiler compiler, sunStorableSymbol symbol, sunExpression expression) {
|
public override void Compile(sunCompiler compiler, sunStorableSymbol symbol, sunExpression expression) {
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
class sunVariableDefinition : sunNode {
|
class sunVariableDefinition : sunNode {
|
||||||
public sunIdentifier Name { get { return this[1] as sunIdentifier; } }
|
public sunIdentifier Name { get { return this[1] as sunIdentifier; } }
|
||||||
public sunAssign Operator { get { return this[2] as sunAssign; } }
|
public sunAssignOperator Operator { get { return this[2] as sunAssignOperator; } }
|
||||||
public sunExpression Expression { get { return this[3] as sunExpression; } }
|
public sunExpression Expression { get { return this[3] as sunExpression; } }
|
||||||
|
|
||||||
public sunSymbolModifiers Modifiers {
|
public sunSymbolModifiers Modifiers {
|
||||||
|
@ -56,7 +56,7 @@
|
||||||
|
|
||||||
class sunStorableAssignment : sunNode {
|
class sunStorableAssignment : sunNode {
|
||||||
public sunIdentifier Name { get { return this[0] as sunIdentifier; } }
|
public sunIdentifier Name { get { return this[0] as sunIdentifier; } }
|
||||||
public sunAssign Operator { get { return this[1] as sunAssign; } }
|
public sunAssignOperator Operator { get { return this[1] as sunAssignOperator; } }
|
||||||
public sunExpression Expression { get { return this[2] as sunExpression; } }
|
public sunExpression Expression { get { return this[2] as sunExpression; } }
|
||||||
|
|
||||||
public sunStorableAssignment(sunSourceLocation location)
|
public sunStorableAssignment(sunSourceLocation location)
|
||||||
|
|
|
@ -90,11 +90,11 @@ namespace arookas {
|
||||||
|
|
||||||
// literals
|
// literals
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case __sunConstants.INT_NUMBER: return new sunIntLiteral(location, token);
|
case __sunConstants.INTEGER_LITERAL: return new sunIntLiteral(location, token);
|
||||||
case __sunConstants.HEX_NUMBER: return new sunHexLiteral(location, token);
|
case __sunConstants.HEX_LITERAL: return new sunHexLiteral(location, token);
|
||||||
case __sunConstants.DEC_NUMBER: return new sunFloatLiteral(location, token);
|
case __sunConstants.FLOAT_LITERAL: return new sunFloatLiteral(location, token);
|
||||||
case __sunConstants.ADR_NUMBER: return new sunAddressLiteral(location, token);
|
case __sunConstants.ADDRESS_LITERAL: return new sunAddressLiteral(location, token);
|
||||||
case __sunConstants.STRING: return new sunStringLiteral(location, token);
|
case __sunConstants.STRING_LITERAL: return new sunStringLiteral(location, token);
|
||||||
case __sunConstants.IDENTIFIER: return new sunIdentifier(location, token);
|
case __sunConstants.IDENTIFIER: return new sunIdentifier(location, token);
|
||||||
case __sunConstants.ELLIPSIS: return new sunEllipsis(location);
|
case __sunConstants.ELLIPSIS: return new sunEllipsis(location);
|
||||||
case __sunConstants.TRUE: return new sunTrue(location);
|
case __sunConstants.TRUE: return new sunTrue(location);
|
||||||
|
@ -103,44 +103,44 @@ namespace arookas {
|
||||||
|
|
||||||
// operators
|
// operators
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case __sunConstants.ADD: return new sunAdd(location);
|
case __sunConstants.ADD: return new sunAddOperator(location);
|
||||||
case __sunConstants.SUB: {
|
case __sunConstants.SUB: {
|
||||||
if (parent == __sunConstants.UNARY_OPERATOR) {
|
if (parent == __sunConstants.UNARY_OPERATOR) {
|
||||||
return new sunNeg(location);
|
return new sunNegateOperator(location);
|
||||||
}
|
}
|
||||||
return new sunSub(location);
|
return new sunSubtractOperator(location);
|
||||||
}
|
}
|
||||||
case __sunConstants.MUL: return new sunMul(location);
|
case __sunConstants.MUL: return new sunMultiplyOperator(location);
|
||||||
case __sunConstants.DIV: return new sunDiv(location);
|
case __sunConstants.DIV: return new sunDivideOperator(location);
|
||||||
case __sunConstants.MOD: return new sunMod(location);
|
case __sunConstants.MOD: return new sunModuloOperator(location);
|
||||||
|
|
||||||
case __sunConstants.BIT_AND: return new sunBitAND(location);
|
case __sunConstants.BAND: return new sunBitwiseAndOperator(location);
|
||||||
case __sunConstants.BIT_OR: return new sunBitOR(location);
|
case __sunConstants.BOR: return new sunBitwiseOrOperator(location);
|
||||||
case __sunConstants.BIT_LSH: return new sunBitLsh(location);
|
case __sunConstants.LSH: return new sunShiftLeftOperator(location);
|
||||||
case __sunConstants.BIT_RSH: return new sunBitRsh(location);
|
case __sunConstants.RSH: return new sunShiftRightOperator(location);
|
||||||
|
|
||||||
case __sunConstants.LOG_AND: return new sunLogAND(location);
|
case __sunConstants.AND: return new sunLogicalAndOperator(location);
|
||||||
case __sunConstants.LOG_OR: return new sunLogOR(location);
|
case __sunConstants.OR: return new sunLogicalOrOperator(location);
|
||||||
case __sunConstants.LOG_NOT: return new sunLogNOT(location);
|
case __sunConstants.NOT: return new sunLogicalNotOperator(location);
|
||||||
|
|
||||||
case __sunConstants.EQ: return new sunEq(location);
|
case __sunConstants.EQ: return new sunEqualOperator(location);
|
||||||
case __sunConstants.NEQ: return new sunNtEq(location);
|
case __sunConstants.NE: return new sunNotEqualOperator(location);
|
||||||
case __sunConstants.LT: return new sunLt(location);
|
case __sunConstants.LT: return new sunLessThanOperator(location);
|
||||||
case __sunConstants.GT: return new sunGt(location);
|
case __sunConstants.GT: return new sunGreaterThanOperator(location);
|
||||||
case __sunConstants.LTEQ: return new sunLtEq(location);
|
case __sunConstants.LE: return new sunLessEqualOperator(location);
|
||||||
case __sunConstants.GTEQ: return new sunGtEq(location);
|
case __sunConstants.GE: return new sunGreaterEqualOperator(location);
|
||||||
|
|
||||||
case __sunConstants.ASSIGN: return new sunAssign(location);
|
case __sunConstants.ASSIGN: return new sunAssignOperator(location);
|
||||||
case __sunConstants.ASSIGN_ADD: return new sunAssignAdd(location);
|
case __sunConstants.ASSIGN_ADD: return new sunAssignAddOperator(location);
|
||||||
case __sunConstants.ASSIGN_SUB: return new sunAssignSub(location);
|
case __sunConstants.ASSIGN_SUB: return new sunAssignSubtractOperator(location);
|
||||||
case __sunConstants.ASSIGN_MUL: return new sunAssignMul(location);
|
case __sunConstants.ASSIGN_MUL: return new sunAssignMultiplyOperator(location);
|
||||||
case __sunConstants.ASSIGN_DIV: return new sunAssignDiv(location);
|
case __sunConstants.ASSIGN_DIV: return new sunAssignDivideOperator(location);
|
||||||
case __sunConstants.ASSIGN_MOD: return new sunAssignMod(location);
|
case __sunConstants.ASSIGN_MOD: return new sunAssignModuloOperator(location);
|
||||||
|
|
||||||
case __sunConstants.ASSIGN_BIT_AND: return new sunAssignBitAND(location);
|
case __sunConstants.ASSIGN_BAND: return new sunAssignBitwiseAndOperator(location);
|
||||||
case __sunConstants.ASSIGN_BIT_OR: return new sunAssignBitOR(location);
|
case __sunConstants.ASSIGN_BOR: return new sunAssignBitwiseOrOperator(location);
|
||||||
case __sunConstants.ASSIGN_BIT_LSH: return new sunAssignBitLsh(location);
|
case __sunConstants.ASSIGN_LSH: return new sunAssignShiftLeftOperator(location);
|
||||||
case __sunConstants.ASSIGN_BIT_RSH: return new sunAssignBitRsh(location);
|
case __sunConstants.ASSIGN_RSH: return new sunAssignShiftRightOperator(location);
|
||||||
|
|
||||||
case __sunConstants.INCREMENT: return new sunIncrement(location);
|
case __sunConstants.INCREMENT: return new sunIncrement(location);
|
||||||
case __sunConstants.DECREMENT: return new sunDecrement(location);
|
case __sunConstants.DECREMENT: return new sunDecrement(location);
|
||||||
|
|
|
@ -17,8 +17,8 @@ IMPORT = "import"
|
||||||
BUILTIN = "builtin"
|
BUILTIN = "builtin"
|
||||||
FUNCTION = "function"
|
FUNCTION = "function"
|
||||||
VAR = "var"
|
VAR = "var"
|
||||||
CONST = "const"
|
|
||||||
LOCAL = "local"
|
LOCAL = "local"
|
||||||
|
CONST = "const"
|
||||||
|
|
||||||
IF = "if"
|
IF = "if"
|
||||||
ELSE = "else"
|
ELSE = "else"
|
||||||
|
@ -59,21 +59,21 @@ MUL = "*"
|
||||||
DIV = "/"
|
DIV = "/"
|
||||||
MOD = "%"
|
MOD = "%"
|
||||||
|
|
||||||
BIT_AND = "&"
|
BAND = "&"
|
||||||
BIT_OR = "|"
|
BOR = "|"
|
||||||
BIT_LSH = "<<"
|
LSH = "<<"
|
||||||
BIT_RSH = ">>"
|
RSH = ">>"
|
||||||
|
|
||||||
LOG_NOT = "!"
|
NOT = "!"
|
||||||
LOG_AND = "&&"
|
AND = "&&"
|
||||||
LOG_OR = "||"
|
OR = "||"
|
||||||
|
|
||||||
EQ = "=="
|
EQ = "=="
|
||||||
NEQ = "!="
|
NE = "!="
|
||||||
LT = "<"
|
LT = "<"
|
||||||
LTEQ = "<="
|
LE = "<="
|
||||||
GT = ">"
|
GT = ">"
|
||||||
GTEQ = ">="
|
GE = ">="
|
||||||
|
|
||||||
ASSIGN = "="
|
ASSIGN = "="
|
||||||
ASSIGN_ADD = "+="
|
ASSIGN_ADD = "+="
|
||||||
|
@ -81,21 +81,21 @@ ASSIGN_SUB = "-="
|
||||||
ASSIGN_MUL = "*="
|
ASSIGN_MUL = "*="
|
||||||
ASSIGN_DIV = "/="
|
ASSIGN_DIV = "/="
|
||||||
ASSIGN_MOD = "%="
|
ASSIGN_MOD = "%="
|
||||||
ASSIGN_BIT_AND = "&="
|
ASSIGN_BAND = "&="
|
||||||
ASSIGN_BIT_OR = "|="
|
ASSIGN_BOR = "|="
|
||||||
ASSIGN_BIT_LSH = "<<="
|
ASSIGN_LSH = "<<="
|
||||||
ASSIGN_BIT_RSH = ">>="
|
ASSIGN_RSH = ">>="
|
||||||
|
|
||||||
INCREMENT = "++"
|
INCREMENT = "++"
|
||||||
DECREMENT = "--"
|
DECREMENT = "--"
|
||||||
|
|
||||||
// literals
|
// literals
|
||||||
IDENTIFIER = <<[_A-Za-z][_A-Za-z0-9]*>>
|
IDENTIFIER = <<[_A-Za-z][_A-Za-z0-9]*>>
|
||||||
DEC_NUMBER = <<-?[0-9]+\.[0-9]+>>
|
FLOAT_LITERAL = <<-?[0-9]+\.[0-9]+>>
|
||||||
HEX_NUMBER = <<-?0x[0-9A-Fa-f]+>>
|
HEX_LITERAL = <<-?0x[0-9A-Fa-f]+>>
|
||||||
INT_NUMBER = <<-?[0-9]+>>
|
INTEGER_LITERAL = <<-?[0-9]+>>
|
||||||
ADR_NUMBER = <<\$[0-9A-Fa-f]{8}>>
|
ADDRESS_LITERAL = <<\$[0-9A-Fa-f]{8}>>
|
||||||
STRING = <<"(\\.|[^"])*">>
|
STRING_LITERAL = <<"(\\.|[^"])*">>
|
||||||
|
|
||||||
%productions%
|
%productions%
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ compound_statement_item =
|
||||||
function_call;
|
function_call;
|
||||||
statement_block = L_BRACE {statement} R_BRACE;
|
statement_block = L_BRACE {statement} R_BRACE;
|
||||||
|
|
||||||
import_statement = IMPORT STRING;
|
import_statement = IMPORT STRING_LITERAL;
|
||||||
yield_statement = YIELD;
|
yield_statement = YIELD;
|
||||||
exit_statement = EXIT;
|
exit_statement = EXIT;
|
||||||
lock_statement = LOCK;
|
lock_statement = LOCK;
|
||||||
|
@ -141,14 +141,14 @@ unlock_statement = UNLOCK;
|
||||||
name_label = IDENTIFIER COLON;
|
name_label = IDENTIFIER COLON;
|
||||||
|
|
||||||
// operators
|
// operators
|
||||||
assignment_operator = ASSIGN | ASSIGN_ADD | ASSIGN_SUB | ASSIGN_MUL | ASSIGN_DIV | ASSIGN_MOD | ASSIGN_BIT_AND | ASSIGN_BIT_OR | ASSIGN_BIT_LSH | ASSIGN_BIT_RSH;
|
assignment_operator = ASSIGN | ASSIGN_ADD | ASSIGN_SUB | ASSIGN_MUL | ASSIGN_DIV | ASSIGN_MOD | ASSIGN_BAND | ASSIGN_BOR | ASSIGN_LSH | ASSIGN_RSH;
|
||||||
ternary_operator = expression QMARK expression COLON expression;
|
ternary_operator = expression QMARK expression COLON expression;
|
||||||
binary_operator =
|
binary_operator =
|
||||||
ADD | SUB | MUL | DIV | MOD | // arithmetic
|
ADD | SUB | MUL | DIV | MOD | // arithmetic
|
||||||
BIT_AND | BIT_OR | BIT_LSH | BIT_RSH | // bitwise
|
BAND | BOR | LSH | RSH | // bitwise
|
||||||
EQ | NEQ | LT | LTEQ | GT | GTEQ | // comparison
|
EQ | NE | LT | LE | GT | GE | // comparison
|
||||||
LOG_AND | LOG_OR; // logical
|
AND | OR; // logical
|
||||||
unary_operator = LOG_NOT | SUB;
|
unary_operator = NOT | SUB;
|
||||||
augment_operator = INCREMENT | DECREMENT;
|
augment_operator = INCREMENT | DECREMENT;
|
||||||
|
|
||||||
// expressions
|
// expressions
|
||||||
|
@ -158,11 +158,11 @@ term =
|
||||||
function_call |
|
function_call |
|
||||||
variable_reference |
|
variable_reference |
|
||||||
variable_augment |
|
variable_augment |
|
||||||
STRING |
|
STRING_LITERAL |
|
||||||
DEC_NUMBER |
|
FLOAT_LITERAL |
|
||||||
ADR_NUMBER |
|
ADDRESS_LITERAL |
|
||||||
HEX_NUMBER |
|
HEX_LITERAL |
|
||||||
INT_NUMBER |
|
INTEGER_LITERAL |
|
||||||
TRUE |
|
TRUE |
|
||||||
FALSE |
|
FALSE |
|
||||||
L_PAREN expression R_PAREN |
|
L_PAREN expression R_PAREN |
|
||||||
|
|
Loading…
Reference in a new issue