예제 #1
0
파일: Lexer.cs 프로젝트: modulexcite/IL2JS
 private InputElement MakeInputElement(InputElementTag tag)
 {
     var res = new InputElement
         (new Location(fileName, startPos, startLine, startColumn, currentPos, currentLine, currentColumn),
          tag,
          sb.ToString());
     sb = new StringBuilder();
     startPos = currentPos;
     startLine = currentLine;
     startColumn = currentColumn;
     if (IsSignificantTag(tag))
     {
         lastSignificantTag = tag;
         wasInExpressionContext = false;
     }
     return res;
 }
예제 #2
0
파일: Lexer.cs 프로젝트: modulexcite/IL2JS
 private void PopClosePunctuator(InputElement closeElem)
 {
     if (openPunctuators.Count == 0)
     {
         var openStr = default(string);
         switch (closeElem.Tag)
         {
             case InputElementTag.RParen:
                 openStr = "(";
                 break;
             case InputElementTag.RBrace:
                 openStr = "{";
                 break;
             case InputElementTag.RSquare:
                 openStr = "[";
                 break;
             default:
                 throw new InvalidOperationException("not a bracket");
         }
         throw MsgError("punctuator", String.Format("no opening '{0}' to match closing '{1}'", openStr, closeElem.Value));
     }
     else
     {
         var openElem = openPunctuators[openPunctuators.Count - 1];
         openPunctuators.RemoveAt(openPunctuators.Count - 1);
         if (closeElem.Tag == InputElementTag.RParen && openElem.Tag == InputElementTag.LParen ||
             closeElem.Tag == InputElementTag.RBrace && openElem.Tag == InputElementTag.LBrace ||
             closeElem.Tag == InputElementTag.RSquare && openElem.Tag == InputElementTag.LSquare)
             return;
         throw MsgError
             ("punctuator", String.Format("closing '{0}' does not match opening '{1}' at ({2}, {3})", closeElem.Value, openElem.Value, openElem.Loc.StartLine, openElem.Loc.StartColumn));
     }
 }
예제 #3
0
파일: Lexer.cs 프로젝트: modulexcite/IL2JS
 private void PushOpenPunctuator(InputElement openElem)
 {
     openPunctuators.Add(openElem);
 }
예제 #4
0
파일: Parser.cs 프로젝트: modulexcite/IL2JS
 private void Regurgitate(InputElement ie)
 {
     lookahead.Push(ie);
 }
예제 #5
0
파일: Parser.cs 프로젝트: modulexcite/IL2JS
 public Parser(Lexer lexer)
 {
     this.lexer = lexer;
     lookahead = new Seq<InputElement>();
     lastLineTerminator = null;
     pendingComments = null;
     pendingCommentsLoc = null;
 }
예제 #6
0
 private void PushOpenPunctuator(InputElement openElem)
 {
     openPunctuators.Add(openElem);
 }