---------------------------------------------------------------------

    |%%%%%|    WhiteBeer - test version
    |wbeer|
    |//   |]]  Copyright (C) 2002 ihitoshi@users.sourceforge.net
    +-----+    All rights reserved
---------------------------------------------------------------------

====INTRODUCTION====
WhiteBeer is a new programming paradigm that is motivated by Noam Chomsky's
Minimalist Program. It uses feature checking mechanism to parse programs so
that it can provide word-order-independence like natural language processing;
on the other hand, many conventional programming languages use BNF-like
grammar that is word-order-sensitive.

In WhiteBeer, both "one plus one" and "plus one one" may be legal operation. 

WhiteBeer has more advantage; it has no predefined grammar like any other
programming language(eg. Java has its Java-grammar and C++ also has), so one
can define its grammar adding new words in its program; word has features and
only the features can define its grammar. In Web environment, words may be
considered as Web resources, so when one creates Web resources any WhiteBeer
program can access them automatically.

Current version of WhiteBeer is implemented with Java(JDK1.3) on RedHat6.2. 

Although the ultimate goal of WhiteBeer is to provide a programming paradigm
previously described, current version of WhiteBeer is intended to a feature
checking parser and has a little functionality of executing program.

I tested this system only on RedHat6.2. Other environment may cause some
troubles. In such case, please tell me about it.

I must say that this program is too adhoc and I want to design it once again.
But I think this implementation can help one to understand the image of
WhiteBeer.

I can not say in what application WhiteBeer is useful or interesting...
If you have some idea, please contact me.


====INSTALLATION====
To use WhiteBeer, you need to set 'WBEER_HOME' value to the top of WhiteBeer
directory and 'JAVA_HOME' to the top of JDK directory. And set 'PATH' to
'${WBEER_HOME}/bin'.

Also WhiteBeer uses ${JAVA_HOME}/lib/tools.jar.
 
wbeer.jar is already included in this package, so compiling is not necessary.
But if you want to build from source codes, you need
jakarta-ant(http://jakarta.apache.org/ant/) and
JavaCC(http://www.webgain.com/products/javacc).

After installing them, edit build.xml to replace property of javacchome value.
Then 'ant build' will make ${WBEER_HOME}/lib/wbeer.jar.

To try the sample program, goto ${WBEER_HOME}/sample and
type 'wbeer.sh -tree -fval'.

After '$wbeer>' appears, type 'I like you <ret>'. Then you will see the tree
diagram.

To show help, type 'wbeer.sh -h'.


====HOW TO USE IT====
WhiteBeer executes the following procedure.

    (1)read source and create Java program.
    (2)compile Java program
    (3)execute Java program

To do (1) and (2), type 'wbeer.sh -make -d <source>'.
Then you can make Java programs from the source, and compile them.
If -d <source> is ignored, WhiteBeer searches default.wb in the current
directory and uses it.

After typing 'wbeer.sh -make ...', many *.java and *.class files are created
in the current directory. 

Then type 'wbeer.sh -exec' to do (3); you can execute program.

After execution, typing 'wbclear.sh' will clear the current directory.

Now what you have to know is how to program it.


====CLASS DEFINITION====
class will be definied as follows.

    class <class name> {
       <features>
       <functions>
    };

Here <class name> is a label of the class.
<features> is used to construct tree structure. <functions> is used to execute
the tree structure.

WhiteBeer executes any program as follows.

    (1)construct tree
    (2)execute tree

Tree construction is done successfully only when one tree is created. Then a
entry funcion in the top of the tree is called.


==CONSTRUCT TREE==
In WhiteBeer paradigm, classes have features.

Features have four attributes; headside/inherent/obligatory/value.
headside/inherent/obligatory are boolean and value is integer.

The main idea is that if class A has a feature F and class B has the same
feature F, then A and B will merge and create one tree. Here feature F of A
and feature F of B is checked.

    A B --> [A B]

Once a feature is checked, the feature can not be used again.

There are constraint to feature checking. If F of A is headside, then F of B
must be noheadside. And if F of A is noheadside, F of B must be headside.

In case F of A is headside, following tree will be created. Here A is a parent
of A and B.

             A
          +--+--+
          |     |
          A     B

From here, I will express such tree as [(A) B]. () means headside.
Similarly, if B is headside, [A (B)] will be created.

If both of A and B is headside or both of A and B is noheadside, they can not
create a tree.

Feature has value as its attribute. There are 2 ways to treat value.

Inherent feature must have its original value and the value can not change
forever. Non-inherent feature need not have its original value (but is
possible to have default value).
Inherent feature acts as constant and non-inherent feature acts as variable.
But assignment a value to non-inherent feature is allowed only once.
non-inherent feature becomes inherent when non-inherent feature checks with
inherent feature. Feature value is copied to non-inherent feature from
inherent feature when they check each other.

There is another constraint; If both feature F1 and F2 are inherent and the
values are different, F1 and F2 can not check.

Obligatory feature needs checking after its parsing. If there are any
obligatory feature remained unchecked, tree construction fails.

You can write features in the field of <features> as follows.

    <type> : <feature name> <variable name> <assign> <value> ;

Here <type> is one of 'headside', 'noheadside', '@headside' and '@noheadside'.
This specifies headside/noheadside and obligatory/non-obligatory attributes.
With '@', the feature is obligatory, otherwise it is non-obligatory.

<feature name> is used to say what feature this is. Only the features of same
<feature name> can check each other.

<variable name> is used to get the feature value or call child function from
the function. About function, I will explain later.

<assign> is one of '=' and ':'. If '=' is used, the feature is inherent and
the value is specified by <value>. If ':' is used, the feature is non-inherent
and the default value is specified by <value>.


Following (1)-(3) figures an example of tree construction. A, B and C are
classes.

I will give an assumpion;
A has a feature F of (noheadside/inherent/obligatory/value=10).
B has a feature F of (headside/non-inherent/obligatory/value=undef) and a
feature G of (headside/non-inherent/obligatory/value=undef).
C has a feature G of (noheadside/inherent/obligatory/value=20).

    (1)A  B  C
    (2)[A (B)] C
    (3)[([A (B)]) C]

At first, A, B and C appears in this order. --(1)
A and B have same feature(F), so they checks each other and create [A (B)].
                                            --(2)
The top of [A (B)] is B, so the tree has feature G. G of [A (B)] is checked
with G of C, then create [([A (B)]) C].     --(3)

In this case, A B C create one tree structure. So this successes.
And the value of F of B becomes 10, because it is checked with F of A.
Similary, the value of G of B becomes 20.

If, for example, G of C is headside, [A (B)] and C can not merge. Then this
is failed because they can not create one tree structure.


====EXECUTE TREE====
The field of <functions> begins with '//$' and end with '//$'.
There you can write Java functions. Only you must do is to write wbMain
function.

    public int wbMain(String args[]) {
        ....
    }

When tree is executed, this function in the top of the tree is called 
(ie. an entry point).

In the function, you can use Java expression. And you can call function of
child in this way.

    ($<class name>$<variable name>).<function name>(<args>) ;

Here <class name> is the label of child class. <variable name> is the feature
that is used to create tree with the child class. <function name> is the
function in the child class. 
<args> is arguments to the function.

This expression is difficulit to use, because usually <class name> is not
determined until tree is created.

wbMain of child can be called in this special way.

    eval("<variable name>", <args>) ;

Here <class name> is not necessary to call the child wbMain function. 

If class A has a headside feature whose <feature name> is F and
<variable name> is f1, and class B has a noheadside feature whose
<feature name> is F and <variable name> is f2, under some condition,
A and B can create a tree [(A) B].
In this case, top of the tree is A, so A.wbMain is called at first. 

If A.wbMain is described like this:

    int wbMain(String args[]) {
        eval("f1", args);
        return 0;
    }

then B.wbMain is called. Here f1 expresses the child class B, because
feature of B (ie. f2) is checked with f1.

Expression like natural language is also possible in this function.

    NLP("<string>") ;

Here <string> is analized in the same way previously explained, a tree is
created and executed.

In <string>, you can use %<variable name> to specify the child class.
"%f A B" means "<the child class> A B".


====HISTORY====

2002/11/02 Test version originally created.


====BUGS====

Maybe alot...


====TODO====

Re-design it.
Make some useful samples.
