Skip to content

Instantly share code, notes, and snippets.

@blwsh
Last active April 24, 2021 05:58
Show Gist options
  • Save blwsh/d4f20c1962fc532ee1990a74eb13d733 to your computer and use it in GitHub Desktop.
Save blwsh/d4f20c1962fc532ee1990a74eb13d733 to your computer and use it in GitHub Desktop.
Readable Language Translators Spec

Spec

Question 2 (50%)

Create your own more advanced interpreted programming language called MYPL. You must do this using the already written TLM as a base. In other words starting from the components of TLM, build up your own language and interpreter. Your language must have the following enhancements:

  1. Boolean expressions in TLM only have one operator: \>". Build into MYPL the use of more boolean operators such as <, ==, =< etc.

  2. Build into MYPL the statement

    \if < booleanexpression > then < statement1 >
    else < statement2 >"
    

    with the usual meaning.

  3. Build into MYPL a simple function declaration structure.

    For the sake of this coursework, your implementation of a function can be as follows:

    • Only one function can be declared and it must be declared at the beginning of the program.

    • The function has no name or parameters.

    • All the variables used in the function are global.

    • The function is called by the statement \call", and it can be called as many times as needed in the main part of the program. For example, MYPL should be able to execute the following code:

      start;
      function;
      do
      x = x-1;
      y = x*x;
      print(x,y);
      while x > 10 ;
      end;
      x = 23; call; x=15; call;
      finish;
      
  4. Enhance MYPL further - for example by making the function feature more general (e.g. with more that one function being declared).

    You may also add any other useful features to MYPL (e.g. add a FOR loop, add more variable names, add the ability to write comments in the program, make MYPL check the whole of a keyword etc).

Rules

This coursework must be undertaken individually. The deadline for handing in the work is 4pm Wednesday April 10th, 2019.

  • You must hand in for question 1:

    • The grammar
    • Derivation sequence syntax tree
    • Derived FSM
    • Derived shift-reduce parsing table
    • Proof using a stack trace that the correct example is parsed and the incorrect example does not parse.

    YOUR SOLUTION TO QUESTION 1 MUST BE A HARD COPY HANDED IN TO THE STUDENT SUPPORT OFFICE BY HAND.

  • You must hand in for question 2:

    • The two les parser.cup and scanner.java dening your nal language. This must allow me to generate an interpreter using JavaCup and validate your tests.

    • Several test programs and screen shots of their execution showing the use of ALL the new features in your language and showing the correctness of your code. If you do not include tests with associated screen shots of the new features of MYPL, they will be assumed not to work,

    • A written report including the following: a statement of what you have achieved in Question 2; and documentation describing HOW you have upgraded TLM for Question 2.

      Here you must explain in your own words how the code you have added to TLM works, any decisions of it, and any future extensions you could achieve given more time.

      YOUR SOLUTION TO QUESTION 1 MUST BE HANDED IN ELECTRONICALLY VIA BRIGHTSPACE.

    • Marking Criteria and Scheme: The coursework assesses the following ability outcomes of the module: * Knowledge (4) and (5), Ability (8). It also, in part, examines outcome Ablity (6). It makes up 50 per cent of your 20 credit module. * QUESTION 1 Criteria: Correctness of your gram- mar, FSM, parsing table, stack trace of the example parse and documentation. Marking Scheme:

        1: (8%); 
        2: (10%);
        3: (24%);
        4: (8%); 
      

To pass

You must at least demonstrated you can create a grammar and translate it into a FSM and then a parsing table, though you may have made some major mistakes.

  • Over 50%

    Your parsing table creation is faithful with respect to the grammar you produce, (there may be S-R conflicts, and some errors, but the method is sound) and you have made a reasonable attempt at generating a stack trace of the example parse and counter-example.

  • Over 60%

    As above, but your grammar is correct, your parsing table is created correctly with respect to the grammar but may have S-R conflicts. You may have some minor errors.

  • Over 70%

    As above, but your grammar is correct and leads to a conflict free parsing table. You may have some minor errors.

  • Over 85%

    Your grammar is correct

@MalaVijaity
Copy link

what is the answer of this question???

@amina408
Copy link

answer of LTM question

@MalaVijaity
Copy link

MalaVijaity commented Apr 24, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment