rouge-ruby / rouge

A pure Ruby code highlighter that is compatible with Pygments
https://rouge.jneen.net/
Other
3.3k stars 732 forks source link

Draft: Add lexer for Mojo language #1995

Closed fnands closed 1 month ago

fnands commented 9 months ago

This is a (first draft) of a lexer for the Mojo programming language.

In principle, Mojo aims to be a superset of Python, so the Mojo lexer inherits from the Python lexer (thanks to @jneen for the suggestion).

I've never written a line of Ruby in my life, so if anything below looks suspect, that's why.

Currently a little stuck on regexes (trying to get to match outer square brackets in function definitions). Any pointers appreciated.

fnands commented 8 months ago

I think I've narrowed it down to the fact that Mojo has parameters as well as functions. So where a python function might look like:

def python_func(arg1, arg2):
    pass

a Mojo function could also have parameters in square brackets:

def mojo_func[param1, param2](arg1, arg2):
    pass

and the regexes don't deal with the parameters yet.