{"id":274,"date":"2008-05-07T01:11:29","date_gmt":"2008-05-07T01:11:29","guid":{"rendered":"http:\/\/blog.cyberwizzard.nl\/?p=274"},"modified":"2016-03-17T21:24:21","modified_gmt":"2016-03-17T20:24:21","slug":"i-hate-grammar","status":"publish","type":"post","link":"https:\/\/blog.cyberwizzard.nl\/?p=274","title":{"rendered":"I Hate Grammar"},"content":{"rendered":"<p align=\"left\">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.<\/p>\n<p align=\"left\">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.<\/p>\n<p align=\"left\">Right now I am working on a project where we want to compile <a href=\"http:\/\/www.mathworks.com\/products\/matlab\/\" target=\"_blank\">Matlab<\/a> code into C or C++, feed it to GCC and finally upload it into a <a href=\"http:\/\/www.xilinx.com\/products\/silicon_solutions\/fpgas\/virtex\/virtex4\/index.htm\" target=\"_blank\">Virtex IV<\/a> FPGA. The FPGA has a Sparc V8 compatible CPU (the <a href=\"http:\/\/www.gaisler.com\/leonmain.html\" target=\"_blank\">Leon 2<\/a> to be exact) and has a number of auxiliary processorswhich are dedicated for mathematical calculations. For those who care: we are using <a href=\"http:\/\/www.recoresystems.com\/index.php?option=com_content&#038;task=view&#038;id=73&#038;Itemid=111\" target=\"_blank\">Montium<\/a> cores for the calculations.<\/p>\n<p align=\"left\">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.<\/p>\n<p align=\"left\">It starts with the Matlab interpreter and the grammar needed for the interpreter. I&#8217;ve been working with <a href=\"http:\/\/www.antlr.org\/\" target=\"_blank\">ANTLR<\/a> 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.<\/p>\n<p align=\"left\">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 (&#8216;;&#8217;) 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 &#8211; but stuff like this is rapidly making the adaption a pain in the &#8230;<\/p>\n<p align=\"left\">Another hair puller is the syntax of the &#8216;if&#8217; statement: no block structure&#8230; 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.<\/p>\n<p align=\"left\">Right now I&#8217;m keeping integers and booleans, logic structures like &#8216;if&#8217;-&#8216;else&#8217; and &#8216;for&#8217; loops. Floating points, bit operators, function definitions and calls &#8211; all have to go. Perhaps I will re-add them later on when needed but right now I don&#8217;t see any reason to keep them around.<\/p>\n<p align=\"left\">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&#8230;).<\/p>\n<div class=\"bleezer-tags:Antlr, Matlab, Grammar, Sparc, Montium\">\n<p style=\"font-size:10px;text-align:right;\">Technorati: <a href=\"http:\/\/www.technorati.com\/tag\/Antlr\" rel=\"tag\">Antlr<\/a> <a href=\"http:\/\/www.technorati.com\/tag\/Matlab\" rel=\"tag\">Matlab<\/a> <a href=\"http:\/\/www.technorati.com\/tag\/Grammar\" rel=\"tag\">Grammar<\/a> <a href=\"http:\/\/www.technorati.com\/tag\/Sparc\" rel=\"tag\">Sparc<\/a> <a href=\"http:\/\/www.technorati.com\/tag\/Montium\" rel=\"tag\">Montium<\/a><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[191,40,195,190,189,193,460,459,194,115,82,192],"class_list":["post-274","post","type-post","status-publish","format-standard","hentry","category-programming","tag-always","tag-and","tag-brain","tag-grammar","tag-hate","tag-hated","tag-no_ok","tag-not_ok","tag-school","tag-went","tag-when","tag-will"],"views":1362,"_links":{"self":[{"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=\/wp\/v2\/posts\/274","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=274"}],"version-history":[{"count":1,"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=\/wp\/v2\/posts\/274\/revisions"}],"predecessor-version":[{"id":456,"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=\/wp\/v2\/posts\/274\/revisions\/456"}],"wp:attachment":[{"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=274"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=274"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=274"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}