%{ static char const rcsid [] = "$Id: maps_pars.y,v 1.1 1998/04/22 10:16:52 stojanov Exp $"; /*****************************************************************************/ /* */ /* Unit: MAPS_PARS (Yacc source specification module - language grammar) */ /* */ /* Author: Nikola Stojanovic */ /* */ /* Revision: 15 APR 98 */ /* */ /* Yacc source code for the parsing module for the specifications written */ /* in the description language */ /* */ /*****************************************************************************/ #include #include #include #include "maps_pars.h" extern int current_line_number; extern char *current_file_name; /* Internal procedures to assemble data structures for the semantic stack */ label_ptr PARS_Label_List (label_ptr list, label_ptr cell); label_ptr PARS_Label_Cell (char *text, char *font, int font_size); strlist_ptr PARS_String_List (strlist_ptr list, char *new_string); %} %start specification %union { long int lint; float real; char * strg; strlist_ptr sptr; label_ptr lptr; load_semantic_record ldsr; range_semantic_record rgsr; landmark_semantic_record lmsr; single_semantic_record sgsr; mark_semantic_record mksr; bulk_semantic_record bksr; indication_semantic_record insr; plain_semantic_record plsr; anmark_semantic_record amsr; atext_semantic_record atsr; afield_semantic_record afsr; origin_semantic_record ogsr; area_semantic_record arsr; page_semantic_record pgsr; box_semantic_record bxsr; underline_semantic_record ulsr; line_semantic_record lnsr; extras_semantic_record ersr; text_semantic_record txsr; label_semantic_record lbsr; font_semantic_record ftsr; annotation_semantic_record ansr; pivot_semantic_record pvsr; info_semantic_record ifsr; } %token T_ABSOLUTE %token T_ADJUSTMENT %token T_ALIAS %token T_ALIGNMENT %token T_ALL %token T_ANNOTATIONS %token T_AT %token T_BANNER %token T_BLACK %token T_BOTTOM %token T_BOX %token T_BOXED %token T_CENTERED %token T_CONTENT %token T_COUNTER %token T_DARKGRAY %token T_DASHED %token T_DESCRIPTION %token T_DOTTED %token T_DOTDASH %token T_DOUBLE %token T_ENDED %token T_EVERY %token T_FIELD %token T_FILE %token T_FONT %token T_FROM %token T_GENERAL %token T_GRAY %token T_IN %token T_INFORMATION %token T_INTERMEDIATE %token T_INTNUM %token T_LABEL %token T_LANDMARK %token T_LANDMARKS %token T_LANDSCAPE %token T_LEFT %token T_LENGTH %token T_LIGHTGRAY %token T_LITERALLY %token T_LOAD %token T_MARK %token T_MARKED %token T_NAME %token T_NO %token T_NOT %token T_NULL %token T_ORIENTATION %token T_ORIGIN %token T_ORIGINS %token T_OUTPUT %token T_PAGE %token T_PATH %token T_PIVOT %token T_PORTRAIT %token T_POSITION %token T_POSTSCRIPT %token T_RANGE %token T_REALNUM %token T_REPEATED %token T_RIGHT %token T_SEQUENCES %token T_SHADE %token T_SHOW %token T_SINGLE %token T_SIZE %token T_SOLID %token T_SPACING %token T_STARTED %token T_STRICT %token T_STRING %token T_STRIPPED %token T_STYLE %token T_TEXT %token T_TICKMARK %token T_TO %token T_TOP %token T_TRAILER %token T_UNDERLINE %token T_UNDERLINED %token T_WHITE %token T_WIDTH %token T_WILDCARD %type place_option position_option number_option description_command orientation size_option line_number start_option end_option font_definition output_definition adjustment_option treatment_option %type shade_option %type seqpath_option style_option %type alias_option name_list %type label_list label %type load_command %type range_option %type label_option %type font_option label_set_option %type mark_option box_mark underline_mark %type landmark_definition %type single_landmark %type bulk_landmarks %type optional_indication %type annotations_command %type optional_marking %type text_option %type field_option %type origin_definition %type origin_range %type page_definition %type box_command %type underline_command %type line_definition %type line_arrangement %type text_format %type banner_option trailer_option %type text_line_spec %type information_command %% specification : list_of_statements ; list_of_statements : list_of_statements statement | ; statement : load_command { CONT_Load_Command ($1.file_name, $1.seq_path, $1.aliases, $1.alignment, $1.range_seq, $1.start_range, $1.stop_range); } | landmark_definition { CONT_Landmark_Definition ($1.landmark_kind, $1.file_name, $1.landmark_sequence, $1.origin, $1.start, $1.stop, $1.mark_kind, $1.underline_mult, $1.mark_sequence, $1.mark_style, $1.mark_shade, $1.label, $1.place, $1.position, $1.font, $1.font_size); } | annotations_command { CONT_Annotations_Command ($1.file_name, $1.counter, $1.mark_kind, $1.underline_mult, $1.mark_style, $1.mark_shade, $1.text, $1.text_font, $1.text_size, $1.field, $1.field_font, $1.field_size, $1.place, $1.position); } | origin_definition { CONT_Origin_Definition ($1.source, $1.file_name, $1.origin_name, $1.position, $1.sequence, $1.from, $1.to); } | description_command { CONT_Description_Command ($1); } | page_definition { CONT_Page_Definition ($1.orientation, $1.size, $1.width, $1.spacing); } | box_command { CONT_Box_Command ($1.sequence, $1.origin, $1.start, $1.stop, $1.style, $1.shade, $1.label, $1.place, $1.position); } | underline_command { CONT_Underline_Command ($1.kind, $1.sequence, $1.origin, $1.start, $1.stop, $1.style, $1.label, $1.place, $1.position); } | line_definition { CONT_Line_Definition ($1.line_kind, $1.line_number, $1.line_code, $1.tick_distance, $1.text, $1.text_repeat, $1.sequence_disabled, $1.banner, $1.banner_font, $1.banner_font_size, $1.adjustment, $1.text_layout, $1.pivot, $1.pivot_seq, $1.trailer, $1.trailer_font, $1.trailer_font_size, $1.start_code, $1.end_code); } | font_definition { CONT_Font_Definition ($1); } | information_command { CONT_Information_Command ($1.info, $1.kind); } | output_definition { CONT_Output_Definition ($1); } ; load_command : T_LOAD T_FILE T_STRING seqpath_option alias_option ';' { $$.file_name = $3; $$.seq_path = $4; $$.aliases = $5; $$.alignment = UNDEFINED; $$.range_seq = NULL; $$.start_range = UNDEFINED; $$.stop_range = UNDEFINED; } | T_LOAD T_ALIGNMENT T_INTNUM range_option ';' { $$.file_name = NULL; $$.seq_path = NULL; $$.aliases = NULL; $$.alignment = $3; $$.range_seq = $4.sequence; $$.start_range = $4.start; $$.stop_range = $4.stop; } | T_LOAD T_FILE T_STRING seqpath_option alias_option T_ALIGNMENT T_INTNUM range_option ';' { $$.file_name = $3; $$.seq_path = $4; $$.aliases = $5; $$.alignment = $7; $$.range_seq = $8.sequence; $$.start_range = $8.start; $$.stop_range = $8.stop; } | T_LOAD T_ALIGNMENT T_INTNUM range_option T_FILE T_STRING seqpath_option alias_option ';' { $$.file_name = $6; $$.seq_path = $7; $$.aliases = $8; $$.alignment = $3; $$.range_seq = $4.sequence; $$.start_range = $4.start; $$.stop_range = $4.stop; } | T_LOAD error ';' { yyerror ("Invalid loading command"); } ; range_option : T_FROM T_INTNUM T_TO T_INTNUM T_IN T_STRING { $$.sequence = $6; $$.start = $2; $$.stop = $4; } | T_FROM T_INTNUM T_LENGTH T_INTNUM T_IN T_STRING { $$.sequence = $6; $$.start = $2; $$.stop = $2 + $4 - 1; } | { $$.sequence = NULL; $$.start = UNDEFINED; $$.stop = UNDEFINED; } ; seqpath_option : T_PATH T_STRING { $$ = $2; } | { $$ = NULL; } ; alias_option : T_ALIAS name_list { $$ = $2; } | { $$ = NULL; } ; style_option : T_STYLE T_STRING { $$ = $2; } | T_STYLE T_SOLID { $$ = NTL0_strsave (SOLID_STYLE); } | T_STYLE T_DOTTED { $$ = NTL0_strsave (DOTTED_STYLE); } | T_STYLE T_DASHED { $$ = NTL0_strsave (DASHED_STYLE); } | T_STYLE T_DOTDASH { $$ = NTL0_strsave (DDASH_STYLE); } | { $$ = NULL; } ; shade_option : T_SHADE T_REALNUM { $$ = $2; } | T_SHADE T_WHITE { $$ = WHITE_SHADE; } | T_SHADE T_LIGHTGRAY { $$ = LIGHTGRAY_SHADE; } | T_SHADE T_GRAY { $$ = GRAY_SHADE; } | T_SHADE T_DARKGRAY { $$ = DARKGRAY_SHADE; } | T_SHADE T_BLACK { $$ = BLACK_SHADE; } | { $$ = (float) UNDEFINED; } ; label_option : T_LABEL label_list place_option position_option { $$.label = $2; $$.place = $3; $$.position = $4; } | { $$.label = NULL; $$.place = UNDEFINED; $$.position = UNDEFINED; } ; label_list : label_list ',' label { $$ = PARS_Label_List ($1, $3); } | label { $$ = $1; } ; label : T_STRING font_option { $$ = PARS_Label_Cell ($1, $2.name, $2.size); } ; font_option : T_FONT T_STRING T_INTNUM { $$.name = $2; $$.size = $3; } | T_FONT T_STRING { $$.name = $2; $$.size = UNDEFINED; } | { $$.name = NULL; $$.size = UNDEFINED; } ; place_option : T_TOP { $$ = TOP_PLACE; } | T_BOTTOM { $$ = BOTTOM_PLACE; } | { $$ = UNDEFINED; } ; position_option : T_LEFT { $$ = LEFT_POSITION; } | T_CENTERED { $$ = CENTERED_POSITION; } | T_RIGHT { $$ = RIGHT_POSITION; } | { $$ = UNDEFINED; } ; mark_option : T_MARKED box_mark { $$.kind = $2.kind; $$.multiple = $2.multiple; $$.sequence = $2.sequence; $$.style = $2.style; $$.shade = $2.shade; $$.label = $2.label; $$.place = $2.place; $$.position = $2.position; } | T_MARKED underline_mark { $$.kind = $2.kind; $$.multiple = $2.multiple; $$.sequence = $2.sequence; $$.style = $2.style; $$.shade = $2.shade; $$.label = $2.label; $$.place = $2.place; $$.position = $2.position; } | { $$.kind = UNDEFINED; $$.multiple = UNDEFINED; $$.sequence = NULL; $$.style = NULL; $$.shade = (float) UNDEFINED; $$.label = NULL; $$.place = UNDEFINED; $$.position = UNDEFINED; } ; box_mark : T_BOX style_option shade_option label_option { $$.kind = BOX_CODE; $$.multiple = UNDEFINED; $$.sequence = NULL; $$.style = $2; $$.shade = $3; $$.label = $4.label; $$.place = $4.place; $$.position = $4.position; } ; underline_mark : T_UNDERLINE number_option T_AT T_STRING style_option label_option { $$.kind = UNDERLINE_CODE; $$.multiple = $2; $$.sequence = $4; $$.style = $5; $$.shade = (float) UNDEFINED; $$.label = $6.label; $$.place = $6.place; $$.position = $6.position; } ; number_option : T_SINGLE { $$ = SINGLE_UNDERLINE; } | T_DOUBLE { $$ = DOUBLE_UNDERLINE; } | { $$ = UNDEFINED; } ; name_list : name_list ',' T_STRING { $$ = PARS_String_List ($1, $3); } | T_STRING { $$ = PARS_String_List (NULL, $1); } ; landmark_definition : single_landmark ';' { $$.landmark_kind = SINGLE_LANDMARK; $$.file_name = NULL; $$.landmark_sequence = $1.sequence; $$.origin = $1.origin; $$.start = $1.start; $$.stop = $1.stop; $$.mark_kind = $1.mark_kind; $$.underline_mult = $1.underline_mult; $$.mark_sequence = $1.mark_sequence; $$.mark_style = $1.mark_style; $$.mark_shade = $1.mark_shade; $$.label = $1.label; $$.place = $1.place; $$.position = $1.position; $$.font = NULL; $$.font_size = UNDEFINED; } | bulk_landmarks ';' { $$.landmark_kind = BULK_LANDMARK; $$.file_name = $1.file_name; $$.landmark_sequence = NULL; $$.origin = NULL; $$.start = UNDEFINED; $$.stop = UNDEFINED; $$.mark_kind = $1.indication; $$.underline_mult = $1.multiple; $$.mark_sequence = $1.sequence; $$.mark_style = $1.style; $$.mark_shade = $1.shade; $$.label = NULL; $$.place = UNDEFINED; $$.position = UNDEFINED; $$.font = $1.label_font_name; $$.font_size = $1.label_font_size; } | T_LANDMARK error ';' { yyerror ("Invalid landmark definition"); } | T_LANDMARKS error ';' { yyerror ("Invalid landmark group specification"); } ; single_landmark : T_LANDMARK T_AT T_STRING T_ORIGIN T_STRING T_POSITION T_INTNUM T_WIDTH T_INTNUM mark_option { $$.sequence = $3; $$.origin = $5; $$.start = $7; $$.stop = $7 + $9 - 1; $$.mark_kind = $10.kind; $$.underline_mult = $10.multiple; $$.mark_sequence = $10.sequence; $$.mark_style = $10.style; $$.mark_shade = $10.shade; $$.label = $10.label; $$.place = $10.place; $$.position = $10.position; } | T_LANDMARK T_AT T_STRING T_ORIGIN T_STRING T_FROM T_INTNUM T_TO T_INTNUM mark_option { $$.sequence = $3; $$.origin = $5; $$.start = $7; $$.stop = $9; $$.mark_kind = $10.kind; $$.underline_mult = $10.multiple; $$.mark_sequence = $10.sequence; $$.mark_style = $10.style; $$.mark_shade = $10.shade; $$.label = $10.label; $$.place = $10.place; $$.position = $10.position; } ; bulk_landmarks : T_LANDMARKS T_FROM T_STRING optional_indication { $$.file_name = $3; $$.indication = $4.kind; $$.multiple = $4.multiple; $$.sequence = $4.sequence; $$.style = $4.style; $$.shade = $4.shade; $$.label_font_name = $4.label_font_name; $$.label_font_size = $4.label_font_size; } ; optional_indication : T_BOXED style_option shade_option label_set_option { $$.kind = BOX_CODE; $$.multiple = UNDEFINED; $$.sequence = NULL; $$.style = $2; $$.shade = $3; $$.label_font_name = $4.name; $$.label_font_size = $4.size; } | T_UNDERLINED number_option style_option label_set_option { $$.kind = UNDERLINE_CODE; $$.multiple = $2; $$.sequence = NULL; $$.style = $3; $$.shade = (float) UNDEFINED; $$.label_font_name = $4.name; $$.label_font_size = $4.size; } | T_UNDERLINED number_option T_AT T_SEQUENCES style_option label_set_option { $$.kind = UNDERLINE_CODE; $$.multiple = $2; $$.sequence = NULL; $$.style = $5; $$.shade = (float) UNDEFINED; $$.label_font_name = $6.name; $$.label_font_size = $6.size; } | T_UNDERLINED number_option T_AT T_STRING style_option label_set_option { $$.kind = UNDERLINE_CODE; $$.multiple = $2; $$.sequence = $4; $$.style = $5; $$.shade = (float) UNDEFINED; $$.label_font_name = $6.name; $$.label_font_size = $6.size; } | { $$.kind = UNDEFINED; $$.multiple = UNDEFINED; $$.sequence = NULL; $$.style = NULL; $$.shade = (float) UNDEFINED; $$.label_font_name = NULL; $$.label_font_size = UNDEFINED; } ; label_set_option : T_LABEL T_FONT T_STRING T_INTNUM { $$.name = $3; $$.size = $4; } | T_LABEL T_FONT T_STRING { $$.name = $3; $$.size = UNDEFINED; } | T_LABEL T_FONT T_INTNUM { $$.name = NULL; $$.size = $3; } | { $$.name = NULL; $$.size = UNDEFINED; } ; annotations_command : T_ANNOTATIONS T_FROM T_STRING optional_marking ';' { $$.file_name = $3; $$.counter = UNDEFINED; $$.mark_kind = $4.mark_kind; $$.underline_mult = $4.underline_mult; $$.mark_style = $4.mark_style; $$.mark_shade = $4.mark_shade; $$.text = $4.text; $$.text_font = $4.text_font; $$.text_size = $4.text_size; $$.field = $4.field; $$.field_font = $4.field_font; $$.field_size = $4.field_size; $$.place = $4.place; $$.position = $4.position; } | T_ANNOTATIONS T_FROM T_STRING T_COUNTER T_INTNUM optional_marking ';' { $$.file_name = $3; $$.counter = $5; $$.mark_kind = $6.mark_kind; $$.underline_mult = $6.underline_mult; $$.mark_style = $6.mark_style; $$.mark_shade = $6.mark_shade; $$.text = $6.text; $$.text_font = $6.text_font; $$.text_size = $6.text_size; $$.field = $6.field; $$.field_font = $6.field_font; $$.field_size = $6.field_size; $$.place = $6.place; $$.position = $6.position; } | T_ANNOTATIONS T_FROM T_STRING T_COUNTER T_ABSOLUTE optional_marking ';' { $$.file_name = $3; $$.counter = 0; $$.mark_kind = $6.mark_kind; $$.underline_mult = $6.underline_mult; $$.mark_style = $6.mark_style; $$.mark_shade = $6.mark_shade; $$.text = $6.text; $$.text_font = $6.text_font; $$.text_size = $6.text_size; $$.field = $6.field; $$.field_font = $6.field_font; $$.field_size = $6.field_size; $$.place = $6.place; $$.position = $6.position; } ; optional_marking : T_BOX T_MARK style_option shade_option text_option field_option place_option position_option { $$.mark_kind = BOX_CODE; $$.underline_mult = UNDEFINED; $$.mark_style = $3; $$.mark_shade = $4; $$.text = $5.text; $$.text_font = $5.font_name; $$.text_size = $5.font_size; $$.field = $6.field; $$.field_font = $6.font_name; $$.field_size = $6.font_size; $$.place = $7; $$.position = $8; } | number_option T_UNDERLINE style_option text_option field_option place_option position_option { $$.mark_kind = UNDERLINE_CODE; $$.underline_mult = $1; $$.mark_style = $3; $$.mark_shade = (float) UNDEFINED; $$.text = $4.text; $$.text_font = $4.font_name; $$.text_size = $4.font_size; $$.field = $5.field; $$.field_font = $5.font_name; $$.field_size = $5.font_size; $$.place = $6; $$.position = $7; } | { $$.mark_kind = UNDEFINED; $$.underline_mult = UNDEFINED; $$.mark_style = NULL; $$.mark_shade = (float) UNDEFINED; $$.text = NULL; $$.text_font = NULL; $$.text_size = UNDEFINED; $$.field = UNDEFINED; $$.field_font = NULL; $$.field_size = UNDEFINED; $$.place = UNDEFINED; $$.position = UNDEFINED; } ; text_option : T_TEXT T_STRING T_FONT T_STRING T_INTNUM { $$.text = $2; $$.font_name = $4; $$.font_size = $5; } | T_TEXT T_STRING T_FONT T_STRING { $$.text = $2; $$.font_name = $4; $$.font_size = UNDEFINED; } | T_TEXT T_STRING T_FONT T_INTNUM { $$.text = $2; $$.font_name = NULL; $$.font_size = $4; } | T_TEXT T_STRING { $$.text = $2; $$.font_name = NULL; $$.font_size = UNDEFINED; } | { $$.text = NULL; $$.font_name = NULL; $$.font_size = UNDEFINED; } ; field_option : T_FIELD T_INTNUM T_FONT T_STRING T_INTNUM { $$.field = $2; $$.font_name = $4; $$.font_size = $5; } | T_FIELD T_INTNUM T_FONT T_STRING { $$.field = $2; $$.font_name = $4; $$.font_size = UNDEFINED; } | T_FIELD T_INTNUM T_FONT T_INTNUM { $$.field = $2; $$.font_name = NULL; $$.font_size = $4; } | T_FIELD T_INTNUM { $$.field = $2; $$.font_name = NULL; $$.font_size = UNDEFINED; } | { $$.field = UNDEFINED; $$.font_name = NULL; $$.font_size = UNDEFINED; } ; origin_definition : T_ORIGIN T_AT T_INTNUM T_IN T_STRING origin_range ';' { $$.source = EXPLICIT_ORIGIN; $$.file_name = NULL; $$.origin_name = NULL; $$.position = $3; $$.sequence = $5; $$.from = $6.from; $$.to = $6.to; } | T_ORIGIN T_STRING T_AT T_INTNUM T_IN T_STRING origin_range ';' { $$.source = EXPLICIT_ORIGIN; $$.file_name = NULL; $$.origin_name = $2; $$.position = $4; $$.sequence = $6; $$.from = $7.from; $$.to = $7.to; } | T_ORIGINS T_FROM T_STRING origin_range ';' { $$.source = FILED_ORIGINS; $$.file_name = $3; $$.origin_name = NULL; $$.position = UNDEFINED; $$.sequence = NULL; $$.from = $4.from; $$.to = $4.to; } | T_ORIGIN error ';' { yyerror ("Invalid origin definition"); } | T_ORIGINS error ';' { yyerror ("Invalid specification of origins"); } ; origin_range : T_FROM T_INTNUM T_TO T_INTNUM { $$.from = $2; $$.to = $4; } | { $$.from = UNDEFINED; $$.to = UNDEFINED; } ; description_command : T_SHOW T_DESCRIPTION ';' { $$ = DESCRIPTION; } | T_NO T_DESCRIPTION ';' { $$ = NO_DESCRIPTION; } | T_SHOW error ';' { yyerror ("Invalid description command"); } | T_NO error ';' { yyerror ("Invalid description command"); } ; page_definition : T_PAGE T_ORIENTATION orientation size_option ';' { $$.orientation = $3; $$.size = $4; $$.width = UNDEFINED; $$.spacing = UNDEFINED; } | T_PAGE T_WIDTH T_INTNUM ';' { $$.orientation = UNDEFINED; $$.size = UNDEFINED; $$.width = $3; $$.spacing = UNDEFINED; } | T_PAGE T_SPACING T_INTNUM ';' { $$.orientation = UNDEFINED; $$.size = UNDEFINED; $$.width = UNDEFINED; $$.spacing = $3; } | T_PAGE error ';' { yyerror ("Invalid page definition"); } ; orientation : T_PORTRAIT { $$ = PORTRAIT_CODE; } | T_LANDSCAPE { $$ = LANDSCAPE_CODE; } ; size_option : T_SIZE T_INTNUM { $$ = $2; } | { $$ = UNDEFINED; } ; box_command : T_BOX T_AT T_STRING T_ORIGIN T_STRING T_POSITION T_INTNUM T_WIDTH T_INTNUM style_option shade_option label_option ';' { $$.sequence = $3; $$.origin = $5; $$.start = $7; $$.stop = $7 + $9 - 1; $$.style = $10; $$.shade = $11; $$.label = $12.label; $$.place = $12.place; $$.position = $12.position; } | T_BOX T_AT T_STRING T_ORIGIN T_STRING T_FROM T_INTNUM T_TO T_INTNUM style_option shade_option label_option ';' { $$.sequence = $3; $$.origin = $5; $$.start = $7; $$.stop = $9; $$.style = $10; $$.shade = $11; $$.label = $12.label; $$.place = $12.place; $$.position = $12.position; } | T_BOX error ';' { yyerror ("Invalid box command"); } ; underline_command : T_UNDERLINE number_option T_AT T_STRING T_ORIGIN T_STRING T_POSITION T_INTNUM T_WIDTH T_INTNUM style_option label_option ';' { $$.kind = $2; $$.sequence = $4; $$.origin = $6; $$.start = $8; $$.stop = $8 + $10 - 1; $$.style = $11; $$.label = $12.label; $$.place = $12.place; $$.position = $12.position; } | T_UNDERLINE number_option T_AT T_STRING T_ORIGIN T_STRING T_FROM T_INTNUM T_TO T_INTNUM style_option label_option ';' { $$.kind = $2; $$.sequence = $4; $$.origin = $6; $$.start = $8; $$.stop = $10; $$.style = $11; $$.label = $12.label; $$.place = $12.place; $$.position = $12.position; } | T_UNDERLINE error ';' { yyerror ("Invalid underline command"); } ; line_definition : T_TOP line_number line_arrangement ';' { $$.line_kind = TOP_LINE; $$.line_number = $2; $$.line_code = $3.line_code; $$.tick_distance = $3.tick_distance; $$.text = $3.text; $$.text_repeat = $3.text_repeat; $$.sequence_disabled = FALSE; $$.banner = UNDEFINED; $$.banner_font = NULL; $$.banner_font_size = UNDEFINED; $$.adjustment = UNDEFINED; $$.text_layout = UNDEFINED; $$.pivot = UNDEFINED; $$.pivot_seq = NULL; $$.trailer = UNDEFINED; $$.trailer_font = NULL; $$.trailer_font_size = UNDEFINED; $$.start_code = UNDEFINED; $$.end_code = UNDEFINED; } | T_INTERMEDIATE line_number line_arrangement ';' { $$.line_kind = INTERMEDIATE_LINE; $$.line_number = $2; $$.line_code = $3.line_code; $$.tick_distance = $3.tick_distance; $$.text = $3.text; $$.text_repeat = $3.text_repeat; $$.sequence_disabled = FALSE; $$.banner = UNDEFINED; $$.banner_font = NULL; $$.banner_font_size = UNDEFINED; $$.adjustment = UNDEFINED; $$.text_layout = UNDEFINED; $$.pivot = UNDEFINED; $$.pivot_seq = NULL; $$.trailer = UNDEFINED; $$.trailer_font = NULL; $$.trailer_font_size = UNDEFINED; $$.start_code = UNDEFINED; $$.end_code = UNDEFINED; } | T_BOTTOM line_number line_arrangement ';' { $$.line_kind = BOTTOM_LINE; $$.line_number = $2; $$.line_code = $3.line_code; $$.tick_distance = $3.tick_distance; $$.text = $3.text; $$.text_repeat = $3.text_repeat; $$.sequence_disabled = FALSE; $$.banner = UNDEFINED; $$.banner_font = NULL; $$.banner_font_size = UNDEFINED; $$.adjustment = UNDEFINED; $$.text_layout = UNDEFINED; $$.pivot = UNDEFINED; $$.pivot_seq = NULL; $$.trailer = UNDEFINED; $$.trailer_font = NULL; $$.trailer_font_size = UNDEFINED; $$.start_code = UNDEFINED; $$.end_code = UNDEFINED; } | T_TEXT line_number text_format ';' { $$.line_kind = TEXT_LINE; $$.line_number = $2; $$.line_code = UNDEFINED; $$.tick_distance = UNDEFINED; $$.text = NULL; $$.text_repeat = UNDEFINED; $$.sequence_disabled = FALSE; $$.banner = $3.banner; $$.banner_font = $3.banner_font; $$.banner_font_size = $3.banner_font_size; $$.adjustment = $3.adjustment; $$.text_layout = $3.text_layout; $$.pivot = $3.pivot; $$.pivot_seq = $3.pivot_seq; $$.trailer = $3.trailer; $$.trailer_font = $3.trailer_font; $$.trailer_font_size = $3.trailer_font_size; $$.start_code = $3.start_code; $$.end_code = $3.end_code; } | T_TEXT line_number T_NULL ';' { $$.line_kind = TEXT_LINE; $$.line_number = $2; $$.line_code = UNDEFINED; $$.tick_distance = UNDEFINED; $$.text = NULL; $$.text_repeat = UNDEFINED; $$.sequence_disabled = TRUE; $$.banner = UNDEFINED; $$.banner_font = NULL; $$.banner_font_size = UNDEFINED; $$.adjustment = UNDEFINED; $$.text_layout = UNDEFINED; $$.pivot = UNDEFINED; $$.pivot_seq = NULL; $$.trailer = UNDEFINED; $$.trailer_font = NULL; $$.trailer_font_size = UNDEFINED; $$.start_code = UNDEFINED; $$.end_code = UNDEFINED; } | T_TOP error ';' { yyerror ("Invalid top line definition"); } | T_INTERMEDIATE error ';' { yyerror ("Invalid intermediate line definition"); } | T_BOTTOM error ';' { yyerror ("Invalid bottom line definition"); } | T_TEXT error ';' { yyerror ("Invalid text line definition"); } ; line_number : T_INTNUM { $$ = $1; } | T_ALL { $$ = ALL_LINES_CODE; } | { $$ = UNDEFINED; } ; line_arrangement : T_TICKMARK T_EVERY T_INTNUM { $$.line_code = TICKMARK_CODE; $$.tick_distance = $3; $$.text = NULL; $$.text_repeat = UNDEFINED; } | T_TICKMARK T_EVERY T_INTNUM T_STRIPPED { $$.line_code = STRIPPED_TICK_CODE; $$.tick_distance = $3; $$.text = NULL; $$.text_repeat = UNDEFINED; } | T_ORIGIN T_NAME { $$.line_code = ORIGIN_CODE; $$.tick_distance = UNDEFINED; $$.text = NULL; $$.text_repeat = UNDEFINED; } | T_LANDMARK T_NAME { $$.line_code = LANDMARK_NAME_CODE; $$.tick_distance = UNDEFINED; $$.text = NULL; $$.text_repeat = UNDEFINED; } | T_TEXT T_STRING { $$.line_code = LINE_TEXT_CODE; $$.tick_distance = UNDEFINED; $$.text = $2; $$.text_repeat = UNDEFINED; } | T_TEXT T_STRING T_REPEATED T_EVERY T_INTNUM { $$.line_code = REPEATED_TEXT_CODE; $$.tick_distance = UNDEFINED; $$.text = $2; $$.text_repeat = $5; } | T_NULL { $$.line_code = NO_CONTENTS; $$.tick_distance = UNDEFINED; $$.text = NULL; $$.text_repeat = UNDEFINED; } ; text_format : banner_option text_line_spec trailer_option start_option end_option { $$.banner = $1.record; $$.banner_font = $1.font_name; $$.banner_font_size = $1.font_size; $$.adjustment = $1.adjustment; $$.text_layout = $2.kind; $$.pivot = $2.pivot_num; $$.pivot_seq = $2.pivot_seq; $$.trailer = $3.record; $$.trailer_font = $3.font_name; $$.trailer_font_size = $3.font_size; $$.start_code = $4; $$.end_code = $5; } ; banner_option : T_BANNER font_option adjustment_option { $$.record = BANNER_CODE; $$.font_name = $2.name; $$.font_size = $2.size; $$.adjustment = $3; } | T_NO T_BANNER { $$.record = NO_BANNER; $$.font_name = NULL; $$.font_size = UNDEFINED; $$.adjustment = UNDEFINED; } | { $$.record = UNDEFINED; $$.font_name = NULL; $$.font_size = UNDEFINED; $$.adjustment = UNDEFINED; } ; adjustment_option : T_ADJUSTMENT T_INTNUM { $$ = $2; } | { $$ = UNDEFINED; } ; text_line_spec : T_LITERALLY { $$.kind = VERBATIM_CODE; $$.pivot_num = UNDEFINED; $$.pivot_seq = NULL; } | T_DOTTED T_PIVOT T_INTNUM { $$.kind = PIVOT_CODE; $$.pivot_num = $3; $$.pivot_seq = NULL; } | T_DOTTED T_PIVOT T_STRING { $$.kind = PIVOT_CODE; $$.pivot_num = UNDEFINED; $$.pivot_seq = $3; } ; trailer_option : T_TRAILER font_option { $$.record = TRAILER_CODE; $$.font_name = $2.name; $$.font_size = $2.size; $$.adjustment = UNDEFINED; } | T_NO T_TRAILER { $$.record = NO_TRAILER; $$.font_name = NULL; $$.font_size = UNDEFINED; $$.adjustment = UNDEFINED; } | { $$.record = UNDEFINED; $$.font_name = NULL; $$.font_size = UNDEFINED; $$.adjustment = UNDEFINED; } ; start_option : T_STARTED { $$ = STARTED_CODE; } | T_NOT T_STARTED { $$ = ENTIRE_SEQUENCE_CODE; } | { $$ = UNDEFINED; } ; end_option : T_ENDED { $$ = ENDED_CODE; } | T_ENDED T_NOT { $$ = ENTIRE_SEQUENCE_CODE; } | { $$ = UNDEFINED; } ; font_definition : T_TEXT T_FONT T_INTNUM ';' { $$ = $3; } | T_TEXT T_FONT error ';' { yyerror ("Invalid font definition"); } ; information_command : T_SHOW T_INFORMATION T_CONTENT treatment_option ';' { $$.info = TRUE; $$.kind = $4; } | T_NO T_INFORMATION T_CONTENT ';' { $$.info = FALSE; $$.kind = UNDEFINED; } ; treatment_option : T_STRICT { $$ = STRICT_CODE; } | T_GENERAL { $$ = GENERAL_CODE; } | T_WILDCARD { $$ = WILDCARD_CODE; } | { $$ = UNDEFINED; } ; output_definition : T_OUTPUT T_TEXT ';' { $$ = TEXT_OUTPUT; } | T_OUTPUT T_POSTSCRIPT ';' { $$ = POSTSCRIPT_OUTPUT; } | T_NO T_OUTPUT ';' { $$ = NO_OUTPUT; } | T_OUTPUT error ';' { yyerror ("Invalid output definition"); } ; %% /*****************************************************************************/ /* */ /* Procedure: yyerror */ /* */ /* Definition of action to be done upon seeing a syntax error */ int yyerror (char *message) { fprintf (stderr, "SYNTAX ERROR: %s\n at or near line %d of file %s.\n\n", message, current_line_number, current_file_name); exit (1); } /*****************************************************************************/ /* */ /* Procedure: PARS_Label_List */ /* */ /* Procedure appends the new label cell to the already assembled part of the */ /* list; returns the updated list */ label_ptr PARS_Label_List (label_ptr list, label_ptr cell) { label_ptr label_scan; if (list == NULL) return cell; else { label_scan = list; while (label_scan -> next != NULL) label_scan = label_scan -> next; label_scan -> next = cell; return list; } } /*****************************************************************************/ /* */ /* Procedure: PARS_Label_Cell */ /* */ /* Procedure creates new label structure cell from the received elements; */ /* returns the created cell */ label_ptr PARS_Label_Cell (char *text, char *font, int font_size) { label_ptr new_cell; new_cell = (label_ptr) NTL0_ckalloc (sizeof (Label_Struct)); new_cell -> text = text; new_cell -> font_name = font; new_cell -> font_size = font_size; new_cell -> next = NULL; return new_cell; } /*****************************************************************************/ /* */ /* Procedure: PARS_String_List */ /* */ /* Procedure appends the new string to the already assembled (part of the) */ /* list; returns the updated list of strings */ strlist_ptr PARS_String_List (strlist_ptr list, char *new_string) { strlist_ptr new_cell, list_scan; new_cell = (strlist_ptr) NTL0_ckalloc (sizeof (StrList_Struct)); new_cell -> string = new_string; new_cell -> next = NULL; if (list == NULL) return new_cell; else { list_scan = list; while (list_scan -> next != NULL) list_scan = list_scan -> next; list_scan -> next = new_cell; return list; } }