#ifndef FORMAT_ADA_CLASS #define FORMAT_ADA_CLASS // format_ada: does the spacing and carriage return formatting to create a // nicely formatted ada program. #include "stack.h" #include "strings.h" class format_ada : private stack { public: // constructor initializes the formatter's state. format_ada(); ~format_ada(); // format: returns a string that is formatted for Ada with a carriage return // and indentation in the appropriate places. the tokens are defined by // the grammar for Ada. string &format(int token, string &token_text); private: // is a space needed for the next word coming in to be formatted? int space_needed; // is an indentation needed in front of this word? int indent_soon; // how many inside bits have been seen so far (if then, cases, etc)? int indent_level; // what was the last token that was formatted? int last_formatted_token; // what was the second to last token that was formatted? int penult_formatted_token; // how many levels of parentheses are nesting these words? int paren_nesting; // how many blocks is this block nested within? int block_nesting; // w_s: has when been seen on this line? int when_seen; // trigger_extra_cr: at the next semicolon, an extra return will be // generated. int trigger_extra_cr; // h_t_f_e_c: tells whether the last semicolon had the trigger for the // extra line. int had_trigger_for_extra_cr; // t_i_c_u: indicates whether the end is for a type definition. int type_is_coming_up; // e_d_o: tells whether an enumerated type is being defined. int enum_def_occurring; // indenting_stack: maintains a record of the token that caused the current // indentation level. stack indenting_stack; // indent: returns a string containing the necessary indentation. string &indent(); struct formatting_stack : public chunk { // e_i_l: the number of indents at which the containing frame ends. int ending_indentation_level; // handlers: are there exception handlers attached to the current frame? int handlers; // header_seen: has the header for package, procedure, etc. been seen // before a begin is encountered? int header_seen; // first_semicolon_after_header: if true, and in the semicolon case, then // this is the first semicolon encountered in the new procedure/function... int first_semicolon_after_header; }; // grab_top: gets the top most element on the stack. formatting_stack *grab_top(char *error_place); // end_block: removes a nested block from the stack. void end_block(); }; #endif