public JSScanner(Context sourceContext) { this.IsAuthoring = false; this.peekModeOn = false; this.keywords = s_Keywords; this.preProcessorOn = false; this.matchIf = 0; this.ppTable = null; this.SetSource(sourceContext); this.currentDocument = null; this.globals = sourceContext.document.engine.Globals; }
internal Context(DocumentContext document, String source_string){ this.document = document; this.source_string = source_string; this.lineNumber = 1; this.startLinePos = 0; this.startPos = 0; this.endLineNumber = 1; this.endLinePos = 0; this.endPos = (source_string == null) ? -1 : source_string.Length; this.token = JSToken.None; this.errorReported = 1000000; }
internal Context(DocumentContext document, string source_string, int lineNumber, int startLinePos, int startPos, int endLineNumber, int endLinePos, int endPos, JSToken token) { this.document = document; this.source_string = source_string; this.lineNumber = lineNumber; this.startLinePos = startLinePos; this.startPos = startPos; this.endLineNumber = endLineNumber; this.endLinePos = endLinePos; this.endPos = endPos; this.token = token; this.errorReported = 0xf4240; }
public JSScanner(){ this.keywords = JSScanner.s_Keywords; this.strSourceCode = null; this.startPos = 0; this.endPos = 0; this.currentPos = 0; this.currentLine = 1; this.startLinePos = 0; this.currentToken = null; this.escapedString = null; this.identifier = new StringBuilder(128); this.idLastPosOnBuilder = 0; this.gotEndOfLine = false; this.IsAuthoring = false; this.peekModeOn = false; this.preProcessorOn = false; this.matchIf = 0; this.ppTable = null; this.currentDocument = null; this.globals = null; this.scanForDebugger = false; }
private void PPRemapPositionInfo(){ GetNextToken(); String filename = null; // this.currentToken.document.documentName; int line = 0; int col = -1; bool endDirective = false; while(JSToken.RightParen != this.currentToken.token){ if (JSToken.Identifier == this.currentToken.token){ if (this.currentToken.Equals("file")){ if (null == this.currentDocument){ if (null == filename){ GetNextToken(); if (JSToken.Assign != this.currentToken.token){ HandleError(JSError.InvalidPositionDirective); goto ignoreDirective; } GetNextToken(); if (JSToken.StringLiteral != this.currentToken.token){ HandleError(JSError.InvalidPositionDirective); goto ignoreDirective; } filename = GetStringLiteral(); if (filename == this.currentToken.document.documentName){ filename = null; HandleError(JSError.InvalidPositionDirective); goto ignoreDirective; } }else{ HandleError(JSError.InvalidPositionDirective); goto ignoreDirective; } }else{ HandleError(JSError.CannotNestPositionDirective); goto ignoreDirective; } }else if (this.currentToken.Equals("line")){ if (null == this.currentDocument){ if (line == 0){ GetNextToken(); if (JSToken.Assign != this.currentToken.token){ HandleError(JSError.InvalidPositionDirective); goto ignoreDirective; } GetNextToken(); if (JSToken.IntegerLiteral != this.currentToken.token){ HandleError(JSError.InvalidPositionDirective); goto ignoreDirective; } String number = this.currentToken.GetCode(); double i = Convert.ToNumber(number, true, true, Missing.Value); if ((double)(int)i == i && i > 0) line = (int)i; else{ line = 1; HandleError(JSError.InvalidPositionDirective); goto ignoreDirective; } }else{ HandleError(JSError.InvalidPositionDirective); goto ignoreDirective; } }else{ HandleError(JSError.CannotNestPositionDirective); goto ignoreDirective; } }else if (this.currentToken.Equals("column")){ if (null == this.currentDocument){ if (col == -1){ GetNextToken(); if (JSToken.Assign != this.currentToken.token){ HandleError(JSError.InvalidPositionDirective); goto ignoreDirective; } GetNextToken(); if (JSToken.IntegerLiteral != this.currentToken.token){ HandleError(JSError.InvalidPositionDirective); goto ignoreDirective; } String number = this.currentToken.GetCode(); double i = Convert.ToNumber(number, true, true, Missing.Value); if ((double)(int)i == i && i >= 0) col = (int)i; else{ col = 0; HandleError(JSError.InvalidPositionDirective); goto ignoreDirective; } }else{ HandleError(JSError.InvalidPositionDirective); goto ignoreDirective; } }else{ HandleError(JSError.CannotNestPositionDirective); goto ignoreDirective; } }else if (this.currentToken.Equals("end")){ // end of the position mapping directive. Put back the old document if (null != this.currentDocument){ // make sure this is the end of it and if not just go to the end of this directive and ignore it GetNextToken(); if (JSToken.RightParen != this.currentToken.token){ HandleError(JSError.InvalidPositionDirective); goto ignoreDirective; }else{ // restore the main document this.currentToken.document = this.currentDocument; this.currentDocument = null; endDirective = true; break; } }else{ // we got an end with no position ever started. Report an error and ignore HandleError(JSError.WrongDirective); goto ignoreDirective; } }else{ HandleError(JSError.InvalidPositionDirective); goto ignoreDirective; } GetNextToken(); if (JSToken.RightParen == this.currentToken.token) break; else if (JSToken.Semicolon == this.currentToken.token) GetNextToken(); continue; } HandleError(JSError.InvalidPositionDirective); ignoreDirective: // ignore the directive while (JSToken.RightParen != this.currentToken.token && JSToken.EndOfFile != this.currentToken.token) GetNextToken(); break; } this.SkipBlanks(); if (';' == GetChar(this.currentPos)){ ++this.currentPos; this.SkipBlanks(); } // the next char must be an end of line or we skip to it if (this.currentPos < this.endPos && !IsLineTerminator(GetChar(this.currentPos++), 0)){ HandleError(JSError.MustBeEOL); while (this.currentPos < this.endPos && !IsLineTerminator(GetChar(this.currentPos++), 0)); } this.currentLine++; this.startLinePos = this.currentPos; // set up or restore the document context if (!endDirective){ if (null == filename && line == 0 && col == -1) HandleError(JSError.InvalidPositionDirective); else{ if (filename == null) filename = this.currentToken.document.documentName; if (line == 0) line = 1; if (col == -1) col = 0; this.currentDocument = this.currentToken.document; this.currentToken.document = new DocumentContext(filename, line, col, this.currentLine, this.currentDocument.sourceItem); } } }
internal void SetSourceContext(DocumentContext document, string source) { this.source_string = source; this.endPos = source.Length; this.document = document; }
private void PPRemapPositionInfo() { this.GetNextToken(); string documentName = null; int startLine = 0; int startCol = -1; bool flag = false; while (JSToken.RightParen != this.currentToken.token) { if (JSToken.Identifier != this.currentToken.token) { goto Label_0342; } if (this.currentToken.Equals("file")) { if (this.currentDocument == null) { if (documentName == null) { this.GetNextToken(); if (JSToken.Assign != this.currentToken.token) { this.HandleError(JSError.InvalidPositionDirective); } else { this.GetNextToken(); if (JSToken.StringLiteral != this.currentToken.token) { this.HandleError(JSError.InvalidPositionDirective); } else { documentName = this.GetStringLiteral(); if (!(documentName == this.currentToken.document.documentName)) { goto Label_0316; } documentName = null; this.HandleError(JSError.InvalidPositionDirective); } } } else { this.HandleError(JSError.InvalidPositionDirective); } } else { this.HandleError(JSError.CannotNestPositionDirective); } } else if (this.currentToken.Equals("line")) { if (this.currentDocument == null) { if (startLine == 0) { this.GetNextToken(); if (JSToken.Assign != this.currentToken.token) { this.HandleError(JSError.InvalidPositionDirective); } else { this.GetNextToken(); if (JSToken.IntegerLiteral != this.currentToken.token) { this.HandleError(JSError.InvalidPositionDirective); } else { double num3 = Microsoft.JScript.Convert.ToNumber(this.currentToken.GetCode(), true, true, Microsoft.JScript.Missing.Value); if ((((int) num3) == num3) && (num3 > 0.0)) { startLine = (int) num3; goto Label_0316; } startLine = 1; this.HandleError(JSError.InvalidPositionDirective); } } } else { this.HandleError(JSError.InvalidPositionDirective); } } else { this.HandleError(JSError.CannotNestPositionDirective); } } else if (this.currentToken.Equals("column")) { if (this.currentDocument == null) { if (startCol == -1) { this.GetNextToken(); if (JSToken.Assign != this.currentToken.token) { this.HandleError(JSError.InvalidPositionDirective); } else { this.GetNextToken(); if (JSToken.IntegerLiteral != this.currentToken.token) { this.HandleError(JSError.InvalidPositionDirective); } else { double num4 = Microsoft.JScript.Convert.ToNumber(this.currentToken.GetCode(), true, true, Microsoft.JScript.Missing.Value); if ((((int) num4) == num4) && (num4 >= 0.0)) { startCol = (int) num4; goto Label_0316; } startCol = 0; this.HandleError(JSError.InvalidPositionDirective); } } } else { this.HandleError(JSError.InvalidPositionDirective); } } else { this.HandleError(JSError.CannotNestPositionDirective); } } else if (this.currentToken.Equals("end")) { if (this.currentDocument != null) { this.GetNextToken(); if (JSToken.RightParen != this.currentToken.token) { this.HandleError(JSError.InvalidPositionDirective); goto Label_0355; } this.currentToken.document = this.currentDocument; this.currentDocument = null; flag = true; break; } this.HandleError(JSError.WrongDirective); } else { this.HandleError(JSError.InvalidPositionDirective); } goto Label_0355; Label_0316: this.GetNextToken(); if (JSToken.RightParen == this.currentToken.token) { break; } if (JSToken.Semicolon == this.currentToken.token) { this.GetNextToken(); } continue; Label_0342: this.HandleError(JSError.InvalidPositionDirective); Label_0355: while ((JSToken.RightParen != this.currentToken.token) && (this.currentToken.token != JSToken.EndOfFile)) { this.GetNextToken(); } break; } this.SkipBlanks(); if (';' == this.GetChar(this.currentPos)) { this.currentPos++; this.SkipBlanks(); } if ((this.currentPos < this.endPos) && !this.IsLineTerminator(this.GetChar(this.currentPos++), 0)) { this.HandleError(JSError.MustBeEOL); while ((this.currentPos < this.endPos) && !this.IsLineTerminator(this.GetChar(this.currentPos++), 0)) { } } this.currentLine++; this.startLinePos = this.currentPos; if (!flag) { if (((documentName == null) && (startLine == 0)) && (startCol == -1)) { this.HandleError(JSError.InvalidPositionDirective); } else { if (documentName == null) { documentName = this.currentToken.document.documentName; } if (startLine == 0) { startLine = 1; } if (startCol == -1) { startCol = 0; } this.currentDocument = this.currentToken.document; this.currentToken.document = new DocumentContext(documentName, startLine, startCol, this.currentLine, this.currentDocument.sourceItem); } } }