示例#1
0
 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;
     }
 }
示例#2
0
 private void ConsumeCommentStatement(ISeq<Statement> statements)
 {
     if (pendingComments != null)
     {
         statements.Add(new CommentStatement(pendingCommentsLoc, pendingComments.ToString()));
         pendingComments = null;
         pendingCommentsLoc = null;
     }
 }
示例#3
0
 // 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;
 }
示例#4
0
 public Parser(Lexer lexer)
 {
     this.lexer = lexer;
     lookahead = new Seq<InputElement>();
     lastLineTerminator = null;
     pendingComments = null;
     pendingCommentsLoc = null;
 }
示例#5
0
 public MessageContext(MessageContext parent, Location loc, Action<StringBuilder> append)
 {
     Parent = parent;
     Loc = loc;
     this.append = append;
 }
示例#6
0
 public static MessageContext TraceFile(Location loc)
 {
     return new MessageContext(null, loc, sb => { });
 }
示例#7
0
 public SyntaxException(Location loc, string context, string details)
 {
     Loc = loc;
     Context = context;
     Details = details;
 }
示例#8
0
 public InputElement(Location loc, InputElementTag tag, string value)
 {
     Loc = loc;
     Tag = tag;
     Value = value;
 }