
Xc           @   s  d  Z  d d l j Z d d l m Z d d l m Z d5 d6 d7 f Z d
   Z	 d   Z
 d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d    Z d!   Z  d"   Z! d#   Z" d$   Z# d%   Z$ d&   Z% d'   Z& d(   Z' d)   Z( d*   Z) d+   Z* d,   Z+ d-   Z, d.   Z- d/   Z. d0   Z/ d1   Z0 d2   Z1 d3   Z2 e Z e j d4 e3  Z4 d S(8   s  
Grammer for file name convention rules, the conventions which
the file name conventions must follow.

The point of having a grammer is two-fold.  We make sure that
we are seeing (minimally) what we expect to see.  And because
we know the expectations we know where the user is allowed
to insert optional version numbers and/or parentheticals.

Parsing a name returns a list containing the following nodes:
string
user_str
hash
entity
date
year
last_4_digits
optional

An optional node contains a list holding the above nodes.


(deal with unspecified optional parenthesis and version numbers in
user file names)

Here is the informal BNF (the formal BNF is this file):
Note that in this informal BNF, the capitalized elements
are those that are implicit in the specification -- they
don't show up in the input rules that are parsed but they
are _added_ to the output.  The capitalized elements are
what can show up in the file system names even though
the elements do not appear in the naming convention rules.

The capitalized elements do not appear in the formal BNF;
the code implementing the respective grammer production
inserts them into the output.

name : bare_name IMPLICIT_SUFFIXES
     | suffixed_name IMPLICIT_PARENS
     | numbered_bullet " " bare_name IMPLICIT_SUFFIXES
     | numbered_bullet " " suffixed_name IMPLICIT_PARENS

IMPLICIT_SUFFIXES : IMPLICIT_VERSION IMPLICIT_PARENS

IMPLICIT_VERSION : "[ v<#>]"

IMPLICIT_PARENS : IMPLICIT_PAREN
                | IMPLICIT_PAREN IMPLICIT_PARENS

IMPLICIT_PAREN : "[" paren_str "]"

bare_name : string
          | user_value
          | bare_name " - " bare_name
          | bare_name " " user_value
          | bare_name " " string

suffixed_name : bare_name opt_user_value_suffix

opt_user_value_suffix : opt_user_values IMPLICIT_VERSION
                      | opt_user_values version_suffix
                      | version_suffix

opt_user_values : "[ - " user_value "]"
                | "[ " string " " user_value "]"
                | "[ - " user_value "]" opt_user_values

version_suffix : " v<#>"
               | " v<#>" paren_str_suffix
               | paren_str_suffix

paren_str_suffix : paren_strs
                 | paren_strs opt_paren_strs
                 | opt_paren_strs

paren_strs : paren_str
           | paren_str paren_strs

opt_paren_strs : "[ "paren_str "]"
               | "[ "paren_str "]" opt_paren_strs

paren_str : " (" paren_str_chars ")"

paren_str_chars : paren_str_char
                | paren_str_char paren_str_chars

paren_str_char : word_char
               | " "

numbered_bullet : "<#>."

user_value : "<#>"
           | "<entity>"
           | "<date>"
           | "<year>"
           | "<last 4 digits>"
           | "<" user_string ">"
           | user_value " " prefaced_user_value

prefaced_user_value : WORD " " user_value

user_string : lower_letter
            | number
            | "("
            | ")"
            | " "

string : word
       | word " " string

word : word_char
     | word_char word_chars

word_char : letter_or_number
          | ","
          | " "
          | "#"
          | "."

letter_or_number : upper_letter
                 | lower_letter
                 | number

upper_letter : A-Z

lower_letter : a-z

number : 0-9
iNi   (   t   tokens(   t
   exceptionst   leftt   WORDt   DASHt   SPACEc         C   s   |  d d S(   Ni    i   (    (   t	   parsenode(    (    s   ./src/enforcer/rules_yacc.pyt   pval   s    c         C   s   |  d |  d <d S(   s,   name : bare_name
            | suffixed_namei   i    N(    (   t   syms(    (    s   ./src/enforcer/rules_yacc.pyt   p_name_simple   s    c         C   s>   |  d d d |  d d d |  d f g |  d |  d <d S(   sX   name : numbered_bullet SPACE bare_name
            | numbered_bullet SPACE suffixed_namei   i    t   stringi   i   N(    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_name_complex   s    c         C   s   |  d |  d <d S(   s   bare_name : stringi   i    N(    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_bare_name_simple_string   s    c         C   s   |  d |  d <d S(   s   bare_name : user_valuei   i    N(    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_bare_name_simple_user_value   s    c         C   s+   |  d d |  d f g |  d |  d <d S(   s$   bare_name : bare_name DASH bare_namei   R
   i   i   i    N(    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_bare_name_complex_string   s    c         C   s1   d t  |  d  |  d f g |  d |  d <d S(   s#   bare_name : string SPACE user_valueR
   i   i   i   i    N(   R   (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_bare_name_string_user_value   s    c         C   s+   |  d d |  d f g |  d |  d <d S(   s&   bare_name : bare_name SPACE user_valuei   R
   i   i   i    N(    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_bare_name_space_user_value   s    c         C   s+   |  d d |  d f g |  d |  d <d S(   s"   bare_name : bare_name SPACE stringi   R
   i   i   i    N(    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_bare_name_space_string   s    c         C   s   |  d |  d |  d <d S(   s/   suffixed_name : bare_name opt_user_value_suffixi   i   i    N(    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_suffixed_name   s    c         C   s   |  d |  d <d S(   sU   opt_user_value_suffix : opt_user_values
                             | version_suffixi   i    N(    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_opt_user_value_suffix_simple   s    c         C   s   |  d |  d |  d <d S(   s6   opt_user_value_suffix : opt_user_values version_suffixi   i   i    N(    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_opt_user_value_suffix_complex   s    c         C   s,   d d |  d f g |  d f g |  d <d S(   s.   opt_user_value : LBRACE DASH user_value RBRACEt   optionalR
   i   i   i    N(    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_opt_user_value   s    c         C   sB   d d |  d t  |  d  |  d f g |  d f g |  d <d S(	   s<   opt_user_value : LBRACE SPACE string SPACE user_value RBRACER   R
   i   i   i   i   i    N(   R   (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_opt_user_value_complex   s    c         C   s   |  d |  d <d S(   s    opt_user_values : opt_user_valuei   i    N(    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_opt_user_values_term   s    c         C   s   |  d |  d |  d <d S(   s0   opt_user_values : opt_user_values opt_user_valuei   i   i    N(    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_opt_user_values_complex   s    c         C   s   |  d |  d <d S(   s   version_suffix : version_hashi   i    N(    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_version_suffix_simple   s    c         C   s   |  d |  d |  d <d S(   s.   version_suffix : version_hash paren_str_suffixi   i   i    N(    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_version_suffix_complex   s    c         C   s   |  d |  d <d S(   s!   version_suffix : paren_str_suffixi   i    N(    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_version_suffix_paren  s    c         C   s   d d g |  d <d S(   s   version_hash : VERSIONR
   s    vt   hashi    N(   s   strings    v(   s   hash(    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_version_hash  s    c         C   s   |  d |  d <d S(   s   paren_str_suffix : paren_strsi   i    N(    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_paren_str_suffix_simple  s    c         C   s   |  d |  d |  d <d S(   s,   paren_str_suffix : paren_strs opt_paren_strsi   i   i    N(    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_paren_str_suffix_complex  s    c         C   s   |  d |  d <d S(   s!   paren_str_suffix : opt_paren_strsi   i    N(    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_paren_str_suffix_opt  s    c         C   s   |  d |  d <d S(   s   paren_strs : paren_stri   i    N(    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_paren_strs_term  s    c         C   s/   d t  |  d  t  |  d  f g |  d <d S(   s!   paren_strs : paren_str paren_strsR
   i   i   i    N(   R   (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_paren_strs_terms  s    c         C   s   |  d |  d <d S(   s   opt_paren_strs : opt_paren_stri   i    N(    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_opt_paren_strs_term$  s    c         C   s   |  d |  d |  d <d S(   s-   opt_paren_strs : opt_paren_str opt_paren_strsi   i   i    N(    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_opt_paren_strs_terms)  s    c         C   s   d |  d f g |  d <d S(   s'   opt_paren_str : LBRACE paren_str RBRACER   i   i    N(    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_opt_paren_str.  s    c         C   s   d |  d f g |  d <d S(   s   paren_str : PAREN_STRR
   i   i    N(    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_paren_str3  s    c         C   s   |  d |  d <d S(   s   user_value : hash
                  | entity
                  | date
                  | year
                  | last_4_digits
                  | user_stri   i    N(    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_user_value8  s    c         C   s+   |  d d |  d f g |  d |  d <d S(   s1   user_value : user_value SPACE prefaced_user_valuei   R
   i   i   i    N(    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_user_value_complexB  s    c         C   s+   d |  d |  d f g |  d |  d <d S(   s+   prefaced_user_value : WORD SPACE user_valueR
   i   i   i   i    N(    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_prefaced_user_valueG  s    c         C   s   d d |  d f g |  d <d S(   s   numbered_bullet : HASH PERIODR   R
   i   i    N(   s   hash(    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_numbered_bulletL  s    c         C   s   d g |  d <d S(   s   hash : HASHR   i    N(   s   hash(    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_hashQ  s    c         C   s   d g |  d <d S(   s   entity : ENTITYt   entityi    N(   R-   (    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_entityV  s    c         C   s   d g |  d <d S(   s   date : DATEt   datei    N(   R/   (    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_date[  s    c         C   s   d g |  d <d S(   s   year : YEARt   yeari    N(   R1   (    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_year`  s    c         C   s   d g |  d <d S(   s   last_4_digits : LAST_4_DIGITSt   last_4_digitsi    N(   R3   (    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_last_4_digitse  s    c         C   s"   d |  d d d !f g |  d <d S(   s   user_str : USER_STRt   user_stri   ii    N(    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt
   p_user_strj  s    c         C   s   d |  d f g |  d <d S(   s   string : WORDR
   i   i    N(    (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_string_wordo  s    c         C   s1   d t  |  d  |  d |  d f g |  d <d S(   s   string : string SPACE WORDR
   i   i   i   i    N(   R   (   R   (    (    s   ./src/enforcer/rules_yacc.pyt   p_string_wordst  s    c         C   s@   |  r0 |  j  } t j | j | j |  j   n  t j    d  S(   N(   t   lexert   ext	   YaccErrort   lexpost   lexdatat   valuet   YaccEOFError(   t   tokR9   (    (    s   ./src/enforcer/rules_yacc.pyt   p_errory  s    	!t   write_tables(   s   leftR   (   s   leftR   (   s   leftR   (5   t   __doc__t   ply.yacct   yacct	   rules_lexR    t    R   R:   t
   precedenceR   R	   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R    R!   R"   R#   R$   R%   R&   R'   R(   R)   R*   R+   R,   R.   R0   R2   R4   R6   R7   R8   RA   t   Falset   parser(    (    (    s   ./src/enforcer/rules_yacc.pyt   <module>   sd   																															
												