Hi Tulip,
 
all t_... are rules for lex.py and all p_... are rules for yacc.py.
See http://www.dabeaz.com/ply/ply.html
 
The t_error() is special rule for error handling.
 
If the lex.py finds during rules analysis the rule t_error() it saves it
into self.lexerrorf. I.e. when error occures the self.lexerrorf(tok)
calling invokes t_error(tok) calling.
 
Best regards,
  Tomas
 
PS: I am sorry that the asn2wrs.py is not very readable and would need
code cleaning and probably few refactorings. But when I started to write
it (based on Aaron S. Lav's PyZ3950 package) I was not able to imagine
how much of ASN.1 complexicity we would need to have implemented.
 


________________________________

        From: wireshark-dev-boun...@wireshark.org
[mailto:wireshark-dev-boun...@wireshark.org] On Behalf Of tulip neo
        Sent: Thursday, March 26, 2009 7:54 AM
        To: wireshark-dev@wireshark.org
        Subject: [Wireshark-dev] Help on ASN2Wrs
        
        
Hi List,
Good morning.
I have some problem with  ASn2wrs.I m developing a parser which should
be capable of generating target code(c/c++) from ASN description.In
other words asn->python data structure->xml->c/c++.I went through the
asn2wrs.py bit by bit and found it very intresting and help full.I need
to store different elements and there type and child in some data
structure so that i can be able to generate a message tree.
 
pls help me how should i proceed.One doubt with Lex.py and asn2wrs.py
  
snippets from lex.py
 
 # No match. Call t_error() if defined.

                if self.lexerrorf:
                    tok = LexToken()
                    tok.value = self.lexdata[lexpos:]
                    tok.lineno = self.lineno
                    tok.type = "error"
                    tok.lexer = self
                    tok.lexpos = lexpos
                    self.lexpos = lexpos
                    newtok = self.lexerrorf(tok)
                    if lexpos == self.lexpos:
 
How does above self.lexerrorf(tok) calls t_error() of asn2wrs.py.i dont
also understand why it is t_.i understand atleast it defines rules.but
how both are maped?same case with the definitions starting with def
p_.do Prefix P_ and t_ have any significance?how they are maped from
lex.py?
 
snippets from asn2wrs.py
def t_error(t):
  global input_file
  raise LexError(t, input_file)
 
Br
Tulip

________________________________

        Add more friends to your messenger and enjoy! Invite them now.
<http://in.rd.yahoo.com/tagline_messenger_6/*http://messenger.yahoo.com/
invite/> 

___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev@wireshark.org>
Archives:    http://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-requ...@wireshark.org?subject=unsubscribe

Reply via email to