anch.org: Anchor

Another Nifty Coding Helper.

Version: 1.3

Anchor: for  i=5;i--;  C: for (i=5;i--;){

Why Anchor?

Anchor saves typing and makes programs easier to read.

Techies might refer to it as a language-independent pseudocode compiler.

Installation

Download and extract the archive.

unzip anchor.zip
cd anchor

Run "make" from within the newly extracted directory.

make
su -c 'make install'

Programming with Anchor

The rules are very simple. A double-space, "  " (tells anchor to enclose the rest of the line in parenthesis). Indentation of 4 spaces {controls the placement of curly brackets}. The remaining lines are automatically terminated with semicolons; any of these rules can be broken by placing your own semicolon ;, space, bracket {, /* comment */ or // at the end of the line, causing the precompiler to skip the line in question.

Compilation

Anchor is designed around C, but it should work with most other curly bracket languages, like Java, PHP and .NET as well. Programs are compiled by putting "anch" in front of the compiler you already use.

make example
anch gcc example.a.c -o example

"Anchored" code can be exported without compilation:

anchor example.a.c > example.c

Experimental "un-anchoring" of code is provided. (requires GNU indent)

unanchor example.c #see how it would look
unanchor example.c > editme.a.c # create a file

see an unanchored C windows program

TCC integration

With TCC installed, you can run Anchor programs directly from the command line.

anch -run example.a.c

Or put the following line

#!/usr/local/bin/anch -run

at the top of files to make executable C scripts:

#!/usr/local/bin/anch -run
#include <stdio.h>
int main  int c, char **v
    while  c--
        printf  "Argument %i is \"%s\"\n",c,v[c]
    return 0

Direct execution

Anchor can use TCC to execute through a pipe. For example, if you have both xsel and TCC installed, you could highlight the above code with the mouse and run it immediately from the selection buffer (without even saving to disk).

xsel | anch -run - [args]

I made a pre-release Linux (RPM) version of TCC here

Changelog

Tue Apr 27 2010 1.3 String arrays can be defined like this:

    char a[6][10]= "rain gear", "boots", "nets",
        "skiff", "outboard", 0
Thu Apr 15 2010 1.2 TCC Integration.

Wed Apr 14 2010 1.1 Buffered comments. Quoted strings. Support for structs & arrays. Lots of bug fixes.

Mon Apr 12 2010 1.0 Completely re-written using flex, a lexical analyzer and parser generator.

Limitations and Copyright

No warrantee! Anchor was created as a learning toy for hobbies and fun; it might lack the swagger of commercial projects. The algorithm is potentially lossy and subject to change, so don't write important software that depends on it. C is a difficult language and Anchor is not guaranteed to make it easier. Our "precompiler", anch is just a simple bash script that creates a temp file and invokes whatever compiler you normally use. You are free to adapt it to your needs under the terms of the Gnu Public License.

Anchor and accompanying documentation is Copyright © 2010 Henry Kroll III. You are free to share, adapt and re-distribute this page under the terms of the Creative Commons SA license inasmuch as it agrees with the terms of the GPL. Any of the above conditions can be waived if you get permission from the copyright holder.

 Anchor
CONTACT
WEBSITE
DOWNLOAD
LISCENSE
FAVORITE
BlinkList
del.icio.us
Digg it
Furl
ma.gnolia
Netvouz
RawSugar
Shadows
Simpy
Spurl
Yahoo MyWeb
Google
DZone
StumbleUpon
Create Social Bookmark Links