File: gen_peg_me.template

package info (click to toggle)
tcllib 1.19-dfsg-2
  • links: PTS
  • area: main
  • in suites: buster
  • size: 67,328 kB
  • sloc: tcl: 208,371; ansic: 14,215; sh: 2,846; xml: 1,766; yacc: 1,145; pascal: 583; makefile: 106; perl: 84; f90: 84; python: 33; ruby: 13; php: 11
file content (61 lines) | stat: -rw-r--r-- 1,330 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# -*- tcl -*-
## Parsing Expression Grammar '@NAME@'.
## Recursive Descent Packrat parser generated
## by the PAGE writer plugin 'me'.
@COPY@
# ### ### ### ######### ######### #########
## Package description

# The commands provided here match an input provided through a buffer
# command to the PE grammar '@NAME@'. The parser is based on the package
# 'grammar::me::tcl' (recursive-descent, packrat, pulling chars,
# pushing the generated AST).

# ### ### ### ######### ######### #########
## Requisites

package require grammar::me::tcl

# ### ### ### ######### ######### #########
## Implementation

namespace eval ::@PKG@ {
    # Import the virtual machine for matching.

    namespace import ::grammar::me::tcl::*
    upvar #0 ::grammar::me::tcl::ok ok
}

# ### ### ### ######### ######### #########
## API Implementation.

proc ::@PKG@::parse {nxcmd emvar astvar} {
    variable ok
    variable se

    upvar 1 $emvar emsg $astvar ast

    init $nxcmd

@MATCH@

    isv_nonterminal_reduce ALL -1
    set ast [sv]
    if {!$ok} {
        foreach {l m} [ier_get] break
        lappend l [lc $l]
        set emsg [list $l $m]
    }

    return $ok
}

# ### ### ### ######### ######### #########
## Internal helper methods

@RULES@

# ### ### ### ######### ######### #########
## Package Management

package provide @PKG@ 0.1