problems with complex import/export attributes
Hi, Yes, I know this is not a RPSL forum, but i think someone of you could help me ;-) I found a problem for RPSL parsers conform with RFC2622. In the RFC2622 (section 6.6) is an example of an import attribute:
import: from AS1 action pref = 1; accept as-foo; except { from AS2 action pref = 2; accept AS226; except { from AS3 action pref = 3; accept {128.9.0.0/16}; } }
Appendix B "Grammar Rules" describes the syntax like below:
... import_attribute: ATTR_IMPORT | ATTR_IMPORT opt_protocol_from opt_protocol_into import_factor
import_expression: import_term | import_term KEYW_REFINE import_expression | import_term KEYW_EXCEPT import_expression
import_term: import_factor ';' | '{' import_factor_list '}'
import_factor_list: import_factor ';' | import_factor_list import_factor ';'
import_factor: import_peering_action_list KEYW_ACCEPT filter
import_peering_action_list: KEYW_FROM peering opt_action | import_peering_action_list KEYW_FROM peering opt_action
...
I feel in import_attribute lakes a line like: | ATTR_IMPORT opt_protocol_from opt_protocol_into import_expression and a look into ftp://ftp.isi.edu/ra/RAToolSet/RAToolSet-4.6.3.tar.gz file src/rpsl/rpsl/rpsl.y agree with me:
... import_attribute: ATTR_IMPORT opt_protocol_from opt_protocol_into import_expr TKN_EOA { $$ = changeCurrentAttr(new AttrImport($2, $3, $4)); } | ATTR_IMPORT opt_protocol_from opt_protocol_into import_factor TKN_EOA { PolicyTerm *term = new PolicyTerm; term->append($4);
$$ = changeCurrentAttr(new AttrImport($2, $3, term)); } | ATTR_IMPORT error TKN_EOA { $$ = $1; handle_error("Error: from <peering> expected.\n"); yyerrok; } ; ..
OK as so far, but rpslcheck as well as my perl parser module breaks while parsing the example above ;-(
fb@sun5 1315> rpslcheck < example ... import: from AS1 action pref = 1; accept as-foo; except { from AS2 action pref = 2; accept AS226; except { ^^^^^^ ***Error: from <peering> expected. from AS3 action pref = 3; accept {128.9.0.0/16}; } } ...
For me looks the grammar correct, but my knowledge about automata theory, languages and computation is worser than my english ;-) Has anybody a solution for this problem ? cheers frank
Frank Bohnsack (Frank.Bohnsack@de.uu.net) on February 1:
Hi,
Yes, I know this is not a RPSL forum, but i think someone of you could help me ;-)
I found a problem for RPSL parsers conform with RFC2622. In the RFC2622 (section 6.6) is an example of an import attribute:
import: from AS1 action pref = 1; accept as-foo; except { from AS2 action pref = 2; accept AS226; except { from AS3 action pref = 3; accept {128.9.0.0/16}; } }
Appendix B "Grammar Rules" describes the syntax like below:
... import_attribute: ATTR_IMPORT | ATTR_IMPORT opt_protocol_from opt_protocol_into import_factor
This is actually my carelessness. The first rule is cut short by a script I wrote that generated the appendix from the lex rules in rpsl.y. The long line that is cut is: import_attribute: ATTR_IMPORT opt_protocol_from opt_protocol_into import_expression | ATTR_IMPORT opt_protocol_from opt_protocol_into import_factor We need both lines. Because the first line always requires a ; at the end.
import_expression: import_term | import_term KEYW_REFINE import_expression | import_term KEYW_EXCEPT import_expression
import_term: import_factor ';' | '{' import_factor_list '}'
import_factor_list: import_factor ';' | import_factor_list import_factor ';'
import_factor: import_peering_action_list KEYW_ACCEPT filter
import_peering_action_list: KEYW_FROM peering opt_action | import_peering_action_list KEYW_FROM peering opt_action
...
I feel in import_attribute lakes a line like:
| ATTR_IMPORT opt_protocol_from opt_protocol_into import_expression
and a look into ftp://ftp.isi.edu/ra/RAToolSet/RAToolSet-4.6.3.tar.gz file src/rpsl/rpsl/rpsl.y agree with me:
... import_attribute: ATTR_IMPORT opt_protocol_from opt_protocol_into import_expr TKN_EOA { $$ = changeCurrentAttr(new AttrImport($2, $3, $4)); } | ATTR_IMPORT opt_protocol_from opt_protocol_into import_factor TKN_EOA { PolicyTerm *term = new PolicyTerm; term->append($4);
$$ = changeCurrentAttr(new AttrImport($2, $3, term)); } | ATTR_IMPORT error TKN_EOA { $$ = $1; handle_error("Error: from <peering> expected.\n"); yyerrok; } ; ..
OK as so far, but rpslcheck as well as my perl parser module breaks while parsing the example above ;-(
fb@sun5 1315> rpslcheck < example ... import: from AS1 action pref = 1; accept as-foo; except { from AS2 action pref = 2; accept AS226; except { ^^^^^^ ***Error: from <peering> expected. from AS3 action pref = 3; accept {128.9.0.0/16}; } } ...
The example is also wrong. If careful examination of the grammar suggests that one can only sequence the excepts, but not nest them inside {}'s. The example should have been: import: from AS1 action pref = 1; accept as-foo; except { from AS2 action pref = 2; accept AS226; } except { from AS3 action pref = 3; accept {128.9.0.0/16}; } This is because the moment you use {, you can only have an import-term in it, which can not have an except, because that is a feature of an import-expression. They are evaluated right to left, which is similar to nesting.
For me looks the grammar correct, but my knowledge about automata theory, languages and computation is worser than my english ;-)
Has anybody a solution for this problem ?
cheers frank
Thanks for noticing. I will fix these when we get a permission to correct this kind of mistakes. Cengiz -- Cengiz Alaettinoglu Packet Design Inc.
participants (2)
-
Cengiz Alaettinoglu
-
Frank Bohnsack