bobbylight / RSyntaxTextArea

A syntax highlighting, code folding text editor for Java Swing applications.
BSD 3-Clause "New" or "Revised" License
1.12k stars 259 forks source link

Is there a way to use additional parsing info for the lexer? #468

Closed kortenkamp closed 1 year ago

kortenkamp commented 2 years ago

Describe the solution you'd like For most languages, calling a function needs a certain, fixed number of parameters. E.g., call( 1, 2) is a different function call than call (5). It would be nice to be able to give a visual clue whether that call is actually defined – that is, allow for the information whether call is a token of type known_function or unknown_function.

Are there any workarounds? Maybe it is possible to extract that information when parsing the line somehow. I would be grateful for hints about any existing parsers that can do similar things.

Additional context A similiar problem would be to identify whether a certain identifier denotes a built-in function or a user-defined function. Again, this depends on parsing of the full file.

bobbylight commented 1 year ago

This is a tricky problem for a couple of reasons:

That said, it is certainly possible to do these things, but it would take legwork in the client app.

if (tokenType == TokenTypes.FUNCTION && stdlibFunctionSet.contains(new String(array, start, end))) {
  tokenType = myCustomTokenType;
}