Improving Lua syntax

SyntaxEditor for WPF Forum

Posted 12 years ago by John Dunn
Version: 12.1.0561

The lualang.def file will use a '.' to delimit the start of keywords. This is incorrect since the '.' is a table delimiter and a key in a table is allowed to be the same string as a builtin function. For example, the following would highlight 'error'.

Even though error does not reference the builtin error function. Is there a way to fix this behavoir? It doesn't seem specific to lua but I didn't see anything int the .def that made it obvious how I might go about fixing it.

Comments (3)

Answer - Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA

Hi John,

I'm sorry but I'm not really seeing anywhere in our lexer definition where we have something specifically saying a dot can come before a keyword.  The lexer just tokenizes dot characters as punctuation, the same as commas.  The free simple Lua language sample doesn't do any parsing or syntax error reporting.  It just does syntax highlighting only.

Were you expecting it to report syntax errors?  If you were looking for that functionality, our product can do that sort of thing, but you'd have to write a parser for the language and add some language services.  Our Getting Started series of QuickStarts walks you through the process of doing so.

Actipro Software Support

Posted 12 years ago by John Dunn

My sample might have been confusing since I used the word error. I'm not looking to detect syntax errors. I just want to highlighter to not think that 


is still a Function. It's still perfectly valid code, it just happens to be a table key. An example using c# might look like

class foo
  public int Console;

Console.WriteLine("this should be highlighted");
foo.Console = 34; // this shouldn't

 So I guess the simple rule is that a function can't have a '.' in front of it. If it does, it's not a function. Given the way Lua parses it's probably '.<whitespace>. Does that make sense?

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA

Hi John,

Ok so in the pattern group for Function, couldn't you just do this:


That would say at the start of the document or not after a dot.

Actipro Software Support

The latest build of this product (v24.1.2) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.