# -*- text -*-
# Parsing Expression Grammar 'TEMPLATE'.
# Generated for unknown, from file 'TEST'

#
# Grammar Start Expression
#

<<MAIN>>:
         call              sym_Expression
         halt

#
# value Symbol 'AddOp'
#

sym_AddOp:
# /
#     '-'
#     '+'

         symbol_restore    AddOp
  found! jump              found_9
         loc_push

         call              choice_7

   fail! value_clear
     ok! value_leaf        AddOp
         symbol_save       AddOp
         error_nonterminal AddOp
         loc_pop_discard

found_9:
     ok! ast_value_push
         return

choice_7:
# /
#     '-'
#     '+'

         error_clear

         loc_push
         error_push

         call              char_2

         error_pop_merge
     ok! jump              oknoast_6

         loc_pop_rewind
         loc_push
         error_push

         call              char_4

         error_pop_merge
     ok! jump              oknoast_6

         loc_pop_rewind
         status_fail
         return

oknoast_6:
         loc_pop_discard
         return

char_2:
# '-'

         input_next        "t -"
     ok! test_char         "-"
         return

char_4:
# '+'

         input_next        "t +"
     ok! test_char         "+"
         return
#
# value Symbol 'Digit'
#

sym_Digit:
# /
#     '0'
#     '1'
#     '2'
#     '3'
#     '4'
#     '5'
#     '6'
#     '7'
#     '8'
#     '9'

         symbol_restore    Digit
  found! jump              found_34
         loc_push

         call              choice_32

   fail! value_clear
     ok! value_leaf        Digit
         symbol_save       Digit
         error_nonterminal Digit
         loc_pop_discard

found_34:
     ok! ast_value_push
         return

choice_32:
# /
#     '0'
#     '1'
#     '2'
#     '3'
#     '4'
#     '5'
#     '6'
#     '7'
#     '8'
#     '9'

         error_clear

         loc_push
         error_push

         call              char_11

         error_pop_merge
     ok! jump              oknoast_31

         loc_pop_rewind
         loc_push
         error_push

         call              char_13

         error_pop_merge
     ok! jump              oknoast_31

         loc_pop_rewind
         loc_push
         error_push

         call              char_15

         error_pop_merge
     ok! jump              oknoast_31

         loc_pop_rewind
         loc_push
         error_push

         call              char_17

         error_pop_merge
     ok! jump              oknoast_31

         loc_pop_rewind
         loc_push
         error_push

         call              char_19

         error_pop_merge
     ok! jump              oknoast_31

         loc_pop_rewind
         loc_push
         error_push

         call              char_21

         error_pop_merge
     ok! jump              oknoast_31

         loc_pop_rewind
         loc_push
         error_push

         call              char_23

         error_pop_merge
     ok! jump              oknoast_31

         loc_pop_rewind
         loc_push
         error_push

         call              char_25

         error_pop_merge
     ok! jump              oknoast_31

         loc_pop_rewind
         loc_push
         error_push

         call              char_27

         error_pop_merge
     ok! jump              oknoast_31

         loc_pop_rewind
         loc_push
         error_push

         call              char_29

         error_pop_merge
     ok! jump              oknoast_31

         loc_pop_rewind
         status_fail
         return

oknoast_31:
         loc_pop_discard
         return

char_11:
# '0'

         input_next        "t 0"
     ok! test_char         "0"
         return

char_13:
# '1'

         input_next        "t 1"
     ok! test_char         "1"
         return

char_15:
# '2'

         input_next        "t 2"
     ok! test_char         "2"
         return

char_17:
# '3'

         input_next        "t 3"
     ok! test_char         "3"
         return

char_19:
# '4'

         input_next        "t 4"
     ok! test_char         "4"
         return

char_21:
# '5'

         input_next        "t 5"
     ok! test_char         "5"
         return

char_23:
# '6'

         input_next        "t 6"
     ok! test_char         "6"
         return

char_25:
# '7'

         input_next        "t 7"
     ok! test_char         "7"
         return

char_27:
# '8'

         input_next        "t 8"
     ok! test_char         "8"
         return

char_29:
# '9'

         input_next        "t 9"
     ok! test_char         "9"
         return
#
# value Symbol 'Expression'
#

sym_Expression:
# /
#     x
#         '\('
#         (Expression)
#         '\)'
#     x
#         (Factor)
#         *
#             x
#                 (MulOp)
#                 (Factor)

         symbol_restore    Expression
  found! jump              found_60
         loc_push
         ast_push

         call              choice_58

   fail! value_clear
     ok! value_reduce      Expression
         symbol_save       Expression
         error_nonterminal Expression
         ast_pop_rewind
         loc_pop_discard

found_60:
     ok! ast_value_push
         return

choice_58:
# /
#     x
#         '\('
#         (Expression)
#         '\)'
#     x
#         (Factor)
#         *
#             x
#                 (MulOp)
#                 (Factor)

         error_clear

         ast_push
         loc_push
         error_push

         call              sequence_41

         error_pop_merge
     ok! jump              ok_57

         ast_pop_rewind
         loc_pop_rewind
         ast_push
         loc_push
         error_push

         call              sequence_54

         error_pop_merge
     ok! jump              ok_57

         ast_pop_rewind
         loc_pop_rewind
         status_fail
         return

ok_57:
         ast_pop_discard
         loc_pop_discard
         return

sequence_41:
# x
#     '\('
#     (Expression)
#     '\)'

         loc_push
         error_clear

         error_push

         call              char_36

         error_pop_merge
   fail! jump              failednoast_43
         ast_push
         error_push

         call              sym_Expression

         error_pop_merge
   fail! jump              failed_42
         error_push

         call              char_39

         error_pop_merge
   fail! jump              failed_42

         ast_pop_discard
         loc_pop_discard
         return

failed_42:
         ast_pop_rewind

failednoast_43:
         loc_pop_rewind
         return

char_36:
# '\('

         input_next        "t ("
     ok! test_char         "("
         return

char_39:
# '\)'

         input_next        "t )"
     ok! test_char         ")"
         return

sequence_54:
# x
#     (Factor)
#     *
#         x
#             (MulOp)
#             (Factor)

         ast_push
         loc_push
         error_clear

         error_push

         call              sym_Factor

         error_pop_merge
   fail! jump              failed_55
         error_push

         call              kleene_51

         error_pop_merge
   fail! jump              failed_55

         ast_pop_discard
         loc_pop_discard
         return

failed_55:
         ast_pop_rewind
         loc_pop_rewind
         return

kleene_51:
# *
#     x
#         (MulOp)
#         (Factor)

         loc_push
         error_push

         call              sequence_48

         error_pop_merge
   fail! jump              failed_52
         loc_pop_discard
         jump              kleene_51

failed_52:
         loc_pop_rewind
         status_ok
         return

sequence_48:
# x
#     (MulOp)
#     (Factor)

         ast_push
         loc_push
         error_clear

         error_push

         call              sym_MulOp

         error_pop_merge
   fail! jump              failed_49
         error_push

         call              sym_Factor

         error_pop_merge
   fail! jump              failed_49

         ast_pop_discard
         loc_pop_discard
         return

failed_49:
         ast_pop_rewind
         loc_pop_rewind
         return
#
# value Symbol 'Factor'
#

sym_Factor:
# x
#     (Term)
#     *
#         x
#             (AddOp)
#             (Term)

         symbol_restore    Factor
  found! jump              found_74
         loc_push
         ast_push

         call              sequence_71

   fail! value_clear
     ok! value_reduce      Factor
         symbol_save       Factor
         error_nonterminal Factor
         ast_pop_rewind
         loc_pop_discard

found_74:
     ok! ast_value_push
         return

sequence_71:
# x
#     (Term)
#     *
#         x
#             (AddOp)
#             (Term)

         ast_push
         loc_push
         error_clear

         error_push

         call              sym_Term

         error_pop_merge
   fail! jump              failed_72
         error_push

         call              kleene_68

         error_pop_merge
   fail! jump              failed_72

         ast_pop_discard
         loc_pop_discard
         return

failed_72:
         ast_pop_rewind
         loc_pop_rewind
         return

kleene_68:
# *
#     x
#         (AddOp)
#         (Term)

         loc_push
         error_push

         call              sequence_65

         error_pop_merge
   fail! jump              failed_69
         loc_pop_discard
         jump              kleene_68

failed_69:
         loc_pop_rewind
         status_ok
         return

sequence_65:
# x
#     (AddOp)
#     (Term)

         ast_push
         loc_push
         error_clear

         error_push

         call              sym_AddOp

         error_pop_merge
   fail! jump              failed_66
         error_push

         call              sym_Term

         error_pop_merge
   fail! jump              failed_66

         ast_pop_discard
         loc_pop_discard
         return

failed_66:
         ast_pop_rewind
         loc_pop_rewind
         return
#
# value Symbol 'MulOp'
#

sym_MulOp:
# /
#     '*'
#     '/'

         symbol_restore    MulOp
  found! jump              found_83
         loc_push

         call              choice_81

   fail! value_clear
     ok! value_leaf        MulOp
         symbol_save       MulOp
         error_nonterminal MulOp
         loc_pop_discard

found_83:
     ok! ast_value_push
         return

choice_81:
# /
#     '*'
#     '/'

         error_clear

         loc_push
         error_push

         call              char_76

         error_pop_merge
     ok! jump              oknoast_80

         loc_pop_rewind
         loc_push
         error_push

         call              char_78

         error_pop_merge
     ok! jump              oknoast_80

         loc_pop_rewind
         status_fail
         return

oknoast_80:
         loc_pop_discard
         return

char_76:
# '*'

         input_next        "t *"
     ok! test_char         "*"
         return

char_78:
# '/'

         input_next        "t /"
     ok! test_char         "/"
         return
#
# value Symbol 'Number'
#

sym_Number:
# x
#     ?
#         (Sign)
#     +
#         (Digit)

         symbol_restore    Number
  found! jump              found_96
         loc_push
         ast_push

         call              sequence_93

   fail! value_clear
     ok! value_reduce      Number
         symbol_save       Number
         error_nonterminal Number
         ast_pop_rewind
         loc_pop_discard

found_96:
     ok! ast_value_push
         return

sequence_93:
# x
#     ?
#         (Sign)
#     +
#         (Digit)

         ast_push
         loc_push
         error_clear

         error_push

         call              optional_86

         error_pop_merge
   fail! jump              failed_94
         error_push

         call              poskleene_89

         error_pop_merge
   fail! jump              failed_94

         ast_pop_discard
         loc_pop_discard
         return

failed_94:
         ast_pop_rewind
         loc_pop_rewind
         return

optional_86:
# ?
#     (Sign)

         loc_push
         error_push

         call              sym_Sign

         error_pop_merge
   fail! loc_pop_rewind
     ok! loc_pop_discard
         status_ok
         return

poskleene_89:
# +
#     (Digit)

         loc_push

         call              sym_Digit

   fail! jump              failed_90

loop_91:
         loc_pop_discard
         loc_push
         error_push

         call              sym_Digit

         error_pop_merge
     ok! jump              loop_91
         status_ok

failed_90:
         loc_pop_rewind
         return
#
# value Symbol 'Sign'
#

sym_Sign:
# /
#     '-'
#     '+'

         symbol_restore    Sign
  found! jump              found_102
         loc_push

         call              choice_7

   fail! value_clear
     ok! value_leaf        Sign
         symbol_save       Sign
         error_nonterminal Sign
         loc_pop_discard

found_102:
     ok! ast_value_push
         return
#
# value Symbol 'Term'
#

sym_Term:
# (Number)

         symbol_restore    Term
  found! jump              found_105
         loc_push
         ast_push

         call              sym_Number

   fail! value_clear
     ok! value_reduce      Term
         symbol_save       Term
         error_nonterminal Term
         ast_pop_rewind
         loc_pop_discard

found_105:
     ok! ast_value_push
         return

#
#
