112

GitHub - vim-jp/vim-vimlparser: VimL parser

 6 years ago
source link: https://github.com/vim-jp/vim-vimlparser
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Vim script parsers

This is Vim script language (a.k.a. VimL) parsers.

Features

The parser to make AST (Abstract Syntax Tree)

Supported languages

This parser provide same feature for following languages.

  • Vim script
  • Python
  • JavaScript

Example

All of interfaces are provided from vimlparser module. VimLParser parse into AST using StringReader, and Compiler to compile nodes.

let s:VP = vimlparser#import()
let code = [
\ 'let s:message = printf("hello %d", 1+(2*3))'
\]
let r = s:VP.StringReader.new(code)
let p = s:VP.VimLParser.new()
let c = s:VP.Compiler.new()
echo join(c.compile(p.parse(r)), "\n")

This above code output following.

(let = s:message (printf "hello %d" (+ 1 (* 2 3))))

About project name

We know a name "VimL" is not the common short form of "Vim scripting language". But we choice "VimL" for historical and practical reasons and compatibility.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK