UNPKG

@lcap/nasl-parser

Version:

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

22 lines (16 loc) 516 B
import { Parser, Grammar } from "nearley"; import grammar from "../../ts/nasl"; import { toNaslAST } from "../../ts/toAST/to-nasl-ast"; const structStr = ` struct A() { let x : Person = 100; let name : String; let age : Integer; } ` describe('Test Struct definition', () => { test('Anti-examples', async () => { const parser = new Parser(Grammar.fromCompiled(grammar)); expect(() => toNaslAST(parser.feed(structStr).results[0])).toThrow('Unresolved type reference'); }); });