Development

Grammar (LL1)

Terminal Symbols

Nonterminal Symbols

Start Symbol

Rules

  1. S ->
  2. S -> function func_name ( Params ) { Block } S
  3. S -> Cmd S
  4. Params -> var Params_c
  5. Params ->
  6. Params_c -> , var Params_c
  7. Params_c ->
  8. Cmd -> { Block }
  9. Cmd -> ;
  10. Cmd -> E ;
  11. Cmd -> return Ee ;
  12. Cmd -> break ;
  13. Cmd -> continue ;
  14. Cmd -> while ( E ) Cmd
  15. Cmd -> for ( Ee ; Ee ; Ee ) Cmd
  16. Cmd -> if ( E ) Cmd Cmd_c
  17. Cmd_c -> else Cmd
  18. Cmd_c ->
  19. Block -> Cmd Block
  20. Block ->
  21. Ee -> E
  22. Ee ->
  23. E -> A E_c
  24. E -> - A E_c
  25. E -> ! A E_c
  26. E_c -> = A E_c
  27. E_c -> += A E_c
  28. E_c -> -= A E_c
  29. E_c -> *= A E_c
  30. E_c -> /= A E_c
  31. E_c -> %= A E_c
  32. E_c ->
  33. A -> B A_c
  34. A_c -> || B A_c
  35. A_c ->
  36. B -> C B_c
  37. B_c -> && C B_c
  38. B_c ->
  39. C -> D C_c
  40. C_c -> < D C_c
  41. C_c -> > D C_c
  42. C_c -> <= D C_c
  43. C_c -> >= D C_c
  44. C_c -> == D C_c
  45. C_c -> != D C_c
  46. C_c ->
  47. D -> F D_c
  48. D_c -> + F D_c
  49. D_c -> - F D_c
  50. D_c ->
  51. F -> G F_c
  52. F_c -> * G F_c
  53. F_c -> / G F_c
  54. F_c -> % G F_c
  55. F_c ->
  56. G -> bool_val
  57. G -> int_val
  58. G -> float_val
  59. G -> string_val
  60. G -> ( E )
  61. G -> ++ var
  62. G -> -- var
  63. G -> var G_c
  64. G -> func_name ( L )
  65. G_c -> ++
  66. G_c -> --
  67. G_c ->
  68. L -> E L_c
  69. L ->
  70. L_c -> , E L_c
  71. L_c ->

Parsing Table

Parsing table for LL1 grammar was generated by the script parsingtbl.php (unknown license, local copy), which was written by L. Vagner. The output of the script is here.

Semantics

Semantics table

Nonterminal Inheritable Synthesized
S
Params rettree
Params_c rettree
Cmd rettree
Cmd_c rettree
Block rettree
Ee rettree
E rettree
E_c optree rettree
A rettree
A_c optree rettree
B rettree
B_c optree rettree
C rettree
C_c optree rettree
D rettree
D_c optree rettree
F rettree
F_c optree rettree
G rettree
G_c optree rettree
L rettree
L_c rettree

Semantic rules

  1. nothing;
  2. global_block.push_back(Cmd.rettree);
  3. context.AddFunction(new function(name, Params.rettree, Block.rettree));
  4. Params.rettree = Params_c.rettree; Params.rettree.push_front(var.name);
  5. Params.rettree = NULL;
  6. Params_c_0.rettree = Params_c_1.rettree; Params_c_0.rettree.push_front(var.name);
  7. Params_c.rettree = NULL;
  8. Cmd.rettree = Block.rettree;
  9. Cmd.rettree = NULL;
  10. Cmd.rettree = E.rettree;
  11. Cmd.rettree = Ee.rettree;
  12. Cmd.rettree = new break;
  13. Cmd.rettree = new continue;
  14. Cmd.rettree = new loop(NULL, E.rettree, NULL, Cmd.rettree);
  15. Cmd.rettree = new loop(Ee_0.rettree, Ee_1.rettree, Ee_2.rettree, Cmd.rettree);
  16. Cmd.rettree = new ifelse(E.rettree, Cmd.rettree, Cmd_c.rettree);
  17. Cmd_c.rettree = Cmd.rettree;
  18. Cmd_c.rettree = NULL;
  19. Block_0.rettree = Block_1_rettree; Block_0.rettree.push_front(Cmd.rettree);
  20. Block.rettree = NULL;
  21. Ee.rettree = E.rettree;
  22. Ee.rettree = NULL;
  23. E_c.optree = A.rettree; E.rettree = E_c.rettree;
  24. E_c.optree = A.rettree; E.rettree = new op_minus(E_c.rettree);
  25. E_c.optree = A.rettree; E.rettree = new op_not(E_c.rettree);
  26. E_c_1.optree = A.rettree; E_c_0.rettree = E_c_1.rettree;
  27. E_c_1.optree = A.rettree; E_c_0.rettree = new op_plus_as(E_c_1.rettree);
  28. by analogy
  29. by analogy
  30. by analogy
  31. by analogy
  32. E_c.rettree = E_c.optree;
  33. by analogy
  34. by analogy
  35. by analogy
  36. by analogy
  37. by analogy
  38. by analogy
  39. by analogy
  40. by analogy
  41. by analogy
  42. by analogy
  43. by analogy
  44. by analogy
  45. by analogy
  46. by analogy
  47. by analogy
  48. by analogy
  49. by analogy
  50. by analogy
  51. by analogy
  52. by analogy
  53. by analogy
  54. by analogy
  55. by analogy
  56. G.rettree = new bool_value(bool_val.value);
  57. by analogy
  58. by analogy
  59. by analogy
  60. G.rettree = E.rettree;
  61. G.rettree = new pre_inc(var.name);
  62. by analogy
  63. G_c.optree = new variable(var.name); G.rettree = G_c.retree;
  64. G_c.optree = new function_call(func_name.name, L.rettree);
  65. G_c.rettree = new post_inc(var.name)
  66. by analogy
  67. G_c.rettree = G_c.optree;
  68. L.rettree = L_c.rettree; L.rettree.push_front(E.rettree);
  69. L.rettree = NULL;
  70. L_c_0.rettree = L_c_1.rettree; L_c_0.rettree.push_front(E.rettree);
  71. L_c.rettree = NULL;
Valid XHTML 1.1
Valid CSS