Charles-Johnson / zia_programming

A language that can program itself
https://zia-lang.org
GNU General Public License v3.0
3 stars 0 forks source link

Implement lexing of commands and syntax colouring #68

Closed Charles-Johnson closed 2 years ago

Charles-Johnson commented 2 years ago

This is first step of the solution of #52

Different kinds of lexemes can be coloured differently on the website

This is possible by exposing a new public method for Context called lex which takes the command as a &str and returning a Vec<Lexeme> this can be used in front ends such as the zia-lang.org website to provide syntax colouring. The current implementation involves duplicated logic that's used in Context::ast_from_expression this is due a refactor that should be a separate PR.

The website callsContext::lexon every render to lex the whole command. For better performance, there should be a method to update the Vec<Lexeme> based on the change in the command as the user types.