Steffen Müller > Acme-Chef-1.01 > Acme::Chef

Download:
Acme-Chef-1.01.tar.gz

Dependencies

Annotate this POD

Related Modules

XML::Twig
HTTP::Daemon
more...
By perlmonks.org

CPAN RT

Open  0
View/Report Bugs
Module Version: 1.01   Source  

NAME ^

Acme::Chef - An interpreter for the Chef programming language

SYNOPSIS ^

  # Using the script that comes with the distribution.
  chef.pl file.chef
  
  # Using the module
  use Acme::Chef;
  
  my $compiled = Acme::Chef->compile($code_string);  
  print $compiled->execute();
  
  my $string = $compiled->dump(); # requires Data::Dumper
  # Save it to disk, send it over the web, whatever.
  my $reconstructed_object = eval $string;
  
  # or:
  $string = $compiled->dump('autorun'); # requires Data::Dumper
  # Save it to disk, send it over the web, whatever.
  my $output_of_chef_program = eval $string;

DESCRIPTION ^

Chef is an esoteric programming language in which programs look like recipes. I needn't mention that using it in production environment, heck, using it for anything but entertainment ought to result in bugs and chaos in reverse order.

All methods provided by Acme::Chef are adequately described in the synopsis. If you don't think so, you need to read the source code.

There has been an update to the Chef specification. I have implemented the changes and marked them in the following documentation with "new specification".

With that out of the way, I would like to present a pod-formatted copy of the Chef specification from David Morgan-Mar's homepage (http://www.dangermouse.net/esoteric/chef.html).

METHODS

This is a list of methods in this package.

compile

Takes Chef source code as first argument and compiles a Chef program from it. This method doesn't run the code, but returns a program object.

execute

Takes no arguments. Runs the program and returns its output.

dump

Takes one optional argument. If it equals 'autorun', dump returns a string that, when evaluated, executes the program and returns the output.

If the argument does not equal 'autorun', a different string is returned that reconstructs the Acme::Chef object.

DESIGN PRINCIPLES ^

LANGUAGE CONCEPTS ^

Ingredients

All recipes have ingredients! The ingredients hold individual data values. All ingredients are numerical, though they can be interpreted as Unicode for I/O purposes. Liquid ingredients will be output as Unicode characters, while dry or unspecified ingredients will be output as numbers.

Mixing Bowls and Baking Dishes

Chef has access to an unlimited supply of mixing bowls and baking dishes. These can contain ingredient values. The ingredients in a mixing bowl or baking dish are ordered, like a stack of pancakes. New ingredients are placed on top, and if values are removed they are removed from the top. Note that if the value of an ingredient changes, the value in the mixing bowl or baking dish does not. The values in the mixing bowls and baking dishes also retain their dry or liquid designations.

Multiple mixing bowls and baking dishes are referred to by an ordinal identifier - "the 2nd mixing bowl". If no identifier is used, the recipe only has one of the relevant utensil. Ordinal identifiers must be digits followed by "st", "nd", "rd" or "th", not words.

SYNTAX ELEMENTS ^

The following items appear in a Chef recipe. Some are optional. Items must appear in the order shown below, with a blank line (two newlines) between each item.

Recipe Title

The recipe title describes in a few words what the program does. For example: "Hello World Souffle", or "Fibonacci Numbers with Caramel Sauce". The recipe title is always the first line of a Chef recipe, and is followed by a full stop.

  recipe-title.

Comments

Comments are placed in a free-form paragraph after the recipe title. Comments are optional.

Ingredient List

The next item in a Chef recipe is the ingredient list. This lists the ingredients to be used by the program. The syntax is

  Ingredients.
  [initial-value] [[measure-type] measure] ingredient-name
  [further ingredients]

Ingredients are listed one per line. The intial-value is a number. New specification: The initial-value is now optional. Attempting to use an ingredient without a defined value is a run-time error. The optional measure can be any of the following:

The optional measure-type may be any of the following:

The ingredient-name may be anything reasonable, and may include space characters. The ingredient list is optional. If present, it declares ingredients with the given initial values and measures.

Cooking Time

  Cooking time: time (hour[s] | minute[s]).

The cooking time statement is optional. The time is a number.

Oven Temperature

  Pre-heat oven to temperature degrees Celcius [(gas mark mark)].

Some recipes require baking. If so, there will be an oven temperature statement. This is optional. The temperature and mark are numbers.

Method

  Method.
  method statements

The method contains the actual recipe instructions. These are written in sentences. Line breaks are ignored in the method of a recipe. Valid method instructions are:

Serves

The final statement in a Chef recipe is a statement of how many people it serves.

  Serves number-of-diners.

This statement writes to STDOUT the contents of the first number-of-diners baking dishes. It begins with the 1st baking dish, removing values from the top one by one and printing them until the dish is empty, then progresses to the next dish, until all the dishes have been printed. The serves statement is optional, but is required if the recipe is to output anything!

Auxiliary Recipes

These are small recipes which are needed to produce specialised ingredients for the main recipe (such as sauces). They are listed after the main recipe. Auxiliary recipes are made by sous-chefs, so they have their own set of mixing bowls and baking dishes which the head Chef never sees, but take copies of all the mixing bowls and baking dishes currently in use by the calling chef when they are called upon. When the auxiliary recipe is finished, the ingredients in its first mixing bowl are placed in the same order into the calling chef's first mixing bowl.

For example, the main recipe calls for a sauce at some point. The sauce recipe is begun by the sous-chef with an exact copy of all the calling chef's mixing bowls and baking dishes. Changes to these bowls and dishes do not affect the calling chef's bowls and dishes. When the sous-chef is finished, he passes his first mixing bowl back to the calling chef, who empties it into his first mixing bowl.

An auxiliary recipe may have all the same items as a main recipe.

BUGS ^

A lot. This is a boring night's result.

In particular, the implementation does not always comply to the specification. While this is admittedly very bad behaviour, the author claims in defense that it usually allows a broader syntax than the specification so you should be safe when sticking to the specification.

AUTHOR ^

Steffen Mueller.

Chef was designed by David Morgan-Mar.

COPYRIGHT AND LICENSE ^

Copyright (c) 2002-2008 Steffen Mueller. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Author can be reached at chef-module at steffen-mueller dot net

syntax highlighting: