Files
ioccc/1993/vanb
Landon Curt Noll 2b92c89be8 fix and improve links within the web site
Entry source is now prog.c for IOCCC years 2014 thru 2020,
or is now dirname.c IOCCC years 1984 thru 2013.

To achieve this state, we renamed the following:

renamed:    2004/hibachi/src/hibachi.c -> 2004/hibachi/hibachi.c
renamed:    2012/omoikane/nyaruko.alt.c -> 2012/omoikane/omoikane.alt.c
renamed:    2012/omoikane/nyaruko.alt2.c -> 2012/omoikane/omoikane.alt2.c
renamed:    2012/omoikane/nyaruko.c -> 2012/omoikane/omoikane.c
renamed:    2012/omoikane/nyaruko.orig.c -> 2012/omoikane/omoikane.orig.c

Modified `bin/subst.entry-index.sh` to add to entry `index.html` file,
links to the `Makefile` and the _C code_ to the top navigation bar.
Changed `bin/subst.entry-index.sh` VERSION from "1.2.2 2024-02-25"
to "1.3 2024-03-02".

Moved printing the Inventory link in the top navigation bar
from `bin/subst.entry-navbar.awk` to `bin/subst.entry-index.sh`.
Changed `bin/subst.entry-navbar.awk` VERSION from "1.0.1 2024-02-23"
to "1.1 2024-03-02".

Moved printing the Inventory link in the top navigation bar
from `bin/subst.year-navbar.awk` to `bin/subst.year-index.sh`.
Changed `bin/subst.year-index.sh` VERSION from "1.0 2024-02-11"
to "1.1 2024-03-02".
Changed `bin/subst.year-navbar.awk` VERSION from "1.0 2024-02-11"
to "1.1 2024-03-02".

Added location names (both default and common) to `author.html`.
Changed `tmp/gen_author_json.sh` VERSION from "1.0 2023-06-06"
to "1.1 2024-03-04".

Added location names (both default and common) to `author.html`.
Changed `bin/gen-authors.sh` VERSION from "1.2 2024-03-09"
to "1.3 2024-03-04".

The manifest and the resulting `.entry.json` files have been changed
for `2004/hibachi` and `2012/omoikane`.

The Makefiles for  `2004/hibachi` and `2012/omoikane` copy the
source file into the "previously used location".  The `make clobber`
rule removes the copied source.  The `.gitignore` files have been
updated accordingly.

Improved how the concept of IOCCC terms _entry_, _author_ and _submission_ are
used in markdown files.

Links to markdown files (files ending in .md) within the repo were
changed to link to HTML files (files ending in .html).  Special cases
where `README.md` became `index.html` were modified accordingly.

Fixed URL for `bugs.html` in Makefile comments.

Fixed name of `bin/sgi.sh` referenced in comments in `.gitignore` files.

Links to locations within the repo are now relative.  For example a
link to `/contact.html` may become `../contact.html' or '../../contact.html`
depending on the directory level of the markdown file.

Nearly all links with absolute URLs under _https://www.ioccc.org_
or `https://ioccc-src.github.io/temp-test-ioccc_ have been changed to
relative paths within the repo.  Some exceptions to this (such as
referring to a GitHub repo) were preserved.

Fixed a number of inside `faq.md` and `bugs.md`.

Added HTML name tags (in the form of an _entry_id_) for each entry
referenced in `bugs.md`.  Fixed links from outside of `bugs.html`
into `bugs.html` accordingly.

Where FAQ entries are referenced, a named tag is used so that if a
FAQ is ever renumbered, links outside of `faq.html` will still work.

Changed the _inventory_order_ of a compressed tarball from _300_
to _100000_.  While this may have been done for the manifest,
this changed had not yet been propagated into the `.entry.json` files.

Links to web sites that were in the for <URL> are now [URL](URL).

Performed `name www` to process all of the above.

Improved format of `authors.html`.  Full names are now bold.
Location codes are now links back into `location.html` and
location names (both default and common) are now italics.
Added _author_handle_ each author.

Changed `bin/gen-authors.sh` VERSION from "1.1 2024-02-25"
to "1.2 2024-03-09".

Improved format of `location.html` as location codes are now bold,
author counts in a given location are now bold, and location names
(both default and common) are now italics.

Changed `bin/gen-location.sh` VERSION from "1.0.1 2024-02-23"
to "1.1 2024-03-04".

Added italic location name after location code in entry
`index.html` files.

Changed `bin/output-index-author.sh` VERSION from "1.4.1 2024-02-23"
to "1.5 2024-03-04".

Added _Location of authors_ to the sidebar as a link to `location.html`.

TODO: While nearly all of the above mentioned changes are likely correct,
      they likely introduced a few errors that need correcting.
2024-03-04 23:45:28 -08:00
..
2024-02-27 23:21:32 -08:00
2023-07-06 21:49:38 -07:00

To build:

make all

Bugs and (Mis)features:

The current status of this entry is:

STATUS: INABIAF - please **DO NOT** fix

For more detailed information see 1993 vanb bugs.

To use:

./vanb 'exp'

where exp is an octal expression. See below for how it can also have hexadecimal and decimal numbers.

Try:

./try.sh

What happens if you use something other than valid digits?

Judges' remarks:

The octal expression may contain:

unary operators:	+, -
binary operators	+, -, *, /, %
hex numbers:		x or X followed by hex digits
decimal numbers:	d or D followed by decimal digits
octal numbers:		octal digits
grouping:		()

No spaces are allowed in the expression. To avoid shell expansion, one should surround the expression in single quotes.

It is a good thing that this program consists of only one expression, otherwise it might become hard to understand. :-)

Author's remarks:

The program does no error checking - erroneous expressions will produce spurious results. Note that unary - is an operator. Thus, decimal -46 would be entered as -d46 and not d-46.

What Makes This Program Special:

  1. Of course, the fact that the program takes input and produces output in octal, rather than a more useful system like decimal, makes it "special".

  2. The entire program consists of a single expression, returned from main().

  3. There are no global or local variables other than the parameters to main().

  4. All of the constants in the program are expressed in octal - including the printf(3) string.

  5. The variables are given names which cause visual confusion with the octal constants.

  6. The program is formatted like a Roman numeral 8. The significance of 8 is obvious. I chose Roman numerals because it is a numbering system even more arcane than octal. It's not very 'deceptive', but it's difficult to deceptively format a program which has no explicit control structures (other than ?:s).

  7. Many simple tasks are done many times. I tried to do these differently each time, to make the program harder to understand.

How It Works:

It's a recursive descent parser, calling main() for all of its recursion. O2 is a state variable, telling main() what grammar non-terminal to parse. **O7 is the next character. O3 is an intermediate result. Whenever you see a construct like:

!(expression with O2)?

it's decrementing and testing O2 to see what state it's in. Comparisons involving **O7 and octal constants are looking for certain characters.

Here's the grammar ('e' denotes the empty string) :

<E>  ::=  <T><E'>
<E'> ::=  +<T><E'> | -<T><E'> | e
<T>  ::=  <F><T'>
<T'> ::=  *<F><T'> | /<F><T'> | %<F><T'> | e
<F>  ::=  +<F> | -<F> | (<E><C> | d<D> | D<D> |  x<X> | X<X> | <O>
<C>  ::=  )
<D>  ::=  [0-9]<D> | e
<X>  ::=  [0-9]<X> | [A-F]<X> | [a-f]<X> | e
<O>  ::=  [0-7]<O> | e

Here's how the grammar nonterminals map to octal state numbers:

<E>  is  012
<E'> is  011
<T>  is  010
<T'> is   07
<F>  is   06
<C>  is  013
<D>  is   04
<X>  is   05
<O>  is   03

Here's a version of the program before it got formatted into the VIII, augmented with comments showing where each state begins. N1 and N2 are notes:

#define O5 main
O5(O2,O7,O3)char**O7;
{
	 return
/* N1 */ !(O2+=~01+01) ?\
	      00:
/* N2 */ !(O2-=02>01) ?\
	      printf("\045\157\012",O5(012,O7+01,00)):
/* O  */ !(O2-=02>>01) ?\
	      (**O7<=067 && **O7>057 ? O5(03,O7,*(*O7)++-060+010*O3):O3):
/* D  */ !(O2-=-O3-~O3) ?\
	      (072>**O7 && 060<=**O7 ? O5(04,O7,012*O3-060+*(*O7)++):O3):
/* X  */ !(O2-=!O3+!!O3) ?\
	      (**O7>057 && **O7<=071 ? O5(05,O7,*(*O7)+++O3*020-060):
	      **O7<=0106 && 0101<=**O7 ? O5(05,O7,020*O3+*(*O7)++-067):
	      0140<**O7 && **O7<0147 ? O5(05,O7,-0127+*(*O7)+++020*O3):O3):
/* F  */ !(O2-=02-01) ?\
	      (**O7==050 ? 050**++*O7,O5(013,O7,O5(012,O7,00)):
	      **O7<056 && 054<**O7 ? 055**++*O7,-O5(06,O7,00):
	      054>**O7 && 052<**O7 ? 050**(*O7)++,O5(06,O7,00):
	      !(**O7^0170)||!(0130^**O7) ? *++*O7,O5(05,O7,00):
	      **O7==0144||**O7==0104 ? ++*O7,O5(04,O7,00):O5(03,O7,00)):
/* T' */ !--O2 ?\
	      (**O7==052 ? O5(07,O7,O3*(*++*O7,O5(06,O7,00))):
	      !(045-**O7) ? O5(07,O7,O3%(03+(*O7)++,O5(06,O7,00))):
	      !(**O7^057) ? O5(07,O7,O3/(03-*++*O7,O5(06,O7,00))):O3):
/* T  */ !(O2+=01-02) ?\
	      O5(07,O7,O5(06,O7,00)):
/* E' */ !(O2+=-02/02) ?\
	      (!(**O7-053)?O5(011,O7,O3+(++*O7,O5(010,O7,00))):
	      !(055^**O7) ? O5(011,O7,O3-(03+*(*O7)++,O5(010,O7,00))):O3):
/* E  */ !(O2-=0563&0215) ?\
	      O5(011,O7,O5(010,O7,00)):
/* C  */ (++*O7,O3);
}

Note N1: It should never enter this state, unless the user invokes the program with no parameters, in which case it just returns 0.

Note N2: Since the program is properly invoked with 1 parameter, this is the first state it will go into. This state just invokes printf, and sends the parser to state 012 (which is <E>).

The E and T states work like this:

int e(){ return eprime( t() ); }

The E' and T' states work like this:

int eprime( int intermediate )
{
    if( ch == '+' )
    {
	ch = nextchar();
	return eprime( intermediate + t() );
    }
    else return intermediate;
}

The D, X and O states work like this (they assume that they're initially called with 0):

int octal( int intermediate )
{
    if( ch>='0' && ch<='7' )
    {
	intermediate = intermediate * 8 + ch - '0';
	ch = nextchar();
	return octal( intermediate );
    }
    else return intermediate;
}

F and C work similarly.

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved. You are free to share and adapt this file under the terms of this license:

Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)

For more information, see: https://creativecommons.org/licenses/by-sa/4.0/