Skip to content

Commit f99f223

Browse files
committed
rewrite ecp
1 parent 3bc4c73 commit f99f223

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+417
-392
lines changed

Diff for: EC.Device/V1/Utils/SwitchCommand.cs renamed to EC.Device/SwitchCommand.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System;
2-
3-
namespace EC.Device;
1+
namespace EC.Device;
42

53
public static class SwitchStick
64
{
File renamed without changes.

Diff for: EC.Device/V1/ECKeyUtil.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System;
2-
3-
namespace EC.Device;
1+
namespace EC.Device;
42

53
public static class ECKeyUtil
64
{

Diff for: EC.Device/V1/KeyStroke.cs

+13-16
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
1-
using System;
1+
namespace EC.Device;
22

3-
namespace EC.Device
3+
public class KeyStroke
44
{
5-
public class KeyStroke
6-
{
7-
public readonly ECKey Key;
8-
public int KeyCode => Key.KeyCode;
9-
public readonly bool Up;
10-
public readonly int Duration;
11-
public readonly DateTime Time;
5+
public readonly ECKey Key;
6+
public int KeyCode => Key.KeyCode;
7+
public readonly bool Up;
8+
public readonly int Duration;
9+
public readonly DateTime Time;
1210

13-
public KeyStroke(ECKey key, bool up = false, int duration = 0, DateTime time = default)
14-
{
15-
Key = key;
16-
Up = up;
17-
Duration = duration;
18-
Time = DateTime.Now;
19-
}
11+
public KeyStroke(ECKey key, bool up = false, int duration = 0, DateTime time = default)
12+
{
13+
Key = key;
14+
Up = up;
15+
Duration = duration;
16+
Time = DateTime.Now;
2017
}
2118
}

Diff for: EC.Device/V1/Utils/NSExtentions.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.Drawing;
1+
using System.Drawing;
32

43
namespace EC.Device;
54

Diff for: EC.Script.Tests/UnitTest1.cs renamed to EC.Script.Tests/ParserTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Text.RegularExpressions;
22

3-
namespace EC.Script.Tests;
3+
namespace ECScript.Tests;
44

55
[TestFixture]
66
public class Tests

Diff for: EC.Script.Tests/PointerUtil.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace EC.Script.Tests;
1+
namespace ECScript.Tests;
22

33
static class PointerUtil
44
{

Diff for: EC.Script.Tests/ScriptUtil.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
using System.Text.RegularExpressions;
2-
using EC.Script;
32
using System.Text;
43

5-
namespace EC.Script.Tests;
4+
namespace ECScript.Tests;
65

76
static class ScriptUtil
87
{

Diff for: EC.Script/Ast/ArrayLiteral.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using ECScript.Syntax;
1+
using EC.Script.Syntax;
22

3-
namespace ECP.Ast;
3+
namespace EC.Script.Ast;
44
internal sealed class ArrayLiteral : Expression
55
{
66
public ArrayLiteral(SyntaxNode syntax) : base(syntax)

Diff for: EC.Script/Ast/AssignExpr.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using ECScript.Syntax;
1+
using EC.Script.Syntax;
22

3-
namespace ECP.Ast;
3+
namespace EC.Script.Ast;
44

55
internal sealed class AssignExpr : Statement
66
{

Diff for: EC.Script/Ast/AstNode.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using ECScript.Syntax;
1+
using EC.Script.Syntax;
22

3-
namespace ECP.Ast;
3+
namespace EC.Script.Ast;
44

55
internal abstract class AstNode
66
{

Diff for: EC.Script/Ast/AstNodeType.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace ECP.Ast;
1+
namespace EC.Script.Ast;
22

33
internal enum AstNodeType
44
{
@@ -13,6 +13,7 @@ internal enum AstNodeType
1313
ConditionalGotoStatement,
1414
ReturnStatement,
1515
ExpressionStatement,
16+
KeyActionStatement,
1617

1718
// Expressions
1819
ErrorExpression,

Diff for: EC.Script/Ast/AstVisitor.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace ECP.Ast;
1+
namespace EC.Script.Ast;
22

33
internal abstract class AstVisitor : IAstVisitor<AstNode>
44
{

Diff for: EC.Script/Ast/AugAssignExpr.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using ECScript.Syntax;
1+
using EC.Script.Syntax;
22

3-
namespace ECP.Ast;
3+
namespace EC.Script.Ast;
44

55
internal sealed class AugAssignExpr : Expression
66
{

Diff for: EC.Script/Ast/BinaryExpr.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using ECScript.Syntax;
1+
using EC.Script.Syntax;
22

3-
namespace ECP.Ast;
3+
namespace EC.Script.Ast;
44

55
internal sealed class BinaryExpr : Expression
66
{

Diff for: EC.Script/Ast/BinaryOperator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace ECP.Ast;
1+
namespace EC.Script.Ast;
22

33
internal enum BinaryOperator
44
{

Diff for: EC.Script/Ast/CallExpr.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
using ECScript.Syntax;
1+
using EC.Script.Syntax;
22
using System.Collections.ObjectModel;
33

4-
namespace ECP.Ast;
4+
namespace EC.Script.Ast;
55

66
internal sealed class CallExpr : Expression
77
{

Diff for: EC.Script/Ast/ConstDecl.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using ECScript.Syntax;
1+
using EC.Script.Syntax;
22

3-
namespace ECP.Ast;
3+
namespace EC.Script.Ast;
44

55
internal sealed class ConstDecl : Statement
66
{

Diff for: EC.Script/Ast/ElseStmt.cs

-17
This file was deleted.

Diff for: EC.Script/Ast/ForStmt.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using ECScript.Syntax;
1+
using EC.Script.Syntax;
22

3-
namespace ECP.Ast;
3+
namespace EC.Script.Ast;
44

55
internal sealed class ForStmt : Statement
66
{

Diff for: EC.Script/Ast/IAstVisitor.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace ECP.Ast;
1+
namespace EC.Script.Ast;
22

33
internal interface IAstVisitor<T>
44
{

Diff for: EC.Script/Ast/IfStmt.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
using ECScript.Syntax;
1+
using EC.Script.Syntax;
22

3-
namespace ECP.Ast;
3+
namespace EC.Script.Ast;
44

55
internal sealed class IfStmt : Statement
66
{
77
public IfStmt(SyntaxNode syntax) : base(syntax)
88
{
99
}
1010

11-
public override AstNodeType Kind => throw new NotImplementedException();
11+
public override AstNodeType Kind => AstNodeType.IfStatement;
1212

1313
public override T Accept<T>(IAstVisitor<T> visitor)
1414
{

Diff for: EC.Script/Ast/KeyAction.cs

+7-54
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,16 @@
1-
using ECScript.Syntax;
1+
using EC.Script.Syntax;
22

3-
namespace ECP.Ast;
4-
5-
/*
6-
internal abstract class KeyAction : Statement
7-
{
8-
protected KeyAction(SyntaxNode syntax) : base(syntax)
9-
{
10-
}
11-
}
12-
13-
internal sealed class ButtonAction : KeyAction
14-
{
15-
public ButtonAction(LexemeValue name)
16-
{
17-
Key = name.Content.ToUpper();
18-
Duration = "50";
19-
}
20-
21-
public ButtonAction(LexemeValue name, IntLiteral duration)
22-
{
23-
Key = name.Content.ToUpper();
24-
Duration = duration.VariableRef.VariableName.Content;
25-
}
26-
27-
public ButtonAction(LexemeValue name, string destination)
28-
{
29-
Key = name.Content.ToUpper();
30-
Duration = destination.ToUpper();
31-
}
32-
33-
public string Key { get; init; }
34-
public string Duration { get; init; }
35-
36-
public override AstNodeType Kind => throw new NotImplementedException();
37-
38-
public override T Accept<T>(IAstVisitor<T> visitor)
39-
{
40-
return visitor.VisitButtonAction(this);
41-
}
42-
}
43-
44-
public class StickAction : ButtonAction
3+
namespace EC.Script.Ast;
4+
internal sealed class KeyActionStatement : Statement
455
{
46-
public StickAction(LexemeValue name, LexemeValue destination) : base(name)
47-
{
48-
Destination = destination;
49-
}
50-
51-
public StickAction(LexemeValue name, LexemeValue destination, IntLiteral duration) : base(name, duration)
6+
public KeyActionStatement(SyntaxNode syntax) : base(syntax)
527
{
53-
Destination = destination;
548
}
559

56-
public LexemeValue Destination { get; init; }
10+
public override AstNodeType Kind => AstNodeType.KeyActionStatement;
5711

5812
public override T Accept<T>(IAstVisitor<T> visitor)
5913
{
60-
return visitor.VisitStickAction(this);
14+
throw new NotImplementedException();
6115
}
62-
}
63-
*/
16+
}

Diff for: EC.Script/Ast/MainProgram.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using ECScript.Syntax;
1+
using EC.Script.Syntax;
22

3-
namespace ECP.Ast;
3+
namespace EC.Script.Ast;
44

55
internal sealed class MainProgram : AstNode
66
{

Diff for: EC.Script/Ast/UnaryExpr.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using ECScript.Syntax;
1+
using EC.Script.Syntax;
22

3-
namespace ECP.Ast;
3+
namespace EC.Script.Ast;
44

55
internal sealed class UnaryExpr : Expression
66
{

Diff for: EC.Script/Ast/Variable.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using ECScript.Syntax;
1+
using EC.Script.Syntax;
22

3-
namespace ECP.Ast;
3+
namespace EC.Script.Ast;
44

55
internal sealed class Variable : Expression
66
{

Diff for: EC.Script/Diagnostic.cs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using EC.Script.Text;
2+
3+
namespace EC.Script;
4+
5+
public sealed class Diagnostic
6+
{
7+
private Diagnostic(bool isError, SourceSpan location, string message)
8+
{
9+
Location = location;
10+
Message = message;
11+
}
12+
13+
public SourceSpan Location { get; init; }
14+
public string Message { get; init; }
15+
16+
public override string ToString() => Message;
17+
}

Diff for: EC.Script/DiagnosticBag.cs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using EC.Script.Text;
2+
using System.Collections;
3+
4+
namespace EC.Script;
5+
6+
internal sealed class DiagnosticBag : IEnumerable<Diagnostic>
7+
{
8+
private readonly List<Diagnostic> _diagnostics = [];
9+
10+
public IEnumerator<Diagnostic> GetEnumerator() => _diagnostics.GetEnumerator();
11+
12+
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
13+
14+
private void Report(SourceSpan location, string message)
15+
{
16+
throw new NotImplementedException();
17+
}
18+
19+
public void ReportInvalidNumber(SourceSpan location, string text)
20+
{
21+
var message = $"{text}";
22+
Report(location, message);
23+
}
24+
}

0 commit comments

Comments
 (0)