npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

coc-lpcd

v1.2.8

Published

parse lpc symbol position and define

Downloads

14

Readme

coc-lpcd

解析lpc(语法定义)引擎生成的符号表,提供符号跳转和自动补全的功能。

安装

:CocInstall coc-lpcd

依赖

需要提供一个编译程序lpc_complie,coc-lpcd使用lpc_complie cmd/command.c,在lpc脚本的根目录project,将指定的lpc文件编译。在project/log/symbol/下生成符号文件,命名为cmd#command.c,将/替换为#。

符号文件的格式为

File:
    : Lines
Lines
    : Line
    | Line Newline Lines
Line:
    : Op ' ' Filename ' ' Lineno ' ' Detail
    ;
Newline
    : '\n'
    ;
Op
    : '1'
    | '2'
    | '3'
    | '4' 
    | '5'
    | '6'
    | '7'
Filename
    : [a-zA-Z0-9_/.]+
Lineno
    : [0-9]+
Detail
    : .*?

符号文件由多行组成,每一行是一个操作,每个操作可能是

|操作|解释|内容detail|钩子位置 |:----:|:----:|:----:|:----: |1|include文件|可以空缺|handle_include |2|define宏|define内容|handle_define |3|定义全局变量|变量名|define_new_variable |4|函数定义|函数名|define_new_function |5|定义局部变量|变量名|add_local_name |6|取消局部变量定义|取消个数|pop_n_locals |7|取消所有的局部变量定义|无|free_all_local_names

文件名和行号来自于yacc解析过程中的current_filecurrent_line

配置

{
    "coc-lpcd.efunc": [
        "/etc/efun_define.c",
        "/sys/object/simul_efun.c"
    ],
    "coc-lpcd.include": "inc",
    "coc-lpcd.workspace": "newtxii",
    "coc-lpcd.complie": "lpc_complie"
}
  1. coc-lpcd.efunc: 这里面定义的函数,任何一个脚本都能访问。
  2. coc-lpcd.include: #include 查找的目录。
  3. coc-lpcd.workspace: 确定根目录project的目录名。
  4. coc-lpcd.complie: 生成符号文件的命令。

代码细节

代码核心部分是个parse函数,传入指定的文件,对编译之后的符号文件进行解析生成FileSymbol

interface FileSymbol {
    lineno: number;
    defined: Symbol[],
    include: Symbol[],
    variable: Symbol[],
    func: Symbol[],
    childFileSymbol: { [key: string]: FileSymbol },
}

interface Symbol {
    name: string,
    line: number,
    filename: string,
    args?: string[],
    op?: LineSymbol[],
    detail?: string,
}

一个文件符号表用FileSymbol,里面包括该文件定义的宏、全局变量、函数。childFileSymbol用于存放include文件的符号表。lineno是include的行数,用于筛选符号定义之前的代码提示。

每一个符号用Symbol表示,可以是宏定义、函数名、全局变量名。包括符号名、定义的行号、定义的文件名、符号携带的参数(只有宏和函数有)和具体内容(宏内容)。

函数定义之前会先定义局部函数变量,开始函数定义的时候,取出所有的局部变量,就是函数变量。

取消局部变量定义的时候,根据数量,从栈里面弹出即可。

释放所有局部变量的时候,清空局部变量栈。

记录最后一个定义的函数符号,将和局部变量的相关的操作全部加入到队列中,在释放所有局部变量的时候,将队列挂到符号的op中。在进行局部变量名提示的时候,根据当前行号找到函数符号,回放队列中的操作,直到当前行,此时队列中剩余的局部变量,就是可以访问的局部变量名。

This extension is built with create-coc-extension