UNPKG

@lcap/nasl-parser

Version:

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

36 lines (26 loc) 889 B
import { Parser, Grammar } from "nearley"; import grammar from "../../ts/nasl"; const testSQL =` logic testSQL() { result = from user in entities::LCAPUser join vMap in entities::LCAPLogicViewMapping on { user.id, user.userId } equals { vMap.id, vMap.logicIdentifier } where (user.userName startWith 'abc') isNull groupby { orderProduct.productId, product.name } orderby user.userName asc , user.id desc vselect { user: { userName, passWord, phone }, vMap } page 1 size 1000; end; result = from user in entities::LCAPUser vselect { X }; } ` describe('Test Weak SQL...', () => { test.skip('Test SQL', async () => { const parser = new Parser(Grammar.fromCompiled(grammar)); parser.feed(testSQL); expect(parser.results.length).toBe(1); }); });