DEV Community


MEML Is Working!

kailyons profile image KaiLikesLinux ・2 min read

MEML has already grown into a reality of sorts. Currently in an early release where I have yet to deal with many of the more pressing issues. I have finally made MEML work. Over the last week, I have built a working lexer and parser with an AST array that works. Tags like p, span, h1, work without a hiccup. I am sharing what each function and tool in the MEML transpiler does because it is one of my most proud creations. I might get a majority of the definitions wrong, but the point is that it works.

The File Itself

The MEML project is composed of a single JavaScript file. I picked JavaScript because I was comparing Deno to NodeJS in a planned article that fell through, but the V compiler I had is not working. The JavaScript uses NodeJS to function and uses NodeJS based tools. The file itself is 257 lines long, and 7.91 kilobytes in size. The primary functions being the parser, lexer, code stitcher, file creator, and the replacer. At the end of the file is where the code gets CLI argument inputs, and either sends the version, the help information, runs the rest of the script.

Simple Overview

The if statement looks at the CLI arguments to see if it should send the help information, version information, or read any given MEML file. It looks for any command line arguments, but if a given command is unknown, the script will undeviatingly not react.

On the command output, the script will set the name of the file given to whatever the user wishes. The command will also permit the use of using any file extension, in case you want to put the HTML into something like an HTM, TXT, or whatever kind of file you prefer. If the output command is not specified, the output will automatically send into an HTML file.

The help and version commands display help information and version information, respectively.

The parser function splits the code into the AST, while the lexer makes sense of it. The code stitcher function takes the lexer's output and turns it into information that the file creator puts in the final file.

The replacer function replaces text to a newly defined set, used most often to split the code.

How to make MEML better

There is a lot of recycling the same functionality, and it would be best to slim down the functions. The translation can be a little janky and has the potential for problems. Right now, the public beta is open, and it is exciting to see what and where this project will go.

Discussion (0)

Editor guide