CSE 130 - Programming Assignment #4 FAQ

  1. How do we skip whitespace in nanoLex.mll?

  2. See hint in http://cseweb.ucsd.edu/classes/fa14/cse130-a/parser_notes/beLexer.mll

  3. In 2a do we have to check if both parts of a binary expression is int?

  4. Yes. And raise a properly worded MLFailure exception otherwise.

  5. Do we have to parse negative values?

  6. No.

  7. There is no specific constructor for Plus/Minus/Div other binary operations.

  8. Use the Bin constructor for all of those.

  9. Does the grader care about the exact text in MLFailure exceptions?.

  10. No. Put something reasonable/understandable.

  11. What does lookup do when it doesn't find a variable in the environment?.

  12. Raise a properly worded MLFailure exception.

  13. What does eval([], Var "hd") return in the extra credit part?.

  14. Thanks to Val:

    1. Add
          type value = ...
                     | Native of string
      
    2. Now if your lookups succeed, check whether it was one of the hd or tl function, and return Native("hd") and Native("tl")
    3. In App, deal with the case where the function expression evaluates to a native function, and run the appropriate OCaml code to execute this function
    In that setting, your result should be:
    # open Nano;;
    # eval ([], Var "hd");;
    - : Nano.value = Native "hd"
    # eval ([], Let("hd", Const(0), Var "hd"));;
    - : Nano.value = Int 0
    

  15. Do we have to ensure that the then and else branch of an if have the same type as in ocaml?

  16. Nope.