Pedigree Chart

Pedigree Chart


You are to read in a set of genealogy information from a file. Interactively you will be prompted to give the ID of a person. You are to print the pedigree chart for that person.

The important thing is to write a correct program. As long as it will run in our lifetime, don't worry too much about efficiency.


COMMAND LINE SYNTAX
  
  pedigree file_name

  The command name will be "pedigree".  The command will have 1 command line
  argument which is the name of the file from which the genealogy information
  is to be read.  If there are any more values on the command line, they will
  be ignored.


INPUT/OUTPUT The query, which is sent to standard output is "Please give the ID the first person in the pedigree chart:" The answer to the query about which ID to start with will come from standard input. The output and error messages will all go to standard output. There is only one query for each execution of the program. DO NOT loop and query for a different person.
GRAMMAR SYNTAX NOTES The following explains the grammar notation: Comments in the grammar are of the form "-- xxxxxxxxxxxxxxxx EOLN". That is, a comment is a "--" followed by any number of characters to the end of line. A production is of the form X :: A B C ... where X is a non-terminal, A, B and C may be terminals or non-terminals. Non-terminals will be words. Terminals will be quoted strings. "\n" means end of line and " " means space or blank. X... means one or more X. [X] means that X is optional. [X]... means 0 or more X. X | Y means X or Y (X Y)... means 1 or more X followed by Y [X Y]... means 0 or more X followed by Y [X | Y]... means a sequence of 0 or more X or Y (X | Y)... means a sequence of 1 or more X or Y X{1..4} means a sequence of 1..4 of X
INPUT GRAMMAR Input :: [Person]... -- The input may be empty Person :: ID_Entry Name_Entry Birth_Event Death_Event Father_Entry Mother_Entry ID_Entry :: "ID: " ID EOLN Name_Entry :: "Name: " [Name] EOLN Birth_Event :: BirthDay_Entry BirthPlace_Entry Death_Event :: DeathDate_Entry DeathPlace_Entry BirthDay_Entry :: "Birthday: " [Birthday] EOLN BirthPlace_Entry :: "Birth Place: " [BirthPlace] EOLN DeathDate_Entry :: "Death Date: " [DeathDate] EOLN DeathPlace_Entry :: "Death Place: " [DeathPlace] EOLN Father_Entry :: "Father: " [Father_ID] EOLN Mother_Entry :: "Mother: " [Mother_ID] EOLN ID :: Digit... Name :: String Birthday :: String BirthPlace :: String DeathDate :: String DeathPlace :: String Father_ID :: ID Mother_ID :: ID String :: [Character]... Digit :: "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" Character :: -- any ASCII character -- The ID will be at most 40 digits long. -- A String is at most 40 characters long. -- A string may be empty.
INPUT ERROR CONDITIONS 1. No File Name on command name. Generates the following error message left justified on a single line: "ERROR: No file name in the command line, terminating program" 2. Invalid input file. Generates the following error message left justified on a single line: "ERROR: Invalid input file, terminating program" There was no input file with the given name, or, the input file was present but not readable, or any other error that made it impossible to read the file. 3. Invalid Syntax Generates the following error message left justified on a single line.: "ERROR: Invalid Syntax on line xxx, skipping current person" Common mistakes: whitespace at beginning of input line, line labels (e.g. "Mother: ") are misspelled, ID is composed of characters other than digits, ID is too long, Birthday, BirthPlace, DeathDate, DeathPlace is too long, ID is missing. 4. No two people may have the same ID. Generates the following error message left justified on a single line: "ERROR: Duplicate ID on Line xxx, skipping current person" where xxx represents the erroneous line number. xxx is a sequence of one or more digits. 2. Mother or Father ID's is syntatically valid but points to someone who does not exist. Generates the following error message left justified on a single line: "ERROR: Invalid Mother or Father ID at line xxx, terminating program" You must wait until all people have been read in before trying to link them up. 6. Invalid answer to the prompt for starting person ID. Generates the following error message left justified on a single line: "ERROR: The ID given is not an integer, please try again" At which point the program issues the prompt again. This goes on until at most 5 prompts have been given. That is, the user gets a total of 5 tries. 7. After prompting for a starting person ID, and receiving a syntactically valid ID, no person with the given ID exists. Generates the following error message left justified on a single line: "ERROR: No person with that ID exists, please try again" At which point the program issues the prompt again. This goes on until at most 5 prompts have been given. That is, the user gets a total of 5 tries.
VALID INPUT EXAMPLES ID: 1 Name: Scott N. Woodfield Birthday: 10 Dec 1951 Birth Place: Ogden, Weber, Utah Death Date: Death Place: Father: 2 Mother: ID: 2 Name: Norman Ray Woodfield Birthday: 4 Apr 1926 Birth Place: Ogden, Weber, Utah Death Date: Death Place: Father: Mother: ID: 21 Name: R2D2 Birthday: Birth Place: Death Date: Death Place: Father: Mother:
INVALID INPUT EXAMPLES ID: 1 Nam: Scott N. Woodfield Birthday: 10 Dec 1951 Birth Place: Ogden, Weber, Utah Death Date: Death Place: Father: 0 Mother: -1 Id: 1 Name: Norman Ray Woodfield Birthday: 4 Apr 1926 Birth Place: Ogden, Weber, Utah Death Date: Death Place: Father: 3 Mother: 10
CONSTRUCTION OF THE OUTPUT Output Format of a Person : -- Some of the non-terminals are defined in the input syntax Output :: [Page]... Page :: "Page: " Page_Number EOLN First_Person Page_Number :: Digit... New_Line :: EOLN First_Person :: New_Line Name_Entry EOLN Generation_1_Info [Father_1] [Mother_1] Father_1 :: New_Line Indent "Father: " Name EOLN Generation_2_Info [Father_2] [Mother_2] Mother_1 :: New_Line Indent "Mother: " Name EOLN Generation_2_Info [Father_2] [Mother_2] Father_2 :: New_Line Indent Indent "Father: " Name EOLN Generation_3_Info [Father_3] [Mother_3] Mother_2 :: New_Line Indent Indent "Mother: " Name EOLN Generation_3_Info [Father_3] [Mother_3] Father_3 :: New_Line Indent Indent Indent "Father: " Name EOLN Generation_4_Info [Father_4] [Mother_4] Mother_3 :: New_Line Indent Indent Indent "Mother: " Name EOLN Generation_4_Info [Father_4] [Mother_4] Father_4 :: Indent Indent Indent Indent "Father: " Page_Pointer EOLN Mother_4 :: Indent Indent Indent Indent "Mother: " Page_Pointer EOLN Page_Pointer :: "(See Page " Page_Number ")" Generation_1_Info :: Indent BirthDay_Entry EOLN Indent BirthPlace_Entry EOLN Indent DeathDay_Entry EOLN Indent DeathPlace_Entry EOLN Generation_2_Info :: Indent Indent BirthDay_Entry EOLN Indent Indent BirthPlace_Entry EOLN Indent Indent DeathDay_Entry EOLN Indent Indent DeathPlace_Entry EOLN Generation_3_Info :: Indent Indent Indent BirthDay_Entry EOLN Indent Indent Indent BirthPlace_Entry EOLN Indent Indent Indent DeathDay_Entry EOLN Indent Indent Indent DeathPlace_Entry EOLN Generation_4_Info :: Indent Indent Indent Indent BirthDay_Entry EOLN Indent Indent Indent Indent BirthPlace_Entry EOLN Indent Indent Indent Indent DeathDay_Entry EOLN Indent Indent Indent Indent DeathPlace_Entry EOLN Indent :: SPACE SPACE SPACE SPACE SPACE SPACE -- Each person is printed at indentation levels 0, 1, 2, 3, or 4. The first -- person on a page is at level 0, second generation people at level 1, -- third generation people at level 2, the fourth generation people at -- level 3, and the fifth generation people at level 4. A single indentation -- level is 6 spaces. Thus, indentation level 0 is 0 spaces, indentation -- level 1 is 6 spaces, indentation 2 is 12 space, indentation level 3 is -- 18 spaces, and indentation level 4 is 24 spaces. The birth and death -- information is always indented one additional level than the indentation -- level for the person. Thus, the birth and death information for the -- fourth generation people is indented 4 levels or 24 spaces. -- Although upto five generations of people can be printed on a page, -- only the first four generations have the birth and death information -- printed. Fifth generation people only have a pointer to the page on -- which they appear as the first person.
OUTPUT CONSTRAINTS and NOTES If a person does not have a Father then nothing is printed for the Father. If a person does not have a Mother then nothing is printed for the Mother. A single page may print more lines than can fit on a physical page. Not all people in an input file may be related. In fact there may be many different disjoint pedigrees. There is NO required order for input. For example, a daughter may come after a parent or before a parent. Thus, to check for a parent link we must wait until all people have been read in. The page numbers will run from 1 to n where n is the number of pages printed. Always start with page 1. The output is one long stream of output. Logically a new page starts when "Page: " appears at the beginning of a line. You, should NOT try to make a logical page start on a physical page. Assume the output just dumps to standard output WITHOUT physical page breaks. The page numbers should be sequential. If the integer i is a page number and i < number of output page then the line "Page: i" should appear, then the contents of Page 1, the the line "Page: i+1", and then the contents of page i+1. j". Similarly, if i is an integer and a line containing "(See Page i)" occurs, then, the next forward reference should contain "(See Page i+1)".
OUTPUT EXAMPLES Page: 1 Name: Scott N. Woodfield Birthday: 10 Dec 1951 Birth Place: Ogden, Weber, Utah Death Date: Death Place: Father: Norman Ray Woodfield Birthday: 4 Apr 1926 Birth Place: Ogden, Weber, Utah Death Date: Death Place: Father: Ray Weldon Woodfield Birthday: Birth Place: Ogden, Weber, Utah Death Date: Death Place: Ogden, Weber, Utah Father: John Aaron Woodfield Birthday: Birth Place: Ogden, Weber, Utah Death Date: Death Place: Father: (See Page 2) Mother: (See Page 3) Mother: Vera Jane Campbell Birthday: Birth Place: Liberty, Weber, Utah Death Date: Death Place: Ogden, Weber, Utah Mother: Florence Clementina Croom Birthday: September 25, 1924 Birth Place: Wilmington, New Hanover, North Carolina Death Date: Death Place: Page: 2 Name: John Woodfield Birthday: about 1860 Birth Place: England Death Date: Death Place: North Odgen, Weber, Utah Page 3 Name: Rachel Roylance Birthday: Birth Place: England Death Date: Death Place: North Odgen, Weber, Utah