so im learning the basics of compiler design from this site: http://compilers.iecc.com/crenshaw/tutor1.txt
and it gave me this code (which can be found at the bottom) (i dont know what language it is. it says 68000 Assembly but it didnt look like any flavor of assembly ive ever seen or the 68000 examples ive googled) and since i dont know how to write in it i decided to use c++. so anyways, this is my first attempt. did i translate it correctly? (note im not asking for advice on how to do it better. that will come later with the finished product)
edit: the i couldnt figure out what the := operator did so i assumed it meant return, because the only other thing i could think of was call itself, but that would become infinite recursion
edit 2: the second page said it was "turbo pascal" which im still not familiar with, but just fyi
I think what he's saying is that you'll eventually convert this into 68k. You'll probably do this later in the tutorials. I'm sure there'll be a code generator section.
yeah i misunderstood. i looked up a turbo pascal tut afterwords and figured it all out. := isnt return (didnt make much sense but it was the only thing i could think of). its like gos assignment operator. it infers type based on value
$ g++ test.cpp -o test
test.cpp: In function ‘void Match(char)’:
test.cpp:65:40: error: invalid conversion from ‘int’ to ‘const char*’ [-fpermissive]
In file included from /usr/lib/gcc/i686-pc-cygwin/4.7.3/include/c++/string:55:0,
from /usr/lib/gcc/i686-pc-cygwin/4.7.3/include/c++/bits/locale_classes.h:42,
from /usr/lib/gcc/i686-pc-cygwin/4.7.3/include/c++/bits/ios_base.h:43,
from /usr/lib/gcc/i686-pc-cygwin/4.7.3/include/c++/ios:43,
from /usr/lib/gcc/i686-pc-cygwin/4.7.3/include/c++/ostream:40,
from /usr/lib/gcc/i686-pc-cygwin/4.7.3/include/c++/iostream:40,
from test.cpp:1:
/usr/lib/gcc/i686-pc-cygwin/4.7.3/include/c++/bits/basic_string.tcc:214:5: error: initializing argument 1 of ‘std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ [-fpermissive]
test.cpp: In function ‘void Expression()’:
test.cpp:99:31: error: invalid operands of types ‘const char*’ and ‘const char [4]’ to binary ‘operator+’
you shouldnt base anything off post count. i post a lot in lounge. im living proof that high post count has nothing to do with skill. however, i did try but i couldnt figure it out. i gave it up though, because i figured i could either continuing translating pascal code writing shell programs, or write my own full bodied compiler based off the stroustrop calculator, which gives me more freedom and flexibility.