CSCI 241 - Lab 5 :
C Strings

Due by 11:59.59pm Monday, December 06th

The URL for this github repository is https://classroom.github.com/a/MlcAyqU0 If your partner is submitting an assignment, please submit one yourself, pointing at the partner's repository.

Introduction

For this assignment create a program pig that will read in English text and translate it into Pig Latin. In particular you'll be working with strings in C.

I'm interested in seeing how much time students estimate an assignment will take versus how much time they actually spend on the assignment. What I'd like you to do is read through this assignment and create a README with your estimated time to complete it. (Feel free to list time for individual components as well if you'd like.) After you get done, I'd like you to add in the actual amount of time you spent.

Programming Details

Pig Latin is used by both adults and children to obfuscate what they are saying from the other. Some of you might have toyed around with the language yourself as a child.

(Un)Translating Pig Latin

For this assignment, you'll be creating two programs: pig and unpig. pig will read in English text and convert it into pig latin. unpig will do the opposite and will take in text in Pig Latin and convert it back to English. Note: Untranslating pig latin is not deterministic, if you start with English and translate via these rules, undoing them will not get you the original. That is fine. Just follow the rules as stated.

Pig Latin Translation Rules

There are a couple of varying rules to Pig Latin. For this assignment, we'll be using the following:

  1. Rule 1:

    If the string begins with a vowel (that is begins with 'a', 'e', 'i', 'o', or 'u') add "yay" to the end of the string.
  2. Rule 2:

    Otherwise, find the first occurance of a vowel, then move all the letters before the vowel to the end of the word and add "ay".

    Note:

    "y" should be considered a vowel in this context.

You can consider a word to be a consecutive sequence of letters (A-Z, a-z). "y" should be treated as a consonant if it is the first letter of the word but as a vowel otherwise.

Punctuation & Grammar

In addition to modifying the words as specified above, your program should also respect the following rules:

Some dialects of pig latin say that you should move "silent" letters to the end as well (such as in the word knife). You can ignore contraction words (don't).

Examples

In general, the words will be translated as follows:
Linux -> Inuxlay

yes -> esyay
example -> exampleyay


Programming Notes

Some guidelines you should follow when working on your solution:

You'll want to think about how to breaks this program into its component parts.


Command line arguments

Additionally, I'd like you to implement a -h and -? flag that prints out a brief usage message and exits the program with a non-zero value. You should do the same if an unknown flag is passed to the program.

You should have your program's main function return 0 upon successful completion of the assigned task.


Man page

You'll also be creating a man page to accompany your tool. Man pages are simply text files that have some additional annotations with formatting instructions -- somewhat similar to LaTeX if you've encountered that as well.

Traditionally, the tool nroff was used to do typesetting of man pages. These days, many systems now have groff and just have nroff as an alias to groff. You can get more info on the various options by seeing the manpage groff_man(7).

Important nroff macros to know

At a minimum, you will need to know the following macros (all go at the start of the line).

.\"
designates a comment line. There usually is a block of these at the top.
.TH <name> <section> <center-footer> <left-footer> <center-header>
Title Heading. Use this after the initial block of comments at the start. It takes the following 5 arguments:
  1. name - name of the command or function
  2. section - section of the manual (1 for user commands)
  3. center-footer - date the page was last modified
  4. left-footer - use "CSCI 241" for man pages in this class
  5. center-header - this is the organization field, use "Oberlin College" for this course
.SH text
A section header. By convention these should be in all caps. Commonly used values are NAME, SYNOPSIS, DESCRIPTION, OPTIONS, DIAGNOSTICS, AUTHOR, BUGS in that order.
.SS text
A subheading. By convention these should only have the initial letter caps.
.P
Start a new paragraph. Each line of the paragraph needs to start in column 1.
.IP text
An indented paragraph. Very useful for describing options.
.B word
Bolds the following word
.I word
Italicizes the following word

Sample manpage

.\" Sample man page for CSCI 241
.\" Roberto Hoyle - Spring 2017

.TH sample_man 1 "05 March 2017" "CSCI 241" "Oberlin College"

.SH NAME
.B sample_man
\- an example of a sample man page

.SH SYNOPSIS
.B sample_man
[ -o outputfile ]
<filename>

.SH DESCRIPTION
Does everything a sample man page should do.

.SH OPTIONS
.IP "-o outputfile"
Do things to be written to an output file.

.SH AUTHOR
Roberto Hoyle (Spring 2017)

.SH BUGS
None!

You can also see/download a longer version.

You should name your file based on the standard convention <name_of_program>.<manual_section>. So for the above page, it would be sample_man_page.1. (Recall that section 1 is user commands.)

To view the processed man page use either of the following commands:

Here is the HTML version of above:

sample_man(1)                   Oberlin College                  sample_man(1)

NAME
       sample_man - an example of a sample man page

SYNOPSIS
       sample_man [ -o outputfile ] <filenames>

DESCRIPTION
       Does everything a sample man page should do.

OPTIONS
       -o outputfile
              Do things to be written to an output file.

AUTHOR
       Roberto Hoyle (Spring 2017)

BUGS
       None!

CSCI 241                        05 March 2017                  sample_man(1)

Extra Credit

Implement other translations. Check out http://www.rinkworks.com/dialect/ and https://www.cs.utexas.edu/users/jbc/home/chef.html for inspiration.

Handin

README

Create a file called README that contains

  1. Your name and a description of the program
  2. A listing of the files with a short one line description of the contents
  3. Any known bugs or incomplete functions
  4. Your estimated time from the start and the actual time taken
  5. Your affirmation as to the honor code if you followed it

Now you should make clean to get rid of your executables and handin your folder containing your source files, Makefile, and README through GitHub

    % git add
    % git commit
    % git push

Remember, if you have issues with commits due to odd merges, it is easier to start over, clone into a new directory, and copy the files over before commiting and pushing.

In addition, if you are working with a partner, you should do git pull periodically to pull their changes into your direction to avoid having to do a merge

Project Teams

It is now time to start thinking about your final project teams. Send me an email with a list of people that you would like to team up with, and a list of people that you would not like to be teamed up with. If I do not get an mail from you, I will assume you have no preferences and will be happy with any team assignment that I make.

Please put a subject on the message starting with [cs241-team].

Grading

Here is what I am looking for in this assignment: