I wrote a grammar to parse incoming SITA messages in airport domain. Grammar text is given below. The problematic part in this grammar is “((CRLF nil) | (CRLF transfer_passenger_data)+)” when I change this part into “(CRLF transfer_passenger_data)+)” grammatica generates the parser just fine, but in the first case it starts to create the parser and program freezes. Do you have any idea why might this happen?
Thank you in advance.
GRAMMARTYPE = "LL"
DESCRIPTION = "A grammar for SITA PTM message syntax."
AUTHOR = "Tuna Ozkasap, <tuna dot ozkasap at tav dot aero>"
VERSION = "0.1"
DATE = "2010/07/15"
LICENSE = "Permission is granted to copy this document verbatim in any
medium, provided that this copyright notice is left intact."
COPYRIGHT = "Copyright (c) 2010 Tuna Ozkasap. All rights reserved."
* this token set is for SITA PTM message
S = <<[ ]>>
CRLF = <<[\n]>>
SLASH = "/"
DOT = "."
EQUALS = "="
ENDPTM = "ENDPTM"
LETTERA = "A"
LETTERB = "B"
LETTERC = "C"
LETTERD = "D"
LETTERE = "E"
LETTERF = "F"
LETTERG = "G"
LETTERH = "H"
LETTERI = "I"
LETTERJ = "J"
LETTERK = "K"
LETTERL = "L"
LETTERM = "M"
LETTERN = "N"
LETTERO = "O"
LETTERP = "P"
LETTERQ = "Q"
LETTERR = "R"
LETTERS = "S"
LETTERT = "T"
LETTERU = "U"
LETTERV = "V"
LETTERW = "W"
LETTERX = "X"
LETTERY = "Y"
LETTERZ = "Z"
DIGIT0 = "0"
DIGIT1 = "1"
DIGIT2 = "2"
DIGIT3 = "3"
DIGIT4 = "4"
DIGIT5 = "5"
DIGIT6 = "6"
DIGIT7 = "7"
DIGIT8 = "8"
DIGIT9 = "9"
* these productions are closely based on the productions
* specified in http://www.w3.org/TR/REC-CSS2/syndata.html
ptm = addresses CRLF
flight_element ((CRLF nil) | (CRLF transfer_passenger_data)+) CRLF
end_message | ptm_nil;
ptm_message_id = LETTERP LETTERT LETTERM;
nil = LETTERN LETTERI LETTERL;
alphanum = num | alpha;
num = DIGIT0 | DIGIT1 | DIGIT2 | DIGIT3 | DIGIT4 | DIGIT5 | DIGIT6 | DIGIT7 | DIGIT8 | DIGIT9;
nonzero = DIGIT1 | DIGIT2 | DIGIT3 | DIGIT4 | DIGIT5 | DIGIT6 | DIGIT7 | DIGIT8 | DIGIT9;
alpha = LETTERA | LETTERB | LETTERC | LETTERD | LETTERE | LETTERF | LETTERG | LETTERH | LETTERI | LETTERJ |
LETTERK | LETTERL | LETTERM | LETTERN | LETTERO | LETTERP | LETTERQ | LETTERR | LETTERS | LETTERT |
LETTERU | LETTERV | LETTERW | LETTERX | LETTERY | LETTERZ;
flight = alphanum alphanum+;
part = LETTERP LETTERA LETTERR LETTERT nonzero num*;
addresses = address (S address)*;
address = alphanum alphanum alphanum alphanum alphanum alphanum alphanum;
comm_ref = DOT comm_ref_address S comm_ref_num;
comm_ref_address = alpha alpha alpha alpha alpha alpha alpha;
comm_ref_num = num num num num num num;
flight_element = flight SLASH date month S airport_list (S part)?;
airport_list = iata_code iata_code?;
iata_code = alpha alpha alpha?;
month = jan | feb | mar | apr | may | jun | jul | aug | sep | oct | nov | dec;
jan = LETTERJ LETTERA LETTERN;
feb = LETTERF LETTERE LETTERB;
mar = LETTERM LETTERA LETTERR;
apr = LETTERA LETTERP LETTERR;
may = LETTERM LETTERA LETTERY;
jun = LETTERJ LETTERU LETTERN;
jul = LETTERJ LETTERU LETTERL;
aug = LETTERA LETTERU LETTERG;
sep = LETTERS LETTERE LETTERP;
oct = LETTERO LETTERC LETTERT;
nov = LETTERN LETTERO LETTERV;
dec = LETTERD LETTERE LETTERC;
date = num num;
transfer_passenger_data = flight date_and_smoking? S
iata_code S num_of_seats fare_class S
baggage_pieces LETTERB (baggage_weight weight_type)?
(child_sym child_count)? (infant_sym infant_count)? space_sym?;
date_and_smoking = (SLASH date smoking_indicator) | (SLASH date) | (SLASH smoking_indicator);
baggage_pieces = num num*;
num_of_seats = num num*;
baggage_weight = num num*;
smoking_indicator = LETTERS | LETTERN;
fare_class = LETTERK | LETTERY | LETTERF;/*TODO: fare classlari ogrenip burayi duzelt*/
weight_type = LETTERK | LETTERL;
/*Optional child, infant and space fields*/
child_sym = DOT LETTERC LETTERH LETTERD;
child_count = num num*;
infant_sym = DOT LETTERI LETTERN LETTERF;
infant_count = num num*;
space_sym = DOT ((LETTERR LETTERQ) | (LETTERS LETTERA));
Grammatica-users mailing list
|Free forum by Nabble||Edit this page|