Skip to content

Define a Hex Literal #455

Closed Answered by b3b00
utech626 asked this question in Q&A
Jun 29, 2024 · 2 comments · 3 replies
Discussion options

You must be logged in to vote

Here is a quick answer.

using sly.lexer;
using sly.lexer.fsm;
using sly.i18n;

namespace hexa
{
    public enum hexalexer
    {
        [Extension]
        HEX,
    }

    public class Extendedhexalexer
    {
        public static void Extendhexalexer(hexalexer token, LexemeAttribute lexem, GenericLexer<hexalexer> lexer)
        {
            if (token == hexalexer.HEX)
            {
                NodeCallback<GenericToken> callbackHEX = (FSMMatch<GenericToken> match) =>
                {
                    // this store the token id the the FSMMatch object to be later returned by GenericLexer.Tokenize 
                    match.Properties[GenericLexer<hexalexer>.DerivedToken] = hexalexer

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@utech626
Comment options

@b3b00
Comment options

b3b00 Jul 1, 2024
Maintainer

@b3b00
Comment options

b3b00 Jul 2, 2024
Maintainer

Answer selected by utech626
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants