Skip to content

Lua lexer classifies keywords as identifiers #8

Open
@kedorlaomer

Description

@kedorlaomer

Using lpeg 1.0.1-1 and lua 5.3.3, I find that

 for kind, text in lxsh.lexers.lua.gmatch 
   'sleep(5); if x >= 0 then print(x) else print(-x) end' do 
    print(kind, text)
end

outputs

identifier      sleep
operator        (
number  5
operator        )
operator        ;
whitespace
identifier      if
whitespace
identifier      x
whitespace
operator        >=
whitespace
number  0
whitespace
identifier      then
whitespace
identifier      print
operator        (
identifier      x
operator        )
whitespace
identifier      else
whitespace
identifier      print
operator        (
operator        -
identifier      x
operator        )
whitespace
identifier      end

It considers all keywords to be identifiers. Only if a keyword is the first token of the string it gets the kind classifier.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions