Skip to content

Commit

Permalink
remove do not ignore attribute on comments as it does not make sense …
Browse files Browse the repository at this point in the history
…now we have channels
  • Loading branch information
b3b00 committed Dec 19, 2024
1 parent d233f94 commit 792d9e0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
1 change: 0 additions & 1 deletion src/sly/lexer/GenericLexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,6 @@ public Token<IN> Transcode(FSMMatch<GenericToken> match)
tok.IsIndent = match.IsIndent;
tok.IsUnIndent = match.IsUnIndent;
tok.IndentationLevel = match.IndentationLevel;
tok.Notignored = match.Result.Notignored;
tok.Channel = match.Result.Channel;
tok.DecimalSeparator = match.DecimalSeparator;
tok.DateTimeValue = match.DateTimeValue;
Expand Down
12 changes: 4 additions & 8 deletions src/sly/lexer/LexerBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -412,29 +412,27 @@ private static IEnumerable<char[]> ParseIdentifierPattern(string pattern)
}
}

private static NodeCallback<GenericToken> GetCallbackSingle<IN>(IN token, bool doNotIgnore, int channel)
private static NodeCallback<GenericToken> GetCallbackSingle<IN>(IN token, int channel)
where IN : struct
{
NodeCallback<GenericToken> callback = match =>
{
match.Properties[GenericLexer<IN>.DerivedToken] = token;
match.Result.IsComment = true;
match.Result.CommentType = CommentType.Single;
match.Result.Notignored = doNotIgnore;
match.Result.Channel = channel;
return match;
};
return callback;
}

private static NodeCallback<GenericToken> GetCallbackMulti<IN>(IN token, bool doNotIgnore, int channel)
private static NodeCallback<GenericToken> GetCallbackMulti<IN>(IN token, int channel)
where IN : struct
{
NodeCallback<GenericToken> callbackMulti = match =>
{
match.Properties[GenericLexer<IN>.DerivedToken] = token;
match.Result.IsComment = true;
match.Result.Notignored = doNotIgnore;
match.Result.CommentType = CommentType.Multi;
match.Result.Channel = channel;
return match;
Expand Down Expand Up @@ -636,8 +634,7 @@ private static BuildResult<ILexer<IN>> BuildGenericLexer<IN>(IDictionary<IN, Lis
fsmBuilder.ConstantTransition(commentAttr.SingleLineCommentStart);
fsmBuilder.Mark(GenericLexer<IN>.single_line_comment_start);
fsmBuilder.End(GenericToken.Comment);
fsmBuilder.CallBack(GetCallbackSingle<IN>(comment.Key, commentAttr.DoNotIgnore,
commentAttr.Channel));
fsmBuilder.CallBack(GetCallbackSingle<IN>(comment.Key, commentAttr.Channel));
}

var hasMultiLine = !string.IsNullOrWhiteSpace(commentAttr.MultiLineCommentStart);
Expand All @@ -650,8 +647,7 @@ private static BuildResult<ILexer<IN>> BuildGenericLexer<IN>(IDictionary<IN, Lis
fsmBuilder.ConstantTransition(commentAttr.MultiLineCommentStart);
fsmBuilder.Mark(GenericLexer<IN>.multi_line_comment_start);
fsmBuilder.End(GenericToken.Comment);
fsmBuilder.CallBack(GetCallbackMulti(comment.Key, commentAttr.DoNotIgnore,
commentAttr.Channel));
fsmBuilder.CallBack(GetCallbackMulti(comment.Key, commentAttr.Channel));
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/sly/lexer/Token.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ public class Token<T> where T:struct
public char DecimalSeparator = '.';
[JsonIgnore]
public char CharDelimiter ='\'';
[JsonIgnore]
public bool Notignored;


[JsonIgnore] private string _hexaPrefix = "0x";

Expand Down
3 changes: 1 addition & 2 deletions src/sly/lexer/attributes/CommentsAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public class CommentAttribute : Attribute

public string SingleLineCommentStart;

public bool DoNotIgnore = false;

public int Channel = 1;

Expand All @@ -22,7 +21,7 @@ public CommentAttribute(string singleLineStart, string multiLineStart, string mu
SingleLineCommentStart = singleLineStart;
MultiLineCommentStart = multiLineStart;
MultiLineCommentEnd = multiLineEnd;
DoNotIgnore = doNotIgnore;
//DoNotIgnore = doNotIgnore;
Channel = channel;
}
}
Expand Down

0 comments on commit 792d9e0

Please sign in to comment.