UNPKG

@lcap/nasl-parser

Version:

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

55 lines (45 loc) 1.08 kB
import { Parser, Grammar } from "nearley"; import grammar from "../../ts/nasl"; const testEntity = ` @( source = "defaultDS", name = "person", table = "sql_School", description = "学校", origin = "ide" ) @createdBy @createdTime @updatedTime @id entity Person { @required @( columnType = @varchar(64), name = "ppperson", label = "人的名字", description = "姓+名", display = [ table -> false, filter -> true, form -> true, detail -> true ], rules1 = ["max(64)", "min(3)"] ) let personName : String; @( description="性别" ) let sex : String; @Column( description="next person" ) let nextPerson : Person; } ` describe('Entity and Annotation Syntax...', () => { test.skip('Entity and Annotation Syntax', async () => { const parser = new Parser(Grammar.fromCompiled(grammar)); parser.feed(testEntity); expect(parser.results.length).toBe(1); }); });