UNPKG

@lcap/nasl-parser

Version:

Take Nasl text to Nasl AST with the help of generalized parsing.

25 lines (20 loc) 531 B
import { Parser, Grammar } from "nearley"; import grammar from "../../ts/nasl"; const ann1 = ` // test @( description = "获取所有的角色名称", triggerType = "", cron = "", transactional = false, ) logic LCAPGetRoleNameList(roleName: String) => result { } ` describe('Test Logic Annotations', () => { test('Builtin Logic Annotation', async () => { const parser = new Parser(Grammar.fromCompiled(grammar)); parser.feed(ann1); expect(parser.results.length).toBe(1); }); });