Skip to content

Instantly share code, notes, and snippets.

@kreezxil
Created April 24, 2022 16:08
Show Gist options
  • Save kreezxil/368fb603cf749145482d969206adf3a8 to your computer and use it in GitHub Desktop.
Save kreezxil/368fb603cf749145482d969206adf3a8 to your computer and use it in GitHub Desktop.
Parser Language
This my proposed parser language for parsing the template files and creating the runtime generated code (rooms, mobs and obs). It will be the basis for the features planned for version 2.0 once it is fleshed out well enough.
@CODE_BEGIN, @BEGIN_CODE, @BEGIN
@CODE_END, @END_CODE, @END
Signifies a block of mud code that is directly injected into the runtime generated object code.
@INJECT data
Use this when you want to write a line of code without a newline resulting.
for example:
@INJECT set_name("
Results in set_name(" waiting for the next output command to generated a newline
@NEWLINE, @NEW_LINE
Injects a newline into the code_view window. This is useful for when you know you need a newline to be generated.
@PROMPT msg
Asks the user via the prompt indicated in msg and returns the result as a string for direct injection into the runtime generated code.
NOTE: No newline is generated
@PROMPT_INT msg
Asks the user via the prompt indicated in msg and returns the result as an integer for direct injection into the runtime generated code.
NOTE: No newline is generated
@PROMPT_CHAR msg
Asks the user via the prompt indicated in msg and returns the result as a character for direct injection into the runtime generated code.
NOTE: No newline is generated
@RANGE_INT x,y
Presents a list of values in the range x to y where x is the lowest value possible and y is the highest value possible. The result is converted to an integer and then directly injected into the runtime generated code.
NOTE: No newline is generated
@RANGE_CHAR a,z
Presents a list of character values in the range a to z where a is the lowest value possible and z is the highest value possible. The result is converted to a character and then directly injected into the runtime generated code.
NOTE: No newline is generated
@RANGE_LIST item,item,...
Presents a list of items and directly injects the item selected into the runtime generated code.
NOTE: No newline is generated
@AUTO
When prepends an @RANGE or @EXIT, will cause automatic value choosing and injection without prompting user and direct injection of results into runtime generated code.
for example: @AUTO RANGE_LIST cat,dog,cow,chicken,snake,pig
In which case a radnom item from that list will be autoselected and injected into your code.
@TEXT msg
Sets the next message to be displayed by the next wizard that comes up, consider this an additional information directive when used in conjunction with @commands that have prompting built in.
@EXIT_PATH
This is an example of command that might use the @TEXT directive. It returns the path as a string for direct injection into the runtime generated code.
NOTE: No newline is generated
@EXIT DIR
This is an example of command that might use the @TEXT directive. It returns the direction as a string for direct injection into the runtime generated code.
NOTE: No newline is generated
@AUTO EXIT format
This is being elaborated upon, so that you don't misuse the syntax. @EXIT_PATH and @EXIT_DIR are not @AUTO_capable unless via use of this command.
format should be one of "PATH,DIR" or "DIR,PATH". The reason being that muds have never agreed as to which comes first.
Note: That should this particular command be in your template file, when it is encountered, all adjacent existing rooms in the map view, include those above and below are automatically linked in to the runtime generated code. It is still possible to manually prompt before and after this function for custom exits.
NOTE 2: No newline is generated
NOTE 3: This command not currently implemented.
@OBJECT msg
Prompts the user via the msg to link an external object to the runtime generated code. The user has the option to browse for the file or directly enter the file's name and path. The file linkage, as with the exit linkages, is converted to mud path format.
NOTE: No newline is generated
NOTE 2: This command not currently implemented.
@INCLUDE FILE
@INCLUDE
If the command directive FILE is supplied and the path to a file is also supplied then the file supplied is loaded and parsed. The included file maybe either parser embedded or not, that is left up to you the coder.
If there are no supplied arguments a dialog will open that will allow you to select and runtime the include file you need.
Proposed New Commands
To be implemented after above
non implemented commands are in place
@VAR name_of_var @command
idea: declare a variant variable of name name_of_var that stores the resulting output of @command without causing code injection.
@IF expression
... true code ...
@ELSE
... false code ...
@ENDIF
Usage: Evaluates expression, if true then code between @IF and @ELSE is parsed, if @ELSE is absent then code upto @ENDIF is parsed if expression was true. If expression is false and @ELSE is not absent, then code between @ELSE and @ENDIF is parsed, otherwise parsing picks up after @ENDIF. Probably won't be using nested structures of this type, depends on how well I write the parser in that regard.
Page last updated: June 22, 2004, 10:53 am
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment