Интегрированные сети ISDN

         

B Грамматические правила


B. Грамматические правила



Ниже рассмотрены формальные грамматические правила RPSL. Основные типы данных определены в разделе 2. Правила записаны с использованием входного языка грамматического разбора GNU Bison.

//**** базовые атрибуты *********************************************

changed_attribute: ATTR_CHANGED TKN_EMAIL TKN_INT

//**** класс aut-num *************************************************

//// as_expression /////////////////////////////////////////////////////

opt_as_expression: | as_expression

as_expression: as_expression OP_OR as_expression_term | as_expression_term

as_expression_term: as_expression_term OP_AND as_expression_factor

| as_expression_term KEYW_EXCEPT as_expression_factor | as_expression_factor

as_expression_factor: '(' as_expression ')' | as_expression_operand

as_expression_operand: TKN_ASNO | TKN_ASNAME

//// router_expression /////////////////////////////////////////////////

opt_router_expression: | router_expression

opt_router_expression_with_at: | KEYW_AT router_expression

router_expression: router_expression OP_OR router_expression_term | router_expression_term

router_expression_term: router_expression_term OP_AND router_expression_factor



| router_expression_term KEYW_EXCEPT router_expression_factor | router_expression_factor

router_expression_factor: '(' router_expression ')' | router_expression_operand

router_expression_operand: TKN_IPV4 | TKN_DNS | TKN_RTRSNAME

//// пиринг ///////////////////////////////////////////////////////////

peering: as_expression opt_router_expression opt_router_expression_with_at

| TKN_PRNGNAME

//// действие ////////////////////////////////////////////////////////////

opt_action: | KEYW_ACTION action

action: single_action | action single_action

single_action: TKN_RP_ATTR '.' TKN_WORD '(' generic_list ')' ';'

| TKN_RP_ATTR TKN_OPERATOR list_item ';' | TKN_RP_ATTR '(' generic_list ')' ';'

| TKN_RP_ATTR '[' generic_list ']' ';' | ';'

//// фильтр ////////////////////////////////////////////////////////////

filter: filter OP_OR filter_term | filter filter_term %prec OP_OR | filter_term

filter_term : filter_term OP_AND filter_factor | filter_factor

filter_factor : OP_NOT filter_factor | '(' filter ')' | filter_operand

filter_operand: KEYW_ANY | '' | filter_rp_attribute | TKN_FLTRNAME

| filter_prefix

filter_prefix: filter_prefix_operand OP_MS | filter_prefix_operand

filter_prefix_operand: TKN_ASNO | KEYW_PEERAS | TKN_ASNAME | TKN_RSNAME

| '{' opt_filter_prefix_list '}'

opt_filter_prefix_list: | filter_prefix_list

filter_prefix_list: filter_prefix_list_prefix | filter_prefix_list ',' filter_prefix_list_prefix

filter_prefix_list_prefix: TKN_PRFXV4 | TKN_PRFXV4RNG

filter_aspath: filter_aspath '|' filter_aspath_term | filter_aspath_term

filter_aspath_term: filter_aspath_term filter_aspath_closure | filter_aspath_closure

filter_aspath_closure: filter_aspath_closure '*' | filter_aspath_closure '?' | filter_aspath_closure '+'

| filter_aspath_factor

filter_aspath_factor: '^' | '$' | '(' filter_aspath ')' | filter_aspath_no

filter_aspath_no: TKN_ASNO | KEYW_PEERAS | TKN_ASNAME | '.' | '[' filter_aspath_range ']'

| '[' '^' filter_aspath_range ']'

filter_aspath_range: | filter_aspath_range TKN_ASNO | filter_aspath_range KEYW_PEERAS

| filter_aspath_range '.' | filter_aspath_range TKN_ASNO '-' TKN_ASNO

| filter_aspath_range TKN_ASNAME

filter_rp_attribute: TKN_RP_ATTR '.' TKN_WORD '(' generic_list ')'

| TKN_RP_ATTR TKN_OPERATOR list_item | TKN_RP_ATTR '(' generic_list ')'

| TKN_RP_ATTR '[' generic_list ']'

//// пара пиринг-действий ///////////////////////////////////////////////

import_peering_action_list: KEYW_FROM peering opt_action

| import_peering_action_list KEYW_FROM peering opt_action

export_peering_action_list: KEYW_TO peering opt_action

| export_peering_action_list KEYW_TO peering opt_action

//// фактор import/export //////////////////////////////////////////////

import_factor: import_peering_action_list KEYW_ACCEPT filter

import_factor_list: import_factor ';' | import_factor_list import_factor ';'

export_factor: export_peering_action_list KEYW_ANNOUNCE filter

export_factor_list: export_factor ';' | export_factor_list export_factor ';'

//// термин import/export ////////////////////////////////////////////////

import_term: import_factor ';' | '{' import_factor_list '}'

export_term: export_factor ';' | '{' export_factor_list '}'

//// выражение import/export //////////////////////////////////////////

import_expression: import_term | import_term KEYW_REFINE import_expression

| import_term KEYW_EXCEPT import_expression

export_expression: export_term | export_term KEYW_REFINE export_expression

| export_term KEYW_EXCEPT export_expression

//// протокол ///////////////////////////////////////////////////////////

opt_protocol_from: | KEYW_PROTOCOL tkn_word

opt_protocol_into: | KEYW_INTO tkn_word

//**** атрибуты import/export ****************************************

import_attribute: ATTR_IMPORT

| ATTR_IMPORT opt_protocol_from opt_protocol_into import_factor

export_attribute: ATTR_EXPORT

| ATTR_EXPORT opt_protocol_from opt_protocol_into export_factor

opt_default_filter: | KEYW_NETWORKS filter

default_attribute: ATTR_DEFAULT KEYW_TO peering

filter_attribute: ATTR_FILTER filter

peering_attribute: ATTR_PEERING peering

//**** класс inet-rtr **************************************************

ifaddr_attribute: ATTR_IFADDR TKN_IPV4 KEYW_MASKLEN TKN_INT opt_action

//// атрибут peer ////////////////////////////////////////////////////

opt_peer_options: | peer_options

peer_options: peer_option | peer_options ',' peer_option

peer_option: tkn_word '(' generic_list ')'

peer_id: TKN_IPV4 | TKN_DNS | TKN_RTRSNAME | TKN_PRNGNAME

peer_attribute: ATTR_PEER tkn_word peer_id opt_peer_options

//**** класс route *****************************************************

aggr_bndry_attribute: ATTR_AGGR_BNDRY as_expression

aggr_mtd_attribute: ATTR_AGGR_MTD KEYW_INBOUND

| ATTR_AGGR_MTD KEYW_OUTBOUND opt_as_expression

//// атрибут inject //////////////////////////////////////////////////

opt_inject_expression: | KEYW_UPON inject_expression

inject_expression: inject_expression OP_OR inject_expression_term | inject_expression_term

inject_expression_term: inject_expression_term OP_AND inject_expression_factor

| inject_expression_factor

inject_expression_factor: '(' inject_expression ')' | inject_expression_operand

inject_expression_operand: KEYW_STATIC

| KEYW_HAVE_COMPONENTS '{' opt_filter_prefix_list '}'

| KEYW_EXCLUDE '{' opt_filter_prefix_list '}'

inject_attribute: ATTR_INJECT opt_router_expression_with_at opt_action opt_inject_expression

//// атрибут components //////////////////////////////////////////////

opt_atomic: | KEYW_ATOMIC

components_list: | filter | components_list KEYW_PROTOCOL tkn_word filter

components_attribute: ATTR_COMPONENTS opt_atomic components_list

//**** набор маршрутов *****************************************************

opt_rs_members_list: /* пустой список */

| rs_members_list

rs_members_list: rs_member | rs_members_list ',' rs_member

rs_member: TKN_ASNO | TKN_ASNO OP_MS | TKN_ASNAME | TKN_ASNAME OP_MS

| TKN_RSNAME | TKN_RSNAME OP_MS | TKN_PRFXV4 | TKN_PRFXV4RNG

rs_members_attribute: ATTR_RS_MEMBERS opt_rs_members_list

//**** словарь ******************************************************

rpattr_attribute: ATTR_RP_ATTR TKN_WORD methods

| ATTR_RP_ATTR TKN_RP_ATTR methods

methods: method | methods method

method: TKN_WORD '(' ')' | TKN_WORD '(' typedef_type_list ')'

| TKN_WORD '(' typedef_type_list ',' TKN_3DOTS ')'

| KEYW_OPERATOR TKN_OPERATOR '(' typedef_type_list ')'

| KEYW_OPERATOR TKN_OPERATOR '(' typedef_type_list ',' TKN_3DOTS ')'

//// атрибут typedef ////////////////////////////////////////////////

typedef_attribute: ATTR_TYPEDEF TKN_WORD typedef_type

typedef_type_list: typedef_type | typedef_type_list ',' typedef_type

typedef_type: KEYW_UNION typedef_type_list | KEYW_RANGE KEYW_OF typedef_type

| TKN_WORD | TKN_WORD '[' TKN_INT ',' TKN_INT ']'

| TKN_WORD '[' TKN_REAL ',' TKN_REAL ']' | TKN_WORD '[' enum_list ']'

| KEYW_LIST '[' TKN_INT ':' TKN_INT ']' KEYW_OF typedef_type

| KEYW_LIST KEYW_OF typedef_type

enum_list: tkn_word | enum_list ',' tkn_word

//// атрибут protocol ////////////////////////////////////////////////

protocol_attribute: ATTR_PROTOCOL tkn_word protocol_options

protocol_options: | protocol_options protocol_option

protocol_option: KEYW_MANDATORY method | KEYW_OPTIONAL method

//**** Описания лексем *********************************************

//// макросы flex, используемые при определении лексем /////////////////////////////

INT [[:digit:]]+

SINT [+-]?{INT}

REAL [+-]?{INT}?\.{INT}({WS}*E{WS}*[+-]?{INT})?

NAME [[:alpha:]]([[:alnum:]_-]*[[:alnum:]])?

ASNO AS{INT}

ASNAME AS-[[:alnum:]_-]*[[:alnum:]]

RSNAME RS-[[:alnum:]_-]*[[:alnum:]]

RTRSNAME RTRS-[[:alnum:]_-]*[[:alnum:]]

PRNGNAME PRNG-[[:alnum:]_-]*[[:alnum:]]

FLTRNAME FLTR-[[:alnum:]_-]*[[:alnum:]]

IPV4 [0-9]+(\.[0-9]+){3,3}

PRFXV4 {IPV4}\/[0-9]+

PRFXV4RNG {PRFXV4}("^+"|"^-"|"^"{INT}|"^"{INT}-{INT})

ENAMECHAR [^()<>,;:\\\"\.[\] \t\r]

ENAME ({ENAMECHAR}+(\.{ENAMECHAR}+)*\.?)|(\"[^\"@\\\r\n]+\")

DNAME [[:alnum:]_-]+

//// Определения лексем >////////////////////////////////////////////////

TKN_INT {SINT}

TKN_INT {INT}:{INT} if each {INT} is two octets

TKN_INT {INT}.{INT}.{INT}.{INT} if each {INT} is one octet

TKN_REAL {REAL}

TKN_STRING То же самое что и в языке СИ

TKN_IPV4 {IPV4}

TKN_PRFXV4 {PRFXV4}

TKN_PRFXV4RNG {PRFXV4RNG}

TKN_ASNO {ASNO}

TKN_ASNAME (({ASNO}|peeras|{ASNAME}):)*{ASNAME}\

(:({ASNO}|peeras|{ASNAME}))*

TKN_RSNAME (({ASNO}|peeras|{RSNAME}):)*{RSNAME}\

(:({ASNO}|peeras|{RSNAME}))*

TKN_RTRSNAME (({ASNO}|peeras|{RTRSNAME}):)*{RTRSNAME}\

(:({ASNO}|peeras|{RTRSNAME}))*

TKN_PRNGNAME (({ASNO}|peeras|{PRNGNAME}):)*{PRNGNAME}\

(:({ASNO}|peeras|{PRNGNAME}))*

TKN_FLTRNAME (({ASNO}|peeras|{FLTRNAME}):)*{FLTRNAME}\

(:({ASNO}|peeras|{FLTRNAME}))*

TKN_BOOLEAN true|false

TKN_RP_ATTR {NAME} if defined in dictionary

TKN_WORD {NAME}

TKN_DNS {DNAME}("."{DNAME})+

TKN_EMAIL {ENAME}@({DNAME}("."{DNAME})+|{IPV4})

Документ RFC-2280 [3] содержит раннюю версию языка RPSL.



Содержание раздела