in reply to Writing an ODL parser?
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}];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Writing an ODL parser?
by dHarry (Abbot) on Jul 30, 2008 at 14:04 UTC | |
by jethro (Monsignor) on Jul 30, 2008 at 18:56 UTC |