Get to know what all neit has to offer and how to use it
Semigen allows you to declare custom command aliases and use them instead of regular ones. Of course, you can still use the default ones whenever you want. You just need to specify the grammar file when building your program.
To use the Semigen engine, create a file, for example grm.txt
, and inside this file specify what command alias you want. For example:
For the exit command -> exit ~ bye
and now in your code anywhere, you can use bye ok
instead of exit ok
.
Semigen allows you to define custom grammar rules to change commands in your Neit code. This feature provides flexibility and helps make your code more readable and maintainable.
You can specify custom grammar rules to replace existing commands. The format is:
<replacement> -> < original>
Example:
say -> print
This replaces print with say. You can now use say
instead of print
to output text. For instance, say "Hello, World!"
will be translated to print "Hello, World!"
during code generation.
In addition to simple command replacements, you can create entire blocks of custom commands. This feature allows you to define a custom command that will be replaced by a block of code. Here's how you can do it:
@your_cmd_name -> { # your code here println "Hello, world!" may v = 1 }
Whenever your_cmd_name
is encountered, it will be replaced by the block of code specified. This is useful for defining reusable code snippets.
Here's a complete example demonstrating both simple command replacement and custom command blocks:
# Define a simple command replacement say -> println # Define a custom command block @initialize -> { println "Initializing..." } # Use the custom commands say hi initialize
In this example:
say hi
will be translated to print hi
.initialize
will be replaced by the block of code defined in the custom command block.Note: Only commands can be changed, not other syntax elements.