问题
I must produce a parsing automat of SPDH protocol.
SPDH defines the structure of request and response messages exchanged between an electronic payment terminal and the server of the bank.
The specifications of this protocol are described in this document: http://www.trauco.com/docs/SPDH-specification_070212.pdf
I specified the following grammar for this protocol:
Frame : = header fids etx ;
header : = fields ;
fields : = field fields | epsilon ;
field : = string | number ;
fids : = fid FieldSeparator fids | epsilon ;
fid : = exp | subfids ;
exp : = string | number| whitespace ;
subfids : = exp RecordSeparator subfids |epsilon ;
whitespace : = space whitespace | epsilon ;
space : = ' ' ;
string : = letter string | digits string | '-' string | period string |epsilon ;
FieldSeparator : = period | epsilon ;
RecordSeparator : = '!'| epsilon ;
number : = digits number | epsilon ;
digits : = '0'|'1'|...|'8'| '9' ;
letter : = 'a'|...|'z'|'A'|...|'Z' ;
period : = '.' ;
etx : = 'ETX'| epsilon ;
I need some help to conceive my application and to implement my grammar.
回答1:
- Have you really specified the grammar?
- What is the target platform?
- What are the tools you are using?
- Are you familiar with parser generators a.k.a compiler-compilers
回答2:
Because I won't create a compiler. I have just to break up the frame into fields. I have in second step to save all fields in a data base.
回答3:
Try creating a state diagram of the frame. Maybe the first time you wown't get it right but this way you will get a better understanding of the frame strucuture.
I would give you a hand but the link provided is not accessible for me. Please email the file or send an alternative link.
来源:https://stackoverflow.com/questions/601746/an-analyzer-for-spdh-frame