internal ElaExpression(Token tok, ElaNodeType type) { Type = type; if (tok != null) { Line = tok.line; Column = tok.col; } }
internal static ElaMessage CreateMessage(int error, string message, int line, int col, Token tok) { var err = String.IsNullOrEmpty(tok.val) ? ElaParserError.InvalidSyntax : ElaParserError.InvalidSyntaxUnexpectedSymbol; var msg = tok.val; if (error == -1) err = ElaParserError.TabNotAllowed; else if (error == Parser._EBLOCK) err = ElaParserError.IncorrectIndentation; else { var arr = message.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (arr.Length == 2) { var head = arr[0].Trim('\"'); var tail = arr[1].Trim('\"'); var exp = tail == "expected"; var e = exp ? ExpectToken(error, head) : InvalidToken(error, tail); if (e != ElaParserError.InvalidRoot || err != ElaParserError.InvalidSyntaxUnexpectedSymbol) { err = e; msg = exp ? head : tail; } } } if (err == ElaParserError.ExpectedEof && !String.IsNullOrEmpty(tok.val)) { err = ElaParserError.InvalidIndentationUnexpectedSymbol; msg = tok.val; } return new ElaMessage(Strings.GetMessage(err, msg), MessageType.Error, (Int32)err, line, col); }
internal ElaTypeClass(Token tok) : base(tok, ElaNodeType.TypeClass) { Members = new List<ElaClassMember>(); }
internal ElaTupleLiteral(Token tok, ElaNodeType type) : base(tok, type) { }
internal ElaBuiltin(Token tok) : base(tok, ElaNodeType.Builtin) { }
internal ElaLazyLiteral(Token tok) : base(tok, ElaNodeType.LazyLiteral) { }
internal ElaCondition(Token tok) : base(tok, ElaNodeType.Condition) { }
internal ElaMatch(Token tok) : this(tok, ElaNodeType.Match) { }
internal ElaRecordLiteral(Token tok) : this(tok, ElaNodeType.RecordLiteral) { }
public void Parse() { la = new Token(); la.val = ""; Get(); Ela(); Expect(0); }
void Get() { for (;;) { t = la; la = scanner.Scan(); if (la.kind <= maxT) { ++errDist; break; } la = t; } }
internal ElaGenerator(Token tok) : base(tok, ElaNodeType.Generator) { }
internal ElaHeader(Token t) : base(t, ElaNodeType.Header) { }
internal ElaFieldDeclaration(Token tok) : base(tok, ElaNodeType.FieldDeclaration) { }
internal ElaAs(Token t) : base(t, ElaNodeType.As) { }
internal ElaRecordLiteral(Token tok, ElaNodeType type) : base(tok, type) { Fields = new List<ElaFieldDeclaration>(); }
internal ElaLambda(Token tok) : base(tok, ElaNodeType.Lambda) { }
internal ElaPrimitive(Token tok) : base(tok, ElaNodeType.Primitive) { }
internal ElaMatch(Token tok, ElaNodeType type) : base(tok, type) { }
internal ElaRange(Token tok) : base(tok, ElaNodeType.Range) { }
internal ElaComprehension(Token tok) : base(tok, ElaNodeType.Comprehension) { }
internal ElaTupleLiteral(Token tok) : base(tok, ElaNodeType.TupleLiteral) { }
internal ElaJuxtaposition(Token tok) : base(tok, ElaNodeType.Juxtaposition) { Parameters = new List<ElaExpression>(); }
internal ElaFieldReference(Token tok) : base(tok, ElaNodeType.FieldReference) { }
internal ElaNewtype(Token tok) : base(tok, ElaNodeType.Newtype) { Constructors = new List<ElaExpression>(); ConstructorFlags = new List<ElaVariableFlags>(); }
internal ElaTry(Token tok) : base(tok, ElaNodeType.Try) { }
internal ElaImportedVariable(Token tok) : base(tok, ElaNodeType.ImportedVariable) { }
internal ElaUnitLiteral(Token tok) : base(tok, ElaNodeType.UnitLiteral) { }
internal ElaNameReference(Token tok) : base(tok, ElaNodeType.NameReference) { }
internal ElaTypeCheck(Token tok) : base(tok, ElaNodeType.TypeCheck) { }