VYPcode Extension
Extension adding syntax highlighting, debugging and interpretation support for the VYPcode language.
Dependencies
- Visual Studio Code version 1.49.0 or higher
- Java 8 interpreter
- it is expected that it can be run using the command
java
, otherwise this must be changed in settings or debug configuration
- uses the default integrated terminal for interpretation and debugging
Details
Detailed information about the features of this extension.
File detection
The extension defines a grammar for the VYPcode language which is used by VS Code for syntax highlighting. Language of a file is detected based on its extension, extensions configured for VYPcode are: vypc
, vypcode
, vc
.
Debugger
The extension adds the debug type vypc
which can be used in debug configurations (in the launch.json
file). If the currently open file is identified as a VYPcode file then two buttons are displayed in the toolbar in the top right corner. These buttons can be used to debug or run the open file using the extension's settings.
Setting program values
Using the VARIABLES
view you can change the values in registers, on stack and in individual chunk items. The new value can be either an integer or a float in the same format as in the source code. It is not possible to edit a whole chunk.
Value watches
The WATCH
view can be used to display specific values. Registers and stack values are identified the same way as in the source code. Chunks can be displayed using their id. Individual chunk items can be accessed by a chunk identifier and an index.
- register: dollar followed by a number or a name of a register
$0
, $NAME
- stack item: expression in square brackets (stack addressing)
[5]
, [$1 + 8]
- chunk: integer of a chunk id
1
- chunk item: chunk id and an integral index
1[0]
The values are displayed as decimal numbers by default, in the same way as in the VARIABLES
view. Floating point formats are available by adding a format specifier to the end of the value identifier. The format specifier starts with the percent symbol %
and is followed by a (case-insensitive) letter specifying the format.
d
: default decimal format
a
: hexadecimal floating point format (used to print floating point numbers)
f
: standard floating point format
Evaluating instructions
While debugging it is possible to use the DEBUG CONSOLE
to evaluate additional instructions. The execution of the program must be paused (e.g. on a breakpoint or by using the pause button). Evaluation supports the same instructions as a normal VYPcode program with the exception of the LABEL
instruction, the READx
instructions and the debug instructions. Output of the evaluated instructions is redirected to the debug console. Except for that the behaviour of the instructions is exactly the same as if they were written in the source code. Evaluating instructions changes the state of the debugged program. Possible errors while evaluating instructions in the console will not end the debugged program.
Added commands
The extension adds two commands used to launch and debug the currently open file. These commands can be used by clicking the previously mentioned buttons or they can be run from the Command Palette
(default keyboard shortcut to open it is Ctrl+Shift+P
), where they are available regardless of the language of the open file.
VYPcode: Debug
: launches the currently open file in debug mode
VYPcode: Run
: executes the currently open file
Interpreting VYPcode programs
The extension contains a jar with a debug adapter which includes the interpreter. By default this adapter is used to execute a VYPcode program by launching it in debug mode with the noDebug
argument, which causes the adapter to blockingly execute the program (ignores all debug commands until the program finishes). It is recommended to set a path to the VYPcode interpreter jar so it can be used instead.
Debug configuration
Every debug configuration must contain three attributes: type
, request
and name
. In addition to these the attribute program
is also required.
request
: how to start debugging, supports only the option launch
name
: name of the configuration, any
type
: debug type, vypc
for VYPcode programs
program
: path to the program to debug
stopOnEntry
: stop before the first instruction when debugging starts
args
: array of arguments to pass to the interpreter, e.g. ["--stack", "10"]
port
: default port to run the debug adapter server on
javaPath
: path to a Java interpreter to use
Settings
Settings of the extension are available under VYPcode
. The settings override the default values but have a lower priority than debug configuration. Their purpose is the same as in the debug configuration.
Port
Java Path
Version
VYPcode Interpreter
: path to the VYPcode interpreter jar