本文整理汇总了C#中Irony.Parsing.SourceLocation类的典型用法代码示例。如果您正苦于以下问题:C# SourceLocation类的具体用法?C# SourceLocation怎么用?C# SourceLocation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SourceLocation类属于Irony.Parsing命名空间,在下文中一共展示了SourceLocation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetText
public void SetText(string text, int offset, bool keepLineNumbering) {
Text = text;
//For line-by-line input, automatically increment line# for every new line
var line = keepLineNumbering ? _location.Line + 1 : 0;
Location = new SourceLocation(offset, line, 0);
_nextNewLinePosition = text.IndexOfAny(_scannerData.LineTerminatorsArray, offset);
}
示例2: Reset
public override void Reset() {
base.Reset();
Indents.Clear();
Indents.Push(0);
OutputTokens.Clear();
PreviousToken = null;
CurrentToken = null;
PreviousTokenLocation = new SourceLocation();
}
示例3: SourceStream
public SourceStream(string text, bool caseSensitive, int tabWidth, SourceLocation initialLocation) {
_text = text;
_textLength = _text.Length;
_chars = Text.ToCharArray();
_stringComparison = caseSensitive ? StringComparison.InvariantCulture : StringComparison.InvariantCultureIgnoreCase;
_tabWidth = tabWidth;
_location = initialLocation;
_previewPosition = _location.Position;
if (_tabWidth <= 1)
_tabWidth = 8;
}
示例4: CreateSpanFor
protected TextSpan CreateSpanFor(SourceLocation location, int endPosition, Source source)
{
var span = new TextSpan
{
iStartLine = location.Line,
iStartIndex = location.Column,
};
if (source != null)
source.GetLineIndexOfPosition(endPosition, out span.iEndLine, out span.iEndIndex);
return span;
}
示例5: ScriptExtent
public ScriptExtent(SourceSpan origSpan, int startOffset, int endOffset)
{
if (startOffset == 0 && endOffset == 0)
{
_span = origSpan;
return;
}
// create a new span with offsets
var location = origSpan.Location;
// we don't adjust line and column for artifical offsets. This is hopefully okay.
var newLocation = new SourceLocation(location.Position + startOffset, location.Line, location.Column);
// don't forget to subtract the start offset here
_span = new SourceSpan(newLocation, origSpan.Length + endOffset - startOffset);
}
示例6: SourceStream
public SourceStream(string text, bool caseSensitive, int tabWidth, SourceLocation initialLocation)
{
Text = text;
_textLength = Text.Length;
_chars = Text.ToCharArray();
#if DNXCORE50
_stringComparison = caseSensitive ? StringComparison.CurrentCulture : StringComparison.CurrentCultureIgnoreCase;
#else
_stringComparison = caseSensitive
? StringComparison.InvariantCulture
: StringComparison.InvariantCultureIgnoreCase;
#endif
_tabWidth = tabWidth;
Location = initialLocation;
PreviewPosition = Location.Position;
if (_tabWidth <= 1)
_tabWidth = 8;
}
示例7: Reset
internal void Reset()
{
CurrentParserState = Parser.InitialState;
CurrentParserInput = null;
CurrentCommentTokens = new TokenList();
ParserStack.Clear();
HasErrors = false;
ParserStack.Push(new ParseTreeNode(CurrentParserState));
CurrentParseTree = null;
OpenBraces.Clear();
ParserTrace.Clear();
CurrentTerminals.Clear();
CurrentToken = null;
PreviousToken = null;
PreviousLineStart = new SourceLocation(0, -1, 0);
BufferedTokens.Clear();
PreviewTokens.Clear();
Values.Clear();
foreach (var filter in TokenFilters)
filter.Reset();
}
示例8: ScriptException
public ScriptException(string message, Exception inner, SourceLocation location, ScriptStackTrace stack)
: base(message, inner) {
Location = location;
ScriptStackTrace = stack;
}
示例9: ShowSourceLocationAndTraceToken
private void ShowSourceLocationAndTraceToken(SourceLocation location, int length)
{
ShowSourceLocation(location, length);
//find token in trace
for (int i = 0; i < lstTokens.Items.Count; i++) {
var tkn = lstTokens.Items[i] as Token;
if (tkn.Location.Position == location.Position) {
lstTokens.SelectedIndex = i;
return;
}//if
}//for i
}
示例10: SetNewPosition
//Computes the Location info (line, col) for a new source position.
private void SetNewPosition(int newPosition) {
if (newPosition < Position)
throw new Exception(Resources.ErrCannotMoveBackInSource);
int p = Position;
int col = Location.Column;
int line = Location.Line;
while(p < newPosition) {
var curr = _chars[p];
switch (curr) {
case '\n': line++; col = 0; break;
case '\r': break;
case '\t': col = (col / _tabWidth + 1) * _tabWidth; break;
default: col++; break;
} //switch
p++;
}
Location = new SourceLocation(p, line, col);
}
示例11: AddParserMessage
public void AddParserMessage(ErrorLevel level, SourceLocation location, string message, params object[] args)
{
if (CurrentParseTree == null) return;
if (CurrentParseTree.ParserMessages.Count >= MaxErrors) return;
if (args != null && args.Length > 0)
message = string.Format(message, args);
CurrentParseTree.ParserMessages.Add(new LogMessage(level, location, message, CurrentParserState));
if (TracingEnabled)
AddTrace(true, message);
}
示例12: CompleteMatch
private Token CompleteMatch(ParsingContext context, ISourceStream source, byte level)
{
string text = source.Text.Substring(source.PreviewPosition);
var matches = Regex.Matches(text, @"\](=*)\]");
foreach(Match match in matches)
{
if (match.Groups[1].Value.Length == (int)level)
{
source.PreviewPosition += match.Index + match.Length;
if (context.VsLineScanState.Value != 0)
{
SourceLocation tokenStart = new SourceLocation();
tokenStart.Position = 0;
string lexeme = source.Text.Substring(0, source.PreviewPosition);
context.VsLineScanState.Value = 0;
return new Token(this, tokenStart, lexeme, null);
}
else
{
return source.CreateToken(this.OutputTerminal);
}
}
}
context.VsLineScanState.TerminalIndex = this.MultilineIndex;
context.VsLineScanState.TokenSubType = level;
return null;
}
示例13: ShowSourceLocation
private void ShowSourceLocation(SourceLocation location, int length)
{
if (location.Position < 0) return;
txtSource.SelectionStart = location.Position;
txtSource.SelectionLength = length;
//txtSource.Select(location.Position, length);
txtSource.ScrollToCaret();
if (tabGrammar.SelectedTab != pageTest)
tabGrammar.SelectedTab = pageTest;
txtSource.Focus();
//lblLoc.Text = location.ToString();
}
示例14: SourceSpan
public SourceSpan(SourceLocation location, int length) {
Location = location;
Length = length;
}
示例15: NeedLineStartToken
private bool NeedLineStartToken(SourceLocation forLocation) {
return Grammar.FlagIsSet(LanguageFlags.EmitLineStartToken) && forLocation.Line > Context.PreviousLineStart.Line;
}