
    4Ysh                     ^    d dl mZ d dlmZ ddlmZmZ d Z G d de      Z G d d	e      Z	y
)    )ConjunctiveGraph)Parser   )
SinkParserRDFSinkc                       y N )argskwargss     {/var/www/sten-cake5-migrate2.hellocrow.space/lexinfo-master/env/lib/python3.12/site-packages/rdflib/plugins/parsers/trig.pybecauseSubGraphr      s        c                       e Zd Zd Zd Zd Zy)TrigSinkParserc                 @   | j                  ||      }|dk  r|S | j                  ||      }|dk\  r|S | j                  ||      }|dk\  r|S | j                  ||      }|dk\  r| j	                  ||      S | j                  ||      }|dk\  r| j	                  ||      S |S )Nr   )	skipSpacegraphsparqlDirective	directivecheckDot	statement)selfargstrhijs        r   directiveOrStatementz#TrigSinkParser.directiveOrStatement   s     NN61%q5HJJvq!6H  +6HNN61%6==++NN61%6==++r   c                 0   | j                  ||      }|dk  r|S |}| j                  |||      }|dk\  r|S ||   dk(  rY| j                  ||dz         }|dk  r| j                  ||d       ||   dk(  r$|j                  | j	                                |dz   S y)Nr   [r   zExpected ] got EOF])r   uri_ref2	BadSyntaxappend	blankNode)r   r   r   resr   s        r   labelOrSubjectzTrigSinkParser.labelOrSubject%   s    NN61%q5HMM&!S)6H!9vq1u-A1uvq*>?ayC

4>>+,1ur   c                 ^   | j                  d||      }|dk\  r|}g }| j                  |||      }|dk\  r|d   }|}n | j                  j                  j                  }| j                  ||      }|dk  r| j                  ||d       |||dz    dk(  r.| j                  ||dz         }|dk  r| j                  ||d       n|}|||dz    dk7  ry|dz   }| j                  }| j                  | _        | j                  }t        | _	        | j                  j                  |      | _        	 | j                  ||      }|dk  r| j                  ||d	       |||dz    d
k(  r|dz   }n+| j                  ||      }|dk  r| j                  ||d       f| j                  | _        || _	        || _        |S )z
        Parse trig graph, i.e.

           <urn:graphname> = { .. triples .. }

        return -1 if it doesn't look like a graph-decl
        raise Exception if it looks like a graph, but isn't.
        GRAPHr   zEOF found when expected graphr   =zEOF found when expecting '{'{r"   zneeded '}', found end.}zexpected statement or '}')	sparqlTokr(   _storer   
identifierr   r$   _parentContext_context_reason2r   newGraphr   )r   r   r   r   rr   oldParentContextreason2s           r   r   zTrigSinkParser.graph8   s    NN7FA.6A1-6aDEAKK%%00ENN61%q5NN61&EF!a!e#vq1u-A1uvq*HIA!a!e#E.."mm--',,U3vq)A1uvq*BCa!a% C'E))&!4A1uvq*EF  ++.r   N)__name__
__module____qualname__r   r(   r   r
   r   r   r   r   
   s    4&?r   r   c                       e Zd ZdZd ZddZy)
TrigParserz$
    An RDFLib parser for TriG

    c                      y r	   r
   )r   s    r   __init__zTrigParser.__init__   s    r   c                 >   |dvrt        d|z        |j                  j                  sJ d       t        |j                  |j                        }||_        |j                  |_        t        |      }|j                  |j                         xs |j                         xs d      }t        ||d      }|j                         }|s|j                         }|j                  |       |j                  j!                         D ]  \  }	}
|j#                  |	|
        y )N)Nutf-8)z%TriG files are always utf-8 encoded, zI was passed: %sz(TriG Parser needs a context-aware store!)storer0    T)baseURIturtle)	ExceptionrA   context_awarer   r0   default_contextnamespace_managerr   
absolutizegetPublicIdgetSystemIdr   getCharacterStreamgetByteStream
loadStream	_bindingsitemsbind)r   sourcer   encoding
conj_graphsinkrC   pstreamprefix	namespaces              r   parsezTrigParser.parse   s   ?*MPXX 
 {{((T*TT(%EKKEDTDTU
%*
" (-'>'>
$z"'' >F$6$6$8>B
 4>**,))+F	V!"!2!2!4 	/FIOOFI.	/r   N)r@   )r8   r9   r:   __doc__r>   rZ   r
   r   r   r<   r<   z   s    
/r   r<   N)
rdflibr   rdflib.parserr   	notation3r   r   r   r   r<   r
   r   r   <module>r_      s.    #   *	mZ m`'/ '/r   