-
Notifications
You must be signed in to change notification settings - Fork 107
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
9deefae
commit 8fa327f
Showing
7 changed files
with
69 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System.Diagnostics; | ||
using OneScript.Localization; | ||
|
||
namespace OneScript.Language.LexicalAnalysis | ||
{ | ||
public class LabelLexerState : LexerState | ||
{ | ||
private static BilingualString MESSAGE_NAME_EXPECTED = new BilingualString( | ||
"Ожидается имя метки", | ||
"Label name expected" | ||
); | ||
|
||
WordLexerState _wordExtractor = new WordLexerState(); | ||
|
||
public override Lexem ReadNextLexem(SourceCodeIterator iterator) | ||
{ | ||
Debug.Assert(iterator.CurrentSymbol == SpecialChars.Tilde); | ||
|
||
var start = new CodeRange(iterator.CurrentLine, iterator.CurrentColumn); | ||
iterator.MoveNext(); | ||
if (!iterator.MoveToContent()) | ||
throw CreateExceptionOnCurrentLine(MESSAGE_NAME_EXPECTED.ToString(), iterator); | ||
|
||
if (!char.IsLetter(iterator.CurrentSymbol)) | ||
throw CreateExceptionOnCurrentLine(MESSAGE_NAME_EXPECTED.ToString(), iterator); | ||
|
||
var result = _wordExtractor.ReadNextLexem(iterator); | ||
result.Type = LexemType.LabelRef; | ||
if (iterator.CurrentSymbol == SpecialChars.Colon) | ||
{ | ||
result.Type = LexemType.Label; | ||
iterator.MoveNext(); | ||
} | ||
|
||
result.Location = start; | ||
return result; | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -22,6 +22,8 @@ public enum LexemType | |
PreprocessorDirective, | ||
Annotation, | ||
Comment, | ||
Label, | ||
LabelRef, | ||
EndOfText | ||
} | ||
} |
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 |
---|---|---|
|
@@ -43,9 +43,7 @@ public enum Token | |
RemoveHandler, | ||
Async, | ||
Await, | ||
Tilde, | ||
Colon, | ||
|
||
|
||
// operators | ||
Plus, | ||
Minus, | ||
|
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