For example you would define a table object:
In this example tablestartfunc() would be called at the start of a table definition, tablefunc() after the whole table was parsed, recordcolumn() would be called with the number of columns as parameter.tableobject : tablestart tabledef(s) tableend { tablefunc($item[1]) } tablestart : 'OBJECT' '=' 'TABLE' "\n" { tablestartfunc() } tabledef : columnnumber | name | bytes | startbyte | columnobject { columnstartfunc() } | rows columnnumber : 'COLUMN_NUMBER' '=' number /\n/ { $return= recordcolumn($item{number}); } number : /\d+/
UPDATE:
Whether you record the table information with the callbacks or by using the $return mechanism of Parse::RecDescent is your decision. In the former case tablefunc doesn't need the $item[1] parameter and columnnumber() doesn't need to set $return. In the latter case columnnumber would need a more elaborate return value, for example $return= ['columnnumber',$item{number}];
In reply to Re: Writing an ODL parser?
by jethro
in thread Writing an ODL parser?
by dHarry
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |