【文件属性】:
文件名称:语法分析:语法分析解析器
文件大小:191KB
文件格式:ZIP
更新时间:2024-03-07 18:22:31
parser compiler syntax-analysis cs143 TypeScript
语法分析
语法分析(lexer之后的编译器步骤)。
安装
npm i @jlguenego/syntax-analysis
用法
您应该使用Typescript以便以更简单的方式检查语法。
const t = defineTerminalAlphabet ( [ '+' , 'int' ] as const ) ;
const nt = defineNonTerminalAlphabet ( [ 'S' , 'E' , 'F' ] as const ) ;
type TA = typeof t ;
type NTA = typeof nt ;
const spec : CFGSpec < TA> = {
startSymbol : 'S' ,
productions : [
{ LHS : 'S' , RHS : [ 'E' ] } ,
{ LHS