added more VCD grammar rules
This commit is contained in:
parent
13b129ad10
commit
76d7c2bc62
58
bin/build.js
58
bin/build.js
@ -9,20 +9,58 @@ const prj = 'vcd_parser';
|
||||
|
||||
const p = new llparse.LLParse(prj);
|
||||
|
||||
const start = p.node('start');
|
||||
const stop = p.node('stop');
|
||||
const declaration = p.node('declaration');
|
||||
const inDeclaration = p.node('inDeclaration');
|
||||
const enddefinitions = p.node('inDeclarationEnd');
|
||||
const simulation = p.node('simulation');
|
||||
const inSimulation = p.node('inSimulation');
|
||||
|
||||
start
|
||||
.match('stop', stop)
|
||||
.otherwise(p.error(1, 'Expected start'));
|
||||
// Add custom uint8_t property to the state
|
||||
p.property('i8', 'declaration');
|
||||
p.property('i8', 'simulation');
|
||||
|
||||
stop
|
||||
.match('start', start)
|
||||
.otherwise(p.error(2, 'Expected start'));
|
||||
// Store method inside a custom property
|
||||
const onDeclaration = p.invoke(p.code.store('declaration'), inDeclaration);
|
||||
const onSimulation = p.invoke(p.code.store('simulation'), inSimulation);
|
||||
|
||||
declaration
|
||||
.select({
|
||||
'$comment': 0,
|
||||
'$date': 1,
|
||||
'$scope': 2,
|
||||
'$timescale': 3,
|
||||
'$upscope': 4,
|
||||
'$var': 5,
|
||||
'$version': 6
|
||||
}, onDeclaration)
|
||||
.match('$enddefinitions', enddefinitions)
|
||||
.otherwise(p.error(1, 'Expected declaration'));
|
||||
|
||||
inDeclaration
|
||||
.match('$end', declaration)
|
||||
.otherwise(p.error(2, 'Expected end of declaration'));
|
||||
|
||||
enddefinitions
|
||||
.match('$end', simulation)
|
||||
.otherwise(p.error(3, 'Expected end of all declaration'));
|
||||
|
||||
simulation
|
||||
.select({
|
||||
'$dumpall': 0,
|
||||
'$dumpoff': 1,
|
||||
'$dumpon': 2,
|
||||
'$dumpvars': 3,
|
||||
'$comment': 4
|
||||
}, onSimulation)
|
||||
.otherwise(p.error(4, 'Expected simulation command'));
|
||||
|
||||
inSimulation
|
||||
.match('$end', simulation)
|
||||
.otherwise(p.error(5, 'Expected end simulation command'));
|
||||
|
||||
// Build
|
||||
|
||||
const artifacts = p.build(start);
|
||||
const artifacts = p.build(declaration);
|
||||
|
||||
fs.writeFileSync(prj + '.h', artifacts.header);
|
||||
// fs.writeFileSync('verilog_preprocessor.bc', artifacts.bitcode);
|
||||
@ -30,6 +68,6 @@ fs.writeFileSync(prj + '.c', artifacts.c);
|
||||
|
||||
const dot = new llparseDot.Dot();
|
||||
|
||||
fs.writeFileSync(prj + '.dot', dot.build(start));
|
||||
fs.writeFileSync(prj + '.dot', dot.build(declaration));
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user