Just cant get my head around these FLEX questions!

This is a discussion on Just cant get my head around these FLEX questions! within the Tech Board forums, part of the Community Boards category; Hey guys, noob here in dire need of help. I am preparing for an exam on Compilers and I have ...

  1. #1
    Registered User
    Join Date
    Mar 2012
    Posts
    2

    Just cant get my head around these FLEX questions!

    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.

    Here's the questions:

    1(i) In a programming language, we declare variables as follows:
    Code:
    var name1,name2,.... : integer;
          othername1,othername2,... : real;  
           otherothername1,...         :  boolean;
         other4name1,...           : char;
    (a) Consider the declaration

    Code:
    var number_of_attendants, sum: integer;
    ticket_price: real;
    symbols: char;
    (b) Construct the syntactic diagram (this is 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. I would really appreciate any help...

    Thanks in advance!

  2. #2
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    Here they are. I would really appreciate any help...
    And what specifically is your question? In general, I would suggest reading your course book and asking your TA
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

  3. #3
    Registered User
    Join Date
    Mar 2012
    Posts
    2
    Quote Originally Posted by QuantumPete View Post
    And what specifically is your question? In general, I would suggest reading your course book and asking your TA




    I only have my class notes to advise, and my lecturer makes little to no sense to me He doesn't explain much and makes me feel dumb when I ask a question (not just me, others in the class agree he is not helpful at all). So I just ask if someone knows how these are solved, so by "reverse engineering" I will be able understand just what's going on.


    Thanks for the reply!

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,598
    So what makes you think you are going to get an answer for that on a C/C++ programming forum?

  5. #5
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Moved to Tech because it's not C++, but a non-featured programming language.

    Also closing, because it violates the homework policy of this site.

    Please reverse-engineer these actions to arrive at correct posting policy.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. i need help with cmake, BISON and FLEX, i am willing to pay
    By Yakir Manor in forum Projects and Job Recruitment
    Replies: 1
    Last Post: 01-17-2012, 04:54 PM
  2. [Flex/Bison] Some questions
    By Leftos in forum C Programming
    Replies: 2
    Last Post: 08-21-2010, 05:16 PM
  3. Flex 3 SDK on Kubuntu
    By sean in forum Linux Programming
    Replies: 3
    Last Post: 12-12-2008, 06:41 PM
  4. C and a bit of yacc/flex
    By -EquinoX- in forum C Programming
    Replies: 1
    Last Post: 10-19-2008, 10:24 AM
  5. flex & YACC question
    By cboard_member in forum Tech Board
    Replies: 2
    Last Post: 03-23-2006, 04:58 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21