Skip to content

Commit 2c3c530

Browse files
author
Andrey Ovsiankin
committed
Merge branch 'develop' of https://github.com/EvilBeaver/OneScript into develop
2 parents f9930dd + 923f1c1 commit 2c3c530

File tree

14 files changed

+542
-492
lines changed

14 files changed

+542
-492
lines changed

Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pipeline {
55

66
environment {
77
VersionPrefix = '2.0.1'
8-
VersionSuffix = 'rc.1'+"+${BUILD_NUMBER}"
8+
VersionSuffix = 'rc.2'+"+${BUILD_NUMBER}"
99
outputEnc = '65001'
1010
}
1111

src/OneScript.Core/Execution/ForbiddenBslProcess.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace OneScript.Execution
2020
/// </summary>
2121
public class ForbiddenBslProcess : IBslProcess
2222
{
23-
public static IBslProcess Instance = new ForbiddenBslProcess();
23+
public static readonly IBslProcess Instance = new ForbiddenBslProcess();
2424

2525
private ForbiddenBslProcess()
2626
{}

src/OneScript.Language/LanguageDef.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,31 @@ public static Token GetToken(string tokText)
282282
public static int GetPriority(Token op)
283283
{
284284
return _priority[op];
285-
}
285+
}
286+
287+
public static int GetBinaryPriority(Token op)
288+
{
289+
return IsBinaryOperator(op) ? _priority[op] : -1;
290+
}
291+
292+
public static int GetUnaryPriority(Token op)
293+
{
294+
return op switch
295+
{
296+
Token.OpenPar => MAX_OPERATION_PRIORITY + 1,
297+
298+
Token.Not => _priority[op],
299+
Token.UnaryMinus => _priority[op],
300+
Token.UnaryPlus => _priority[op],
301+
302+
Token.Minus => _priority[Token.UnaryMinus],
303+
Token.Plus => _priority[Token.UnaryPlus],
304+
305+
_ => MAX_OPERATION_PRIORITY
306+
};
307+
}
308+
309+
286310

287311
[MethodImpl(MethodImplOptions.AggressiveInlining)]
288312
public static bool IsBuiltInFunction(Token token)

src/OneScript.Language/SyntaxAnalysis/AstNodes/BinaryOperationNode.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,13 @@ public BinaryOperationNode(Lexem operation) : base(NodeKind.BinaryOperation, ope
1717
{
1818
Operation = operation.Token;
1919
}
20+
21+
public BinaryOperationNode(BslSyntaxNode firstArg, BslSyntaxNode secondArg, Lexem operation)
22+
: base(NodeKind.BinaryOperation, operation)
23+
{
24+
Operation = operation.Token;
25+
AddChild(firstArg);
26+
AddChild(secondArg);
27+
}
2028
}
2129
}

src/OneScript.Language/SyntaxAnalysis/AstNodes/ConditionNode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public ConditionNode(Lexem startLexem) : base(NodeKind.Condition, startLexem)
2626
public IEnumerable<BslSyntaxNode> GetAlternatives()
2727
{
2828
if(_alternativesStart == 0)
29-
return new BslSyntaxNode[0];
29+
return System.Array.Empty<BslSyntaxNode>();
3030

3131
return Children
3232
.Skip(_alternativesStart)

src/OneScript.Language/SyntaxAnalysis/AstNodes/LineMarkerNode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ public LineMarkerNode(CodeRange location, NodeKind kind)
1818
Kind = kind;
1919
}
2020

21-
public override IReadOnlyList<BslSyntaxNode> Children => new BslSyntaxNode[0];
21+
public override IReadOnlyList<BslSyntaxNode> Children => System.Array.Empty<BslSyntaxNode>();
2222
}
2323
}

src/OneScript.Language/SyntaxAnalysis/AstNodes/MethodNode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public MethodNode() : base(NodeKind.Method)
3030
public IReadOnlyList<VariableDefinitionNode> VariableDefinitions()
3131
{
3232
if (VariableSection == default)
33-
return new VariableDefinitionNode[0];
33+
return System.Array.Empty<VariableDefinitionNode>();
3434

3535
return VariableSection.Children
3636
.Cast<VariableDefinitionNode>()

src/OneScript.Language/SyntaxAnalysis/AstNodes/MethodSignatureNode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public IEnumerable<MethodParameterNode> GetParameters()
2828
{
2929
var paramList = Children.FirstOrDefault(x => x.Kind == NodeKind.MethodParameters);
3030
if (paramList == default)
31-
return new MethodParameterNode[0];
31+
return System.Array.Empty<MethodParameterNode>();
3232

3333
return ((NonTerminalNode) paramList).Children.Cast<MethodParameterNode>();
3434
}

src/OneScript.Language/SyntaxAnalysis/AstNodes/TerminalNode.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ public TerminalNode(NodeKind kind, Lexem lexem)
2626
Location = lexem.Location;
2727
}
2828

29-
public override IReadOnlyList<BslSyntaxNode> Children => EmptyChildren;
30-
31-
private static readonly BslSyntaxNode[] EmptyChildren = new BslSyntaxNode[0];
29+
public override IReadOnlyList<BslSyntaxNode> Children => System.Array.Empty<BslSyntaxNode>();
3230
}
3331
}

src/OneScript.Language/SyntaxAnalysis/AstNodes/UnaryOperationNode.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ public class UnaryOperationNode : NonTerminalNode
1616
public UnaryOperationNode(Lexem operation) : base(NodeKind.UnaryOperation, operation)
1717
{
1818
Operation = operation.Token;
19-
}
19+
}
20+
21+
public UnaryOperationNode(BslSyntaxNode arg, Lexem operation) : base(NodeKind.UnaryOperation, operation)
22+
{
23+
Operation = operation.Token;
24+
AddChild(arg);
25+
}
2026
}
2127
}

0 commit comments

Comments
 (0)