Ventimore Ltd | ||
HOME DOCS | ||
High Level Language (HLL) SpecificationThe BSV editor can run scripts written in user-defined high-level languages by providing and installing HLL language modules. This document describes how to do that. CAVEAT: The high level language module specification is subject to change. In particular, the current implementation requires the language module to be compiled with MSVC Version 15.9.9 with C++17 support switched on. It is likely that the current C++ interface will be wrapped with a C interface, and the C++ interface deprecated. High Level Language (HLL) ModulesThe BSV editor comes with the API-compliant language module for the Hello language pre-installed. The Hello language module is open-source code. Source is available at Hello GitHub repository. To make a language available, the language provider must register the language module and supply the language compiler as a DLL as per this document. Language RegistrationLanguage registration allows the editor to detect the presence of language modules. To register a language module, the following steps must be taken
HLL CompilerA HLL module makes the compiler available to the BSV editor via the following function: debuggable* create_<language_name>_compiler(); The compiler object must be derived from the debuggable interface. (See Internals.h) class my_HLL_compiler : public debuggable { virtual std::pair<bool, std::string> compile(const std::string& filename) override; virtual std::pair<bool, std::string> execute(const std::string& script_txt) override; virtual std::pair<bool, std::string> go() override; virtual std::pair<bool, std::string> step_over() override; virtual std::pair<bool, std::string> step_into() override; virtual void stop() override; } The compiler should exhibit the following behaviour.
The editor displays the values in stack, alt-stack and symbol_table defined in debuggable. Remarks1. By convention, API functions return std::pair<bool, std::string>(true, "") if they complete successfully and return std::pair<bool, std::string>(false, error-message) if they do not. 2. The Hello language module is a Q&D hand-crafted language compiler. It follows the tradition pipeline tokeniser → parser → AST → instruction pipeline → optimiser Further documentation will be added. SecurityThe BSV Editor makes calls into another DLL/shared object, which opens up the possibiliy of malicious code in a HLL module doing harm. It is therefore advised that only trusted language modules, or ones compiled from source code, are installed. This site will maintain a list of trusted publicly-available language modules (none currently available).
Copyright (c) Ventimore Ltd (UK), 2011, 2012, 2017, 2018, 2019. |