## -*- tcl -*-
##
## Snit-based Tcl/PARAM implementation of the parsing
## expression grammar
##
##	TEMPLATE
##
## Generated from file	TEST
##            for user  unknown
##
# # ## ### ##### ######## ############# #####################
## Requirements

package require Tcl 8.5
package require snit
package require pt::rde ; # Implementation of the PARAM
			  # virtual machine underlying the
			  # Tcl/PARAM code used below.

# # ## ### ##### ######## ############# #####################
##

snit::type ::PARSER {
    # # ## ### ##### ######## #############
    ## Public API

    constructor {} {
	# Create the runtime supporting the parsing process.
	set myparser [pt::rde ${selfns}::ENGINE]
	return
    }

    method parse {channel} {
	$myparser reset $channel
	MAIN ; # Entrypoint for the generated code.
	return [$myparser complete]
    }

    method parset {text} {
	$myparser reset
	$myparser data $text
	MAIN ; # Entrypoint for the generated code.
	return [$myparser complete]
    }

    # # ## ### ###### ######## #############
    ## Configuration

    pragma -hastypeinfo    0
    pragma -hastypemethods 0
    pragma -hasinfo        0
    pragma -simpledispatch 1

    # # ## ### ###### ######## #############
    ## Data structures.

    variable myparser {} ; # Our instantiation of the PARAM.

    # # ## ### ###### ######## #############
    ## BEGIN of GENERATED CODE. DO NOT EDIT.

    #
    # Grammar Start Expression
    #
    
    proc MAIN {} { upvar 1 myparser myparser
        sym_eos
        return
    }
    
    #
    # value Symbol 'eos'
    #
    
    proc sym_eos {} { upvar 1 myparser myparser
        # x
        #     (ex)
        #     *
        #         x
        #             +
        #                 <space>
        #             (ex)
    
        $myparser si:value_symbol_start eos
        sequence_11
        $myparser si:reduce_symbol_end eos
        return
    }
    
    proc sequence_11 {} { upvar 1 myparser myparser
        # x
        #     (ex)
        #     *
        #         x
        #             +
        #                 <space>
        #             (ex)
    
        $myparser si:value_state_push
        sym_ex
        $myparser si:valuevalue_part
        kleene_9
        $myparser si:value_state_merge
        return
    }
    
    proc kleene_9 {} { upvar 1 myparser myparser
        # *
        #     x
        #         +
        #             <space>
        #         (ex)
    
        while {1} {
            $myparser si:void2_state_push
        sequence_7
            $myparser si:kleene_close
        }
        return
    }
    
    proc sequence_7 {} { upvar 1 myparser myparser
        # x
        #     +
        #         <space>
        #     (ex)
    
        $myparser si:void_state_push
        poskleene_4
        $myparser si:voidvalue_part
        sym_ex
        $myparser si:value_state_merge
        return
    }
    
    proc poskleene_4 {} { upvar 1 myparser myparser
        # +
        #     <space>
    
        $myparser i_loc_push
        $myparser si:next_space
        $myparser si:kleene_abort
        while {1} {
            $myparser si:void2_state_push
        $myparser si:next_space
            $myparser si:kleene_close
        }
        return
    }
    
    #
    # value Symbol 'ex'
    #
    
    proc sym_ex {} { upvar 1 myparser myparser
        # x
        #     +
        #         x
        #             !
        #                 (X)
        #             [xz]
        #     ?
        #         (X)
    
        $myparser si:value_symbol_start ex
        sequence_25
        $myparser si:reduce_symbol_end ex
        return
    }
    
    proc sequence_25 {} { upvar 1 myparser myparser
        # x
        #     +
        #         x
        #             !
        #                 (X)
        #             [xz]
        #     ?
        #         (X)
    
        $myparser si:void_state_push
        poskleene_20
        $myparser si:voidvalue_part
        optional_23
        $myparser si:value_state_merge
        return
    }
    
    proc poskleene_20 {} { upvar 1 myparser myparser
        # +
        #     x
        #         !
        #             (X)
        #         [xz]
    
        $myparser i_loc_push
        sequence_18
        $myparser si:kleene_abort
        while {1} {
            $myparser si:void2_state_push
        sequence_18
            $myparser si:kleene_close
        }
        return
    }
    
    proc sequence_18 {} { upvar 1 myparser myparser
        # x
        #     !
        #         (X)
        #     [xz]
    
        $myparser si:void_state_push
        notahead_15
        $myparser si:voidvoid_part
        $myparser si:next_class xz
        $myparser si:void_state_merge
        return
    }
    
    proc notahead_15 {} { upvar 1 myparser myparser
        # !
        #     (X)
    
        $myparser si:value_notahead_start
        sym_X
        $myparser si:value_notahead_exit
        return
    }
    
    proc optional_23 {} { upvar 1 myparser myparser
        # ?
        #     (X)
    
        $myparser si:void2_state_push
        sym_X
        $myparser si:void_state_merge_ok
        return
    }
    
    #
    # value Symbol 'X'
    #
    
    proc sym_X {} { upvar 1 myparser myparser
        # 'x'
    
        $myparser si:void_symbol_start X
        $myparser si:next_char x
        $myparser si:void_leaf_symbol_end X
        return
    }
    
    ## END of GENERATED CODE. DO NOT EDIT.
    # # ## ### ###### ######## #############
}

# # ## ### ##### ######## ############# #####################
## Ready

package provide SNIT_PACKAGE 1
return