-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
7 changed files
with
66 additions
and
71 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
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
namespace Silverfly; | ||
|
||
public class DefaultPrecedenceLevels : PrecedenceLevels | ||
{ | ||
public static string Assignment = nameof(Assignment); | ||
public static string Conditional = nameof(Conditional); | ||
public static string Sum = nameof(Sum); | ||
public static string Product = nameof(Sum); | ||
public static string Exponent = nameof(Exponent); | ||
public static string Prefix = nameof(Prefix); | ||
public static string PostFix = nameof(PostFix); | ||
public static string Call = nameof(Call); | ||
|
||
public DefaultPrecedenceLevels() | ||
{ | ||
AddPrecedence(Assignment); | ||
AddPrecedence(Conditional); | ||
AddPrecedence(Sum); | ||
AddPrecedence(Product); | ||
AddPrecedence(Exponent); | ||
AddPrecedence(Prefix); | ||
AddPrecedence(PostFix); | ||
AddPrecedence(Call); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Silverfly; | ||
|
||
public abstract class PrecedenceLevels | ||
{ | ||
private readonly List<string> precedenceLevels = new List<string>(); | ||
|
||
public int GetPrecedence(string level) | ||
{ | ||
var index = precedenceLevels.IndexOf(level); | ||
|
||
return index == -1 ? precedenceLevels.Count : index; | ||
} | ||
|
||
public void AddPrecedence(string level) | ||
{ | ||
if (!precedenceLevels.Contains(level)) | ||
{ | ||
precedenceLevels.Add(level); | ||
} | ||
} | ||
|
||
public void InsertPrecedence(int index, string level) | ||
{ | ||
if (!precedenceLevels.Contains(level)) | ||
{ | ||
precedenceLevels.Insert(index, level); | ||
} | ||
} | ||
} |
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