Tutorial

Subject Verb Object Pattern

// Joe saw Jane.
Joe.see-(Jane);

Babel is composed of sentences. Each sentence ends with a semi-colon. The “//” mark indicates a line comment, which means that the text following it will be ignored by the parser. Whitespace is ignored by the parser which means that you could put spaces or line breaks anywhere and it will still parse the same.

Sentences follow a Subject-Verb-Object pattern. The subject of the sentence is usually first. This is followed by a dot to separate the verb. Then the object of the sentence is enclosed in parenthesis. This follows a C++, C# or Java pattern of object.method(argument).

In natural language we use morphology to change the sound and spelling of words to indicate things like plurals and tensing . In Babel this information is pulled out of the words and added as special characters. The past tensing of the verb “saw” in the example is done with a minus sign attached in a suffix like manner. A plus sign is used for future tense words and if no suffix is present then present tense is assumed for the verb.

Nouns are always capitalized. Currently there is no way to indicate that a noun a proper noun. In spoken English this is specified by the absence of an article (e.g. “the”, “a” or “an”.)

Implicit Subjects and Sentence as an Object

// See Jane run.
You.see(Jane.run());
see(Jane.run());

Whenever the initial subject is left off, an implicit noun “You” is used as the subject. The above sentences are logical equivalents. In English we often drop and make implicit the subject of a sentence when it is the person we are speaking to.

The object of the sentence is another sentence. The object of a sentence can be empty, a noun, a set of nouns, another sentence, or just an adjective. Unlike computer programming languages there is max of only one object of a sentence. Information that you would think would be used for multiple arguments would probably be attached directly to the verb as a prepositional phrase.

Adjectives and Adverbs

// The tall man walked slowly.
Man tall.walk- slow();

In this sentence the adjective “tall” is attached to the noun “Man” and adverb “slow” is attached to the verb “Walk”.

The suffix “-ly” is dropped from “slowly”. When English is spoken the suffix is used to indicate that it’s an adverb, but in Babel that is made explicit by the formatting.

There is no object of this particular sentence so the parentheses are left empty.

Prepositional Phrases and Restrictive Clauses

// The quick brown fox jumped over the lazy dog.
Fox quick brown.jump- over[Dog lazy]();

// The horse that I rode died.
Horse that[I.ride-()].die-();

The prepositional phrase “over the lazy dog” is attached to the verb “jump”. Prepositions are attached as if they were adverbs followed by the object of the proposition contained in square brackets.

Restrictive clauses are handled much like a prepositional phrase, but they are instead attached to a noun.

In the reference implementation when these prepositional phrases and restrictive clauses are parsed they are created as adverb and adjective objects but have the contents of the brackets attached.

Declarations

// Joe is tall.
Joe.is(tall);
Joe.tall;

// Joe was tall.
Joe.is-(tall);

// Joe is a human.
Joe.Human;

The top two statements are logically identical. When the verb is left off the verb is assumed to be “is”.

Unfortunately there is no shorthand for was, so in order to express the past tense you have to explicitly use the “is” verb with a past tense suffix.

When the object in a declaration is a noun then the sentence is saying that the subject is a subclass of the object.

Noun Sets

// Tashonda sent e-mail, cards, and letters.
Tashonda.send-(Email & Card* & Letter*);

// Tashonda sent e-mail, cards, or letters.
Tashonda.send-(Email | Card* | Letter*);

// Mrs. Doubtfire gave Tabitha and Samantha quizzes.
MrsDoubtfire.give- to[Tabitha & Samantha](Quiz*);

// Juanita and Celso worked hard.
Juanita & Celso.work- hard();

Anywhere that a noun can be used a set of nouns can be used instead. Simply chain them together with ampersands for an and set and using pipes for or set. You can not mix and and or in a single set.

Also note that the asterisk is used as a suffix to specify a plural.

Gerunds

// I love running.
I.love(Run=);

// Charles is working in the garden.
Charles.Work= in[Garden];

A gerund is a noun that is built from a verb by attaching an “-ing” suffix. Note that the gerund words are capitalized since they are nouns.

The “-ing” suffix is also attached to present tense participles, which are verbs that are used as adjectives, but there is no support in Babel yet for participles.

Questions

// Where are you going?
where(You.are(Go=));

// What were you reading this morning?
what(You.read- this[Morning]());

// May I postpone this assignment?
may(I.postpone(Assignment));

// Is Joe tall?
is tall(Joe);

// Where is Joe?
where(Joe);

// What is the color of horse that I am riding?
what color(Horse that[I.is-(Ride=)]);

Questions are written with the interrogative word as a verb.

Questions usually use an implicit subject, so a subject of “You” is attached to the question when parsed. Asking a question is technically giving an order since an answer is being demanded.

Currently the parser is hard coded to recognize specific interrogatives. This is less than ideal since it makes the parser English specific and in the future a symbol may be introduced to indicate that a statement is a question.

Babel Limitations

Babel is very much a work in progress. Below are some of the areas that may be improved upon.

Conjunctions

Most conjunctions are not currently available in the language. Complex sentences can not easily be expressed without them.

Articles

The language does not support articles (a, an, and the) right now. In natural language these are used to indicate that a noun is proper. It’s questionable whether this information is important enough be included in the language.

If support for articles was added it might take the form of adding an underscore before or after the noun. Or the articles could be added as adjectives, something which could be done right now.

Questions

Currently the parser is hard coded to recognize specific interrogatives. This is less than ideal since it makes the parser English specific and in the future a symbol may be introduced to indicate that a statement is a question.

Modifiers

Words that modify an adjective or adverb (e.g. very, slightly, rather, quite) can not be expressed properly. For instance, it is not really possible to say “the very black dog” since the modifier “very” needs to be attached to the adjective “black” and not the noun “dog”.

Negatives (e.g. The dog that is not running.) would also need to be attached as a modifier.

A Language for Thoughts