当前位置: 首页>>代码示例>>C#>>正文


C# IParseContext.LocationMinus方法代码示例

本文整理汇总了C#中IParseContext.LocationMinus方法的典型用法代码示例。如果您正苦于以下问题:C# IParseContext.LocationMinus方法的具体用法?C# IParseContext.LocationMinus怎么用?C# IParseContext.LocationMinus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IParseContext的用法示例。


在下文中一共展示了IParseContext.LocationMinus方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddExpressionNode

		internal static void AddExpressionNode (char c, IParseContext context)
		{
			Debug.Assert (c != '@' && c!= '-', "AspNetExpressionState should not be passed a directive or comment");

			switch (c) {
			//DATABINDING EXPRESSION <%#
			case '#':
				context.Nodes.Push (new AspNetDataBindingExpression (context.LocationMinus (3)));
				break;
			//RESOURCE EXPRESSION <%$
			case '$':
				context.Nodes.Push (new AspNetResourceExpression (context.LocationMinus (3)));
				break;
			//RENDER EXPRESSION <%=
			case '=':
				context.Nodes.Push (new AspNetRenderExpression (context.LocationMinus (3)));
				break;
			//HTML ENCODED EXPRESSION <%:
			case ':':
				context.Nodes.Push (new AspNetHtmlEncodedExpression (context.LocationMinus (3)));
				break;
			// RENDER BLOCK
			default:
				context.Nodes.Push (new AspNetRenderBlock (context.LocationMinus (3)));
				break;
			}
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:27,代码来源:AspNetExpressionState.cs

示例2: PushChar

		public override State PushChar (char c, IParseContext context, ref string rollback)
		{
			if (context.CurrentStateLength == 1) {
				Debug.Assert (c != '@' && c!= '-', 
					"AspNetExpressionState should not be passed a directive or comment");
				
				switch (c) {
				
				//DATABINDING EXPRESSION <%#
				case '#':
					context.Nodes.Push (new AspNetDataBindingExpression (context.LocationMinus (3)));
					break;
					
				//RESOURCE EXPRESSION <%$
				case '$':
					context.Nodes.Push (new AspNetResourceExpression (context.LocationMinus (3)));
					break;
				
				//RENDER EXPRESSION <%=
				case '=':
					context.Nodes.Push (new AspNetRenderExpression (context.LocationMinus (3)));
					break;
				
				//HTML ENCODED EXPRESSION <%:
				case ':':
					context.Nodes.Push (new AspNetHtmlEncodedExpression (context.LocationMinus (3)));
					break;
				
				// RENDER BLOCK
				default:
					context.Nodes.Push (new AspNetRenderBlock (context.LocationMinus (2)));
					break;
				}
				return null;
			}
			else if (c == '%') {
				if (context.StateTag != PERCENT)
					context.StateTag = PERCENT;
			}
			else if (c == '>') {
				if (context.StateTag == PERCENT) {
					XNode expr = (XNode) context.Nodes.Pop ();
					expr.End (context.Location);
					if (context.BuildTree) {
						XObject ob = context.Nodes.Peek ();
						if (ob is XContainer) {
							((XContainer)ob).AddChildNode (expr);
						}
					 	//FIXME: add to other kinds of node, e.g. if used within a tag
					}
					return Parent;
				} else {
					context.StateTag = NONE;
				}
			}
			
			return null;
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:58,代码来源:AspNetExpressionState.cs

示例3: PushChar

		public override State PushChar (char c, IParseContext context, ref string rollback)
		{
			if (context.CurrentStateLength == 1) {
				switch (c) {
				case '(':
					context.StateTag = NONE_EXPLICIT;
					context.Nodes.Push (new RazorExplicitExpression (context.LocationMinus (2)));
					return null;

				default:
					context.StateTag = NONE_IMPLICIT;
					if (!(context.PreviousState is RazorSpeculativeState))
						context.Nodes.Push (new RazorImplicitExpression (context.LocationMinus (2)));
					break;
				}
			}

			switch (c)
			{
				case '(':
					if (context.StateTag == NONE_EXPLICIT)
						context.StateTag = INSIDE_BRACKET_EXPLICIT;
					else if (context.StateTag == NONE_IMPLICIT)
						context.StateTag = INSIDE_BRACKET_IMPLICIT;
					context.KeywordBuilder.Append (c);
					break;

				case ')':
					if (context.StateTag == NONE_EXPLICIT) {
						StateEngineService.EndCodeFragment<RazorExplicitExpression> (context);
						return Parent;
					}
					else if (context.StateTag != NONE_IMPLICIT) {
						if (context.KeywordBuilder.Length > 0)
							context.KeywordBuilder.Remove (0, 1);
						if (context.KeywordBuilder.Length == 0)
							context.StateTag = (context.StateTag == INSIDE_BRACKET_IMPLICIT ? NONE_IMPLICIT : NONE_EXPLICIT);
					}
					break;

				default:
					// Space between function's name and open bracket not allowed in razor, e.g. @Html.Raw (foo) 
					if (!(Char.IsLetterOrDigit (c) || allowedChars.Any (ch => ch == c))
							&& context.StateTag == NONE_IMPLICIT) {
						StateEngineService.EndCodeFragment<RazorImplicitExpression> (context, 1);
						rollback = String.Empty;
						if (Parent is RazorSpeculativeState)
							return Parent.Parent;
						return Parent;
					}
					break;
			}

			return null;
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:55,代码来源:RazorExpressionState.cs

示例4: PushChar

		public override State PushChar (char c, IParseContext context, ref string rollback)
		{
			if (context.CurrentStateLength == 0)
				context.StateTag = 0;
			
			if (c == '<') {
				if (context.StateTag == 0) {
					context.StateTag++;
					return null;
				}
			}
			if (context.StateTag > 0) {
				if (CLOSE[context.StateTag] == c) {
					context.StateTag++;
					if (context.StateTag == CLOSE.Length) {
						var el = (XElement) context.Nodes.Pop ();
						var closing = new XClosingTag (new XName ("script"), context.LocationMinus (CLOSE.Length));
						closing.End (context.Location);
						el.Close (closing);
						return Parent;
					}
				} else {
					context.StateTag = 0;
				}
			}
			return null;
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:27,代码来源:HtmlScriptBodyState.cs

示例5: PushChar

		public override State PushChar (char c, IParseContext context, ref string rollback)
		{
			if (context.CurrentStateLength == 1) {
				context.Nodes.Push (new XProcessingInstruction (context.LocationMinus ("<?".Length)));
			}
			
			if (c == '?') {
				if (context.StateTag == NOMATCH) {
					context.StateTag = QUESTION;
					return null;
				}
			} else if (c == '>' && context.StateTag == QUESTION) {
				// if the '?' is followed by a '>', the state has ended
				// so attach a node to the DOM and end the state
				XProcessingInstruction xpi = (XProcessingInstruction) context.Nodes.Pop ();
				
				if (context.BuildTree) {
					xpi.End (context.Location);
					((XContainer) context.Nodes.Peek ()).AddChildNode (xpi); 
				}
				return Parent;
			} else {
				context.StateTag = NOMATCH;
			}
			
			return null;
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:27,代码来源:XmlProcessingInstructionState.cs

示例6: PushChar

		public override State PushChar (char c, IParseContext context, ref string rollback)
		{
			if (context.CurrentStateLength == 1) {
				context.Nodes.Push (new XCData (context.LocationMinus ("<![CDATA[".Length + 1)));
			}
			
			if (c == ']') {
				//make sure we know when there are two ']' chars together
				if (context.StateTag == NOMATCH)
					context.StateTag = SINGLE_BRACKET;
				else
					context.StateTag = DOUBLE_BRACKET;
				
			} else if (c == '>' && context.StateTag == DOUBLE_BRACKET) {
				// if the ']]' is followed by a '>', the state has ended
				// so attach a node to the DOM and end the state
				XCData cdata = (XCData) context.Nodes.Pop ();
				
				if (context.BuildTree) {
					cdata.End (context.Location);
					((XContainer) context.Nodes.Peek ()).AddChildNode (cdata); 
				}
				return Parent;
			} else {
				// not any part of a ']]>', so make sure matching is reset
				context.StateTag = NOMATCH;
			}
			
			return null;
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:30,代码来源:XmlCDataState.cs

示例7: PushChar

		public override State PushChar (char c, IParseContext context, ref string rollback)
		{
			AspNetDirective directive = context.Nodes.Peek () as AspNetDirective;
			
			if (directive == null || directive.IsComplete) {
				directive = new AspNetDirective (context.LocationMinus (4)); // 4 == <%@ + current char
				context.Nodes.Push (directive);
			}
			
			if (c == '<') {
				context.LogError ("Unexpected '<' in directive.");
				rollback = string.Empty;
				return MalformedTagState;
			}
			
			Debug.Assert (!directive.IsComplete);
			
			if (context.StateTag != ENDING && c == '%') {
				context.StateTag = ENDING;
				return null;
			}
			
			
			if (context.StateTag == ENDING) {
				if (c == '>') {
					//have already checked that directive is not null, i.e. top of stack is our directive
					context.Nodes.Pop ();
					
					if (!directive.IsNamed) {
						context.LogError ("Directive closed prematurely.");
					} else {
						directive.End (context.Location);
						if (context.BuildTree) {
							XContainer container = (XContainer) context.Nodes.Peek ();
							container.AddChildNode (directive);
						}
					}
					return Parent;
				}
				//ending but not '>'? Error; go to end.
			}
			else if (char.IsLetter (c)) {
				rollback = string.Empty;
				if (!directive.IsNamed) {
					return NameState;
				} else {
					return AttributeState;
				}
			}
			else if (char.IsWhiteSpace (c))
				return null;
			
			rollback = string.Empty;
			context.LogError ("Unexpected character '" + c + "' in tag.");
			return MalformedTagState;
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:56,代码来源:AspNetDirectiveState.cs

示例8: PushChar

		public override State PushChar (char c, IParseContext context, ref string rollback)
		{
			string key;

			switch (context.StateTag) {
			case UNKNOWN:
				context.KeywordBuilder.Append (c);
				key = context.KeywordBuilder.ToString ();
				if (!RazorSymbols.CanBeStatementOrDirective (key)) {
					context.Nodes.Push (new RazorImplicitExpression (context.LocationMinus (key.Length + 1)));
					rollback = String.Empty;
					return EnsureSetAndAdopted<RazorExpressionState> (ref expressionState);
				}
				if (key == "using")
					context.StateTag = USING;
				else if (RazorSymbols.IsDirective (key))
					context.StateTag = POSSIBLE_DIRECTIVE;
				else if (RazorSymbols.IsStatement (key))
					context.StateTag = POSSIBLE_STATEMENT;

				break;

			// Using can be either statement: @using (resource) {}, or directive: @using System.IO
			case USING:
				if (c == '(' || c == '\n')
					return SwitchToStatement (context, ref rollback);
				else if (Char.IsLetterOrDigit(c))
					return SwitchToDirective (context, ref rollback);

				context.KeywordBuilder.Append (c);
				break;

			case POSSIBLE_STATEMENT:
				if (Char.IsWhiteSpace (c) || c == '{' || c == '(')
					return SwitchToStatement(context, ref rollback);

				context.KeywordBuilder.Append (c);
				context.StateTag = UNKNOWN;
				break;

			case POSSIBLE_DIRECTIVE:
				if (Char.IsWhiteSpace (c) || c == '{')
					return SwitchToDirective (context, ref rollback);

				context.KeywordBuilder.Append (c);
				context.StateTag = UNKNOWN;
				break;
			}

			return null;
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:51,代码来源:RazorSpeculativeState.cs

示例9: PushChar

		public override State PushChar (char c, IParseContext context, ref string rollback)
		{
			if (context.CurrentStateLength == 1) {
				context.Nodes.Push (new AspNetServerComment (context.LocationMinus (context.CurrentStateLength + "<%--".Length)));
			}
			
			switch (context.StateTag) {
			case NOMATCH:
				if (c == '-')
					context.StateTag = SINGLE_DASH;
				break;
				
			case SINGLE_DASH:
				if (c == '-')
					context.StateTag = DOUBLE_DASH;
				else
					context.StateTag = NOMATCH;
				break;
				
			case DOUBLE_DASH:
				if (c == '%')
					context.StateTag = PERCENT;
				else
					context.StateTag = NOMATCH;
				break;
				
			case PERCENT:
				if (c == '>') {
					AspNetServerComment comment = (AspNetServerComment) context.Nodes.Pop ();
					comment.End (context.Location);
					if (context.BuildTree) {
						XObject ob = context.Nodes.Peek ();
						if (ob is XContainer) {
							((XContainer)ob).AddChildNode (comment);
						}
					 	//FIXME: add to other kinds of node, e.g. if used within a tag
					}
					return Parent;
				}
				break;
			}
			
			return null;
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:44,代码来源:AspNetServerCommentState.cs

示例10: PushChar

		public override State PushChar (char c, IParseContext context, ref string rollback)
		{
			if (context.CurrentStateLength == 1) {
				bracketsBuilder.Clear ();
				var block = context.Nodes.FirstOrDefault (n => n is RazorCodeBlock);
				if (block == null) {
					var razorBlock = new RazorCodeBlock (context.LocationMinus (2));
					context.Nodes.Push (razorBlock);
					CorrespondingBlock = razorBlock;
				} else
					CorrespondingBlock = block as RazorCodeFragment;
			}

			switch (c) {
			case '{':
				return ParseOpeningBracket (c, context);

			case '}':
				return ParseClosingBracket<RazorCodeBlock> (c, context, Parent);
			}

			return base.PushChar (c, context, ref rollback);
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:23,代码来源:RazorCodeBlockState.cs

示例11: PushChar

		public override State PushChar (char c, IParseContext context, ref string rollback)
		{
			if (context.CurrentStateLength == 1) {
				context.Nodes.Push (new RazorComment (context.LocationMinus (2)));
				return null;
			}

			switch (context.StateTag) {
			case NOMATCH:
				if (c == '*')
					context.StateTag = STAR;
				break;

			case STAR:
				if (c == '@') {
					StateEngineService.EndCodeFragment<RazorComment> (context);
					return Parent;
				} else
					context.StateTag = NOMATCH;
				break;
			}

			return null;
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:24,代码来源:RazorCommentState.cs

示例12: PushChar

		public override State PushChar (char c, IParseContext context, ref string rollback)
		{
			if (context.CurrentStateLength == 1) {
				context.Nodes.Push (new XComment (context.LocationMinus ("<!--".Length + 1)));
			}
			
			if (c == '-') {
				//make sure we know when there are two '-' chars together
				if (context.StateTag == NOMATCH)
					context.StateTag = SINGLE_DASH;
				else
					context.StateTag = DOUBLE_DASH;
				
			} else if (context.StateTag == DOUBLE_DASH) {
				if (c == '>') {
					// if the '--' is followed by a '>', the state has ended
					// so attach a node to the DOM and end the state
					XComment comment = (XComment) context.Nodes.Pop ();
					
					if (context.BuildTree) {
						comment.End (context.Location);
						((XContainer) context.Nodes.Peek ()).AddChildNode (comment);
					}
					
					rollback = string.Empty;
					return Parent;
				} else {
					context.LogWarning ("The string '--' should not appear within comments.");
				}
			} else {
				// not any part of a '-->', so make sure matching is reset
				context.StateTag = NOMATCH;
			}
			
			return null;
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:36,代码来源:XmlCommentState.cs

示例13: PushChar

		public override State PushChar (char c, IParseContext context, ref string rollback)
		{
			XDocType doc = context.Nodes.Peek () as XDocType;
			if (doc == null) {
				doc = new XDocType (context.LocationMinus ("<!DOCTYPE".Length + 1));
				context.Nodes.Push (doc);
			}
			
			if (!doc.RootElement.IsValid) {
				if (XmlChar.IsWhitespace (c))
					return null;
				else if (XmlChar.IsFirstNameChar (c)) {
					rollback = "";
					return nameState;
				}
			}
			else if (doc.PublicFpi == null) {
				if (context.StateTag == 0) {
					if (c == 's' || c == 'S') {
						context.StateTag = 1;
						return null;
					} else if (c == 'p' || c == 'P') {
						context.StateTag = -1;
						return null;
					} if (XmlChar.IsWhitespace (c)) {
						return null;
					}
				} else if (Math.Abs (context.StateTag) < 6) {
					if (context.StateTag > 0) {
						if ("YSTEM"[context.StateTag - 1] == c || "ystem"[context.StateTag - 1] == c) {
							context.StateTag++;
							if (context.StateTag == 6) {
								context.StateTag = 0;
								doc.PublicFpi = "";
							}
							return null;
						}
					} else {
						int absState = Math.Abs (context.StateTag) - 1;
						if ("UBLIC"[absState] == c || "ublic"[absState] == c) {
							context.StateTag--;
							return null;
						}
					}
				} else {
					if (context.KeywordBuilder.Length == 0) {
						if (XmlChar.IsWhitespace (c))
							return null;
						else if (c == '"') {
							context.KeywordBuilder.Append (c);
							return null;
						}
					} else {
						if (c == '"') {
							context.KeywordBuilder.Remove (0,1);
							doc.PublicFpi = context.KeywordBuilder.ToString ();
							context.KeywordBuilder.Length = 0;
							context.StateTag = 0;
						} else {
							context.KeywordBuilder.Append (c);
						}
						return null;
					}
				}
			}
			else if (doc.Uri == null) {
				if (context.KeywordBuilder.Length == 0) {
					if (XmlChar.IsWhitespace (c))
						return null;
					else if (c == '"') {
						context.KeywordBuilder.Append (c);
						return null;
					}
				} else {
					if (c == '"') {
						context.KeywordBuilder.Remove (0,1);
						doc.Uri = context.KeywordBuilder.ToString ();
						context.KeywordBuilder.Length = 0;
					} else {
						context.KeywordBuilder.Append (c);
					}
					return null;
				}
			}
			else if (doc.InternalDeclarationRegion.End.Line <= 0) {
				if (XmlChar.IsWhitespace (c))
						return null;
				switch (context.StateTag) {
				case 0:
					if (c == '[') {
						doc.InternalDeclarationRegion = new DomRegion (context.Location, DomLocation.Empty);
						context.StateTag = 1;
						return null;
					}
					break;
				case 1:
					if (c == '<') {
						context.StateTag = 2;
						return null;
					} else if (c == ']') {
//.........这里部分代码省略.........
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:101,代码来源:XmlDocTypeState.cs

示例14: PushChar

		public override State PushChar (char c, IParseContext context, ref string rollback)
		{
			if (c == '<') {
				if (context.StateTag != FREE)
					context.LogError ("Incomplete tag opening; encountered unexpected '<'.",
						new MonoDevelop.Projects.Dom.DomRegion (
							context.LocationMinus (LengthFromOpenBracket (context) + 1),
							context.LocationMinus (1)));
				context.StateTag = BRACKET;
				return null;
			}
			
			switch (context.StateTag) {
			case FREE:
				//FIXME: handle entities?
				return null;
				
			case BRACKET:
				if (c == '?') {
					rollback = string.Empty;
					return this.ProcessingInstructionState;
				} else if (c == '!') {
					context.StateTag = BRACKET_EXCLAM;
					return null;
				} else if (c == '/') {
					return this.ClosingTagState;
				} else if (char.IsLetter (c) || c == '_') {
					rollback = string.Empty;
					return TagState;
				}
				break;
				
			case BRACKET_EXCLAM:
				if (c == '[') {
					context.StateTag = CDATA;
					return null;
				} else if (c == '-') {
					context.StateTag = COMMENT;
					return null;
				} else if (c == 'D') {
					context.StateTag = DOCTYPE;
					return null;
				}
				break;
			
			case COMMENT:
				if (c == '-')
					return CommentState;
				break;
				
			case CDATA:
				string cdataStr = "CDATA[";
				if (c == cdataStr [context.KeywordBuilder.Length]) {
					context.KeywordBuilder.Append (c);
					if (context.KeywordBuilder.Length < cdataStr.Length)
						return null;
					else
						return CDataState;
				} else {
					context.KeywordBuilder.Length = 0;
				}
				break;
				
			case DOCTYPE:
				string docTypeStr = "OCTYPE";
				if (c == docTypeStr [context.KeywordBuilder.Length]) {
					context.KeywordBuilder.Append (c);
					if (context.KeywordBuilder.Length < docTypeStr.Length)
						return null;
					else
						return DocTypeState;
				} else {
					context.KeywordBuilder.Length = 0;
				}
				break;
			}
			
			context.LogError ("Incomplete tag opening; encountered unexpected character '" + c + "'.",
				new MonoDevelop.Projects.Dom.DomRegion (
					context.LocationMinus (LengthFromOpenBracket (context)),
					context.Location));
			
			context.StateTag = FREE;
			return null;
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:85,代码来源:XmlFreeState.cs

示例15: PushChar

		public override State PushChar (char c, IParseContext context, ref string rollback)
		{
			XAttribute att = context.Nodes.Peek () as XAttribute;

			//state has just been entered
			if (context.CurrentStateLength == 1)  {
				if (context.PreviousState is XmlNameState) {
					//error parsing name
					if (!att.IsNamed) {
						context.Nodes.Pop ();
						rollback = string.Empty;
						return Parent;
					}
					context.StateTag = GETTINGEQ;
				}
				else if (context.PreviousState is XmlAttributeValueState) {
					//Got value, so end attribute
					context.Nodes.Pop ();
					att.End (context.LocationMinus (1));
					IAttributedXObject element = (IAttributedXObject) context.Nodes.Peek ();
					element.Attributes.AddAttribute (att);
					rollback = string.Empty;
					return Parent;
				}
				else {
					//starting a new attribute
					Debug.Assert (att == null);
					Debug.Assert (context.StateTag == NAMING);
					att = new XAttribute (context.LocationMinus (1));
					context.Nodes.Push (att);
					rollback = string.Empty;
					return XmlNameState;
				}
			}

			if (context.StateTag == GETTINGEQ) {
				if (char.IsWhiteSpace (c)) {
					return null;
				}
				if (c == '=') {
					context.StateTag = GETTINGVAL;
					return null;
				}
				context.LogError ("Expecting = in attribute, got '" + c + "'.");
			} else if (context.StateTag == GETTINGVAL) {
				if (char.IsWhiteSpace (c)) {
					return null;
				}
				rollback = string.Empty;
				return AttributeValueState;
			} else if (c != '<') {
				//parent handles message for '<'
				context.LogError ("Unexpected character '" + c + "' in attribute.");
			}

			if (att != null)
				context.Nodes.Pop ();
			
			rollback = string.Empty;
			return Parent;
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:61,代码来源:XmlAttributeState.cs


注:本文中的IParseContext.LocationMinus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。