-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
17 changed files
with
130 additions
and
75 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 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using System; | ||
using System.Linq; | ||
|
||
namespace PkgdefLanguage | ||
{ | ||
public partial class Document | ||
{ | ||
private void ValidateDocument() | ||
{ | ||
foreach (ParseItem item in Items) | ||
{ | ||
// Unknown symbols | ||
if (item.Type == ItemType.Unknown) | ||
{ | ||
item.Errors.Add("Unknown token at this location."); | ||
} | ||
|
||
// Registry key | ||
if (item.Type == ItemType.RegistryKey) | ||
{ | ||
var trimmedText = item.Text.Trim(); | ||
|
||
if (!trimmedText.EndsWith("]")) | ||
{ | ||
item.Errors.Add("Unclosed registry key entry. Add the missing ] character"); | ||
} | ||
|
||
if (trimmedText.Contains("/") && !trimmedText.Contains("\\/")) | ||
{ | ||
item.Errors.Add("Use the backslash character as delimiter instead of forward slash."); | ||
} | ||
} | ||
|
||
// Properties | ||
else if (item.Type == ItemType.Operator) | ||
{ | ||
ParseItem name = item.Previous; | ||
ParseItem value = item.Next; | ||
|
||
if (name?.Type == ItemType.String) | ||
{ | ||
if (name.Text == "\"@\"") | ||
{ | ||
name.Errors.Add("To set a registry key's default value, use '@' without quotation marks"); | ||
} | ||
} | ||
else if (name?.Type == ItemType.Literal && name?.Text != "@") | ||
{ | ||
name.Errors.Add("Value names must be enclosed in quotation marks."); | ||
} | ||
} | ||
|
||
// Make sure strings are correctly closed with quotation mark | ||
if (item.Type == ItemType.String) | ||
{ | ||
if (!item.Text.EndsWith("\"")) | ||
{ | ||
item.Errors.Add("Value names must be enclosed in quotation marks."); | ||
} | ||
} | ||
|
||
// Unknown references | ||
foreach (Reference reference in item.References) | ||
{ | ||
if (!CompletionCatalog.Variables.Any(v => v.Key.Equals(reference.Value.Text, StringComparison.OrdinalIgnoreCase))) | ||
{ | ||
reference.Value.Errors.Add($"The variable \"{item.Text}\" doens't exist."); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -8,6 +8,7 @@ public enum ItemType | |
RegistryKey, | ||
String, | ||
Literal, | ||
Operator, | ||
Unknown, | ||
} | ||
} |
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