modules/rpsl/peering.y

/* [<][>]
[^][v][top][bottom][index][help] */

FUNCTIONS

This source file includes following functions.
  1. yyparse
  2. peeringerror

   1 %{
   2 /*
   3   filename: peering.y
   4 
   5   description:
   6     Defines the grammar for an RPSL peering attribute.  It was mostly
   7     stolen from the IRRToolSet, simplified by removing ability to parse
   8     things defined by a dictionary (we use XML for extensibility rather
   9     than a dictionary).
  10 
  11   notes:
  12     Defines tokens for the associated lexer, peering.l.
  13 */
  14 %}
  15 
  16 %union {
  17     char *sval;
  18 }
  19 
  20 %token OP_OR OP_AND 
  21 %token TKN_ASNO TKN_ASNAME
  22 %token TKN_IPV4 TKN_DNS TKN_RTRSNAME TKN_PRNGNAME
  23 %token KEYW_EXCEPT
  24 %token KEYW_AT
  25 %token <sval> TKN_DNS
  26 %type <sval> domain_name
  27 
  28 %{
  29 #include <stdio.h>
  30 #include <stdarg.h>
  31 #include <stdlib.h>
  32 
  33 int yyerror(const char *s);
  34 void syntax_error(char *fmt, ...);
  35 
  36 %}
  37 
  38 %%
     /* [<][>][^][v][top][bottom][index][help] */
  39 
  40 
  41 peering: as_expr opt_router_expr opt_router_expr_with_at
  42 | TKN_PRNGNAME
  43 ;
  44 
  45 as_expr: as_expr OP_OR as_expr_term
  46 | as_expr_term 
  47 ;
  48 
  49 as_expr_term: as_expr_term OP_AND as_expr_factor 
  50 | as_expr_term KEYW_EXCEPT as_expr_factor 
  51 | as_expr_factor
  52 ;
  53 
  54 as_expr_factor: '(' as_expr ')' 
  55 | as_expr_operand
  56 ;
  57 
  58 as_expr_operand: TKN_ASNO 
  59 | TKN_ASNAME 
  60 ;
  61 
  62 opt_router_expr:
  63 | router_expr
  64 ;
  65 
  66 opt_router_expr_with_at: 
  67 | KEYW_AT router_expr
  68 ;
  69 
  70 router_expr: router_expr OP_OR router_expr_term
  71 | router_expr_term
  72 ;
  73 
  74 router_expr_term: router_expr_term OP_AND router_expr_factor
  75 | router_expr_term KEYW_EXCEPT router_expr_factor
  76 | router_expr_factor
  77 ;
  78 
  79 router_expr_factor: '(' router_expr ')'
  80 | router_expr_operand
  81 ;
  82 
  83 router_expr_operand: TKN_IPV4
  84 | domain_name {
  85     if (strlen($1) > 255) {
  86         syntax_error("Domain name \"%s\" is longer than 255 characters", $1);
  87     }
  88 }
  89 | TKN_RTRSNAME
  90 ;
  91 
  92 domain_name: TKN_DNS
  93 | domain_name '.' TKN_DNS
  94 ;
  95 
  96 %%
  97 
  98 #undef peeringerror
  99 #undef yyerror
 100 
 101 int
 102 peeringerror (const char *s)
     /* [<][>][^][v][top][bottom][index][help] */
 103 {
 104     yyerror(s);
 105     return 0;
 106 }
 107 

/* [<][>][^][v][top][bottom][index][help] */