Exercises on ANTLR syntactic descriptions

  1. Expressions over binary +
  2. Expressions over binary + (with right associativity)
  3. Expressions over binary + (with AST +(1,2,3,4) for 1+2+3+4)
  4. Expressions over binary + (with AST sum(1,2,3,4) for 1+2+3+4)
  5. Expressions over binary + and -
  6. Expressions over binary + and *
  7. Expressions over binary + and * (with AST +(1,2,*(3,4,5)) for 1+2+3*4*5)
  8. Parenthesized expressions over binary + and *
  9. Parenthesized expressions over binary + and * (with AST +(1,*(+(2,3,4),5,6)) for 1+(2+3+4)*5*6)
  10. Expressions over binary +, -, *, and /
  11. Parenthesized expressions over binary +, -, *, /, and ^
  12. Parenthesized expressions over binary +, -, *, /, and ^ (^ with lower precedence than * and /)
  13. Parenthesized expressions over binary +, -, *, /, and ^ (^ with lowest precedence)
  14. Expressions over unary signs and binary +, -, * and /
  15. Expressions over unary signs and ^
  16. Expressions over unary signs and ^ (^ with highest precedence)
  17. Parenthesized expressions over unary signs and binary +, -, and ^
  18. Parenthesized expressions over unary signs and binary +, -, and ^ (^ with highest precedence)
  19. Parenthesized expressions over unary signs and not, and binary +, -, *, /, <, >, =, and and or
  20. Expressions over binary + and field access with .
  21. Expressions over binary + and indexed access with brackets
  22. Expressions over binary + and function calls
  23. Expressions over binary + and dereferences with ^
  24. Parenthesized expressions over binary +, function calls, indexed access, field access and dereferences
  25. Parenthesized expressions over unary signs and not, binary +, -, *, /, ^, <, >, =, and and or, function calls, indexed access and field access
  26. Lists of items separated by commas with optional ending comma
  27. Conflict resolution: left recursion
  28. Conflict resolution: two valid alternatives with the same lookahead
  29. Conflict resolution: loop may iterate too many times
  30. Conflict resolution: infinite loops
  31. Conflict resolution: AST ambiguity
  32. Number lists
  33. Trade routes
  34. Hierarchic Graphs
  35. Identifiers with subscripts

Extra list of exercises

  1. Simplified grammar for C expressions
  2. Simplified grammar for C declarations
  3. Simplified grammar for C statements
  4. Grammar for Pascal expressions
  5. Grammar for Pascal type definitions
  6. Grammar for Pascal statements