Hey guys, noob here in dire need of help.

I am preparing for an exam on Compilers and I have serious trouble answering some --seemingly simple --- questions concerning the FLEX logical analyser.

I know, the first thing is for me is to go back to my notes and try harder, but sadly my lecturer just makes little sence to me (and others in the class, to that extent). I have read a few things on the Wikipedia article (doesn't help much) and I would like to ask any experts for help on these two questions (and hopefully I'll get it, the same way that Pavlov fed his dogs!)

Here's the questions:

1(i) In a programming languge, we declare variables as follows:

var name1,name2,.... : integer;

othername1,othername2,... : real;

otherothername1,... : boolean;

other4name1,... : char;

(a) Write a real life example of a variable declaration in this language.

(b) Construct the syntactic diagram (this is about circles,squares and arrows

and pretty frustrating, arrgh!)

(c) Define the variables in Backus-Naur form.

(d) Write the associated LEX program in C.

(e) Define the tokens, lexemes and patterns existing in this process.

(e) Define a formal expression regarding variable declaration in this language

and construct the relevant finite automaton.

Ok, and the second one goes...

2) A subset of a natural language contains these sentences:

1) Triangle ABC.

2) Line Segment AB.

3) Angle A.

In this set, names of triangles are formed by putting three letters together,

all drawn from the alphabet {A,B,C,D,E}. Line segment names are defined by

putting two letters together from the previous alphabet. And angle names are

(suprise!) given by any letter in that alphabet.

a) Write a LEX program (i know this is in C) that identifies words from the previous set of phrases, such that an input of the form "triangle BCD" returns:

---Triangle: a geometric entity (lol at that)

---BCD: name of a geometric entity

b) Define the tokens, lexemes and patterns to be found in formal expressions concerning these three sentences.

c) Construct the finite automaton that corresponds to the formal expressios to describe the names of geometric entities in that language. Use this to see if the name AYZ is recognizable.

Here they are. 1) a) i can do, so I would really appreciate any help with all the rest.

Thanks in advance.

I am preparing for an exam on Compilers and I have serious trouble answering some --seemingly simple --- questions concerning the FLEX logical analyser.

I know, the first thing is for me is to go back to my notes and try harder, but sadly my lecturer just makes little sence to me (and others in the class, to that extent). I have read a few things on the Wikipedia article (doesn't help much) and I would like to ask any experts for help on these two questions (and hopefully I'll get it, the same way that Pavlov fed his dogs!)

Here's the questions:

1(i) In a programming languge, we declare variables as follows:

var name1,name2,.... : integer;

othername1,othername2,... : real;

otherothername1,... : boolean;

other4name1,... : char;

(a) Write a real life example of a variable declaration in this language.

(b) Construct the syntactic diagram (this is about circles,squares and arrows

and pretty frustrating, arrgh!)

(c) Define the variables in Backus-Naur form.

(d) Write the associated LEX program in C.

(e) Define the tokens, lexemes and patterns existing in this process.

(e) Define a formal expression regarding variable declaration in this language

and construct the relevant finite automaton.

Ok, and the second one goes...

2) A subset of a natural language contains these sentences:

1) Triangle ABC.

2) Line Segment AB.

3) Angle A.

In this set, names of triangles are formed by putting three letters together,

all drawn from the alphabet {A,B,C,D,E}. Line segment names are defined by

putting two letters together from the previous alphabet. And angle names are

(suprise!) given by any letter in that alphabet.

a) Write a LEX program (i know this is in C) that identifies words from the previous set of phrases, such that an input of the form "triangle BCD" returns:

---Triangle: a geometric entity (lol at that)

---BCD: name of a geometric entity

b) Define the tokens, lexemes and patterns to be found in formal expressions concerning these three sentences.

c) Construct the finite automaton that corresponds to the formal expressios to describe the names of geometric entities in that language. Use this to see if the name AYZ is recognizable.

Here they are. 1) a) i can do, so I would really appreciate any help with all the rest.

Thanks in advance.