0.0.2 • Published 2 years ago
pbasic-language-pack v0.0.2
PBasic Language Pack
A language pack for CodeMirror built using Lezer designed to provide insight into PBasic v2.5 code.
Implemented Language Features
AST Parsing
- General language syntax
- Arithmetic expressions
- Expression grouping
- Significant line endings
- Line ending stand-ins via
: - Pattern matching
- Compile-time if/else, select NOTE: all compile-time information is currently shoved under the 'Preprocessor' token
VAR / CONdeclarations- general syntax
BIT/NIB/BYTE/WORD<TYPE>(N)arrays
.LOWBYTE/.HIGHBYTEAUXIOBRANCHBUTTONCOMPARECONFIGPINCOUNTDATA- named
DATA WORD-typedDATA@address-edDATA- reserved
DATA - repeated
DATA - expressions in
DATA
- named
DEBUG/SER/I2C/LCD,INandOUTforms- simple
DEBUG - all format specifiers
- all special cases
- simple
DO ... LOOPDO WHILE ...DO UNTIL ...DO ... LOOP WHILEDO ... LOOP UNTILDO ... LOOP
DTMFOUTENDEXITFOR ... NEXTFREQOUTGETGOSUBGOTOHIGHIF ... THEN ... ELSEIF ... THENELSEIFELSE
INPUTIOTERMLCDCMDLOOKDOWNLOOKUPLOWMAINIONAPON ... GOSUB/GOTOOUTPUTOWINOWOUTPAUSEPOLL___PULSINPULSOUTPUTPWMRANDOMRCTIMEREADRETURNREVERSERUNSELECT ... CASE- Simple cases
- Multiple cases
- Comparison cases
- Range cases
- Else case
SHIFTINSHIFTOUTSLEEPSTOPSTORETOGGLEWRITEXOUT
Todo: test it all :D
FAQ:
- Use
syntaxTree()to get the syntax tree from a editor state. THere is no obvious documentation which states this >:( - Many of the necessary types for interfacing with the library are private, so sometimes using
type PrivType = Parameters<fnWithPrivType>[0];will be necessary