public Location Union(Location other) { if (File != other.File) throw new InvalidOperationException("locations are from distinct files"); if (StartPos <= other.StartPos) { if (EndPos >= other.EndPos) return this; else return new Location (File, StartPos, StartLine, StartColumn, other.EndPos, other.EndLine, other.EndColumn); } else { if (EndPos >= other.EndPos) return new Location (File, other.StartPos, other.StartLine, other.StartColumn, EndPos, EndLine, EndColumn); else return other; } }
private void ConsumeCommentStatement(ISeq<Statement> statements) { if (pendingComments != null) { statements.Add(new CommentStatement(pendingCommentsLoc, pendingComments.ToString())); pendingComments = null; pendingCommentsLoc = null; } }
// TODO: Invoke within statement parsers private Expression ConsumeCommentExpression(Expression e) { if (pendingComments != null) { e = new CommentExpression(pendingCommentsLoc, e, pendingComments.ToString()); pendingComments = null; pendingCommentsLoc = null; } return e; }
public Parser(Lexer lexer) { this.lexer = lexer; lookahead = new Seq<InputElement>(); lastLineTerminator = null; pendingComments = null; pendingCommentsLoc = null; }
public MessageContext(MessageContext parent, Location loc, Action<StringBuilder> append) { Parent = parent; Loc = loc; this.append = append; }
public static MessageContext TraceFile(Location loc) { return new MessageContext(null, loc, sb => { }); }
public SyntaxException(Location loc, string context, string details) { Loc = loc; Context = context; Details = details; }
public InputElement(Location loc, InputElementTag tag, string value) { Loc = loc; Tag = tag; Value = value; }