Skip to content

Request in operator #1969

Open
Open
@rebcabin

Description

@rebcabin

I'll work around it for now, but the in operator would be useful. Here is part of my hand-written lexer that could use it:

def eat_white(self : LasrLexer) -> None:
    c: str = peek(self)
    while c != EOF_SIGNAL and c in WHITESPACE:
        c = read(self.fd, 1)
        if c == NEWLINE:
            self.col = 1
            self.line += 1
        else:
            self.col += 1
        c = peek(self)

produces:

/Users/brian/CLionProjects/lpython/src/bin/python /Users/brian/CLionProjects/lpython/lasr/LP-pycharm/lasr_lexer.py 
semantic error: Comparison operator not implemented
   --> /Users/brian/CLionProjects/lpython/lasr/LP-pycharm/lasr_lexer.py:163:31
    |
163 |     while c != EOF_SIGNAL and c in WHITESPACE:
    |                               ^^^^^^^^^^^^^^^ 

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions