2024-01-31 09:21:30 -06:00
|
|
|
using Microsoft.Iris.Asm.Models;
|
|
|
|
|
using Sprache;
|
2024-01-29 21:42:06 -06:00
|
|
|
using System.Linq;
|
|
|
|
|
|
2024-01-29 21:57:00 -06:00
|
|
|
namespace Microsoft.Iris.Asm;
|
2024-01-29 21:42:06 -06:00
|
|
|
|
2024-02-04 21:44:53 -06:00
|
|
|
public static partial class Lexer
|
2024-01-29 21:42:06 -06:00
|
|
|
{
|
|
|
|
|
public static readonly Parser<string> AlphanumericText = Parse.LetterOrDigit.AtLeastOnce().Text();
|
|
|
|
|
|
2024-02-08 10:50:57 -06:00
|
|
|
public static readonly Parser<string> WordText = Parse.Letter.AtLeastOnce().Text();
|
|
|
|
|
|
2024-02-08 13:32:44 -06:00
|
|
|
public static readonly Parser<string> WholeNumber = Parse.Digit.AtLeastOnce().Text();
|
|
|
|
|
|
2024-02-10 21:37:12 -06:00
|
|
|
public static readonly Parser<string> Identifier = Parse.LetterOrDigit.Or(Parse.Chars('_', '-')).AtLeastOnce().Text();
|
|
|
|
|
|
2024-01-29 21:42:06 -06:00
|
|
|
public static readonly Parser<string> Uri = Parse.LetterOrDigit.Or(Parse.Chars(":/!._-")).AtLeastOnce().Text();
|
|
|
|
|
|
|
|
|
|
public static readonly Parser<string> StatementEnd = Parse.Char(';').Return(";").Or(Parse.LineTerminator);
|
|
|
|
|
|
2024-02-04 22:09:21 -06:00
|
|
|
public static readonly Parser<IImport> Import = ParseImport;
|
|
|
|
|
|
2024-02-05 09:23:46 -06:00
|
|
|
public static readonly Parser<IDirective> Directive = ParseDirective;
|
|
|
|
|
|
2024-02-04 22:09:21 -06:00
|
|
|
public static readonly Parser<IBodyItem> BodyItem = ParseBodyItem;
|
|
|
|
|
|
2024-01-29 21:42:06 -06:00
|
|
|
public static readonly Parser<Program> Program =
|
2024-02-08 10:50:57 -06:00
|
|
|
from directives in Directive.Many()
|
2024-01-29 21:42:06 -06:00
|
|
|
from body in BodyItem.Many()
|
2024-02-08 10:50:57 -06:00
|
|
|
select new Program(directives, body);
|
2024-01-29 21:42:06 -06:00
|
|
|
|
2024-01-30 22:44:48 -06:00
|
|
|
private static IInput ConsumeWhitespace(IInput input) => Parse.WhiteSpace.Many()(input).Remainder;
|
2024-01-29 21:42:06 -06:00
|
|
|
}
|