Page 4 of 4
Re: Writing a compiler - how?
Posted: Fri May 04, 2012 5:20 am
by JuEeHa
turdus wrote:
For me at the university in the first 2 semesters we learned programming by only matchematical mean with paper and pencil. I'm pretty sure you cannot imagine this (or even imagine how to learn programming without a computer). You can bet most of you would cry if had to understand the matchematical formula of a simple loop (for the courious, I've attached it). So my learning language was math. Later I had courses that tought how specific languages like C, ADA, Eiffel, Java etc. implement that theory.
That seems pretty interesting. Are there any online courses where it would be possible to learn programming that way?
Re: Writing a compiler - how?
Posted: Fri May 04, 2012 6:52 am
by turdus
JuEeHa wrote:That seems pretty interesting. Are there any online courses where it would be possible to learn programming that way?
Don't think so, did not find anything on the university's homepage (only student exchange program). But I've found an english description of the training:
http://www.inf.elte.hu/english/studies/ ... ammes.aspx
Funny how things change, when I attended to (several years ago), there was no such thing, BSc/MSc just an university degree. There was no geoinformatics then, and no media courses.
I feel old...
Re: Writing a compiler - how?
Posted: Fri May 04, 2012 7:13 am
by Combuster
The closest thing to program logic I know is
http://www.cs.uu.nl/docs/vakken/pc/1112 ... s/main.pdf - and fortunately it was in English. It's probably nowhere near ancient CS teachings and it basically works the opposite direction by reducing code to a mathematical representation.
More on topic would be
http://www.cs.uu.nl/wiki/pub/TC/CourseM ... 111101.pdf - I don't have the dragon book so I can't say how much better it is, but this is definitely cheaper
.
Re: Writing a compiler - how?
Posted: Wed May 09, 2012 7:10 am
by JamesM
MessiahAndrw wrote:Rudster816 wrote:I think you need to read your own link
. Number 8 is >, <, >=, <=. Number 13 is &&.
I stand corrected. May explain a couple of bugs I've encountered in the past.
I've got into the habit of explicitly using brackets lately since I deal with many languages day-to-day, just for situations like this!
You were correct, Rudster816 was wrong.
That table is ordered lowest-to-highest precedence. I have my C99 standard open in front of me, but to save me typing it all out I below paste part of the comment from Clang's function "ParseExpression".
Code: Select all
/// multiplicative-expression: [C99 6.5.5]
/// Note: in C++, apply pm-expression instead of cast-expression
/// cast-expression
/// multiplicative-expression '*' cast-expression
/// multiplicative-expression '/' cast-expression
/// multiplicative-expression '%' cast-expression
///
/// additive-expression: [C99 6.5.6]
/// multiplicative-expression
/// additive-expression '+' multiplicative-expression
/// additive-expression '-' multiplicative-expression
///
/// shift-expression: [C99 6.5.7]
/// additive-expression
/// shift-expression '<<' additive-expression
/// shift-expression '>>' additive-expression
///
/// relational-expression: [C99 6.5.8]
/// shift-expression
/// relational-expression '<' shift-expression
/// relational-expression '>' shift-expression
/// relational-expression '<=' shift-expression
/// relational-expression '>=' shift-expression
///
/// equality-expression: [C99 6.5.9]
/// relational-expression
/// equality-expression '==' relational-expression
/// equality-expression '!=' relational-expression
///
/// AND-expression: [C99 6.5.10]
/// equality-expression
/// AND-expression '&' equality-expression
///
/// exclusive-OR-expression: [C99 6.5.11]
/// AND-expression
/// exclusive-OR-expression '^' AND-expression
///
/// inclusive-OR-expression: [C99 6.5.12]
/// exclusive-OR-expression
/// inclusive-OR-expression '|' exclusive-OR-expression
///
/// logical-AND-expression: [C99 6.5.13]
/// inclusive-OR-expression
/// logical-AND-expression '&&' inclusive-OR-expression
///
/// logical-OR-expression: [C99 6.5.14]
/// logical-AND-expression
/// logical-OR-expression '||' logical-AND-expression
///
/// conditional-expression: [C99 6.5.15]
/// logical-OR-expression
/// logical-OR-expression '?' expression ':' conditional-expression
/// [GNU] logical-OR-expression '?' ':' conditional-expression
/// [C++] the third operand is an assignment-expression
///
/// assignment-expression: [C99 6.5.16]
/// conditional-expression
/// unary-expression assignment-operator assignment-expression
/// [C++] throw-expression [C++ 15]
///
/// assignment-operator: one of
/// = *= /= %= += -= <<= >>= &= ^= |=
///
/// expression: [C99 6.5.17]
/// assignment-expression ...[opt]
/// expression ',' assignment-expression ...[opt]