Issue #367 resolved

Scala Highlighter is broken

Anonymous avatarAnonymous created an issue

The scala highlighter in pygments is quite useless.

I attach a patch that fixes most of the obvious problems and even does some feeble attempts at semicolon inference (i.e. nicely formatted code should be highlighted acceptably, but it should be easy to write code that breaks the highlighting). It produces acceptable highlighting on the scalaz code I tested it on.

Florian Hars <florian (at) hars.de>

Reported by guest

Comments (7)

  1. Anonymous

    I attaced a file showing some of the problems:

    • Neither `interface` nor interface is highlighted as in identifier, although both are
    • val isn't highlighted as a keyword
    • Nested commtents are broken
    • Multiline strings are broken
    • is highlighted as an error, although it is a valid name
    • foo_+ is highlighted as an identifier followed by an operator, although it is a single itentifier
    • foo_⌬⌬ is totally borked.

    More prolems with the old lexer:

    • The deprecated type names boolean|byte|char|double|float|int|long|short|void are highligted different from their prefered uppercase versions
    • The class names String|Int|Array|HashMap are highlighted different from all other class names

    Thing the new lexer doesn't solve:

    • Any name can designate almost everything (a type, a class, a method, a variable, an operator), you can only make the decision after type checking. So I make some common sense assumptions:
    • an identifier that starts with an uppercase letter is a Name.class
    • an identifier that starts with any other type of letter is a Name
    • a backticked itentifier is a Name
    • an identifier consisting of opchars is an Operator This can be as off as you want, but captures conventional practice.
  2. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.