Skip to content

Conversation

@manux81
Copy link

@manux81 manux81 commented Jun 27, 2021

With reference to:
dabeaz#62
I've found a problem with tokens remapping in the eventuality of:
reflags = re.IGNORECASE
This change allows creating special cases ignoring capitalization in the eventuality of
reflags = re.IGNORECASE assignment in Lexer class.

Example:
class MyLexer(sly.Lexer):
reflags = re.IGNORECASE
# Base ID rule
ID = r'[a-zA-Z_][a-zA-Z0-9_]*'

# Special cases
ID['if'] = IF
ID['else'] = ELSE
ID['while'] = WHILE
# Now if,If,IF,iF are handle as the same special cases

With reference to:
dabeaz#62
I've found a problem with tokens remapping in the eventuality of:
reflags = re.IGNORECASE
This change allows creating special cases ignoring capitalization in the eventuality of
reflags = re.IGNORECASE assignment in Lexer class.

Example:
class MyLexer(sly.Lexer):
    reflags = re.IGNORECASE
    # Base ID rule
    ID = r'[a-zA-Z_][a-zA-Z0-9_]*'

    # Special cases
    ID['if'] = IF
    ID['else'] = ELSE
    ID['while'] = WHILE
    # Now if,If,IF,iF are handle as the same special cases
@bugengine bugengine force-pushed the master branch 2 times, most recently from 4f13918 to ab00964 Compare January 22, 2023 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant