Archive

Posts Tagged ‘ogc’

ogc 6.0rc2

July 18th, 2011 subogero Comments off

ogc 6.0 rc2 is out for the general public to enjoy. It now supports any number of user defined variables in the form of $FOO or $SPAM. Dollar sign plus all-caps. I know, it’s somewhat LarryWallesque. The dollar-sign, not the all-caps, you understand.

Just to show the severity of my mental state, I’ve implemented “hash-buckets” in C. With vi.

ogc 5.0

May 7th, 2011 subogero Comments off

The new version of the Lazy Man’s calculator maximizes laziness by taking your expressions directly from the command line. No pipes, no interactivity, no interpreter-scripts. Just what the customer wants.

$ ogc -e 2*21
42

The clever customer can actually take ogc’s laziness to even greater extremes. Just add the following line to ~/.bashrc

alias og='ogc -e'

And voilá:

$ og xFFd
255

You can download sources and Linux/Win32 binaries from the ogc page.

Geeks can clone the git repo as well:

git clone https://github.com/subogero/ogc.git
git clone http://subogero.dyndns.org/git/ogc.git

ogc 4.2 – Math Functions

August 22nd, 2010 subogero Comments off

The introduction of the lex (flex) tokenizer into the ogc development allows an incredible amount of new bloatware to be implemented. The first menacing omen was floating-point support.

And now it’s math functions. Our friends from <math.h> sin, cos, atan, log, exp, sqrt are available as @s @c @a @l @e @r. The little bastards, besides looking very ugly, also perform a sneaky implicit floating-point conversion.

Check it out. But where will this all end?

ogc 4.1 – Floating But Not Sinking

August 3rd, 2010 subogero Comments off

Erm… ogc 4.0 had some certain erm… bugs in its syntax.

But ogc 4.1 is now downloadable from the ogc page. Including native Linux and Windows binaries.

Interpreter Scripts

November 9th, 2009 subogero Comments off

I wanted to turn the ogc calculator into a full-blown interpreter, to be able to create an executable ogc test-script:

#!/usr/bin/ogc
# Test script for ogc.
# Invoke: "ogc Test" or simply "./Test"
# It shall produce the following output:
# 42
# 42
# 42

# 42 hex
11*3*2 x

# 42 oct
 F*2+4 o # Leading space

# 42 dec
 52 d # Leading tab

 # Leading tab and comment

This is called an executable interpreter script, starting with the Shebang line, which tells the kernel which binary program shall run the script.

Unfortunately it did not produce any output, ogc just started waiting for user input in its particularly silly way. What was wrong? I had to find out more about how interpreter scripts and shebangs work in Unix. It turned out the kernel passes the filename of the interpreter scipt as an argument to the interpreter. Upon executing Test, the kernel actually does this:

/usr/bin/ogc Test

Should have thought. A simple stdin-stdout filter is not enough, the interpreter itself shall be able to redirect its input into a specified file.

I modified ogc, so 3.0 can be used in both ways:

ogc Test
./Test

And to make it even more elegant, ogc 3.1 skips printing an output for whitespace/comment-only lines, including the shebang. The test script now does only what it really should: stressing 3 times what Life, Universe and Everything is all about.

Categories: Uncategorized Tags: ,

Manual Pages

August 15th, 2009 subogero Comments off

The day has come, and I’ve started writing documentation, but this time Linux style. In other words, I’ve just created the manual pages for my Newbie-projects, “ogc” and “go“.

Some important points I’ve learned from the Linux Man Page Howto:

Manual pages are written in the “groff” (GNU troff) markup language. Just start from another program’s man page, it’ll be easy.

Manual pages of user-commands shall be installed into “/usr/share/man/man1″

The manual page of user-program “foo” shall be called either “foo.1″ or “foo.1.gz” (gzipped).

To read foo’s manual page, type

man foo

It’s that easy.

Categories: posts Tags: , ,

ogc – The OG Calculator

July 29th, 2009 subogero Comments off

So my yacc studies led me to a series of thoughts about writing my own command-line calculator with integer arithmetics. Which the Windows Calculator is not.

I set the following goals:

  • 32-bit integer arithmetics (don’t ask me why, I just need it at work, OK?)
  • decimal, octal and hexadecimal formats
  • unlimited undo
  • a fair amount of memory registers
  • ability to continue from the last result (+5 should add 5 to the last result)
  • no mouse clicking
  • following Unix/GNU conventions

The program’s called ogc. I wrote it in yacc surprisingly quickly. The related info and the sources are available on my dedicated ogc page.

Categories: posts Tags: , , ,