Skip to content

Commit

Permalink
debug tagger ATT syntax updated
Browse files Browse the repository at this point in the history
  • Loading branch information
HJLebbink committed Jun 4, 2018
1 parent 9995999 commit 64676e2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,10 @@ public IEnumerable<ITagSpan<AsmTokenTag>> GetTags(NormalizedSnapshotSpanCollecti
yield return new TagSpan<AsmTokenTag>(NasmIntelTokenTagger.New_Span(pos[k], offset, curSpan), this._misc);
break;
}
default:
{
yield return new TagSpan<AsmTokenTag>(NasmIntelTokenTagger.New_Span(pos[k], offset, curSpan), this._label);
break;
}
}

break;
}
default:
Expand All @@ -174,6 +172,7 @@ public IEnumerable<ITagSpan<AsmTokenTag>> GetTags(NormalizedSnapshotSpanCollecti
case AsmTokenType.UNKNOWN: // asmToken is not a known keyword, check if it is numerical
{
if (asmToken.Equals("OFFSET"))

{
yield return new TagSpan<AsmTokenTag>(NasmIntelTokenTagger.New_Span(pos[k], offset, curSpan), this._directive);
k++; // goto the next word
Expand Down Expand Up @@ -211,13 +210,13 @@ public IEnumerable<ITagSpan<AsmTokenTag>> GetTags(NormalizedSnapshotSpanCollecti
}
default: break;
}

}
}
AsmDudeToolsStatic.Print_Speed_Warning(time1, "MasmDisassemblyTokenTagger");
}

#region Private Member Methods

private static bool IsConstant(string token)
{
if (long.TryParse(token, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out var dummy1))
Expand Down Expand Up @@ -262,7 +261,9 @@ private static bool IsSourceCode(string line, List<(int BeginPos, int Length, bo
}
return true;
}

#endregion

#region Public Static Methods

public static string Keyword((int, int, bool) pos, string line)
Expand All @@ -274,6 +275,7 @@ public static SnapshotSpan New_Span((int, int, bool) pos, int offset, SnapshotSp
{
return new SnapshotSpan(lineSnapShot.Snapshot, new Span(pos.Item1 + offset, pos.Item2 - pos.Item1));
}

#endregion Public Static Methods
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,15 @@ public IEnumerable<ITagSpan<AsmTokenTag>> GetTags(NormalizedSnapshotSpanCollecti
k++;
if (k == nKeywords) break;
string asmToken3 = NasmIntelTokenTagger.Keyword(pos[k], line);
if (asmToken3.Equals("PTR"))
switch (asmToken3)
{
yield return new TagSpan<AsmTokenTag>(New_Span(pos[k], offset, curSpan), this._misc);
}
else
{
yield return new TagSpan<AsmTokenTag>(NasmIntelTokenTagger.New_Span(pos[k], offset, curSpan), this._label);
case "PTR":
{
yield return new TagSpan<AsmTokenTag>(New_Span(pos[k], offset, curSpan), this._misc);
break;
}
yield return new TagSpan<AsmTokenTag>(NasmIntelTokenTagger.New_Span(pos[k], offset, curSpan), this._label);
break;
}
break;
}
Expand Down
16 changes: 7 additions & 9 deletions VS/CSHARP/asm-dude-vsix/SyntaxHighlighting/NasmAttTokenTagger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,15 @@ public IEnumerable<ITagSpan<AsmTokenTag>> GetTags(NormalizedSnapshotSpanCollecti
ITextSnapshotLine containingLine = curSpan.Start.GetContainingLine();

string line = containingLine.GetText().ToUpper();
IList<(int beginPos, int length, bool isLabel)> pos = new List<(int beginPos, int length, bool isLabel)>(AsmSourceTools.SplitIntoKeywordPos(line));
var pos = new List<(int BeginPos, int Length, bool IsLabel)>(AsmSourceTools.SplitIntoKeywordPos(line));

int offset = containingLine.Start.Position;
int nKeywords = pos.Count;

for (int k = 0; k < nKeywords; k++)
{
string asmToken = NasmIntelTokenTagger.Keyword(pos[k], line);

// keyword starts with a remark char
if (AsmSourceTools.IsRemarkChar(asmToken[0]))
{
Expand All @@ -107,7 +108,7 @@ public IEnumerable<ITagSpan<AsmTokenTag>> GetTags(NormalizedSnapshotSpanCollecti
}

// keyword k is a label definition
if (pos[k].isLabel)
if (pos[k].IsLabel)
{
//AsmDudeToolsStatic.Output_INFO("NasmTokenTagger:GetTags: found label " +asmToken);
if (IsProperLabelDef(asmToken, containingLine.LineNumber, out AsmTokenTag asmTokenTag))
Expand All @@ -116,7 +117,6 @@ public IEnumerable<ITagSpan<AsmTokenTag>> GetTags(NormalizedSnapshotSpanCollecti
continue;
}
}

AsmTokenType keywordType = this._asmDudeTools.Get_Token_Type_Att(asmToken);
switch (keywordType)
{
Expand Down Expand Up @@ -174,16 +174,14 @@ public IEnumerable<ITagSpan<AsmTokenTag>> GetTags(NormalizedSnapshotSpanCollecti
}
case AsmTokenType.UNKNOWN: // asmToken is not a known keyword, check if it is numerical
{
//if (AsmTools.AsmSourceTools.Parse_Constant(asmToken, true).Valid)
if (AsmSourceTools.Evaluate_Constant(asmToken, true).Valid)
//if (AsmSourceTools.Parse_Constant(asmToken, true).Valid)
{
yield return new TagSpan<AsmTokenTag>(NasmIntelTokenTagger.New_Span(pos[k], offset, curSpan), this._constant);

}
else if (asmToken.StartsWith("\"") && asmToken.EndsWith("\""))
{
yield return new TagSpan<AsmTokenTag>(NasmIntelTokenTagger.New_Span(pos[k], offset, curSpan), this._constant);

}
else
{
Expand Down Expand Up @@ -259,7 +257,7 @@ public IEnumerable<ITagSpan<AsmTokenTag>> GetTags(NormalizedSnapshotSpanCollecti
}
}
}
AsmDudeToolsStatic.Print_Speed_Warning(time1, "AttTokenTagger");
AsmDudeToolsStatic.Print_Speed_Warning(time1, "NasmAttTokenTagger");
}

#region Public Static Methods
Expand Down Expand Up @@ -324,9 +322,9 @@ public static string Keyword((int, int, bool) pos, string line)
return line.Substring(pos.Item1, pos.Item2 - pos.Item1);
}

public static SnapshotSpan New_Span((int, int, bool) pos, int offset, SnapshotSpan lineSnapShot)
public static SnapshotSpan New_Span((int BeginPos, int Length, bool IsLabel) pos, int offset, SnapshotSpan lineSnapShot)
{
return new SnapshotSpan(lineSnapShot.Snapshot, new Span(pos.Item1 + offset, pos.Item2 - pos.Item1));
return new SnapshotSpan(lineSnapShot.Snapshot, new Span(pos.BeginPos + offset, pos.Length - pos.BeginPos));
}
#endregion Public Static Methods

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ public IEnumerable<ITagSpan<AsmTokenTag>> GetTags(NormalizedSnapshotSpanCollecti
}
case AsmTokenType.UNKNOWN: // asmToken is not a known keyword, check if it is numerical
{
if (AsmTools.AsmSourceTools.Parse_Constant(asmToken, true).Valid)
//if (AsmTools.AsmSourceTools.Evaluate_Constant(asmToken, true).Valid)
if (AsmSourceTools.Evaluate_Constant(asmToken, true).Valid)
//if (AsmSourceTools.Parse_Constant(asmToken, true).Valid)
{
yield return new TagSpan<AsmTokenTag>(NasmIntelTokenTagger.New_Span(pos[k], offset, curSpan), this._constant);
}
Expand Down Expand Up @@ -246,7 +246,7 @@ public IEnumerable<ITagSpan<AsmTokenTag>> GetTags(NormalizedSnapshotSpanCollecti
if (assember.HasFlag(AssemblerEnum.NASM_INTEL) || assember.HasFlag(AssemblerEnum.NASM_ATT))
{
yield return new TagSpan<AsmTokenTag>(NasmIntelTokenTagger.New_Span(pos[k], offset, curSpan), this._directive);
}
}
break;
}
case AsmTokenType.Mnemonic:
Expand All @@ -267,7 +267,7 @@ public IEnumerable<ITagSpan<AsmTokenTag>> GetTags(NormalizedSnapshotSpanCollecti
}
}
}
AsmDudeToolsStatic.Print_Speed_Warning(time1, "NasmTokenTagger");
AsmDudeToolsStatic.Print_Speed_Warning(time1, "NasmIntelTokenTagger");
}

#region Public Static Methods
Expand Down

0 comments on commit 64676e2

Please sign in to comment.