I Hate Grammar

I hate grammar. I learned the English language when I was 9 years old (as it is not my native language) while trying to read the manual of QuickBasic under DOS. By the time we actually got English lessons in school I was years ahead of most people in my class and even up to the end of high school I never had to read the books we used in school. Instead I read a lot of English books which provided enough sence for the language to stay clear of any official grammar.

But I am drifting here. The problem in computer land is that we use grammar. Every programming language uses a grammar to allow a human to tell the computer what it should do.

Right now I am working on a project where we want to compile Matlab code into C or C++, feed it to GCC and finally upload it into a Virtex IV FPGA. The FPGA has a Sparc V8 compatible CPU (the Leon 2 to be exact) and has a number of auxiliary processorswhich are dedicated for mathematical calculations. For those who care: we are using Montium cores for the calculations.

Even though we pretty much have solved how to drive the whole thing in theory (not in real life as we are just starting), putting it all together is a bit harder.

It starts with the Matlab interpreter and the grammar needed for the interpreter. I’ve been working with ANTLR in the past to generate a compiler for my own toy language. It supported pretty much everything the old QuickBasic language did except the syntax was much more like Java.

I installed ANTLRWorks to use the shiny new GUI to speed up stuff and immediately ran into a wall: Matlab uses a syntax which sometimes end a statement with a semi-colon (‘;’) and sometimes not, depending if the programmer wants to see intermediate results. I am trying to base my grammar on Java here as it is nice and strict – but stuff like this is rapidly making the adaption a pain in the …

Another hair puller is the syntax of the ‘if’ statement: no block structure… Another one lacking the block structure is the function definition. As we are targeting mathematical speedup here and our Virtex board has no display, I will probably sacrifice some stuff to simplify the compiler.

Right now I’m keeping integers and booleans, logic structures like ‘if’-‘else’ and ‘for’ loops. Floating points, bit operators, function definitions and calls – all have to go. Perhaps I will re-add them later on when needed but right now I don’t see any reason to keep them around.

As soon as I got my sub-set grammar complete I will put it up on my site as nobody on the internet seems to have done this before (I found posts from 1992 with no solutions…).

Japan Blog Study Tour

Ambient systems and voices

IMG_3383 Today we went to Ginza to test a new system. Ginza is a region in Tokyo with all kinds of fancy stores (read: expensive) with all the big names next to each other, from Chanel to Louis Vuiton. We started out in the underground passage next to the A3 exit where the experiment would begin. Everyone got a PDA with some ridiculous name and a wristband with an RFID reader inside of it. Next, you put on the headphones and the system would guide you to the surface. It immediately went wrong: we walk a lot faster than Japanese people so we ended up in situations like: "Pass left of the termi…" – "Go straight by…" – "Walk up the stairs on the…" – "Turn around and go back to the crossing with the red booth on your right, this time walk up the stairs on the left". Great…

Japan Blog Study Tour

Little Boy

IMG_2572 Today (Sunday) we went to Hiroshima on a culture day. We jumped on the Shinkansen (Nozomi number 5) to Hiroshima from Kyoto. One of the group had a GPS system for cycling which can show the current speed and other statistics and we clocked the train at a top speed of 303 km/h. At that speed we found a smoking booth between two trains. So after we bought some coffee from a nice young lady on board, we checked out the smoking booth. After some hilarious situations in a small booth with 2 cups of coffee and cigarettes (taking sudden corners at 300km/h is dangerous for people in the vicinity with open mugs) we arrived after 1,5 hours at Hiroshima.