Exemplo n.º 1
0
		public AspParser (string filename, TextReader input)
		{
			this.filename = filename;
			fileText = input.ReadToEnd ();
			StringReader reader = new StringReader (fileText);
			tokenizer = new AspTokenizer (reader);
		}
Exemplo n.º 2
0
 public AspParser(string filename, TextReader input)
 {
     this.filename            = filename;
     this.fileText            = input.ReadToEnd();
     this.fileReader          = new StringReader(this.fileText);
     this._internalLineOffset = 0;
     tokenizer = new AspTokenizer(this.fileReader);
 }
Exemplo n.º 3
0
        public void Parse()
        {
            if (tokenizer == null)
            {
                OnError("AspParser not initialized properly.");
                return;
            }

            int           token;
            string        id;
            TagAttributes attributes;
            TagType       tagtype = TagType.Text;
            StringBuilder text    = new StringBuilder();

            try
            {
                while ((token = tokenizer.get_token()) != Token.EOF)
                {
                    BeginElement();

                    if (tokenizer.Verbatim)
                    {
                        string end_verbatim  = "</" + verbatimID + ">";
                        string verbatim_text = GetVerbatim(token, end_verbatim);

                        if (verbatim_text == null)
                        {
                            OnError("Unexpected EOF processing " + verbatimID);
                        }

                        tokenizer.Verbatim = false;

                        EndElement();
                        endPosition -= end_verbatim.Length;
                        OnTextParsed(verbatim_text);
                        beginPosition = endPosition;
                        endPosition  += end_verbatim.Length;
                        OnTagParsed(TagType.Close, verbatimID, null);
                        continue;
                    }

                    if (token == '<')
                    {
                        GetTag(out tagtype, out id, out attributes);
                        EndElement();
                        if (tagtype == TagType.ServerComment)
                        {
                            continue;
                        }

                        if (tagtype == TagType.Text)
                        {
                            OnTextParsed(id);
                        }
                        else
                        {
                            OnTagParsed(tagtype, id, attributes);
                        }

                        continue;
                    }

                    if (tokenizer.Value.Trim().Length == 0 && tagtype == TagType.Directive)
                    {
                        continue;
                    }

                    text.Length = 0;
                    do
                    {
                        text.Append(tokenizer.Value);
                        token = tokenizer.get_token();
                    }while (token != '<' && token != Token.EOF);

                    tokenizer.put_back();
                    EndElement();
                    OnTextParsed(text.ToString());
                }
            }
            finally
            {
                if (fileReader != null)
                {
                    fileReader.Close();
                    fileReader = null;
                }
                checksum  = tokenizer.Checksum;
                tokenizer = null;
            }

            OnParsingComplete();
        }
Exemplo n.º 4
0
		public AspParser (string filename, TextReader input)
		{
			this.filename = filename;
			this.fileText = input.ReadToEnd ();
			this.fileReader = new StringReader (this.fileText);
			this._internalLineOffset = 0;
			tokenizer = new AspTokenizer (this.fileReader);
		}
Exemplo n.º 5
0
		public void Parse ()
		{
			if (tokenizer == null) {
				OnError ("AspParser not initialized properly.");
				return;
			}
			
			int token;
			string id;
			TagAttributes attributes;
			TagType tagtype = TagType.Text;
			StringBuilder text =  new StringBuilder ();

			try {
				while ((token = tokenizer.get_token ()) != Token.EOF) {
					BeginElement ();

					if (tokenizer.Verbatim){
						string end_verbatim = "</" + verbatimID + ">";
						string verbatim_text = GetVerbatim (token, end_verbatim);

						if (verbatim_text == null)
							OnError ("Unexpected EOF processing " + verbatimID);

						tokenizer.Verbatim = false;

						EndElement ();
						endPosition -= end_verbatim.Length;
						OnTextParsed (verbatim_text);
						beginPosition = endPosition;
						endPosition += end_verbatim.Length;
						OnTagParsed (TagType.Close, verbatimID, null);
						continue;
					}
				
					if (token == '<') {
						GetTag (out tagtype, out id, out attributes);
						EndElement ();
						if (tagtype == TagType.ServerComment)
							continue;

						if (tagtype == TagType.Text)
							OnTextParsed (id);
						else
							OnTagParsed (tagtype, id, attributes);

						continue;
					}

					if (tokenizer.Value.Trim ().Length == 0 && tagtype == TagType.Directive) {
						continue;
					}

					text.Length = 0;
					do {
						text.Append (tokenizer.Value);
						token = tokenizer.get_token ();
					} while (token != '<' && token != Token.EOF);

					tokenizer.put_back ();
					EndElement ();
					OnTextParsed (text.ToString ());
				}
			} finally {
				if (fileReader != null) {
					fileReader.Close ();
					fileReader = null;
				}
				checksum = tokenizer.Checksum;
				tokenizer = null;
			}

			OnParsingComplete ();
		}