@lcap/nasl-parser
Version:
Take Nasl text to Nasl AST with the help of generalized parsing.
55 lines (45 loc) • 1.08 kB
text/typescript
import { Parser, Grammar } from "nearley";
import grammar from "../../ts/nasl";
const testEntity = `
@(
source = "defaultDS",
name = "person",
table = "sql_School",
description = "学校",
origin = "ide"
)
entity Person {
@(
columnType = ,
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;
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);
});
});