This repository has been archived by the owner on Oct 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
52b521d
commit 76c2714
Showing
7 changed files
with
110 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,34 @@ | ||
using System.Text; | ||
using System.Text.RegularExpressions; | ||
|
||
namespace Rockstar.Engine.Expressions; | ||
|
||
public class Variable(string name, Source source) : Expression(source) { | ||
|
||
public abstract class Variable(string name, Source source) : Expression(source) { | ||
public string Name => name; | ||
public override void Print(StringBuilder sb, int depth) { | ||
sb.Indent(depth).AppendLine($"variable: {name}"); | ||
} | ||
} | ||
|
||
protected static Regex whitespace = new("\\s+", RegexOptions.Compiled); | ||
|
||
protected string NormalizedName | ||
=> String.Join("_", whitespace.Split(Name)); | ||
|
||
public abstract string Key { get; } | ||
} | ||
|
||
public class SimpleVariable(string name, Source source) : Variable(name, source) { | ||
public SimpleVariable(string name) : this(name, Source.None) { } | ||
public override string Key => Name.ToLowerInvariant(); | ||
} | ||
|
||
public class ProperVariable(string name, Source source) : Variable(name, source) { | ||
public ProperVariable(string name) : this(name, Source.None) { } | ||
public override string Key => NormalizedName.ToUpperInvariant(); | ||
} | ||
|
||
public class CommonVariable(string name, Source source) : Variable(name, source) { | ||
public CommonVariable(string name) : this(name, Source.None) { } | ||
public override string Key => NormalizedName.ToLowerInvariant(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters