VS Code language support for Malib scripts.
Features
- Syntax highlighting for
.malibfiles. - Line and block comments.
- Strings and supported escape sequences.
- Core commands such as
read columns,split chars,comment line,comment line at,comment block,match index,match case,span max,debug,coverage,string quotes,string multiline,param,const,let,flag,if,for,print,push,pop,clear,ruleset,analyzer,run, andwhen. - Lifecycle and scoped blocks such as
before,after,tokenizer, andlocal let. - Relative rules with
before whenandafter when. - Rule gates with
@requires(_flag, !_other_flag). whenpattern items such ascap,push,in,as,at,int,real,string,span_until,max,any,opt,not,mask,line_end, andline_gap.- Single-quoted Malib values and double-quoted source-token patterns.
- Arithmetic operators for runtime counters.
- Runtime properties and methods such as
.count,.columns,.last,.mid(...),.trim,.contains(...),.replace(...),.split_protected(...),source.*,global.*, andmatch.*. - Iteration forms such as
for item, idx in list,for ... reverse,for i from a to b, andfor i from a until b. - Analyzer runs such as
run analyzer name from text value with { ... }andrun analyzer name in match. - Scan-control commands such as
cut,cut first,cut range, andcut all. - Transformation commands such as
replace match with,delete range,insert before, andinsert after. - Host value functions such as
read_file,read_lines, andread_csv. - Semantic token highlighting layered on top of TextMate scopes for real symbol meaning: functions, variables, params, flags, consts, loop indices, captures, properties, methods, keywords, and decorators.
- Snippets for common Malib commands and blocks.
- Hover documentation for reserved words, commands, pattern items, built-ins, and runtime properties.
- Symbol hover for
param,let,const,flag, captures,fun, andrulesetdeclarations. - Go to definition for local variables, constants, flags, functions, captures, and rulesets.
- Rename symbol support with
F2for known Malib symbols in the current document. - Basic completions for language keywords and symbols declared in the current document.
- Inlay hints for function call arguments and
forloop item/index variables. - Folding ranges for Malib brace blocks such as
ruleset,analyzer,fun,when,if,for,before,after, andtokenizer. - Document and selection formatting with conservative two-space indentation.
- Hierarchical document outline for params, flags, values, functions, rulesets, analyzers, lifecycle blocks, and
whenrules. - Signature help for
call function_name(...), plus ruleset/analyzer parameter hints duringrunexpressions. - Basic diagnostics for
call,run,run analyzer,ref,@requires, flag declarations, const reassignment, unknown assignment targets, collection references, relativebefore when/after when, and match transformation commands such ascut,replace match,delete range, andinsert. - Quick fixes for common diagnostics, including flag naming,
runversuscall, analyzer runs, const reassignment, missing variable declarations, and missing@requiresflags.
Local Development
Open editors/vscode-malib in VS Code and run the extension development host.
Run the extension test suite from this folder with:
npm test
The extension is intentionally editor-facing only. Malib parser, compiler, runtime, and diagnostics stay in matlalib-core.
Use examples/full-syntax.malib as the living syntax fixture for highlighting decisions. When the Malib language grows, update that file first or alongside the grammar, then verify that the TextMate scopes still highlight the complete syntax shape.
The test suite also covers productive migration fixtures:
comparison/cases/004-validaciones-estaticas/malib/validaciones_estaticas.malibcomparison/cases/005-codigo-muerto/malib/program.malib
Packaging
Before packaging or publishing, run:
npm test
npm run package
To publish to the Visual Studio Marketplace, make sure the publisher field in package.json matches your Marketplace publisher id, then run:
npm run publish
Example
read columns 7..72
split chars ".(),;:"
comment line "//"
comment block "/*" "*/"
string quotes "'\""
match case insensitive
debug off
coverage on
const reserved_words = ['IF', 'ELSE', 'PERFORM']
flag _in_procedure = off
let found = 'NO'
let dsn_names = []
let last_dsn = ''
match index off
ruleset cobol_scan {
debug on {
tokens: true
matches: true
variables: ['found']
}
when (in reserved_words cap keyword) {
found = 'SI'
push dsn_names, keyword
}
}
when ("TO" cap destino) {
before when ("MOVE" cap origen) {
found = 'SI'
push dsn_names, origen
}
}
run cobol_scan
pop dsn_names into last_dsn
pop dsn_names
print last_dsn, dsn_names.count