jsymbol
所属分类:数据结构
开发工具:TypeScript
文件大小:0KB
下载次数:0
上传日期:2022-12-07 10:25:07
上 传 者:
sh-1993
说明: 编译器解释器中使用的符号和符号表的数据结构。用TypeScript编写,可以是...
(Data structures for symbols and symbol table to be used in compilers/interpreters. Written in TypeScript and can be used in TypeScript and JavaScript projects.)
文件列表:
.npmignore (37, 2023-12-28)
.travis.yml (170, 2023-12-28)
.vscode/ (0, 2023-12-28)
.vscode/launch.json (888, 2023-12-28)
.vscode/settings.json (90, 2023-12-28)
LICENSE (1062, 2023-12-28)
package.json (1530, 2023-12-28)
src/ (0, 2023-12-28)
src/index.ts (4024, 2023-12-28)
test/ (0, 2023-12-28)
test/index.test.ts (8704, 2023-12-28)
tsconfig.json (356, 2023-12-28)
tslint.json (2201, 2023-12-28)
yarn.lock (117259, 2023-12-28)
# jsymbol
[![Build Status](https://travis-ci.org/solzacode/jsymbol.svg?branch=master)](https://travis-ci.org/solzacode/jsymbol)
[![NPM version](https://badge.fury.io/js/jsymbol.svg)](https://www.npmjs.com/package/jsymbol)
[![Coverage Status](https://coveralls.io/repos/github/solzacode/jsymbol/badge.svg?branch=master)](https://coveralls.io/github/solzacode/jsymbol?branch=master)
Data structures for symbols and symbol table to be used in compilers/interpreters. Written in TypeScript and can be used in TypeScript and JavaScript projects.
## Installation
### Using yarn
```sh
yarn add jsymbol
```
### Using npm
```sh
npm install jsymbol --save
```
## Usage
### TypeScript
```typescript
import { SymbolTable, AstSymbol } from "jsymbol";
let st: SymbolTable
= new SymbolTable(s => s.identifier);
let sym: AstSymbol = new AstSymbol("counter", "variable"); // symbol and its type
st.add(sym);
st.enterScope();
// assert: st.lookup("counter") === sym;
st.exitScope();
```
### JavaScript
```javascript
const jsymbol = require("jsymbol");
let st = new jsymbol.SymbolTable(s => s.identifier);
let sym = new jsymbol.AstSymbol("counter", "variable");
st.add(sym);
st.enterScope();
// assert: st.lookup("counter") === sym;
st.exitScope();
```
近期下载者:
相关文件:
收藏者: