Index: apps/pt ================================================================== --- apps/pt +++ apps/pt @@ -9,12 +9,14 @@ # When debugging package loading trouble, show the search paths #puts [join $auto_path \n] # # ## ### ##### ######## ############# ##################### -package require pt::pgen +package require pt::pgen 1.0.3 +package require pt::util package require fileutil +package require try namespace eval ::pt::app { namespace export generate help namespace ensemble create } @@ -23,11 +25,11 @@ proc main {} { global argv argv0 errorInfo if {![llength $argv]} { lappend argv help } if {[catch { - ::pt::app {*}$argv + set status [::pt::app {*}$argv] } msg]} { set elines [split $errorInfo \n] if {[llength $elines] == 3} { if {[string match *unknown* $msg]} { #puts stderr "$argv0 $msg" @@ -46,11 +48,11 @@ } set prefix {INTERNAL ERROR :: } puts ${prefix}[join $elines \n$prefix] exit 1 } - exit 0 + exit $status } # # ## ### ##### ######## ############# ##################### proc ::pt::app::helpHelp {} { @@ -73,10 +75,11 @@ puts stderr "" } else { puts stderr \t[join [split [string map [list @ $argv0] [string trim [::pt::app::${topic}Help]]] \n] \n\t] puts stderr "" } + return 0 } proc ::pt::app::Topics {} { namespace eval ::TEMP { namespace import ::pt::app::* } set commands [info commands ::TEMP::*] @@ -109,19 +112,31 @@ # Just enough that the help code can extract the method name return -code error "wrong # args, should be \"@ generate ...\"" } set args [lassign $args parserformat] - lassign [lrange $args end-2 end] parserfile grammarformat grammarfile + lassign [lrange $args end-2 end] \ + parserfile grammarformat grammarfile set args [Template [lrange $args 0 end-3]] lappend args -file $grammarfile - fileutil::writeFile $parserfile \ - [::pt::pgen $grammarformat \ - [fileutil::cat $grammarfile] \ - $parserformat {*}$args] - return + puts "Reading $grammarformat $grammarfile ..." + set grammar [fileutil::cat $grammarfile] + + puts "Generating a $parserformat parser ..." + try { + set parser [::pt::pgen $grammarformat $grammar $parserformat {*}$args] + } trap {PT RDE SYNTAX} {e o} { + puts [pt::util error2readable $e $grammar] + return 1 + } + + puts "Saving to $parserfile ..." + fileutil::writeFile $parserfile $parser + + puts OK + return 0 } # Lift template specifications from file paths to the file's contents. proc ::pt::app::Template {optiondict} { Index: embedded/man/files/apps/pt.n ================================================================== --- embedded/man/files/apps/pt.n +++ embedded/man/files/apps/pt.n @@ -548,10 +548,14 @@ \fBX::Y\fR the parser command will be \fBX::Y\fR\&. .TP \fB-package\fR string The value of this option is the name of the package to generate\&. The default value is \fBPACKAGE\fR\&. +.TP +\fB-version\fR string +The value of this option is the version of the package to generate\&. +The default value is \fB1\fR\&. .PP .SH "C PARSER" The \fBc\fR format is executable code, a parser for the grammar\&. The parser implementation is written in C and can be tweaked to the users' needs through a multitude of options\&. @@ -708,10 +712,14 @@ The value of this option is the name of the package to generate, without leading colons\&. Note, it serves double-duty as the name of the class to generate too, if option \fB-class\fR is not specified, see above\&. The default value is \fBPACKAGE\fR, applying if neither option \fB-package\fR nor \fB-class\fR were specified\&. +.TP +\fB-version\fR string +The value of this option is the version of the package to generate\&. +The default value is \fB1\fR\&. .PP .SH "TCLOO PARSER" The \fBoo\fR format is executable code, a parser for the grammar\&. It is a Tcl package holding a \fBTclOO\fR class, whose instances are parsers for the input grammar\&. @@ -742,10 +750,14 @@ The value of this option is the name of the package to generate, without leading colons\&. Note, it serves double-duty as the name of the class to generate too, if option \fB-class\fR is not specified, see above\&. The default value is \fBPACKAGE\fR, applying if neither option \fB-package\fR nor \fB-class\fR were specified\&. +.TP +\fB-version\fR string +The value of this option is the version of the package to generate\&. +The default value is \fB1\fR\&. .PP .SH "GRAMMAR CONTAINER" The \fBcontainer\fR format is another form of describing parsing expression grammars\&. While data in this format is executable it does not constitute a parser for the grammar\&. It always has to be used in Index: embedded/man/files/modules/pt/pt_cparam_config_critcl.n ================================================================== --- embedded/man/files/modules/pt/pt_cparam_config_critcl.n +++ embedded/man/files/modules/pt/pt_cparam_config_critcl.n @@ -1,10 +1,10 @@ '\" '\" Generated from file 'pt_cparam_config_critcl\&.man' by tcllib/doctools with format 'nroff' '\" Copyright (c) 2009 Andreas Kupries '\" -.TH "pt::cparam::configuration::critcl" n 1\&.0\&.1 tcllib "Parser Tools" +.TH "pt::cparam::configuration::critcl" n 1\&.0\&.2 tcllib "Parser Tools" .\" The -*- nroff -*- definitions below are for supplemental macros used .\" in Tcl/Tk manual entries. .\" .\" .AP type name in/out ?indent? .\" Start paragraph describing an argument to a library procedure. @@ -274,13 +274,13 @@ .SH NAME pt::cparam::configuration::critcl \- C/PARAM, Canned configuration, Critcl .SH SYNOPSIS package require \fBTcl 8\&.5\fR .sp -package require \fBpt::cparam::configuration::critcl ?1\&.0\&.1?\fR +package require \fBpt::cparam::configuration::critcl ?1\&.0\&.2?\fR .sp -\fB::pt::cparam::configuration::critcl\fR \fBdef\fR \fIname\fR \fIcmdprefix\fR +\fB::pt::cparam::configuration::critcl\fR \fBdef\fR \fIname\fR \fIpkg\fR \fIversion\fR \fIcmdprefix\fR .sp .BE .SH DESCRIPTION .PP Are you lost ? @@ -299,14 +299,14 @@ .PP IMAGE: arch_core_support .PP .SH API .TP -\fB::pt::cparam::configuration::critcl\fR \fBdef\fR \fIname\fR \fIcmdprefix\fR +\fB::pt::cparam::configuration::critcl\fR \fBdef\fR \fIname\fR \fIpkg\fR \fIversion\fR \fIcmdprefix\fR The command applies the configuration provided by this package to the \fIcmdprefix\fR, causing the creation of \fBcritcl\fR-based parsers -whose class is \fIname\fR\&. +whose class is \fIname\fR, in package \fIpkg\fR with \fIversion\fR\&. .sp The use of a command prefix as API allows application of the configuration to not only \fBpt::peg::to::cparam\fR (\fBpt::peg::to::cparam configure\fR), but also export manager instances and PEG containers (\fB$export configuration set\fR and ADDED embedded/man/files/modules/pt/pt_cparam_config_tea.n Index: embedded/man/files/modules/pt/pt_cparam_config_tea.n ================================================================== --- /dev/null +++ embedded/man/files/modules/pt/pt_cparam_config_tea.n @@ -0,0 +1,333 @@ +'\" +'\" Generated from file 'pt_cparam_config_tea\&.man' by tcllib/doctools with format 'nroff' +'\" Copyright (c) 2009 Andreas Kupries +'\" +.TH "pt::cparam::configuration::tea" n 0\&.1 tcllib "Parser Tools" +.\" The -*- nroff -*- definitions below are for supplemental macros used +.\" in Tcl/Tk manual entries. +.\" +.\" .AP type name in/out ?indent? +.\" Start paragraph describing an argument to a library procedure. +.\" type is type of argument (int, etc.), in/out is either "in", "out", +.\" or "in/out" to describe whether procedure reads or modifies arg, +.\" and indent is equivalent to second arg of .IP (shouldn't ever be +.\" needed; use .AS below instead) +.\" +.\" .AS ?type? ?name? +.\" Give maximum sizes of arguments for setting tab stops. Type and +.\" name are examples of largest possible arguments that will be passed +.\" to .AP later. If args are omitted, default tab stops are used. +.\" +.\" .BS +.\" Start box enclosure. From here until next .BE, everything will be +.\" enclosed in one large box. +.\" +.\" .BE +.\" End of box enclosure. +.\" +.\" .CS +.\" Begin code excerpt. +.\" +.\" .CE +.\" End code excerpt. +.\" +.\" .VS ?version? ?br? +.\" Begin vertical sidebar, for use in marking newly-changed parts +.\" of man pages. The first argument is ignored and used for recording +.\" the version when the .VS was added, so that the sidebars can be +.\" found and removed when they reach a certain age. If another argument +.\" is present, then a line break is forced before starting the sidebar. +.\" +.\" .VE +.\" End of vertical sidebar. +.\" +.\" .DS +.\" Begin an indented unfilled display. +.\" +.\" .DE +.\" End of indented unfilled display. +.\" +.\" .SO ?manpage? +.\" Start of list of standard options for a Tk widget. The manpage +.\" argument defines where to look up the standard options; if +.\" omitted, defaults to "options". The options follow on successive +.\" lines, in three columns separated by tabs. +.\" +.\" .SE +.\" End of list of standard options for a Tk widget. +.\" +.\" .OP cmdName dbName dbClass +.\" Start of description of a specific option. cmdName gives the +.\" option's name as specified in the class command, dbName gives +.\" the option's name in the option database, and dbClass gives +.\" the option's class in the option database. +.\" +.\" .UL arg1 arg2 +.\" Print arg1 underlined, then print arg2 normally. +.\" +.\" .QW arg1 ?arg2? +.\" Print arg1 in quotes, then arg2 normally (for trailing punctuation). +.\" +.\" .PQ arg1 ?arg2? +.\" Print an open parenthesis, arg1 in quotes, then arg2 normally +.\" (for trailing punctuation) and then a closing parenthesis. +.\" +.\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages. +.if t .wh -1.3i ^B +.nr ^l \n(.l +.ad b +.\" # Start an argument description +.de AP +.ie !"\\$4"" .TP \\$4 +.el \{\ +. ie !"\\$2"" .TP \\n()Cu +. el .TP 15 +.\} +.ta \\n()Au \\n()Bu +.ie !"\\$3"" \{\ +\&\\$1 \\fI\\$2\\fP (\\$3) +.\".b +.\} +.el \{\ +.br +.ie !"\\$2"" \{\ +\&\\$1 \\fI\\$2\\fP +.\} +.el \{\ +\&\\fI\\$1\\fP +.\} +.\} +.. +.\" # define tabbing values for .AP +.de AS +.nr )A 10n +.if !"\\$1"" .nr )A \\w'\\$1'u+3n +.nr )B \\n()Au+15n +.\" +.if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n +.nr )C \\n()Bu+\\w'(in/out)'u+2n +.. +.AS Tcl_Interp Tcl_CreateInterp in/out +.\" # BS - start boxed text +.\" # ^y = starting y location +.\" # ^b = 1 +.de BS +.br +.mk ^y +.nr ^b 1u +.if n .nf +.if n .ti 0 +.if n \l'\\n(.lu\(ul' +.if n .fi +.. +.\" # BE - end boxed text (draw box now) +.de BE +.nf +.ti 0 +.mk ^t +.ie n \l'\\n(^lu\(ul' +.el \{\ +.\" Draw four-sided box normally, but don't draw top of +.\" box if the box started on an earlier page. +.ie !\\n(^b-1 \{\ +\h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' +.\} +.el \}\ +\h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' +.\} +.\} +.fi +.br +.nr ^b 0 +.. +.\" # VS - start vertical sidebar +.\" # ^Y = starting y location +.\" # ^v = 1 (for troff; for nroff this doesn't matter) +.de VS +.if !"\\$2"" .br +.mk ^Y +.ie n 'mc \s12\(br\s0 +.el .nr ^v 1u +.. +.\" # VE - end of vertical sidebar +.de VE +.ie n 'mc +.el \{\ +.ev 2 +.nf +.ti 0 +.mk ^t +\h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n' +.sp -1 +.fi +.ev +.\} +.nr ^v 0 +.. +.\" # Special macro to handle page bottom: finish off current +.\" # box/sidebar if in box/sidebar mode, then invoked standard +.\" # page bottom macro. +.de ^B +.ev 2 +'ti 0 +'nf +.mk ^t +.if \\n(^b \{\ +.\" Draw three-sided box if this is the box's first page, +.\" draw two sides but no top otherwise. +.ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c +.el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c +.\} +.if \\n(^v \{\ +.nr ^x \\n(^tu+1v-\\n(^Yu +\kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c +.\} +.bp +'fi +.ev +.if \\n(^b \{\ +.mk ^y +.nr ^b 2 +.\} +.if \\n(^v \{\ +.mk ^Y +.\} +.. +.\" # DS - begin display +.de DS +.RS +.nf +.sp +.. +.\" # DE - end display +.de DE +.fi +.RE +.sp +.. +.\" # SO - start of list of standard options +.de SO +'ie '\\$1'' .ds So \\fBoptions\\fR +'el .ds So \\fB\\$1\\fR +.SH "STANDARD OPTIONS" +.LP +.nf +.ta 5.5c 11c +.ft B +.. +.\" # SE - end of list of standard options +.de SE +.fi +.ft R +.LP +See the \\*(So manual entry for details on the standard options. +.. +.\" # OP - start of full description for a single option +.de OP +.LP +.nf +.ta 4c +Command-Line Name: \\fB\\$1\\fR +Database Name: \\fB\\$2\\fR +Database Class: \\fB\\$3\\fR +.fi +.IP +.. +.\" # CS - begin code excerpt +.de CS +.RS +.nf +.ta .25i .5i .75i 1i +.. +.\" # CE - end code excerpt +.de CE +.fi +.RE +.. +.\" # UL - underline word +.de UL +\\$1\l'|0\(ul'\\$2 +.. +.\" # QW - apply quotation marks to word +.de QW +.ie '\\*(lq'"' ``\\$1''\\$2 +.\"" fix emacs highlighting +.el \\*(lq\\$1\\*(rq\\$2 +.. +.\" # PQ - apply parens and quotation marks to word +.de PQ +.ie '\\*(lq'"' (``\\$1''\\$2)\\$3 +.\"" fix emacs highlighting +.el (\\*(lq\\$1\\*(rq\\$2)\\$3 +.. +.\" # QR - quoted range +.de QR +.ie '\\*(lq'"' ``\\$1''\\-``\\$2''\\$3 +.\"" fix emacs highlighting +.el \\*(lq\\$1\\*(rq\\-\\*(lq\\$2\\*(rq\\$3 +.. +.\" # MT - "empty" string +.de MT +.QW "" +.. +.BS +.SH NAME +pt::cparam::configuration::tea \- C/PARAM, Canned configuration, TEA +.SH SYNOPSIS +package require \fBTcl 8\&.5\fR +.sp +package require \fBpt::cparam::configuration::tea ?0\&.1?\fR +.sp +\fB::pt::cparam::configuration::tea\fR \fBdef\fR \fIname\fR \fIpkg\fR \fIversion\fR \fIcmdprefix\fR +.sp +.BE +.SH DESCRIPTION +.PP +Are you lost ? +Do you have trouble understanding this document ? +In that case please read the overview provided by the +\fIIntroduction to Parser Tools\fR\&. This document is the +entrypoint to the whole system the current package is a part of\&. +.PP +This package is an adjunct to \fBpt::peg::to::cparam\fR, to make +the use of this highly configurable package easier by providing a +canned configuration\&. When applied this configuration causes the +package \fBpt::peg::to::cparam\fR to generate plain parser code +ready for inclusion into a \fITEA\fR-based C extension\&. +.PP +It is a supporting package in the Core Layer of Parser Tools\&. +.PP +IMAGE: arch_core_support +.PP +.SH API +.TP +\fB::pt::cparam::configuration::tea\fR \fBdef\fR \fIname\fR \fIpkg\fR \fIversion\fR \fIcmdprefix\fR +The command applies the configuration provided by this package to the +\fIcmdprefix\fR, causing the creation of \fBtea\fR-based parsers +whose class is \fIname\fR, in package \fIpkg\fR with \fIversion\fR\&. +.sp +The use of a command prefix as API allows application of the +configuration to not only \fBpt::peg::to::cparam\fR +(\fBpt::peg::to::cparam configure\fR), but also export manager +instances and PEG containers (\fB$export configuration set\fR and +\fB[$container exporter] configuration set\fR respectively)\&. +.sp +Or anything other command prefix accepting two arguments, option and +value\&. +.PP +.SH "BUGS, IDEAS, FEEDBACK" +This document, and the package it describes, will undoubtedly contain +bugs and other problems\&. +Please report such in the category \fIpt\fR of the +\fITcllib Trackers\fR [http://core\&.tcl\&.tk/tcllib/reportlist]\&. +Please also report any ideas for enhancements you may have for either +package and/or documentation\&. +.SH KEYWORDS +EBNF, LL(k), PEG, TDPL, context-free languages, expression, grammar, matching, parser, parsing expression, parsing expression grammar, push down automaton, recursive descent, state, top-down parsing languages, transducer +.SH CATEGORY +Parsing and Grammars +.SH COPYRIGHT +.nf +Copyright (c) 2009 Andreas Kupries + +.fi Index: embedded/man/files/modules/pt/pt_peg_export_peg.n ================================================================== --- embedded/man/files/modules/pt/pt_peg_export_peg.n +++ embedded/man/files/modules/pt/pt_peg_export_peg.n @@ -406,17 +406,17 @@ / DAPOSTROPH (!DAPOSTROPH Char)* DAPOSTROPH WHITESPACE ; Class <- OPENB (!CLOSEB Range)* CLOSEB WHITESPACE ; Range <- Char TO Char / Char ; StartExpr <- OPEN Expression CLOSE ; -void: Final <- END SEMICOLON WHITESPACE ; +void: Final <- "END" WHITESPACE SEMICOLON WHITESPACE ; # -------------------------------------------------------------------- # Lexing constructs Identifier <- Ident WHITESPACE ; -leaf: Ident <- ('_' / ':' / ) ('_' / ':' / )* ; +leaf: Ident <- ([_:] / ) ([_:] / )* ; Char <- CharSpecial / CharOctalFull / CharOctalPart / CharUnicode / CharUnescaped ; leaf: CharSpecial <- "\\\\" [nrt'"\\[\\]\\\\] ; @@ -430,15 +430,14 @@ void: TO <- '-' ; void: OPENB <- "[" ; void: CLOSEB <- "]" ; void: APOSTROPH <- "'" ; void: DAPOSTROPH <- '"' ; -void: PEG <- "PEG" WHITESPACE ; +void: PEG <- "PEG" !([_:] / ) WHITESPACE ; void: IS <- "<-" WHITESPACE ; leaf: VOID <- "void" WHITESPACE ; # Implies that definition has no semantic value\&. leaf: LEAF <- "leaf" WHITESPACE ; # Implies that definition has no terminals\&. -void: END <- "END" WHITESPACE ; void: SEMICOLON <- ";" WHITESPACE ; void: COLON <- ":" WHITESPACE ; void: SLASH <- "/" WHITESPACE ; leaf: AND <- "&" WHITESPACE ; leaf: NOT <- "!" WHITESPACE ; Index: embedded/man/files/modules/pt/pt_peg_from_peg.n ================================================================== --- embedded/man/files/modules/pt/pt_peg_from_peg.n +++ embedded/man/files/modules/pt/pt_peg_from_peg.n @@ -1,10 +1,10 @@ '\" '\" Generated from file 'from\&.inc' by tcllib/doctools with format 'nroff' '\" Copyright (c) 2009 Andreas Kupries '\" -.TH "pt::peg::from::peg" n 1\&.0\&.2 tcllib "Parser Tools" +.TH "pt::peg::from::peg" n 1\&.0\&.3 tcllib "Parser Tools" .\" The -*- nroff -*- definitions below are for supplemental macros used .\" in Tcl/Tk manual entries. .\" .\" .AP type name in/out ?indent? .\" Start paragraph describing an argument to a library procedure. @@ -274,11 +274,11 @@ .SH NAME pt::peg::from::peg \- PEG Conversion\&. Read PEG format .SH SYNOPSIS package require \fBTcl 8\&.5\fR .sp -package require \fBpt::peg::from::peg ?1\&.0\&.2?\fR +package require \fBpt::peg::from::peg ?1\&.0\&.3?\fR .sp \fBpt::peg::from::peg\fR \fBconvert\fR \fItext\fR .sp .BE .SH DESCRIPTION @@ -356,17 +356,17 @@ / DAPOSTROPH (!DAPOSTROPH Char)* DAPOSTROPH WHITESPACE ; Class <- OPENB (!CLOSEB Range)* CLOSEB WHITESPACE ; Range <- Char TO Char / Char ; StartExpr <- OPEN Expression CLOSE ; -void: Final <- END SEMICOLON WHITESPACE ; +void: Final <- "END" WHITESPACE SEMICOLON WHITESPACE ; # -------------------------------------------------------------------- # Lexing constructs Identifier <- Ident WHITESPACE ; -leaf: Ident <- ('_' / ':' / ) ('_' / ':' / )* ; +leaf: Ident <- ([_:] / ) ([_:] / )* ; Char <- CharSpecial / CharOctalFull / CharOctalPart / CharUnicode / CharUnescaped ; leaf: CharSpecial <- "\\\\" [nrt'"\\[\\]\\\\] ; @@ -380,15 +380,14 @@ void: TO <- '-' ; void: OPENB <- "[" ; void: CLOSEB <- "]" ; void: APOSTROPH <- "'" ; void: DAPOSTROPH <- '"' ; -void: PEG <- "PEG" WHITESPACE ; +void: PEG <- "PEG" !([_:] / ) WHITESPACE ; void: IS <- "<-" WHITESPACE ; leaf: VOID <- "void" WHITESPACE ; # Implies that definition has no semantic value\&. leaf: LEAF <- "leaf" WHITESPACE ; # Implies that definition has no terminals\&. -void: END <- "END" WHITESPACE ; void: SEMICOLON <- ";" WHITESPACE ; void: COLON <- ":" WHITESPACE ; void: SLASH <- "/" WHITESPACE ; leaf: AND <- "&" WHITESPACE ; leaf: NOT <- "!" WHITESPACE ; Index: embedded/man/files/modules/pt/pt_peg_import_peg.n ================================================================== --- embedded/man/files/modules/pt/pt_peg_import_peg.n +++ embedded/man/files/modules/pt/pt_peg_import_peg.n @@ -369,17 +369,17 @@ / DAPOSTROPH (!DAPOSTROPH Char)* DAPOSTROPH WHITESPACE ; Class <- OPENB (!CLOSEB Range)* CLOSEB WHITESPACE ; Range <- Char TO Char / Char ; StartExpr <- OPEN Expression CLOSE ; -void: Final <- END SEMICOLON WHITESPACE ; +void: Final <- "END" WHITESPACE SEMICOLON WHITESPACE ; # -------------------------------------------------------------------- # Lexing constructs Identifier <- Ident WHITESPACE ; -leaf: Ident <- ('_' / ':' / ) ('_' / ':' / )* ; +leaf: Ident <- ([_:] / ) ([_:] / )* ; Char <- CharSpecial / CharOctalFull / CharOctalPart / CharUnicode / CharUnescaped ; leaf: CharSpecial <- "\\\\" [nrt'"\\[\\]\\\\] ; @@ -393,15 +393,14 @@ void: TO <- '-' ; void: OPENB <- "[" ; void: CLOSEB <- "]" ; void: APOSTROPH <- "'" ; void: DAPOSTROPH <- '"' ; -void: PEG <- "PEG" WHITESPACE ; +void: PEG <- "PEG" !([_:] / ) WHITESPACE ; void: IS <- "<-" WHITESPACE ; leaf: VOID <- "void" WHITESPACE ; # Implies that definition has no semantic value\&. leaf: LEAF <- "leaf" WHITESPACE ; # Implies that definition has no terminals\&. -void: END <- "END" WHITESPACE ; void: SEMICOLON <- ";" WHITESPACE ; void: COLON <- ":" WHITESPACE ; void: SLASH <- "/" WHITESPACE ; leaf: AND <- "&" WHITESPACE ; leaf: NOT <- "!" WHITESPACE ; Index: embedded/man/files/modules/pt/pt_peg_interp.n ================================================================== --- embedded/man/files/modules/pt/pt_peg_interp.n +++ embedded/man/files/modules/pt/pt_peg_interp.n @@ -1,10 +1,10 @@ '\" '\" Generated from file 'pt_peg_interp\&.man' by tcllib/doctools with format 'nroff' '\" Copyright (c) 2009 Andreas Kupries '\" -.TH "pt::peg::interp" n 1 tcllib "Parser Tools" +.TH "pt::peg::interp" n 1\&.0\&.1 tcllib "Parser Tools" .\" The -*- nroff -*- definitions below are for supplemental macros used .\" in Tcl/Tk manual entries. .\" .\" .AP type name in/out ?indent? .\" Start paragraph describing an argument to a library procedure. @@ -274,11 +274,11 @@ .SH NAME pt::peg::interp \- Interpreter for parsing expression grammars .SH SYNOPSIS package require \fBTcl 8\&.5\fR .sp -package require \fBpt::peg::interp ?1?\fR +package require \fBpt::peg::interp ?1\&.0\&.1?\fR .sp package require \fBpt::rde ?1?\fR .sp package require \fBsnit \fR .sp Index: embedded/man/files/modules/pt/pt_peg_language.n ================================================================== --- embedded/man/files/modules/pt/pt_peg_language.n +++ embedded/man/files/modules/pt/pt_peg_language.n @@ -633,17 +633,17 @@ / DAPOSTROPH (!DAPOSTROPH Char)* DAPOSTROPH WHITESPACE ; Class <- OPENB (!CLOSEB Range)* CLOSEB WHITESPACE ; Range <- Char TO Char / Char ; StartExpr <- OPEN Expression CLOSE ; -void: Final <- END SEMICOLON WHITESPACE ; +void: Final <- "END" WHITESPACE SEMICOLON WHITESPACE ; # -------------------------------------------------------------------- # Lexing constructs Identifier <- Ident WHITESPACE ; -leaf: Ident <- ('_' / ':' / ) ('_' / ':' / )* ; +leaf: Ident <- ([_:] / ) ([_:] / )* ; Char <- CharSpecial / CharOctalFull / CharOctalPart / CharUnicode / CharUnescaped ; leaf: CharSpecial <- "\\\\" [nrt'"\\[\\]\\\\] ; @@ -657,15 +657,14 @@ void: TO <- '-' ; void: OPENB <- "[" ; void: CLOSEB <- "]" ; void: APOSTROPH <- "'" ; void: DAPOSTROPH <- '"' ; -void: PEG <- "PEG" WHITESPACE ; +void: PEG <- "PEG" !([_:] / ) WHITESPACE ; void: IS <- "<-" WHITESPACE ; leaf: VOID <- "void" WHITESPACE ; # Implies that definition has no semantic value\&. leaf: LEAF <- "leaf" WHITESPACE ; # Implies that definition has no terminals\&. -void: END <- "END" WHITESPACE ; void: SEMICOLON <- ";" WHITESPACE ; void: COLON <- ":" WHITESPACE ; void: SLASH <- "/" WHITESPACE ; leaf: AND <- "&" WHITESPACE ; leaf: NOT <- "!" WHITESPACE ; Index: embedded/man/files/modules/pt/pt_peg_to_cparam.n ================================================================== --- embedded/man/files/modules/pt/pt_peg_to_cparam.n +++ embedded/man/files/modules/pt/pt_peg_to_cparam.n @@ -1,10 +1,10 @@ '\" '\" Generated from file 'to\&.inc' by tcllib/doctools with format 'nroff' '\" Copyright (c) 2009 Andreas Kupries '\" -.TH "pt::peg::to::cparam" n 1\&.1\&.1 tcllib "Parser Tools" +.TH "pt::peg::to::cparam" n 1\&.1\&.2 tcllib "Parser Tools" .\" The -*- nroff -*- definitions below are for supplemental macros used .\" in Tcl/Tk manual entries. .\" .\" .AP type name in/out ?indent? .\" Start paragraph describing an argument to a library procedure. @@ -274,11 +274,11 @@ .SH NAME pt::peg::to::cparam \- PEG Conversion\&. Write CPARAM format .SH SYNOPSIS package require \fBTcl 8\&.5\fR .sp -package require \fBpt::peg::to::cparam ?1\&.1\&.1?\fR +package require \fBpt::peg::to::cparam ?1\&.1\&.2?\fR .sp \fBpt::peg::to::cparam\fR \fBreset\fR .sp \fBpt::peg::to::cparam\fR \fBconfigure\fR .sp Index: embedded/man/files/modules/pt/pt_peg_to_peg.n ================================================================== --- embedded/man/files/modules/pt/pt_peg_to_peg.n +++ embedded/man/files/modules/pt/pt_peg_to_peg.n @@ -1,10 +1,10 @@ '\" '\" Generated from file 'to\&.inc' by tcllib/doctools with format 'nroff' '\" Copyright (c) 2009 Andreas Kupries '\" -.TH "pt::peg::to::peg" n 1\&.0\&.1 tcllib "Parser Tools" +.TH "pt::peg::to::peg" n 1\&.0\&.2 tcllib "Parser Tools" .\" The -*- nroff -*- definitions below are for supplemental macros used .\" in Tcl/Tk manual entries. .\" .\" .AP type name in/out ?indent? .\" Start paragraph describing an argument to a library procedure. @@ -274,11 +274,11 @@ .SH NAME pt::peg::to::peg \- PEG Conversion\&. Write PEG format .SH SYNOPSIS package require \fBTcl 8\&.5\fR .sp -package require \fBpt::peg::to::peg ?1\&.0\&.1?\fR +package require \fBpt::peg::to::peg ?1\&.0\&.2?\fR .sp package require \fBpt::peg \fR .sp package require \fBpt::pe \fR .sp @@ -428,17 +428,17 @@ / DAPOSTROPH (!DAPOSTROPH Char)* DAPOSTROPH WHITESPACE ; Class <- OPENB (!CLOSEB Range)* CLOSEB WHITESPACE ; Range <- Char TO Char / Char ; StartExpr <- OPEN Expression CLOSE ; -void: Final <- END SEMICOLON WHITESPACE ; +void: Final <- "END" WHITESPACE SEMICOLON WHITESPACE ; # -------------------------------------------------------------------- # Lexing constructs Identifier <- Ident WHITESPACE ; -leaf: Ident <- ('_' / ':' / ) ('_' / ':' / )* ; +leaf: Ident <- ([_:] / ) ([_:] / )* ; Char <- CharSpecial / CharOctalFull / CharOctalPart / CharUnicode / CharUnescaped ; leaf: CharSpecial <- "\\\\" [nrt'"\\[\\]\\\\] ; @@ -452,15 +452,14 @@ void: TO <- '-' ; void: OPENB <- "[" ; void: CLOSEB <- "]" ; void: APOSTROPH <- "'" ; void: DAPOSTROPH <- '"' ; -void: PEG <- "PEG" WHITESPACE ; +void: PEG <- "PEG" !([_:] / ) WHITESPACE ; void: IS <- "<-" WHITESPACE ; leaf: VOID <- "void" WHITESPACE ; # Implies that definition has no semantic value\&. leaf: LEAF <- "leaf" WHITESPACE ; # Implies that definition has no terminals\&. -void: END <- "END" WHITESPACE ; void: SEMICOLON <- ";" WHITESPACE ; void: COLON <- ":" WHITESPACE ; void: SLASH <- "/" WHITESPACE ; leaf: AND <- "&" WHITESPACE ; leaf: NOT <- "!" WHITESPACE ; Index: embedded/man/files/modules/pt/pt_peg_to_tclparam.n ================================================================== --- embedded/man/files/modules/pt/pt_peg_to_tclparam.n +++ embedded/man/files/modules/pt/pt_peg_to_tclparam.n @@ -1,10 +1,10 @@ '\" '\" Generated from file 'to\&.inc' by tcllib/doctools with format 'nroff' '\" Copyright (c) 2009 Andreas Kupries '\" -.TH "pt::peg::to::tclparam" n 1 tcllib "Parser Tools" +.TH "pt::peg::to::tclparam" n 1\&.0\&.1 tcllib "Parser Tools" .\" The -*- nroff -*- definitions below are for supplemental macros used .\" in Tcl/Tk manual entries. .\" .\" .AP type name in/out ?indent? .\" Start paragraph describing an argument to a library procedure. @@ -274,11 +274,11 @@ .SH NAME pt::peg::to::tclparam \- PEG Conversion\&. Write TCLPARAM format .SH SYNOPSIS package require \fBTcl 8\&.5\fR .sp -package require \fBpt::peg::to::tclparam ?1?\fR +package require \fBpt::peg::to::tclparam ?1\&.0\&.1?\fR .sp \fBpt::peg::to::tclparam\fR \fBreset\fR .sp \fBpt::peg::to::tclparam\fR \fBconfigure\fR .sp Index: embedded/man/files/modules/pt/pt_pexpression.n ================================================================== --- embedded/man/files/modules/pt/pt_pexpression.n +++ embedded/man/files/modules/pt/pt_pexpression.n @@ -1,10 +1,10 @@ '\" '\" Generated from file 'pt_pexpression\&.man' by tcllib/doctools with format 'nroff' '\" Copyright (c) 2009 Andreas Kupries '\" -.TH "pt::pe" n 1 tcllib "Parser Tools" +.TH "pt::pe" n 1\&.0\&.1 tcllib "Parser Tools" .\" The -*- nroff -*- definitions below are for supplemental macros used .\" in Tcl/Tk manual entries. .\" .\" .AP type name in/out ?indent? .\" Start paragraph describing an argument to a library procedure. @@ -274,11 +274,11 @@ .SH NAME pt::pe \- Parsing Expression Serialization .SH SYNOPSIS package require \fBTcl 8\&.5\fR .sp -package require \fBpt::pe ?1?\fR +package require \fBpt::pe ?1\&.0\&.1?\fR .sp package require \fBchar \fR .sp \fB::pt::pe\fR \fBverify\fR \fIserial\fR ?\fIcanonvar\fR? .sp Index: embedded/man/files/modules/pt/pt_rdengine.n ================================================================== --- embedded/man/files/modules/pt/pt_rdengine.n +++ embedded/man/files/modules/pt/pt_rdengine.n @@ -1,10 +1,10 @@ '\" '\" Generated from file 'pt_rdengine\&.man' by tcllib/doctools with format 'nroff' '\" Copyright (c) 2009 Andreas Kupries '\" -.TH "pt::rde" n 1\&.0\&.2 tcllib "Parser Tools" +.TH "pt::rde" n 1\&.0\&.3 tcllib "Parser Tools" .\" The -*- nroff -*- definitions below are for supplemental macros used .\" in Tcl/Tk manual entries. .\" .\" .AP type name in/out ?indent? .\" Start paragraph describing an argument to a library procedure. @@ -274,11 +274,11 @@ .SH NAME pt::rde \- Parsing Runtime Support, PARAM based .SH SYNOPSIS package require \fBTcl 8\&.5\fR .sp -package require \fBpt::rde ?1\&.0\&.2?\fR +package require \fBpt::rde ?1\&.0\&.3?\fR .sp package require \fBsnit \fR .sp package require \fBstruct::stack 1\&.4\fR .sp Index: embedded/man/files/modules/pt/pt_tclparam_config_snit.n ================================================================== --- embedded/man/files/modules/pt/pt_tclparam_config_snit.n +++ embedded/man/files/modules/pt/pt_tclparam_config_snit.n @@ -1,10 +1,10 @@ '\" '\" Generated from file 'pt_tclparam_config_snit\&.man' by tcllib/doctools with format 'nroff' '\" Copyright (c) 2009 Andreas Kupries '\" -.TH "pt::tclparam::configuration::snit" n 1\&.0\&.1 tcllib "Parser Tools" +.TH "pt::tclparam::configuration::snit" n 1\&.0\&.2 tcllib "Parser Tools" .\" The -*- nroff -*- definitions below are for supplemental macros used .\" in Tcl/Tk manual entries. .\" .\" .AP type name in/out ?indent? .\" Start paragraph describing an argument to a library procedure. @@ -274,13 +274,13 @@ .SH NAME pt::tclparam::configuration::snit \- Tcl/PARAM, Canned configuration, Snit .SH SYNOPSIS package require \fBTcl 8\&.5\fR .sp -package require \fBpt::tclparam::configuration::snit ?1\&.0\&.1?\fR +package require \fBpt::tclparam::configuration::snit ?1\&.0\&.2?\fR .sp -\fB::pt::tclparam::configuration::snit\fR \fBdef\fR \fIname\fR \fIcmdprefix\fR +\fB::pt::tclparam::configuration::snit\fR \fBdef\fR \fIname\fR \fIpkg\fR \fIversion\fR \fIcmdprefix\fR .sp .BE .SH DESCRIPTION .PP Are you lost ? @@ -299,14 +299,14 @@ .PP IMAGE: arch_core_support .PP .SH API .TP -\fB::pt::tclparam::configuration::snit\fR \fBdef\fR \fIname\fR \fIcmdprefix\fR +\fB::pt::tclparam::configuration::snit\fR \fBdef\fR \fIname\fR \fIpkg\fR \fIversion\fR \fIcmdprefix\fR The command applies the configuration provided by this package to the \fIcmdprefix\fR, causing the creation of \fBsnit\fR-based parsers -whose class is \fIname\fR\&. +whose class is \fIname\fR, in package \fIpkg\fR with \fIversion\fR\&. .sp The use of a command prefix as API allows application of the configuration to not only \fBpt::peg::to::tclparam\fR (\fBpt::peg::to::tclparam configure\fR), but also export manager instances and PEG containers (\fB$export configuration set\fR and Index: embedded/man/files/modules/pt/pt_tclparam_config_tcloo.n ================================================================== --- embedded/man/files/modules/pt/pt_tclparam_config_tcloo.n +++ embedded/man/files/modules/pt/pt_tclparam_config_tcloo.n @@ -1,10 +1,10 @@ '\" '\" Generated from file 'pt_tclparam_config_tcloo\&.man' by tcllib/doctools with format 'nroff' '\" Copyright (c) 2009 Andreas Kupries '\" -.TH "pt::tclparam::configuration::tcloo" n 1\&.0\&.3 tcllib "Parser Tools" +.TH "pt::tclparam::configuration::tcloo" n 1\&.0\&.4 tcllib "Parser Tools" .\" The -*- nroff -*- definitions below are for supplemental macros used .\" in Tcl/Tk manual entries. .\" .\" .AP type name in/out ?indent? .\" Start paragraph describing an argument to a library procedure. @@ -274,13 +274,13 @@ .SH NAME pt::tclparam::configuration::tcloo \- Tcl/PARAM, Canned configuration, Tcloo .SH SYNOPSIS package require \fBTcl 8\&.5\fR .sp -package require \fBpt::tclparam::configuration::tcloo ?1\&.0\&.3?\fR +package require \fBpt::tclparam::configuration::tcloo ?1\&.0\&.4?\fR .sp -\fB::pt::tclparam::configuration::tcloo\fR \fBdef\fR \fIname\fR \fIcmdprefix\fR +\fB::pt::tclparam::configuration::tcloo\fR \fBdef\fR \fIname\fR \fIpkg\fR \fIversion\fR \fIcmdprefix\fR .sp .BE .SH DESCRIPTION .PP Are you lost ? @@ -299,14 +299,14 @@ .PP IMAGE: arch_core_support .PP .SH API .TP -\fB::pt::tclparam::configuration::tcloo\fR \fBdef\fR \fIname\fR \fIcmdprefix\fR +\fB::pt::tclparam::configuration::tcloo\fR \fBdef\fR \fIname\fR \fIpkg\fR \fIversion\fR \fIcmdprefix\fR The command applies the configuration provided by this package to the \fIcmdprefix\fR, causing the creation of \fBOO\fR-based parsers -whose class is \fIname\fR\&. +whose class is \fIname\fR, in package \fIpkg\fR with \fIversion\fR\&. .sp The use of a command prefix as API allows application of the configuration to not only \fBpt::peg::to::tclparam\fR (\fBpt::peg::to::tclparam configure\fR), but also export manager instances and PEG containers (\fB$export configuration set\fR and ADDED embedded/man/files/modules/pt/pt_util.n Index: embedded/man/files/modules/pt/pt_util.n ================================================================== --- /dev/null +++ embedded/man/files/modules/pt/pt_util.n @@ -0,0 +1,341 @@ +'\" +'\" Generated from file 'pt_util\&.man' by tcllib/doctools with format 'nroff' +'\" Copyright (c) 2009 Andreas Kupries +'\" +.TH "pt::util" n 1 tcllib "Parser Tools" +.\" The -*- nroff -*- definitions below are for supplemental macros used +.\" in Tcl/Tk manual entries. +.\" +.\" .AP type name in/out ?indent? +.\" Start paragraph describing an argument to a library procedure. +.\" type is type of argument (int, etc.), in/out is either "in", "out", +.\" or "in/out" to describe whether procedure reads or modifies arg, +.\" and indent is equivalent to second arg of .IP (shouldn't ever be +.\" needed; use .AS below instead) +.\" +.\" .AS ?type? ?name? +.\" Give maximum sizes of arguments for setting tab stops. Type and +.\" name are examples of largest possible arguments that will be passed +.\" to .AP later. If args are omitted, default tab stops are used. +.\" +.\" .BS +.\" Start box enclosure. From here until next .BE, everything will be +.\" enclosed in one large box. +.\" +.\" .BE +.\" End of box enclosure. +.\" +.\" .CS +.\" Begin code excerpt. +.\" +.\" .CE +.\" End code excerpt. +.\" +.\" .VS ?version? ?br? +.\" Begin vertical sidebar, for use in marking newly-changed parts +.\" of man pages. The first argument is ignored and used for recording +.\" the version when the .VS was added, so that the sidebars can be +.\" found and removed when they reach a certain age. If another argument +.\" is present, then a line break is forced before starting the sidebar. +.\" +.\" .VE +.\" End of vertical sidebar. +.\" +.\" .DS +.\" Begin an indented unfilled display. +.\" +.\" .DE +.\" End of indented unfilled display. +.\" +.\" .SO ?manpage? +.\" Start of list of standard options for a Tk widget. The manpage +.\" argument defines where to look up the standard options; if +.\" omitted, defaults to "options". The options follow on successive +.\" lines, in three columns separated by tabs. +.\" +.\" .SE +.\" End of list of standard options for a Tk widget. +.\" +.\" .OP cmdName dbName dbClass +.\" Start of description of a specific option. cmdName gives the +.\" option's name as specified in the class command, dbName gives +.\" the option's name in the option database, and dbClass gives +.\" the option's class in the option database. +.\" +.\" .UL arg1 arg2 +.\" Print arg1 underlined, then print arg2 normally. +.\" +.\" .QW arg1 ?arg2? +.\" Print arg1 in quotes, then arg2 normally (for trailing punctuation). +.\" +.\" .PQ arg1 ?arg2? +.\" Print an open parenthesis, arg1 in quotes, then arg2 normally +.\" (for trailing punctuation) and then a closing parenthesis. +.\" +.\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages. +.if t .wh -1.3i ^B +.nr ^l \n(.l +.ad b +.\" # Start an argument description +.de AP +.ie !"\\$4"" .TP \\$4 +.el \{\ +. ie !"\\$2"" .TP \\n()Cu +. el .TP 15 +.\} +.ta \\n()Au \\n()Bu +.ie !"\\$3"" \{\ +\&\\$1 \\fI\\$2\\fP (\\$3) +.\".b +.\} +.el \{\ +.br +.ie !"\\$2"" \{\ +\&\\$1 \\fI\\$2\\fP +.\} +.el \{\ +\&\\fI\\$1\\fP +.\} +.\} +.. +.\" # define tabbing values for .AP +.de AS +.nr )A 10n +.if !"\\$1"" .nr )A \\w'\\$1'u+3n +.nr )B \\n()Au+15n +.\" +.if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n +.nr )C \\n()Bu+\\w'(in/out)'u+2n +.. +.AS Tcl_Interp Tcl_CreateInterp in/out +.\" # BS - start boxed text +.\" # ^y = starting y location +.\" # ^b = 1 +.de BS +.br +.mk ^y +.nr ^b 1u +.if n .nf +.if n .ti 0 +.if n \l'\\n(.lu\(ul' +.if n .fi +.. +.\" # BE - end boxed text (draw box now) +.de BE +.nf +.ti 0 +.mk ^t +.ie n \l'\\n(^lu\(ul' +.el \{\ +.\" Draw four-sided box normally, but don't draw top of +.\" box if the box started on an earlier page. +.ie !\\n(^b-1 \{\ +\h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' +.\} +.el \}\ +\h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' +.\} +.\} +.fi +.br +.nr ^b 0 +.. +.\" # VS - start vertical sidebar +.\" # ^Y = starting y location +.\" # ^v = 1 (for troff; for nroff this doesn't matter) +.de VS +.if !"\\$2"" .br +.mk ^Y +.ie n 'mc \s12\(br\s0 +.el .nr ^v 1u +.. +.\" # VE - end of vertical sidebar +.de VE +.ie n 'mc +.el \{\ +.ev 2 +.nf +.ti 0 +.mk ^t +\h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n' +.sp -1 +.fi +.ev +.\} +.nr ^v 0 +.. +.\" # Special macro to handle page bottom: finish off current +.\" # box/sidebar if in box/sidebar mode, then invoked standard +.\" # page bottom macro. +.de ^B +.ev 2 +'ti 0 +'nf +.mk ^t +.if \\n(^b \{\ +.\" Draw three-sided box if this is the box's first page, +.\" draw two sides but no top otherwise. +.ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c +.el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c +.\} +.if \\n(^v \{\ +.nr ^x \\n(^tu+1v-\\n(^Yu +\kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c +.\} +.bp +'fi +.ev +.if \\n(^b \{\ +.mk ^y +.nr ^b 2 +.\} +.if \\n(^v \{\ +.mk ^Y +.\} +.. +.\" # DS - begin display +.de DS +.RS +.nf +.sp +.. +.\" # DE - end display +.de DE +.fi +.RE +.sp +.. +.\" # SO - start of list of standard options +.de SO +'ie '\\$1'' .ds So \\fBoptions\\fR +'el .ds So \\fB\\$1\\fR +.SH "STANDARD OPTIONS" +.LP +.nf +.ta 5.5c 11c +.ft B +.. +.\" # SE - end of list of standard options +.de SE +.fi +.ft R +.LP +See the \\*(So manual entry for details on the standard options. +.. +.\" # OP - start of full description for a single option +.de OP +.LP +.nf +.ta 4c +Command-Line Name: \\fB\\$1\\fR +Database Name: \\fB\\$2\\fR +Database Class: \\fB\\$3\\fR +.fi +.IP +.. +.\" # CS - begin code excerpt +.de CS +.RS +.nf +.ta .25i .5i .75i 1i +.. +.\" # CE - end code excerpt +.de CE +.fi +.RE +.. +.\" # UL - underline word +.de UL +\\$1\l'|0\(ul'\\$2 +.. +.\" # QW - apply quotation marks to word +.de QW +.ie '\\*(lq'"' ``\\$1''\\$2 +.\"" fix emacs highlighting +.el \\*(lq\\$1\\*(rq\\$2 +.. +.\" # PQ - apply parens and quotation marks to word +.de PQ +.ie '\\*(lq'"' (``\\$1''\\$2)\\$3 +.\"" fix emacs highlighting +.el (\\*(lq\\$1\\*(rq\\$2)\\$3 +.. +.\" # QR - quoted range +.de QR +.ie '\\*(lq'"' ``\\$1''\\-``\\$2''\\$3 +.\"" fix emacs highlighting +.el \\*(lq\\$1\\*(rq\\-\\*(lq\\$2\\*(rq\\$3 +.. +.\" # MT - "empty" string +.de MT +.QW "" +.. +.BS +.SH NAME +pt::util \- General utilities +.SH SYNOPSIS +package require \fBTcl 8\&.5\fR +.sp +package require \fBpt::ast ?1?\fR +.sp +\fB::pt::util\fR \fBerror2readable\fR \fIerror\fR \fItext\fR +.sp +\fB::pt::util\fR \fBerror2position\fR \fIerror\fR \fItext\fR +.sp +\fB::pt::util\fR \fBerror2text\fR \fIerror\fR +.sp +.BE +.SH DESCRIPTION +.PP +Are you lost ? +Do you have trouble understanding this document ? +In that case please read the overview provided by the +\fIIntroduction to Parser Tools\fR\&. This document is the +entrypoint to the whole system the current package is a part of\&. +.PP +This package provides general utility commands\&. +.PP +This is a supporting package in the Core Layer of Parser Tools\&. +.PP +IMAGE: arch_core_support +.PP +.SH API +.TP +\fB::pt::util\fR \fBerror2readable\fR \fIerror\fR \fItext\fR +This command takes the structured form of a syntax \fIerror\fR as +thrown by parser runtimes and the input \fItext\fR to the parser which +caused that error and returns a string describing the error in a +human-readable form\&. +.sp +The input \fItext\fR is required to convert the character +position of the error into a more readable line/column format, and to +provide excerpts of the input around the error position\&. +.TP +\fB::pt::util\fR \fBerror2position\fR \fIerror\fR \fItext\fR +This command takes the structured form of a syntax \fIerror\fR as +thrown by parser runtimes and the input \fItext\fR to the parser which +caused that error and returns a 2-element list containing the line +number and column index for the error's character position in the +input, in this order\&. +.TP +\fB::pt::util\fR \fBerror2text\fR \fIerror\fR +This command takes the structured form of a syntax \fIerror\fR as +thrown by parser runtimes and returns a list of strings, each +describing a possible expected input in a human-readable form\&. +.PP +.SH "BUGS, IDEAS, FEEDBACK" +This document, and the package it describes, will undoubtedly contain +bugs and other problems\&. +Please report such in the category \fIpt\fR of the +\fITcllib Trackers\fR [http://core\&.tcl\&.tk/tcllib/reportlist]\&. +Please also report any ideas for enhancements you may have for either +package and/or documentation\&. +.SH KEYWORDS +EBNF, LL(k), PEG, TDPL, context-free languages, expression, grammar, matching, parser, parsing expression, parsing expression grammar, push down automaton, recursive descent, state, top-down parsing languages, transducer +.SH CATEGORY +Parsing and Grammars +.SH COPYRIGHT +.nf +Copyright (c) 2009 Andreas Kupries + +.fi Index: embedded/man/index.n ================================================================== --- embedded/man/index.n +++ embedded/man/index.n @@ -1559,10 +1559,13 @@ \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl +.TP +\fBfiles/modules/pt/pt_cparam_config_tea\&.n\fR +pt::cparam::configuration::tea .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR @@ -1652,10 +1655,13 @@ \fBfiles/modules/pt/pt_tclparam_config_snit\&.n\fR pt::tclparam::configuration::snit .TP \fBfiles/modules/pt/pt_tclparam_config_tcloo\&.n\fR pt::tclparam::configuration::tcloo +.TP +\fBfiles/modules/pt/pt_util\&.n\fR +pt::util .TP \fBfiles/modules/pt/pt_to_api\&.n\fR pt_export_api .TP \fBfiles/modules/pt/pt_from_api\&.n\fR @@ -2849,10 +2855,13 @@ \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl +.TP +\fBfiles/modules/pt/pt_cparam_config_tea\&.n\fR +pt::cparam::configuration::tea .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR @@ -2942,10 +2951,13 @@ \fBfiles/modules/pt/pt_tclparam_config_snit\&.n\fR pt::tclparam::configuration::snit .TP \fBfiles/modules/pt/pt_tclparam_config_tcloo\&.n\fR pt::tclparam::configuration::tcloo +.TP +\fBfiles/modules/pt/pt_util\&.n\fR +pt::util .TP \fBfiles/modules/pt/pt_to_api\&.n\fR pt_export_api .TP \fBfiles/modules/pt/pt_from_api\&.n\fR @@ -3278,10 +3290,13 @@ \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl +.TP +\fBfiles/modules/pt/pt_cparam_config_tea\&.n\fR +pt::cparam::configuration::tea .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR @@ -3371,10 +3386,13 @@ \fBfiles/modules/pt/pt_tclparam_config_snit\&.n\fR pt::tclparam::configuration::snit .TP \fBfiles/modules/pt/pt_tclparam_config_tcloo\&.n\fR pt::tclparam::configuration::tcloo +.TP +\fBfiles/modules/pt/pt_util\&.n\fR +pt::util .TP \fBfiles/modules/pt/pt_to_api\&.n\fR pt_export_api .TP \fBfiles/modules/pt/pt_from_api\&.n\fR @@ -3944,10 +3962,13 @@ \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl +.TP +\fBfiles/modules/pt/pt_cparam_config_tea\&.n\fR +pt::cparam::configuration::tea .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR @@ -4037,10 +4058,13 @@ \fBfiles/modules/pt/pt_tclparam_config_snit\&.n\fR pt::tclparam::configuration::snit .TP \fBfiles/modules/pt/pt_tclparam_config_tcloo\&.n\fR pt::tclparam::configuration::tcloo +.TP +\fBfiles/modules/pt/pt_util\&.n\fR +pt::util .TP \fBfiles/modules/pt/pt_to_api\&.n\fR pt_export_api .TP \fBfiles/modules/pt/pt_from_api\&.n\fR @@ -5123,10 +5147,13 @@ \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl +.TP +\fBfiles/modules/pt/pt_cparam_config_tea\&.n\fR +pt::cparam::configuration::tea .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR @@ -5216,10 +5243,13 @@ \fBfiles/modules/pt/pt_tclparam_config_snit\&.n\fR pt::tclparam::configuration::snit .TP \fBfiles/modules/pt/pt_tclparam_config_tcloo\&.n\fR pt::tclparam::configuration::tcloo +.TP +\fBfiles/modules/pt/pt_util\&.n\fR +pt::util .TP \fBfiles/modules/pt/pt_to_api\&.n\fR pt_export_api .TP \fBfiles/modules/pt/pt_from_api\&.n\fR @@ -5588,10 +5618,13 @@ \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl +.TP +\fBfiles/modules/pt/pt_cparam_config_tea\&.n\fR +pt::cparam::configuration::tea .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR @@ -5681,10 +5714,13 @@ \fBfiles/modules/pt/pt_tclparam_config_snit\&.n\fR pt::tclparam::configuration::snit .TP \fBfiles/modules/pt/pt_tclparam_config_tcloo\&.n\fR pt::tclparam::configuration::tcloo +.TP +\fBfiles/modules/pt/pt_util\&.n\fR +pt::util .TP \fBfiles/modules/pt/pt_to_api\&.n\fR pt_export_api .TP \fBfiles/modules/pt/pt_from_api\&.n\fR @@ -6551,10 +6587,13 @@ \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl +.TP +\fBfiles/modules/pt/pt_cparam_config_tea\&.n\fR +pt::cparam::configuration::tea .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR @@ -6644,10 +6683,13 @@ \fBfiles/modules/pt/pt_tclparam_config_snit\&.n\fR pt::tclparam::configuration::snit .TP \fBfiles/modules/pt/pt_tclparam_config_tcloo\&.n\fR pt::tclparam::configuration::tcloo +.TP +\fBfiles/modules/pt/pt_util\&.n\fR +pt::util .TP \fBfiles/modules/pt/pt_to_api\&.n\fR pt_export_api .TP \fBfiles/modules/pt/pt_from_api\&.n\fR @@ -6788,10 +6830,13 @@ \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl +.TP +\fBfiles/modules/pt/pt_cparam_config_tea\&.n\fR +pt::cparam::configuration::tea .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR @@ -6881,10 +6926,13 @@ \fBfiles/modules/pt/pt_tclparam_config_snit\&.n\fR pt::tclparam::configuration::snit .TP \fBfiles/modules/pt/pt_tclparam_config_tcloo\&.n\fR pt::tclparam::configuration::tcloo +.TP +\fBfiles/modules/pt/pt_util\&.n\fR +pt::util .TP \fBfiles/modules/pt/pt_to_api\&.n\fR pt_export_api .TP \fBfiles/modules/pt/pt_from_api\&.n\fR @@ -6923,10 +6971,13 @@ \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl +.TP +\fBfiles/modules/pt/pt_cparam_config_tea\&.n\fR +pt::cparam::configuration::tea .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR @@ -7016,10 +7067,13 @@ \fBfiles/modules/pt/pt_tclparam_config_snit\&.n\fR pt::tclparam::configuration::snit .TP \fBfiles/modules/pt/pt_tclparam_config_tcloo\&.n\fR pt::tclparam::configuration::tcloo +.TP +\fBfiles/modules/pt/pt_util\&.n\fR +pt::util .TP \fBfiles/modules/pt/pt_to_api\&.n\fR pt_export_api .TP \fBfiles/modules/pt/pt_from_api\&.n\fR @@ -7097,10 +7151,13 @@ \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl +.TP +\fBfiles/modules/pt/pt_cparam_config_tea\&.n\fR +pt::cparam::configuration::tea .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR @@ -7190,10 +7247,13 @@ \fBfiles/modules/pt/pt_tclparam_config_snit\&.n\fR pt::tclparam::configuration::snit .TP \fBfiles/modules/pt/pt_tclparam_config_tcloo\&.n\fR pt::tclparam::configuration::tcloo +.TP +\fBfiles/modules/pt/pt_util\&.n\fR +pt::util .TP \fBfiles/modules/pt/pt_to_api\&.n\fR pt_export_api .TP \fBfiles/modules/pt/pt_from_api\&.n\fR @@ -7544,10 +7604,13 @@ \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl +.TP +\fBfiles/modules/pt/pt_cparam_config_tea\&.n\fR +pt::cparam::configuration::tea .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR @@ -7637,10 +7700,13 @@ \fBfiles/modules/pt/pt_tclparam_config_snit\&.n\fR pt::tclparam::configuration::snit .TP \fBfiles/modules/pt/pt_tclparam_config_tcloo\&.n\fR pt::tclparam::configuration::tcloo +.TP +\fBfiles/modules/pt/pt_util\&.n\fR +pt::util .TP \fBfiles/modules/pt/pt_to_api\&.n\fR pt_export_api .TP \fBfiles/modules/pt/pt_from_api\&.n\fR @@ -7805,10 +7871,13 @@ \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl +.TP +\fBfiles/modules/pt/pt_cparam_config_tea\&.n\fR +pt::cparam::configuration::tea .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR @@ -7898,10 +7967,13 @@ \fBfiles/modules/pt/pt_tclparam_config_snit\&.n\fR pt::tclparam::configuration::snit .TP \fBfiles/modules/pt/pt_tclparam_config_tcloo\&.n\fR pt::tclparam::configuration::tcloo +.TP +\fBfiles/modules/pt/pt_util\&.n\fR +pt::util .TP \fBfiles/modules/pt/pt_to_api\&.n\fR pt_export_api .TP \fBfiles/modules/pt/pt_from_api\&.n\fR @@ -9101,10 +9173,13 @@ \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl +.TP +\fBfiles/modules/pt/pt_cparam_config_tea\&.n\fR +pt::cparam::configuration::tea .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR @@ -9194,10 +9269,13 @@ \fBfiles/modules/pt/pt_tclparam_config_snit\&.n\fR pt::tclparam::configuration::snit .TP \fBfiles/modules/pt/pt_tclparam_config_tcloo\&.n\fR pt::tclparam::configuration::tcloo +.TP +\fBfiles/modules/pt/pt_util\&.n\fR +pt::util .TP \fBfiles/modules/pt/pt_to_api\&.n\fR pt_export_api .TP \fBfiles/modules/pt/pt_from_api\&.n\fR @@ -9587,10 +9665,13 @@ \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl +.TP +\fBfiles/modules/pt/pt_cparam_config_tea\&.n\fR +pt::cparam::configuration::tea .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR @@ -9680,10 +9761,13 @@ \fBfiles/modules/pt/pt_tclparam_config_snit\&.n\fR pt::tclparam::configuration::snit .TP \fBfiles/modules/pt/pt_tclparam_config_tcloo\&.n\fR pt::tclparam::configuration::tcloo +.TP +\fBfiles/modules/pt/pt_util\&.n\fR +pt::util .TP \fBfiles/modules/pt/pt_to_api\&.n\fR pt_export_api .TP \fBfiles/modules/pt/pt_from_api\&.n\fR @@ -10235,10 +10319,13 @@ \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl +.TP +\fBfiles/modules/pt/pt_cparam_config_tea\&.n\fR +pt::cparam::configuration::tea .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR @@ -10328,10 +10415,13 @@ \fBfiles/modules/pt/pt_tclparam_config_snit\&.n\fR pt::tclparam::configuration::snit .TP \fBfiles/modules/pt/pt_tclparam_config_tcloo\&.n\fR pt::tclparam::configuration::tcloo +.TP +\fBfiles/modules/pt/pt_util\&.n\fR +pt::util .TP \fBfiles/modules/pt/pt_to_api\&.n\fR pt_export_api .TP \fBfiles/modules/pt/pt_from_api\&.n\fR @@ -10415,10 +10505,13 @@ \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl +.TP +\fBfiles/modules/pt/pt_cparam_config_tea\&.n\fR +pt::cparam::configuration::tea .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR @@ -10508,10 +10601,13 @@ \fBfiles/modules/pt/pt_tclparam_config_snit\&.n\fR pt::tclparam::configuration::snit .TP \fBfiles/modules/pt/pt_tclparam_config_tcloo\&.n\fR pt::tclparam::configuration::tcloo +.TP +\fBfiles/modules/pt/pt_util\&.n\fR +pt::util .TP \fBfiles/modules/pt/pt_to_api\&.n\fR pt_export_api .TP \fBfiles/modules/pt/pt_from_api\&.n\fR Index: embedded/man/toc.n ================================================================== --- embedded/man/toc.n +++ embedded/man/toc.n @@ -946,10 +946,13 @@ \fIfiles/modules/pt/pt_astree\&.n\fR: Abstract Syntax Tree Serialization .TP \fBpt::cparam::configuration::critcl\fR \fIfiles/modules/pt/pt_cparam_config_critcl\&.n\fR: C/PARAM, Canned configuration, Critcl .TP +\fBpt::cparam::configuration::tea\fR +\fIfiles/modules/pt/pt_cparam_config_tea\&.n\fR: C/PARAM, Canned configuration, TEA +.TP \fBpt::json_language\fR \fIfiles/modules/pt/pt_json_language\&.n\fR: The JSON Grammar Exchange Format .TP \fBpt::param\fR \fIfiles/modules/pt/pt_param\&.n\fR: PackRat Machine Specification @@ -1039,10 +1042,13 @@ \fIfiles/modules/pt/pt_tclparam_config_snit\&.n\fR: Tcl/PARAM, Canned configuration, Snit .TP \fBpt::tclparam::configuration::tcloo\fR \fIfiles/modules/pt/pt_tclparam_config_tcloo\&.n\fR: Tcl/PARAM, Canned configuration, Tcloo .TP +\fBpt::util\fR +\fIfiles/modules/pt/pt_util\&.n\fR: General utilities +.TP \fBpt_export_api\fR \fIfiles/modules/pt/pt_to_api\&.n\fR: Parser Tools Export API .TP \fBpt_import_api\fR \fIfiles/modules/pt/pt_from_api\&.n\fR: Parser Tools Import API Index: embedded/www/index.html ================================================================== --- embedded/www/index.html +++ embedded/www/index.html @@ -748,11 +748,11 @@ grammar::me_intro context-free languages - grammar::me_intro · grammar::peg · grammar::peg::interp · pt · pt::ast · pt::cparam::configuration::critcl · pt::json_language · pt::param · pt::pe · pt::pe::op · pt::peg · pt::peg::container · pt::peg::container::peg · pt::peg::export · pt::peg::export::container · pt::peg::export::json · pt::peg::export::peg · pt::peg::from::container · pt::peg::from::json · pt::peg::from::peg · pt::peg::import · pt::peg::import::container · pt::peg::import::json · pt::peg::import::peg · pt::peg::interp · pt::peg::to::container · pt::peg::to::cparam · pt::peg::to::json · pt::peg::to::param · pt::peg::to::peg · pt::peg::to::tclparam · pt::peg_language · pt::pegrammar · pt::pgen · pt::rde · pt::tclparam::configuration::snit · pt::tclparam::configuration::tcloo · pt_export_api · pt_import_api · pt_introduction · pt_parse_peg · pt_parser_api · pt_peg_op + grammar::me_intro · grammar::peg · grammar::peg::interp · pt · pt::ast · pt::cparam::configuration::critcl · pt::cparam::configuration::tea · pt::json_language · pt::param · pt::pe · pt::pe::op · pt::peg · pt::peg::container · pt::peg::container::peg · pt::peg::export · pt::peg::export::container · pt::peg::export::json · pt::peg::export::peg · pt::peg::from::container · pt::peg::from::json · pt::peg::from::peg · pt::peg::import · pt::peg::import::container · pt::peg::import::json · pt::peg::import::peg · pt::peg::interp · pt::peg::to::container · pt::peg::to::cparam · pt::peg::to::json · pt::peg::to::param · pt::peg::to::peg · pt::peg::to::tclparam · pt::peg_language · pt::pegrammar · pt::pgen · pt::rde · pt::tclparam::configuration::snit · pt::tclparam::configuration::tcloo · pt::util · pt_export_api · pt_import_api · pt_introduction · pt_parse_peg · pt_parser_api · pt_peg_op control control · term · term::ansi::code · term::ansi::code::attr · term::ansi::code::ctrl · term::ansi::code::macros · term::ansi::ctrl::unix · term::ansi::send · term::interact::menu · term::interact::pager · term::receive · term::receive::bind · term::send @@ -1214,11 +1214,11 @@ grammar::aycock EBNF - pt · pt::ast · pt::cparam::configuration::critcl · pt::json_language · pt::param · pt::pe · pt::pe::op · pt::peg · pt::peg::container · pt::peg::container::peg · pt::peg::export · pt::peg::export::container · pt::peg::export::json · pt::peg::export::peg · pt::peg::from::container · pt::peg::from::json · pt::peg::from::peg · pt::peg::import · pt::peg::import::container · pt::peg::import::json · pt::peg::import::peg · pt::peg::interp · pt::peg::to::container · pt::peg::to::cparam · pt::peg::to::json · pt::peg::to::param · pt::peg::to::peg · pt::peg::to::tclparam · pt::peg_language · pt::pegrammar · pt::pgen · pt::rde · pt::tclparam::configuration::snit · pt::tclparam::configuration::tcloo · pt_export_api · pt_import_api · pt_introduction · pt_parse_peg · pt_parser_api · pt_peg_op + pt · pt::ast · pt::cparam::configuration::critcl · pt::cparam::configuration::tea · pt::json_language · pt::param · pt::pe · pt::pe::op · pt::peg · pt::peg::container · pt::peg::container::peg · pt::peg::export · pt::peg::export::container · pt::peg::export::json · pt::peg::export::peg · pt::peg::from::container · pt::peg::from::json · pt::peg::from::peg · pt::peg::import · pt::peg::import::container · pt::peg::import::json · pt::peg::import::peg · pt::peg::interp · pt::peg::to::container · pt::peg::to::cparam · pt::peg::to::json · pt::peg::to::param · pt::peg::to::peg · pt::peg::to::tclparam · pt::peg_language · pt::pegrammar · pt::pgen · pt::rde · pt::tclparam::configuration::snit · pt::tclparam::configuration::tcloo · pt::util · pt_export_api · pt_import_api · pt_introduction · pt_parse_peg · pt_parser_api · pt_peg_op eccentricity struct::graph::op @@ -1354,11 +1354,11 @@ doctools::html::cssdefaults · doctools::idx::export · doctools::idx::export::docidx · doctools::idx::export::html · doctools::idx::export::json · doctools::idx::export::nroff · doctools::idx::export::text · doctools::idx::export::wiki · doctools::nroff::man_macros · doctools::toc::export · doctools::toc::export::doctoc · doctools::toc::export::html · doctools::toc::export::json · doctools::toc::export::nroff · doctools::toc::export::text · doctools::toc::export::wiki · pt::peg::export::container · pt::peg::export::json · pt::peg::export::peg expression - grammar::me_intro · grammar::peg · grammar::peg::interp · pt · pt::ast · pt::cparam::configuration::critcl · pt::json_language · pt::param · pt::pe · pt::pe::op · pt::peg · pt::peg::container · pt::peg::container::peg · pt::peg::export · pt::peg::export::container · pt::peg::export::json · pt::peg::export::peg · pt::peg::from::container · pt::peg::from::json · pt::peg::from::peg · pt::peg::import · pt::peg::import::container · pt::peg::import::json · pt::peg::import::peg · pt::peg::interp · pt::peg::to::container · pt::peg::to::cparam · pt::peg::to::json · pt::peg::to::param · pt::peg::to::peg · pt::peg::to::tclparam · pt::peg_language · pt::pegrammar · pt::pgen · pt::rde · pt::tclparam::configuration::snit · pt::tclparam::configuration::tcloo · pt_export_api · pt_import_api · pt_introduction · pt_parse_peg · pt_parser_api · pt_peg_op + grammar::me_intro · grammar::peg · grammar::peg::interp · pt · pt::ast · pt::cparam::configuration::critcl · pt::cparam::configuration::tea · pt::json_language · pt::param · pt::pe · pt::pe::op · pt::peg · pt::peg::container · pt::peg::container::peg · pt::peg::export · pt::peg::export::container · pt::peg::export::json · pt::peg::export::peg · pt::peg::from::container · pt::peg::from::json · pt::peg::from::peg · pt::peg::import · pt::peg::import::container · pt::peg::import::json · pt::peg::import::peg · pt::peg::interp · pt::peg::to::container · pt::peg::to::cparam · pt::peg::to::json · pt::peg::to::param · pt::peg::to::peg · pt::peg::to::tclparam · pt::peg_language · pt::pegrammar · pt::pgen · pt::rde · pt::tclparam::configuration::snit · pt::tclparam::configuration::tcloo · pt::util · pt_export_api · pt_import_api · pt_introduction · pt_parse_peg · pt_parser_api · pt_peg_op extended namespace namespacex @@ -1625,11 +1625,11 @@ gpx grammar - grammar::aycock · grammar::fa · grammar::fa::dacceptor · grammar::fa::dexec · grammar::fa::op · grammar::me::cpu · grammar::me::cpu::core · grammar::me::cpu::gasm · grammar::me::tcl · grammar::me_intro · grammar::me_vm · grammar::peg · grammar::peg::interp · pt · pt::ast · pt::cparam::configuration::critcl · pt::json_language · pt::param · pt::pe · pt::pe::op · pt::peg · pt::peg::container · pt::peg::container::peg · pt::peg::export · pt::peg::export::container · pt::peg::export::json · pt::peg::export::peg · pt::peg::from::container · pt::peg::from::json · pt::peg::from::peg · pt::peg::import · pt::peg::import::container · pt::peg::import::json · pt::peg::import::peg · pt::peg::interp · pt::peg::to::container · pt::peg::to::cparam · pt::peg::to::json · pt::peg::to::param · pt::peg::to::peg · pt::peg::to::tclparam · pt::peg_language · pt::pegrammar · pt::pgen · pt::rde · pt::tclparam::configuration::snit · pt::tclparam::configuration::tcloo · pt_export_api · pt_import_api · pt_introduction · pt_parse_peg · pt_parser_api · pt_peg_op + grammar::aycock · grammar::fa · grammar::fa::dacceptor · grammar::fa::dexec · grammar::fa::op · grammar::me::cpu · grammar::me::cpu::core · grammar::me::cpu::gasm · grammar::me::tcl · grammar::me_intro · grammar::me_vm · grammar::peg · grammar::peg::interp · pt · pt::ast · pt::cparam::configuration::critcl · pt::cparam::configuration::tea · pt::json_language · pt::param · pt::pe · pt::pe::op · pt::peg · pt::peg::container · pt::peg::container::peg · pt::peg::export · pt::peg::export::container · pt::peg::export::json · pt::peg::export::peg · pt::peg::from::container · pt::peg::from::json · pt::peg::from::peg · pt::peg::import · pt::peg::import::container · pt::peg::import::json · pt::peg::import::peg · pt::peg::interp · pt::peg::to::container · pt::peg::to::cparam · pt::peg::to::json · pt::peg::to::param · pt::peg::to::peg · pt::peg::to::tclparam · pt::peg_language · pt::pegrammar · pt::pgen · pt::rde · pt::tclparam::configuration::snit · pt::tclparam::configuration::tcloo · pt::util · pt_export_api · pt_import_api · pt_introduction · pt_parse_peg · pt_parser_api · pt_peg_op graph grammar::me::cpu::gasm · struct::graph · struct::graph::op · struct::graph_v1 · struct::queue · struct::stack @@ -2125,11 +2125,11 @@ docstrip · docstrip_util · tcldocstrip LL(k) - grammar::me_intro · grammar::peg · grammar::peg::interp · pt · pt::ast · pt::cparam::configuration::critcl · pt::json_language · pt::param · pt::pe · pt::pe::op · pt::peg · pt::peg::container · pt::peg::container::peg · pt::peg::export · pt::peg::export::container · pt::peg::export::json · pt::peg::export::peg · pt::peg::from::container · pt::peg::from::json · pt::peg::from::peg · pt::peg::import · pt::peg::import::container · pt::peg::import::json · pt::peg::import::peg · pt::peg::interp · pt::peg::to::container · pt::peg::to::cparam · pt::peg::to::json · pt::peg::to::param · pt::peg::to::peg · pt::peg::to::tclparam · pt::peg_language · pt::pegrammar · pt::pgen · pt::rde · pt::tclparam::configuration::snit · pt::tclparam::configuration::tcloo · pt_export_api · pt_import_api · pt_introduction · pt_parse_peg · pt_parser_api · pt_peg_op + grammar::me_intro · grammar::peg · grammar::peg::interp · pt · pt::ast · pt::cparam::configuration::critcl · pt::cparam::configuration::tea · pt::json_language · pt::param · pt::pe · pt::pe::op · pt::peg · pt::peg::container · pt::peg::container::peg · pt::peg::export · pt::peg::export::container · pt::peg::export::json · pt::peg::export::peg · pt::peg::from::container · pt::peg::from::json · pt::peg::from::peg · pt::peg::import · pt::peg::import::container · pt::peg::import::json · pt::peg::import::peg · pt::peg::interp · pt::peg::to::container · pt::peg::to::cparam · pt::peg::to::json · pt::peg::to::param · pt::peg::to::peg · pt::peg::to::tclparam · pt::peg_language · pt::pegrammar · pt::pgen · pt::rde · pt::tclparam::configuration::snit · pt::tclparam::configuration::tcloo · pt::util · pt_export_api · pt_import_api · pt_introduction · pt_parse_peg · pt_parser_api · pt_peg_op local searching struct::graph::op @@ -2228,11 +2228,11 @@ valtype::creditcard::mastercard matching - grammar::me_intro · grammar::peg::interp · pt · pt::ast · pt::cparam::configuration::critcl · pt::json_language · pt::param · pt::pe · pt::pe::op · pt::peg · pt::peg::container · pt::peg::container::peg · pt::peg::export · pt::peg::export::container · pt::peg::export::json · pt::peg::export::peg · pt::peg::from::container · pt::peg::from::json · pt::peg::from::peg · pt::peg::import · pt::peg::import::container · pt::peg::import::json · pt::peg::import::peg · pt::peg::interp · pt::peg::to::container · pt::peg::to::cparam · pt::peg::to::json · pt::peg::to::param · pt::peg::to::peg · pt::peg::to::tclparam · pt::peg_language · pt::pegrammar · pt::pgen · pt::rde · pt::tclparam::configuration::snit · pt::tclparam::configuration::tcloo · pt_export_api · pt_import_api · pt_introduction · pt_parse_peg · pt_parser_api · pt_peg_op · struct::graph::op + grammar::me_intro · grammar::peg::interp · pt · pt::ast · pt::cparam::configuration::critcl · pt::cparam::configuration::tea · pt::json_language · pt::param · pt::pe · pt::pe::op · pt::peg · pt::peg::container · pt::peg::container::peg · pt::peg::export · pt::peg::export::container · pt::peg::export::json · pt::peg::export::peg · pt::peg::from::container · pt::peg::from::json · pt::peg::from::peg · pt::peg::import · pt::peg::import::container · pt::peg::import::json · pt::peg::import::peg · pt::peg::interp · pt::peg::to::container · pt::peg::to::cparam · pt::peg::to::json · pt::peg::to::param · pt::peg::to::peg · pt::peg::to::tclparam · pt::peg_language · pt::pegrammar · pt::pgen · pt::rde · pt::tclparam::configuration::snit · pt::tclparam::configuration::tcloo · pt::util · pt_export_api · pt_import_api · pt_introduction · pt_parse_peg · pt_parser_api · pt_peg_op · struct::graph::op math math · math::bigfloat · math::bignum · math::calculus · math::complexnumbers · math::constants · math::decimal · math::fuzzy · math::geometry · math::interpolate · math::linearalgebra · math::optimize · math::polynomials · math::rationalfunctions · math::special · simulation::annealing · simulation::montecarlo · simulation::random @@ -2632,11 +2632,11 @@ tepam · tepam::argument_dialogbox parser - doctools::idx::parse · doctools::tcl::parse · doctools::toc::parse · grammar::aycock · pt · pt::ast · pt::cparam::configuration::critcl · pt::json_language · pt::param · pt::pe · pt::pe::op · pt::peg · pt::peg::container · pt::peg::container::peg · pt::peg::export · pt::peg::export::container · pt::peg::export::json · pt::peg::export::peg · pt::peg::from::container · pt::peg::from::json · pt::peg::from::peg · pt::peg::import · pt::peg::import::container · pt::peg::import::json · pt::peg::import::peg · pt::peg::interp · pt::peg::to::container · pt::peg::to::cparam · pt::peg::to::json · pt::peg::to::param · pt::peg::to::peg · pt::peg::to::tclparam · pt::peg_language · pt::pegrammar · pt::pgen · pt::rde · pt::tclparam::configuration::snit · pt::tclparam::configuration::tcloo · pt_export_api · pt_import_api · pt_introduction · pt_parse_peg · pt_parser_api · pt_peg_op · xsxp + doctools::idx::parse · doctools::tcl::parse · doctools::toc::parse · grammar::aycock · pt · pt::ast · pt::cparam::configuration::critcl · pt::cparam::configuration::tea · pt::json_language · pt::param · pt::pe · pt::pe::op · pt::peg · pt::peg::container · pt::peg::container::peg · pt::peg::export · pt::peg::export::container · pt::peg::export::json · pt::peg::export::peg · pt::peg::from::container · pt::peg::from::json · pt::peg::from::peg · pt::peg::import · pt::peg::import::container · pt::peg::import::json · pt::peg::import::peg · pt::peg::interp · pt::peg::to::container · pt::peg::to::cparam · pt::peg::to::json · pt::peg::to::param · pt::peg::to::peg · pt::peg::to::tclparam · pt::peg_language · pt::pegrammar · pt::pgen · pt::rde · pt::tclparam::configuration::snit · pt::tclparam::configuration::tcloo · pt::util · pt_export_api · pt_import_api · pt_introduction · pt_parse_peg · pt_parser_api · pt_peg_op · xsxp parser generator page · page_intro · page_pluginmgr · page_util_flow · page_util_norm_lemon · page_util_norm_peg · page_util_peg · page_util_quote @@ -2647,16 +2647,16 @@ bench::in · bibtex · doctools2idx_introduction · doctools2toc_introduction · doctools::idx · doctools::idx::import · doctools::toc · doctools::toc::import · grammar::aycock · grammar::fa · grammar::fa::dacceptor · grammar::fa::dexec · grammar::fa::op · grammar::me::cpu · grammar::me::cpu::core · grammar::me::cpu::gasm · grammar::me::tcl · grammar::me_intro · grammar::me_vm · grammar::peg · grammar::peg::interp · htmlparse · huddle · string::token::shell · yaml parsing expression - grammar::peg · grammar::peg::interp · pt · pt::ast · pt::cparam::configuration::critcl · pt::json_language · pt::param · pt::pe · pt::pe::op · pt::peg · pt::peg::container · pt::peg::container::peg · pt::peg::export · pt::peg::export::container · pt::peg::export::json · pt::peg::export::peg · pt::peg::from::container · pt::peg::from::json · pt::peg::from::peg · pt::peg::import · pt::peg::import::container · pt::peg::import::json · pt::peg::import::peg · pt::peg::interp · pt::peg::to::container · pt::peg::to::cparam · pt::peg::to::json · pt::peg::to::param · pt::peg::to::peg · pt::peg::to::tclparam · pt::peg_language · pt::pegrammar · pt::pgen · pt::rde · pt::tclparam::configuration::snit · pt::tclparam::configuration::tcloo · pt_export_api · pt_import_api · pt_introduction · pt_parse_peg · pt_parser_api · pt_peg_op + grammar::peg · grammar::peg::interp · pt · pt::ast · pt::cparam::configuration::critcl · pt::cparam::configuration::tea · pt::json_language · pt::param · pt::pe · pt::pe::op · pt::peg · pt::peg::container · pt::peg::container::peg · pt::peg::export · pt::peg::export::container · pt::peg::export::json · pt::peg::export::peg · pt::peg::from::container · pt::peg::from::json · pt::peg::from::peg · pt::peg::import · pt::peg::import::container · pt::peg::import::json · pt::peg::import::peg · pt::peg::interp · pt::peg::to::container · pt::peg::to::cparam · pt::peg::to::json · pt::peg::to::param · pt::peg::to::peg · pt::peg::to::tclparam · pt::peg_language · pt::pegrammar · pt::pgen · pt::rde · pt::tclparam::configuration::snit · pt::tclparam::configuration::tcloo · pt::util · pt_export_api · pt_import_api · pt_introduction · pt_parse_peg · pt_parser_api · pt_peg_op parsing expression grammar - grammar::me_intro · grammar::peg · grammar::peg::interp · page_util_peg · pt · pt::ast · pt::cparam::configuration::critcl · pt::json_language · pt::param · pt::pe · pt::pe::op · pt::peg · pt::peg::container · pt::peg::container::peg · pt::peg::export · pt::peg::export::container · pt::peg::export::json · pt::peg::export::peg · pt::peg::from::container · pt::peg::from::json · pt::peg::from::peg · pt::peg::import · pt::peg::import::container · pt::peg::import::json · pt::peg::import::peg · pt::peg::interp · pt::peg::to::container · pt::peg::to::cparam · pt::peg::to::json · pt::peg::to::param · pt::peg::to::peg · pt::peg::to::tclparam · pt::peg_language · pt::pegrammar · pt::pgen · pt::rde · pt::tclparam::configuration::snit · pt::tclparam::configuration::tcloo · pt_export_api · pt_import_api · pt_introduction · pt_parse_peg · pt_parser_api · pt_peg_op + grammar::me_intro · grammar::peg · grammar::peg::interp · page_util_peg · pt · pt::ast · pt::cparam::configuration::critcl · pt::cparam::configuration::tea · pt::json_language · pt::param · pt::pe · pt::pe::op · pt::peg · pt::peg::container · pt::peg::container::peg · pt::peg::export · pt::peg::export::container · pt::peg::export::json · pt::peg::export::peg · pt::peg::from::container · pt::peg::from::json · pt::peg::from::peg · pt::peg::import · pt::peg::import::container · pt::peg::import::json · pt::peg::import::peg · pt::peg::interp · pt::peg::to::container · pt::peg::to::cparam · pt::peg::to::json · pt::peg::to::param · pt::peg::to::peg · pt::peg::to::tclparam · pt::peg_language · pt::pegrammar · pt::pgen · pt::rde · pt::tclparam::configuration::snit · pt::tclparam::configuration::tcloo · pt::util · pt_export_api · pt_import_api · pt_introduction · pt_parse_peg · pt_parser_api · pt_peg_op partial application lambda @@ -2692,11 +2692,11 @@ rcs PEG - grammar::me_intro · page_util_norm_peg · page_util_peg · pt · pt::ast · pt::cparam::configuration::critcl · pt::json_language · pt::param · pt::pe · pt::pe::op · pt::peg · pt::peg::container · pt::peg::container::peg · pt::peg::export · pt::peg::export::container · pt::peg::export::json · pt::peg::export::peg · pt::peg::from::container · pt::peg::from::json · pt::peg::from::peg · pt::peg::import · pt::peg::import::container · pt::peg::import::json · pt::peg::import::peg · pt::peg::interp · pt::peg::to::container · pt::peg::to::cparam · pt::peg::to::json · pt::peg::to::param · pt::peg::to::peg · pt::peg::to::tclparam · pt::peg_language · pt::pegrammar · pt::pgen · pt::rde · pt::tclparam::configuration::snit · pt::tclparam::configuration::tcloo · pt_export_api · pt_import_api · pt_introduction · pt_parse_peg · pt_parser_api · pt_peg_op + grammar::me_intro · page_util_norm_peg · page_util_peg · pt · pt::ast · pt::cparam::configuration::critcl · pt::cparam::configuration::tea · pt::json_language · pt::param · pt::pe · pt::pe::op · pt::peg · pt::peg::container · pt::peg::container::peg · pt::peg::export · pt::peg::export::container · pt::peg::export::json · pt::peg::export::peg · pt::peg::from::container · pt::peg::from::json · pt::peg::from::peg · pt::peg::import · pt::peg::import::container · pt::peg::import::json · pt::peg::import::peg · pt::peg::interp · pt::peg::to::container · pt::peg::to::cparam · pt::peg::to::json · pt::peg::to::param · pt::peg::to::peg · pt::peg::to::tclparam · pt::peg_language · pt::pegrammar · pt::pgen · pt::rde · pt::tclparam::configuration::snit · pt::tclparam::configuration::tcloo · pt::util · pt_export_api · pt_import_api · pt_introduction · pt_parse_peg · pt_parser_api · pt_peg_op performance bench · bench::in · bench::out::csv · bench::out::text · bench_intro · bench_lang_intro · bench_lang_spec · profiler @@ -2862,11 +2862,11 @@ hook push down automaton - grammar::me_intro · grammar::peg · grammar::peg::interp · pt · pt::ast · pt::cparam::configuration::critcl · pt::json_language · pt::param · pt::pe · pt::pe::op · pt::peg · pt::peg::container · pt::peg::container::peg · pt::peg::export · pt::peg::export::container · pt::peg::export::json · pt::peg::export::peg · pt::peg::from::container · pt::peg::from::json · pt::peg::from::peg · pt::peg::import · pt::peg::import::container · pt::peg::import::json · pt::peg::import::peg · pt::peg::interp · pt::peg::to::container · pt::peg::to::cparam · pt::peg::to::json · pt::peg::to::param · pt::peg::to::peg · pt::peg::to::tclparam · pt::peg_language · pt::pegrammar · pt::pgen · pt::rde · pt::tclparam::configuration::snit · pt::tclparam::configuration::tcloo · pt_export_api · pt_import_api · pt_introduction · pt_parse_peg · pt_parser_api · pt_peg_op + grammar::me_intro · grammar::peg · grammar::peg::interp · pt · pt::ast · pt::cparam::configuration::critcl · pt::cparam::configuration::tea · pt::json_language · pt::param · pt::pe · pt::pe::op · pt::peg · pt::peg::container · pt::peg::container::peg · pt::peg::export · pt::peg::export::container · pt::peg::export::json · pt::peg::export::peg · pt::peg::from::container · pt::peg::from::json · pt::peg::from::peg · pt::peg::import · pt::peg::import::container · pt::peg::import::json · pt::peg::import::peg · pt::peg::interp · pt::peg::to::container · pt::peg::to::cparam · pt::peg::to::json · pt::peg::to::param · pt::peg::to::peg · pt::peg::to::tclparam · pt::peg_language · pt::pegrammar · pt::pgen · pt::rde · pt::tclparam::configuration::snit · pt::tclparam::configuration::tcloo · pt::util · pt_export_api · pt_import_api · pt_introduction · pt_parse_peg · pt_parser_api · pt_peg_op Keywords: Q @@ -2958,11 +2958,11 @@ struct::queue · struct::record recursive descent - grammar::me_intro · grammar::peg · grammar::peg::interp · pt · pt::ast · pt::cparam::configuration::critcl · pt::json_language · pt::param · pt::pe · pt::pe::op · pt::peg · pt::peg::container · pt::peg::container::peg · pt::peg::export · pt::peg::export::container · pt::peg::export::json · pt::peg::export::peg · pt::peg::from::container · pt::peg::from::json · pt::peg::from::peg · pt::peg::import · pt::peg::import::container · pt::peg::import::json · pt::peg::import::peg · pt::peg::interp · pt::peg::to::container · pt::peg::to::cparam · pt::peg::to::json · pt::peg::to::param · pt::peg::to::peg · pt::peg::to::tclparam · pt::peg_language · pt::pegrammar · pt::pgen · pt::rde · pt::tclparam::configuration::snit · pt::tclparam::configuration::tcloo · pt_export_api · pt_import_api · pt_introduction · pt_parse_peg · pt_parser_api · pt_peg_op + grammar::me_intro · grammar::peg · grammar::peg::interp · pt · pt::ast · pt::cparam::configuration::critcl · pt::cparam::configuration::tea · pt::json_language · pt::param · pt::pe · pt::pe::op · pt::peg · pt::peg::container · pt::peg::container::peg · pt::peg::export · pt::peg::export::container · pt::peg::export::json · pt::peg::export::peg · pt::peg::from::container · pt::peg::from::json · pt::peg::from::peg · pt::peg::import · pt::peg::import::container · pt::peg::import::json · pt::peg::import::peg · pt::peg::interp · pt::peg::to::container · pt::peg::to::cparam · pt::peg::to::json · pt::peg::to::param · pt::peg::to::peg · pt::peg::to::tclparam · pt::peg_language · pt::pegrammar · pt::pgen · pt::rde · pt::tclparam::configuration::snit · pt::tclparam::configuration::tcloo · pt::util · pt_export_api · pt_import_api · pt_introduction · pt_parse_peg · pt_parser_api · pt_peg_op reduce generator · struct::list @@ -3501,11 +3501,11 @@ tcl::chan::std state - grammar::fa · grammar::fa::dacceptor · grammar::fa::dexec · grammar::fa::op · grammar::peg · grammar::peg::interp · pt · pt::ast · pt::cparam::configuration::critcl · pt::json_language · pt::param · pt::pe · pt::pe::op · pt::peg · pt::peg::container · pt::peg::container::peg · pt::peg::export · pt::peg::export::container · pt::peg::export::json · pt::peg::export::peg · pt::peg::from::container · pt::peg::from::json · pt::peg::from::peg · pt::peg::import · pt::peg::import::container · pt::peg::import::json · pt::peg::import::peg · pt::peg::interp · pt::peg::to::container · pt::peg::to::cparam · pt::peg::to::json · pt::peg::to::param · pt::peg::to::peg · pt::peg::to::tclparam · pt::peg_language · pt::pegrammar · pt::pgen · pt::rde · pt::tclparam::configuration::snit · pt::tclparam::configuration::tcloo · pt_export_api · pt_import_api · pt_introduction · pt_parse_peg · pt_parser_api · pt_peg_op + grammar::fa · grammar::fa::dacceptor · grammar::fa::dexec · grammar::fa::op · grammar::peg · grammar::peg::interp · pt · pt::ast · pt::cparam::configuration::critcl · pt::cparam::configuration::tea · pt::json_language · pt::param · pt::pe · pt::pe::op · pt::peg · pt::peg::container · pt::peg::container::peg · pt::peg::export · pt::peg::export::container · pt::peg::export::json · pt::peg::export::peg · pt::peg::from::container · pt::peg::from::json · pt::peg::from::peg · pt::peg::import · pt::peg::import::container · pt::peg::import::json · pt::peg::import::peg · pt::peg::interp · pt::peg::to::container · pt::peg::to::cparam · pt::peg::to::json · pt::peg::to::param · pt::peg::to::peg · pt::peg::to::tclparam · pt::peg_language · pt::pegrammar · pt::pgen · pt::rde · pt::tclparam::configuration::snit · pt::tclparam::configuration::tcloo · pt::util · pt_export_api · pt_import_api · pt_introduction · pt_parse_peg · pt_parser_api · pt_peg_op state (de)serialization namespacex @@ -3709,11 +3709,11 @@ pt::peg::to::tclparam TDPL - grammar::peg · grammar::peg::interp · pt · pt::ast · pt::cparam::configuration::critcl · pt::json_language · pt::param · pt::pe · pt::pe::op · pt::peg · pt::peg::container · pt::peg::container::peg · pt::peg::export · pt::peg::export::container · pt::peg::export::json · pt::peg::export::peg · pt::peg::from::container · pt::peg::from::json · pt::peg::from::peg · pt::peg::import · pt::peg::import::container · pt::peg::import::json · pt::peg::import::peg · pt::peg::interp · pt::peg::to::container · pt::peg::to::cparam · pt::peg::to::json · pt::peg::to::param · pt::peg::to::peg · pt::peg::to::tclparam · pt::peg_language · pt::pegrammar · pt::pgen · pt::rde · pt::tclparam::configuration::snit · pt::tclparam::configuration::tcloo · pt_export_api · pt_import_api · pt_introduction · pt_parse_peg · pt_parser_api · pt_peg_op + grammar::peg · grammar::peg::interp · pt · pt::ast · pt::cparam::configuration::critcl · pt::cparam::configuration::tea · pt::json_language · pt::param · pt::pe · pt::pe::op · pt::peg · pt::peg::container · pt::peg::container::peg · pt::peg::export · pt::peg::export::container · pt::peg::export::json · pt::peg::export::peg · pt::peg::from::container · pt::peg::from::json · pt::peg::from::peg · pt::peg::import · pt::peg::import::container · pt::peg::import::json · pt::peg::import::peg · pt::peg::interp · pt::peg::to::container · pt::peg::to::cparam · pt::peg::to::json · pt::peg::to::param · pt::peg::to::peg · pt::peg::to::tclparam · pt::peg_language · pt::pegrammar · pt::pgen · pt::rde · pt::tclparam::configuration::snit · pt::tclparam::configuration::tcloo · pt::util · pt_export_api · pt_import_api · pt_introduction · pt_parse_peg · pt_parser_api · pt_peg_op temp file fileutil @@ -3889,11 +3889,11 @@ string::token · string::token::shell top-down parsing languages - grammar::me_intro · grammar::peg · grammar::peg::interp · pt · pt::ast · pt::cparam::configuration::critcl · pt::json_language · pt::param · pt::pe · pt::pe::op · pt::peg · pt::peg::container · pt::peg::container::peg · pt::peg::export · pt::peg::export::container · pt::peg::export::json · pt::peg::export::peg · pt::peg::from::container · pt::peg::from::json · pt::peg::from::peg · pt::peg::import · pt::peg::import::container · pt::peg::import::json · pt::peg::import::peg · pt::peg::interp · pt::peg::to::container · pt::peg::to::cparam · pt::peg::to::json · pt::peg::to::param · pt::peg::to::peg · pt::peg::to::tclparam · pt::peg_language · pt::pegrammar · pt::pgen · pt::rde · pt::tclparam::configuration::snit · pt::tclparam::configuration::tcloo · pt_export_api · pt_import_api · pt_introduction · pt_parse_peg · pt_parser_api · pt_peg_op + grammar::me_intro · grammar::peg · grammar::peg::interp · pt · pt::ast · pt::cparam::configuration::critcl · pt::cparam::configuration::tea · pt::json_language · pt::param · pt::pe · pt::pe::op · pt::peg · pt::peg::container · pt::peg::container::peg · pt::peg::export · pt::peg::export::container · pt::peg::export::json · pt::peg::export::peg · pt::peg::from::container · pt::peg::from::json · pt::peg::from::peg · pt::peg::import · pt::peg::import::container · pt::peg::import::json · pt::peg::import::peg · pt::peg::interp · pt::peg::to::container · pt::peg::to::cparam · pt::peg::to::json · pt::peg::to::param · pt::peg::to::peg · pt::peg::to::tclparam · pt::peg_language · pt::pegrammar · pt::pgen · pt::rde · pt::tclparam::configuration::snit · pt::tclparam::configuration::tcloo · pt::util · pt_export_api · pt_import_api · pt_introduction · pt_parse_peg · pt_parser_api · pt_peg_op torrent bee @@ -3914,11 +3914,11 @@ debug · debug::caller · debug::heartbeat · debug::timestamp transducer - grammar::aycock · grammar::fa · grammar::fa::dacceptor · grammar::fa::dexec · grammar::fa::op · grammar::me_intro · grammar::peg · grammar::peg::interp · pt · pt::ast · pt::cparam::configuration::critcl · pt::json_language · pt::param · pt::pe · pt::pe::op · pt::peg · pt::peg::container · pt::peg::container::peg · pt::peg::export · pt::peg::export::container · pt::peg::export::json · pt::peg::export::peg · pt::peg::from::container · pt::peg::from::json · pt::peg::from::peg · pt::peg::import · pt::peg::import::container · pt::peg::import::json · pt::peg::import::peg · pt::peg::interp · pt::peg::to::container · pt::peg::to::cparam · pt::peg::to::json · pt::peg::to::param · pt::peg::to::peg · pt::peg::to::tclparam · pt::peg_language · pt::pegrammar · pt::pgen · pt::rde · pt::tclparam::configuration::snit · pt::tclparam::configuration::tcloo · pt_export_api · pt_import_api · pt_introduction · pt_parse_peg · pt_parser_api · pt_peg_op + grammar::aycock · grammar::fa · grammar::fa::dacceptor · grammar::fa::dexec · grammar::fa::op · grammar::me_intro · grammar::peg · grammar::peg::interp · pt · pt::ast · pt::cparam::configuration::critcl · pt::cparam::configuration::tea · pt::json_language · pt::param · pt::pe · pt::pe::op · pt::peg · pt::peg::container · pt::peg::container::peg · pt::peg::export · pt::peg::export::container · pt::peg::export::json · pt::peg::export::peg · pt::peg::from::container · pt::peg::from::json · pt::peg::from::peg · pt::peg::import · pt::peg::import::container · pt::peg::import::json · pt::peg::import::peg · pt::peg::interp · pt::peg::to::container · pt::peg::to::cparam · pt::peg::to::json · pt::peg::to::param · pt::peg::to::peg · pt::peg::to::tclparam · pt::peg_language · pt::pegrammar · pt::pgen · pt::rde · pt::tclparam::configuration::snit · pt::tclparam::configuration::tcloo · pt::util · pt_export_api · pt_import_api · pt_introduction · pt_parse_peg · pt_parser_api · pt_peg_op transfer transfer::connect · transfer::copy · transfer::copy::queue · transfer::data::destination · transfer::data::source · transfer::receiver · transfer::transmitter Index: embedded/www/tcllib/files/apps/pt.html ================================================================== --- embedded/www/tcllib/files/apps/pt.html +++ embedded/www/tcllib/files/apps/pt.html @@ -356,10 +356,13 @@ command will be X::X. Whereas for a namespaced value X::Y the parser command will be X::Y.

-package string

The value of this option is the name of the package to generate. The default value is PACKAGE.

+
-version string
+

The value of this option is the version of the package to generate. +The default value is 1.

C Parser

The c format is executable code, a parser for the grammar. The parser implementation is written in C and can be tweaked to the users' @@ -484,10 +487,13 @@

The value of this option is the name of the package to generate, without leading colons. Note, it serves double-duty as the name of the class to generate too, if option -class is not specified, see above. The default value is PACKAGE, applying if neither option -package nor -class were specified.

+
-version string
+

The value of this option is the version of the package to generate. +The default value is 1.

TclOO Parser

The oo format is executable code, a parser for the grammar. It is a Tcl package holding a TclOO class, whose instances are @@ -514,10 +520,13 @@

The value of this option is the name of the package to generate, without leading colons. Note, it serves double-duty as the name of the class to generate too, if option -class is not specified, see above. The default value is PACKAGE, applying if neither option -package nor -class were specified.

+
-version string
+

The value of this option is the version of the package to generate. +The default value is 1.

Grammar Container

The container format is another form of describing parsing expression grammars. While data in this format is executable it does Index: embedded/www/tcllib/files/modules/pt/pt_cparam_config_critcl.html ================================================================== --- embedded/www/tcllib/files/modules/pt/pt_cparam_config_critcl.html +++ embedded/www/tcllib/files/modules/pt/pt_cparam_config_critcl.html @@ -106,11 +106,11 @@ | Keyword Index | Categories | Modules | Applications ]


-

pt::cparam::configuration::critcl(n) 1.0.1 tcllib "Parser Tools"

+

pt::cparam::configuration::critcl(n) 1.0.2 tcllib "Parser Tools"

Name

pt::cparam::configuration::critcl - C/PARAM, Canned configuration, Critcl

Table Of Contents

    @@ -126,14 +126,14 @@

Synopsis

  • package require Tcl 8.5
  • -
  • package require pt::cparam::configuration::critcl ?1.0.1?
  • +
  • package require pt::cparam::configuration::critcl ?1.0.2?

Description

Are you lost ? @@ -149,14 +149,14 @@

It is a supporting package in the Core Layer of Parser Tools.

arch_core_support

API

-
::pt::cparam::configuration::critcl def name cmdprefix
+
::pt::cparam::configuration::critcl def name pkg version cmdprefix

The command applies the configuration provided by this package to the cmdprefix, causing the creation of critcl-based parsers -whose class is name.

+whose class is name, in package pkg with version.

The use of a command prefix as API allows application of the configuration to not only pt::peg::to::cparam (pt::peg::to::cparam configure), but also export manager instances and PEG containers ($export configuration set and [$container exporter] configuration set respectively).

ADDED embedded/www/tcllib/files/modules/pt/pt_cparam_config_tea.html Index: embedded/www/tcllib/files/modules/pt/pt_cparam_config_tea.html ================================================================== --- /dev/null +++ embedded/www/tcllib/files/modules/pt/pt_cparam_config_tea.html @@ -0,0 +1,184 @@ + + +pt::cparam::configuration::tea - Parser Tools + + + + + +
+
[ + Tcllib Home +| Main Table Of Contents +| Table Of Contents +| Keyword Index +| Categories +| Modules +| Applications + ]
+

pt::cparam::configuration::tea(n) 0.1 tcllib "Parser Tools"

+

Name

+

pt::cparam::configuration::tea - C/PARAM, Canned configuration, TEA

+
+ +

Synopsis

+
+
    +
  • package require Tcl 8.5
  • +
  • package require pt::cparam::configuration::tea ?0.1?
  • +
+ +
+
+

Description

+

Are you lost ? +Do you have trouble understanding this document ? +In that case please read the overview provided by the +Introduction to Parser Tools. This document is the +entrypoint to the whole system the current package is a part of.

+

This package is an adjunct to pt::peg::to::cparam, to make +the use of this highly configurable package easier by providing a +canned configuration. When applied this configuration causes the +package pt::peg::to::cparam to generate plain parser code +ready for inclusion into a TEA-based C extension.

+

It is a supporting package in the Core Layer of Parser Tools.

+

arch_core_support

+
+

API

+
+
::pt::cparam::configuration::tea def name pkg version cmdprefix
+

The command applies the configuration provided by this package to the +cmdprefix, causing the creation of tea-based parsers +whose class is name, in package pkg with version.

+

The use of a command prefix as API allows application of the +configuration to not only pt::peg::to::cparam +(pt::peg::to::cparam configure), but also export manager +instances and PEG containers ($export configuration set and +[$container exporter] configuration set respectively).

+

Or anything other command prefix accepting two arguments, option and +value.

+
+
+

Bugs, Ideas, Feedback

+

This document, and the package it describes, will undoubtedly contain +bugs and other problems. +Please report such in the category pt of the +Tcllib Trackers. +Please also report any ideas for enhancements you may have for either +package and/or documentation.

+
+ +

Category

+

Parsing and Grammars

+
+ +
Index: embedded/www/tcllib/files/modules/pt/pt_peg_export_peg.html ================================================================== --- embedded/www/tcllib/files/modules/pt/pt_peg_export_peg.html +++ embedded/www/tcllib/files/modules/pt/pt_peg_export_peg.html @@ -256,15 +256,15 @@ Literal <- APOSTROPH (!APOSTROPH Char)* APOSTROPH WHITESPACE / DAPOSTROPH (!DAPOSTROPH Char)* DAPOSTROPH WHITESPACE ; Class <- OPENB (!CLOSEB Range)* CLOSEB WHITESPACE ; Range <- Char TO Char / Char ; StartExpr <- OPEN Expression CLOSE ; -void: Final <- END SEMICOLON WHITESPACE ; +void: Final <- "END" WHITESPACE SEMICOLON WHITESPACE ; # -------------------------------------------------------------------- # Lexing constructs Identifier <- Ident WHITESPACE ; -leaf: Ident <- ('_' / ':' / <alpha>) ('_' / ':' / <alnum>)* ; +leaf: Ident <- ([_:] / <alpha>) ([_:] / <alnum>)* ; Char <- CharSpecial / CharOctalFull / CharOctalPart / CharUnicode / CharUnescaped ; leaf: CharSpecial <- "\\" [nrt'"\[\]\\] ; leaf: CharOctalFull <- "\\" [0-2][0-7][0-7] ; @@ -275,15 +275,14 @@ void: TO <- '-' ; void: OPENB <- "[" ; void: CLOSEB <- "]" ; void: APOSTROPH <- "'" ; void: DAPOSTROPH <- '"' ; -void: PEG <- "PEG" WHITESPACE ; +void: PEG <- "PEG" !([_:] / <alnum>) WHITESPACE ; void: IS <- "<-" WHITESPACE ; leaf: VOID <- "void" WHITESPACE ; # Implies that definition has no semantic value. leaf: LEAF <- "leaf" WHITESPACE ; # Implies that definition has no terminals. -void: END <- "END" WHITESPACE ; void: SEMICOLON <- ";" WHITESPACE ; void: COLON <- ":" WHITESPACE ; void: SLASH <- "/" WHITESPACE ; leaf: AND <- "&" WHITESPACE ; leaf: NOT <- "!" WHITESPACE ; Index: embedded/www/tcllib/files/modules/pt/pt_peg_from_peg.html ================================================================== --- embedded/www/tcllib/files/modules/pt/pt_peg_from_peg.html +++ embedded/www/tcllib/files/modules/pt/pt_peg_from_peg.html @@ -106,11 +106,11 @@ | Keyword Index | Categories | Modules | Applications ]
-

pt::peg::from::peg(n) 1.0.2 tcllib "Parser Tools"

+

pt::peg::from::peg(n) 1.0.3 tcllib "Parser Tools"

Name

pt::peg::from::peg - PEG Conversion. Read PEG format

Table Of Contents

    @@ -141,11 +141,11 @@

Synopsis

  • package require Tcl 8.5
  • -
  • package require pt::peg::from::peg ?1.0.2?
  • +
  • package require pt::peg::from::peg ?1.0.3?
@@ -214,15 +214,15 @@ Literal <- APOSTROPH (!APOSTROPH Char)* APOSTROPH WHITESPACE / DAPOSTROPH (!DAPOSTROPH Char)* DAPOSTROPH WHITESPACE ; Class <- OPENB (!CLOSEB Range)* CLOSEB WHITESPACE ; Range <- Char TO Char / Char ; StartExpr <- OPEN Expression CLOSE ; -void: Final <- END SEMICOLON WHITESPACE ; +void: Final <- "END" WHITESPACE SEMICOLON WHITESPACE ; # -------------------------------------------------------------------- # Lexing constructs Identifier <- Ident WHITESPACE ; -leaf: Ident <- ('_' / ':' / <alpha>) ('_' / ':' / <alnum>)* ; +leaf: Ident <- ([_:] / <alpha>) ([_:] / <alnum>)* ; Char <- CharSpecial / CharOctalFull / CharOctalPart / CharUnicode / CharUnescaped ; leaf: CharSpecial <- "\\" [nrt'"\[\]\\] ; leaf: CharOctalFull <- "\\" [0-2][0-7][0-7] ; @@ -233,15 +233,14 @@ void: TO <- '-' ; void: OPENB <- "[" ; void: CLOSEB <- "]" ; void: APOSTROPH <- "'" ; void: DAPOSTROPH <- '"' ; -void: PEG <- "PEG" WHITESPACE ; +void: PEG <- "PEG" !([_:] / <alnum>) WHITESPACE ; void: IS <- "<-" WHITESPACE ; leaf: VOID <- "void" WHITESPACE ; # Implies that definition has no semantic value. leaf: LEAF <- "leaf" WHITESPACE ; # Implies that definition has no terminals. -void: END <- "END" WHITESPACE ; void: SEMICOLON <- ";" WHITESPACE ; void: COLON <- ":" WHITESPACE ; void: SLASH <- "/" WHITESPACE ; leaf: AND <- "&" WHITESPACE ; leaf: NOT <- "!" WHITESPACE ; Index: embedded/www/tcllib/files/modules/pt/pt_peg_import_peg.html ================================================================== --- embedded/www/tcllib/files/modules/pt/pt_peg_import_peg.html +++ embedded/www/tcllib/files/modules/pt/pt_peg_import_peg.html @@ -224,15 +224,15 @@ Literal <- APOSTROPH (!APOSTROPH Char)* APOSTROPH WHITESPACE / DAPOSTROPH (!DAPOSTROPH Char)* DAPOSTROPH WHITESPACE ; Class <- OPENB (!CLOSEB Range)* CLOSEB WHITESPACE ; Range <- Char TO Char / Char ; StartExpr <- OPEN Expression CLOSE ; -void: Final <- END SEMICOLON WHITESPACE ; +void: Final <- "END" WHITESPACE SEMICOLON WHITESPACE ; # -------------------------------------------------------------------- # Lexing constructs Identifier <- Ident WHITESPACE ; -leaf: Ident <- ('_' / ':' / <alpha>) ('_' / ':' / <alnum>)* ; +leaf: Ident <- ([_:] / <alpha>) ([_:] / <alnum>)* ; Char <- CharSpecial / CharOctalFull / CharOctalPart / CharUnicode / CharUnescaped ; leaf: CharSpecial <- "\\" [nrt'"\[\]\\] ; leaf: CharOctalFull <- "\\" [0-2][0-7][0-7] ; @@ -243,15 +243,14 @@ void: TO <- '-' ; void: OPENB <- "[" ; void: CLOSEB <- "]" ; void: APOSTROPH <- "'" ; void: DAPOSTROPH <- '"' ; -void: PEG <- "PEG" WHITESPACE ; +void: PEG <- "PEG" !([_:] / <alnum>) WHITESPACE ; void: IS <- "<-" WHITESPACE ; leaf: VOID <- "void" WHITESPACE ; # Implies that definition has no semantic value. leaf: LEAF <- "leaf" WHITESPACE ; # Implies that definition has no terminals. -void: END <- "END" WHITESPACE ; void: SEMICOLON <- ";" WHITESPACE ; void: COLON <- ":" WHITESPACE ; void: SLASH <- "/" WHITESPACE ; leaf: AND <- "&" WHITESPACE ; leaf: NOT <- "!" WHITESPACE ; Index: embedded/www/tcllib/files/modules/pt/pt_peg_interp.html ================================================================== --- embedded/www/tcllib/files/modules/pt/pt_peg_interp.html +++ embedded/www/tcllib/files/modules/pt/pt_peg_interp.html @@ -106,11 +106,11 @@ | Keyword Index | Categories | Modules | Applications ]
-

pt::peg::interp(n) 1 tcllib "Parser Tools"

+

pt::peg::interp(n) 1.0.1 tcllib "Parser Tools"

Name

pt::peg::interp - Interpreter for parsing expression grammars

Table Of Contents

    @@ -140,11 +140,11 @@

Synopsis

  • package require Tcl 8.5
  • -
  • package require pt::peg::interp ?1?
  • +
  • package require pt::peg::interp ?1.0.1?
  • package require pt::rde ?1?
  • package require snit
  • ::pt::peg::interp objectName grammar
  • Index: embedded/www/tcllib/files/modules/pt/pt_peg_language.html ================================================================== --- embedded/www/tcllib/files/modules/pt/pt_peg_language.html +++ embedded/www/tcllib/files/modules/pt/pt_peg_language.html @@ -423,15 +423,15 @@ Literal <- APOSTROPH (!APOSTROPH Char)* APOSTROPH WHITESPACE / DAPOSTROPH (!DAPOSTROPH Char)* DAPOSTROPH WHITESPACE ; Class <- OPENB (!CLOSEB Range)* CLOSEB WHITESPACE ; Range <- Char TO Char / Char ; StartExpr <- OPEN Expression CLOSE ; -void: Final <- END SEMICOLON WHITESPACE ; +void: Final <- "END" WHITESPACE SEMICOLON WHITESPACE ; # -------------------------------------------------------------------- # Lexing constructs Identifier <- Ident WHITESPACE ; -leaf: Ident <- ('_' / ':' / <alpha>) ('_' / ':' / <alnum>)* ; +leaf: Ident <- ([_:] / <alpha>) ([_:] / <alnum>)* ; Char <- CharSpecial / CharOctalFull / CharOctalPart / CharUnicode / CharUnescaped ; leaf: CharSpecial <- "\\" [nrt'"\[\]\\] ; leaf: CharOctalFull <- "\\" [0-2][0-7][0-7] ; @@ -442,15 +442,14 @@ void: TO <- '-' ; void: OPENB <- "[" ; void: CLOSEB <- "]" ; void: APOSTROPH <- "'" ; void: DAPOSTROPH <- '"' ; -void: PEG <- "PEG" WHITESPACE ; +void: PEG <- "PEG" !([_:] / <alnum>) WHITESPACE ; void: IS <- "<-" WHITESPACE ; leaf: VOID <- "void" WHITESPACE ; # Implies that definition has no semantic value. leaf: LEAF <- "leaf" WHITESPACE ; # Implies that definition has no terminals. -void: END <- "END" WHITESPACE ; void: SEMICOLON <- ";" WHITESPACE ; void: COLON <- ":" WHITESPACE ; void: SLASH <- "/" WHITESPACE ; leaf: AND <- "&" WHITESPACE ; leaf: NOT <- "!" WHITESPACE ; Index: embedded/www/tcllib/files/modules/pt/pt_peg_to_cparam.html ================================================================== --- embedded/www/tcllib/files/modules/pt/pt_peg_to_cparam.html +++ embedded/www/tcllib/files/modules/pt/pt_peg_to_cparam.html @@ -106,11 +106,11 @@ | Keyword Index | Categories | Modules | Applications ]
    -

    pt::peg::to::cparam(n) 1.1.1 tcllib "Parser Tools"

    +

    pt::peg::to::cparam(n) 1.1.2 tcllib "Parser Tools"

    Name

    pt::peg::to::cparam - PEG Conversion. Write CPARAM format

    Table Of Contents

      @@ -142,11 +142,11 @@

    Synopsis

    • package require Tcl 8.5
    • -
    • package require pt::peg::to::cparam ?1.1.1?
    • +
    • package require pt::peg::to::cparam ?1.1.2?
    • pt::peg::to::cparam reset
    • pt::peg::to::cparam configure
    • pt::peg::to::cparam configure option
    • Index: embedded/www/tcllib/files/modules/pt/pt_peg_to_peg.html ================================================================== --- embedded/www/tcllib/files/modules/pt/pt_peg_to_peg.html +++ embedded/www/tcllib/files/modules/pt/pt_peg_to_peg.html @@ -106,11 +106,11 @@ | Keyword Index | Categories | Modules | Applications ]
      -

      pt::peg::to::peg(n) 1.0.1 tcllib "Parser Tools"

      +

      pt::peg::to::peg(n) 1.0.2 tcllib "Parser Tools"

      Name

      pt::peg::to::peg - PEG Conversion. Write PEG format

      Table Of Contents

        @@ -142,11 +142,11 @@

      Synopsis

      • package require Tcl 8.5
      • -
      • package require pt::peg::to::peg ?1.0.1?
      • +
      • package require pt::peg::to::peg ?1.0.2?
      • package require pt::peg
      • package require pt::pe
      • package require text::write
        @@ -269,15 +269,15 @@ Literal <- APOSTROPH (!APOSTROPH Char)* APOSTROPH WHITESPACE / DAPOSTROPH (!DAPOSTROPH Char)* DAPOSTROPH WHITESPACE ; Class <- OPENB (!CLOSEB Range)* CLOSEB WHITESPACE ; Range <- Char TO Char / Char ; StartExpr <- OPEN Expression CLOSE ; -void: Final <- END SEMICOLON WHITESPACE ; +void: Final <- "END" WHITESPACE SEMICOLON WHITESPACE ; # -------------------------------------------------------------------- # Lexing constructs Identifier <- Ident WHITESPACE ; -leaf: Ident <- ('_' / ':' / <alpha>) ('_' / ':' / <alnum>)* ; +leaf: Ident <- ([_:] / <alpha>) ([_:] / <alnum>)* ; Char <- CharSpecial / CharOctalFull / CharOctalPart / CharUnicode / CharUnescaped ; leaf: CharSpecial <- "\\" [nrt'"\[\]\\] ; leaf: CharOctalFull <- "\\" [0-2][0-7][0-7] ; @@ -288,15 +288,14 @@ void: TO <- '-' ; void: OPENB <- "[" ; void: CLOSEB <- "]" ; void: APOSTROPH <- "'" ; void: DAPOSTROPH <- '"' ; -void: PEG <- "PEG" WHITESPACE ; +void: PEG <- "PEG" !([_:] / <alnum>) WHITESPACE ; void: IS <- "<-" WHITESPACE ; leaf: VOID <- "void" WHITESPACE ; # Implies that definition has no semantic value. leaf: LEAF <- "leaf" WHITESPACE ; # Implies that definition has no terminals. -void: END <- "END" WHITESPACE ; void: SEMICOLON <- ";" WHITESPACE ; void: COLON <- ":" WHITESPACE ; void: SLASH <- "/" WHITESPACE ; leaf: AND <- "&" WHITESPACE ; leaf: NOT <- "!" WHITESPACE ; Index: embedded/www/tcllib/files/modules/pt/pt_peg_to_tclparam.html ================================================================== --- embedded/www/tcllib/files/modules/pt/pt_peg_to_tclparam.html +++ embedded/www/tcllib/files/modules/pt/pt_peg_to_tclparam.html @@ -106,11 +106,11 @@ | Keyword Index | Categories | Modules | Applications ]
        -

        pt::peg::to::tclparam(n) 1 tcllib "Parser Tools"

        +

        pt::peg::to::tclparam(n) 1.0.1 tcllib "Parser Tools"

        Name

        pt::peg::to::tclparam - PEG Conversion. Write TCLPARAM format

        Table Of Contents

          @@ -138,11 +138,11 @@

        Synopsis

        • package require Tcl 8.5
        • -
        • package require pt::peg::to::tclparam ?1?
        • +
        • package require pt::peg::to::tclparam ?1.0.1?
        • pt::peg::to::tclparam reset
        • pt::peg::to::tclparam configure
        • pt::peg::to::tclparam configure option
        • Index: embedded/www/tcllib/files/modules/pt/pt_pexpression.html ================================================================== --- embedded/www/tcllib/files/modules/pt/pt_pexpression.html +++ embedded/www/tcllib/files/modules/pt/pt_pexpression.html @@ -106,11 +106,11 @@ | Keyword Index | Categories | Modules | Applications ]
          -

          pt::pe(n) 1 tcllib "Parser Tools"

          +

          pt::pe(n) 1.0.1 tcllib "Parser Tools"

          Name

          pt::pe - Parsing Expression Serialization

          Table Of Contents

            @@ -131,11 +131,11 @@

          Synopsis

          • package require Tcl 8.5
          • -
          • package require pt::pe ?1?
          • +
          • package require pt::pe ?1.0.1?
          • package require char
          • ::pt::pe verify serial ?canonvar?
          • ::pt::pe verify-as-canonical serial
          • Index: embedded/www/tcllib/files/modules/pt/pt_rdengine.html ================================================================== --- embedded/www/tcllib/files/modules/pt/pt_rdengine.html +++ embedded/www/tcllib/files/modules/pt/pt_rdengine.html @@ -106,11 +106,11 @@ | Keyword Index | Categories | Modules | Applications ]
            -

            pt::rde(n) 1.0.2 tcllib "Parser Tools"

            +

            pt::rde(n) 1.0.3 tcllib "Parser Tools"

            Name

            pt::rde - Parsing Runtime Support, PARAM based

            Table Of Contents

              @@ -130,11 +130,11 @@

            Synopsis

            • package require Tcl 8.5
            • -
            • package require pt::rde ?1.0.2?
            • +
            • package require pt::rde ?1.0.3?
            • package require snit
            • package require struct::stack 1.4
            • package require pt::ast 1.1
              Index: embedded/www/tcllib/files/modules/pt/pt_tclparam_config_snit.html ================================================================== --- embedded/www/tcllib/files/modules/pt/pt_tclparam_config_snit.html +++ embedded/www/tcllib/files/modules/pt/pt_tclparam_config_snit.html @@ -106,11 +106,11 @@ | Keyword Index | Categories | Modules | Applications ]
              -

              pt::tclparam::configuration::snit(n) 1.0.1 tcllib "Parser Tools"

              +

              pt::tclparam::configuration::snit(n) 1.0.2 tcllib "Parser Tools"

              Name

              pt::tclparam::configuration::snit - Tcl/PARAM, Canned configuration, Snit

              Table Of Contents

                @@ -126,14 +126,14 @@

              Synopsis

              • package require Tcl 8.5
              • -
              • package require pt::tclparam::configuration::snit ?1.0.1?
              • +
              • package require pt::tclparam::configuration::snit ?1.0.2?

              Description

              Are you lost ? @@ -149,14 +149,14 @@

              It is a supporting package in the Core Layer of Parser Tools.

              arch_core_support

              API

              -
              ::pt::tclparam::configuration::snit def name cmdprefix
              +
              ::pt::tclparam::configuration::snit def name pkg version cmdprefix

              The command applies the configuration provided by this package to the cmdprefix, causing the creation of snit-based parsers -whose class is name.

              +whose class is name, in package pkg with version.

              The use of a command prefix as API allows application of the configuration to not only pt::peg::to::tclparam (pt::peg::to::tclparam configure), but also export manager instances and PEG containers ($export configuration set and [$container exporter] configuration set respectively).

              Index: embedded/www/tcllib/files/modules/pt/pt_tclparam_config_tcloo.html ================================================================== --- embedded/www/tcllib/files/modules/pt/pt_tclparam_config_tcloo.html +++ embedded/www/tcllib/files/modules/pt/pt_tclparam_config_tcloo.html @@ -106,11 +106,11 @@ | Keyword Index | Categories | Modules | Applications ]
              -

              pt::tclparam::configuration::tcloo(n) 1.0.3 tcllib "Parser Tools"

              +

              pt::tclparam::configuration::tcloo(n) 1.0.4 tcllib "Parser Tools"

              Name

              pt::tclparam::configuration::tcloo - Tcl/PARAM, Canned configuration, Tcloo

              Table Of Contents

                @@ -126,14 +126,14 @@

              Synopsis

              • package require Tcl 8.5
              • -
              • package require pt::tclparam::configuration::tcloo ?1.0.3?
              • +
              • package require pt::tclparam::configuration::tcloo ?1.0.4?

              Description

              Are you lost ? @@ -149,14 +149,14 @@

              It is a supporting package in the Core Layer of Parser Tools.

              arch_core_support

              API

              -
              ::pt::tclparam::configuration::tcloo def name cmdprefix
              +
              ::pt::tclparam::configuration::tcloo def name pkg version cmdprefix

              The command applies the configuration provided by this package to the cmdprefix, causing the creation of OO-based parsers -whose class is name.

              +whose class is name, in package pkg with version.

              The use of a command prefix as API allows application of the configuration to not only pt::peg::to::tclparam (pt::peg::to::tclparam configure), but also export manager instances and PEG containers ($export configuration set and [$container exporter] configuration set respectively).

              ADDED embedded/www/tcllib/files/modules/pt/pt_util.html Index: embedded/www/tcllib/files/modules/pt/pt_util.html ================================================================== --- /dev/null +++ embedded/www/tcllib/files/modules/pt/pt_util.html @@ -0,0 +1,189 @@ + + +pt::util - Parser Tools + + + + + +
              +
              [ + Tcllib Home +| Main Table Of Contents +| Table Of Contents +| Keyword Index +| Categories +| Modules +| Applications + ]
              +

              pt::util(n) 1 tcllib "Parser Tools"

              +

              Name

              +

              pt::util - General utilities

              +
              + +

              Synopsis

              +
              +
                +
              • package require Tcl 8.5
              • +
              • package require pt::ast ?1?
              • +
              + +
              +
              +

              Description

              +

              Are you lost ? +Do you have trouble understanding this document ? +In that case please read the overview provided by the +Introduction to Parser Tools. This document is the +entrypoint to the whole system the current package is a part of.

              +

              This package provides general utility commands.

              +

              This is a supporting package in the Core Layer of Parser Tools.

              +

              arch_core_support

              +
              +

              API

              +
              +
              ::pt::util error2readable error text
              +

              This command takes the structured form of a syntax error as +thrown by parser runtimes and the input text to the parser which +caused that error and returns a string describing the error in a +human-readable form.

              +

              The input text is required to convert the character +position of the error into a more readable line/column format, and to +provide excerpts of the input around the error position.

              +
              ::pt::util error2position error text
              +

              This command takes the structured form of a syntax error as +thrown by parser runtimes and the input text to the parser which +caused that error and returns a 2-element list containing the line +number and column index for the error's character position in the +input, in this order.

              +
              ::pt::util error2text error
              +

              This command takes the structured form of a syntax error as +thrown by parser runtimes and returns a list of strings, each +describing a possible expected input in a human-readable form.

              +
              +
              +

              Bugs, Ideas, Feedback

              +

              This document, and the package it describes, will undoubtedly contain +bugs and other problems. +Please report such in the category pt of the +Tcllib Trackers. +Please also report any ideas for enhancements you may have for either +package and/or documentation.

              +
              + +

              Category

              +

              Parsing and Grammars

              +
              + +
              Index: embedded/www/tcllib/toc.html ================================================================== --- embedded/www/tcllib/toc.html +++ embedded/www/tcllib/toc.html @@ -915,133 +915,141 @@ pt::cparam::configuration::critcl C/PARAM, Canned configuration, Critcl +pt::cparam::configuration::tea +C/PARAM, Canned configuration, TEA + + pt::json_language The JSON Grammar Exchange Format - + pt::param PackRat Machine Specification - + pt::pe Parsing Expression Serialization - + pt::pe::op Parsing Expression Utilities - + pt::peg Parsing Expression Grammar Serialization - + pt::peg::container PEG Storage - + pt::peg::container::peg PEG Storage. Canned PEG grammar specification - + pt::peg::export PEG Export - + pt::peg::export::container PEG Export Plugin. Write CONTAINER format - + pt::peg::export::json PEG Export Plugin. Write JSON format - + pt::peg::export::peg PEG Export Plugin. Write PEG format - + pt::peg::from::container PEG Conversion. From CONTAINER format - + pt::peg::from::json PEG Conversion. Read JSON format - + pt::peg::from::peg PEG Conversion. Read PEG format - + pt::peg::import PEG Import - + pt::peg::import::container PEG Import Plugin. From CONTAINER format - + pt::peg::import::json PEG Import Plugin. Read JSON format - + pt::peg::import::peg PEG Import Plugin. Read PEG format - + pt::peg::interp Interpreter for parsing expression grammars - + pt::peg::to::container PEG Conversion. Write CONTAINER format - + pt::peg::to::cparam PEG Conversion. Write CPARAM format - + pt::peg::to::json PEG Conversion. Write JSON format - + pt::peg::to::param PEG Conversion. Write PARAM format - + pt::peg::to::peg PEG Conversion. Write PEG format - + pt::peg::to::tclparam PEG Conversion. Write TCLPARAM format - + pt::peg_language PEG Language Tutorial - + pt::pegrammar Introduction to Parsing Expression Grammars - + pt::pgen Parser Generator - + pt::rde Parsing Runtime Support, PARAM based - + pt::tclparam::configuration::snit Tcl/PARAM, Canned configuration, Snit - + pt::tclparam::configuration::tcloo Tcl/PARAM, Canned configuration, Tcloo + +pt::util +General utilities + pt_export_api Parser Tools Export API Index: embedded/www/toc.html ================================================================== --- embedded/www/toc.html +++ embedded/www/toc.html @@ -1026,133 +1026,141 @@ pt::cparam::configuration::critcl C/PARAM, Canned configuration, Critcl +pt::cparam::configuration::tea +C/PARAM, Canned configuration, TEA + + pt::json_language The JSON Grammar Exchange Format - + pt::param PackRat Machine Specification - + pt::pe Parsing Expression Serialization - + pt::pe::op Parsing Expression Utilities - + pt::peg Parsing Expression Grammar Serialization - + pt::peg::container PEG Storage - + pt::peg::container::peg PEG Storage. Canned PEG grammar specification - + pt::peg::export PEG Export - + pt::peg::export::container PEG Export Plugin. Write CONTAINER format - + pt::peg::export::json PEG Export Plugin. Write JSON format - + pt::peg::export::peg PEG Export Plugin. Write PEG format - + pt::peg::from::container PEG Conversion. From CONTAINER format - + pt::peg::from::json PEG Conversion. Read JSON format - + pt::peg::from::peg PEG Conversion. Read PEG format - + pt::peg::import PEG Import - + pt::peg::import::container PEG Import Plugin. From CONTAINER format - + pt::peg::import::json PEG Import Plugin. Read JSON format - + pt::peg::import::peg PEG Import Plugin. Read PEG format - + pt::peg::interp Interpreter for parsing expression grammars - + pt::peg::to::container PEG Conversion. Write CONTAINER format - + pt::peg::to::cparam PEG Conversion. Write CPARAM format - + pt::peg::to::json PEG Conversion. Write JSON format - + pt::peg::to::param PEG Conversion. Write PARAM format - + pt::peg::to::peg PEG Conversion. Write PEG format - + pt::peg::to::tclparam PEG Conversion. Write TCLPARAM format - + pt::peg_language PEG Language Tutorial - + pt::pegrammar Introduction to Parsing Expression Grammars - + pt::pgen Parser Generator - + pt::rde Parsing Runtime Support, PARAM based - + pt::tclparam::configuration::snit Tcl/PARAM, Canned configuration, Snit - + pt::tclparam::configuration::tcloo Tcl/PARAM, Canned configuration, Tcloo + +pt::util +General utilities + pt_export_api Parser Tools Export API @@ -2901,133 +2909,141 @@ pt::cparam::configuration::critcl C/PARAM, Canned configuration, Critcl +pt::cparam::configuration::tea +C/PARAM, Canned configuration, TEA + + pt::json_language The JSON Grammar Exchange Format - + pt::param PackRat Machine Specification - + pt::pe Parsing Expression Serialization - + pt::pe::op Parsing Expression Utilities - + pt::peg Parsing Expression Grammar Serialization - + pt::peg::container PEG Storage - + pt::peg::container::peg PEG Storage. Canned PEG grammar specification - + pt::peg::export PEG Export - + pt::peg::export::container PEG Export Plugin. Write CONTAINER format - + pt::peg::export::json PEG Export Plugin. Write JSON format - + pt::peg::export::peg PEG Export Plugin. Write PEG format - + pt::peg::from::container PEG Conversion. From CONTAINER format - + pt::peg::from::json PEG Conversion. Read JSON format - + pt::peg::from::peg PEG Conversion. Read PEG format - + pt::peg::import PEG Import - + pt::peg::import::container PEG Import Plugin. From CONTAINER format - + pt::peg::import::json PEG Import Plugin. Read JSON format - + pt::peg::import::peg PEG Import Plugin. Read PEG format - + pt::peg::interp Interpreter for parsing expression grammars - + pt::peg::to::container PEG Conversion. Write CONTAINER format - + pt::peg::to::cparam PEG Conversion. Write CPARAM format - + pt::peg::to::json PEG Conversion. Write JSON format - + pt::peg::to::param PEG Conversion. Write PARAM format - + pt::peg::to::peg PEG Conversion. Write PEG format - + pt::peg::to::tclparam PEG Conversion. Write TCLPARAM format - + pt::peg_language PEG Language Tutorial - + pt::pegrammar Introduction to Parsing Expression Grammars - + pt::pgen Parser Generator - + pt::rde Parsing Runtime Support, PARAM based - + pt::tclparam::configuration::snit Tcl/PARAM, Canned configuration, Snit - + pt::tclparam::configuration::tcloo Tcl/PARAM, Canned configuration, Tcloo + +pt::util +General utilities + pt_export_api Parser Tools Export API Index: embedded/www/toc0.html ================================================================== --- embedded/www/toc0.html +++ embedded/www/toc0.html @@ -1026,133 +1026,141 @@ pt::cparam::configuration::critcl C/PARAM, Canned configuration, Critcl +pt::cparam::configuration::tea +C/PARAM, Canned configuration, TEA + + pt::json_language The JSON Grammar Exchange Format - + pt::param PackRat Machine Specification - + pt::pe Parsing Expression Serialization - + pt::pe::op Parsing Expression Utilities - + pt::peg Parsing Expression Grammar Serialization - + pt::peg::container PEG Storage - + pt::peg::container::peg PEG Storage. Canned PEG grammar specification - + pt::peg::export PEG Export - + pt::peg::export::container PEG Export Plugin. Write CONTAINER format - + pt::peg::export::json PEG Export Plugin. Write JSON format - + pt::peg::export::peg PEG Export Plugin. Write PEG format - + pt::peg::from::container PEG Conversion. From CONTAINER format - + pt::peg::from::json PEG Conversion. Read JSON format - + pt::peg::from::peg PEG Conversion. Read PEG format - + pt::peg::import PEG Import - + pt::peg::import::container PEG Import Plugin. From CONTAINER format - + pt::peg::import::json PEG Import Plugin. Read JSON format - + pt::peg::import::peg PEG Import Plugin. Read PEG format - + pt::peg::interp Interpreter for parsing expression grammars - + pt::peg::to::container PEG Conversion. Write CONTAINER format - + pt::peg::to::cparam PEG Conversion. Write CPARAM format - + pt::peg::to::json PEG Conversion. Write JSON format - + pt::peg::to::param PEG Conversion. Write PARAM format - + pt::peg::to::peg PEG Conversion. Write PEG format - + pt::peg::to::tclparam PEG Conversion. Write TCLPARAM format - + pt::peg_language PEG Language Tutorial - + pt::pegrammar Introduction to Parsing Expression Grammars - + pt::pgen Parser Generator - + pt::rde Parsing Runtime Support, PARAM based - + pt::tclparam::configuration::snit Tcl/PARAM, Canned configuration, Snit - + pt::tclparam::configuration::tcloo Tcl/PARAM, Canned configuration, Tcloo + +pt::util +General utilities + pt_export_api Parser Tools Export API Index: embedded/www/toc1.html ================================================================== --- embedded/www/toc1.html +++ embedded/www/toc1.html @@ -1161,133 +1161,141 @@ pt::cparam::configuration::critcl C/PARAM, Canned configuration, Critcl +pt::cparam::configuration::tea +C/PARAM, Canned configuration, TEA + + pt::json_language The JSON Grammar Exchange Format - + pt::param PackRat Machine Specification - + pt::pe Parsing Expression Serialization - + pt::pe::op Parsing Expression Utilities - + pt::peg Parsing Expression Grammar Serialization - + pt::peg::container PEG Storage - + pt::peg::container::peg PEG Storage. Canned PEG grammar specification - + pt::peg::export PEG Export - + pt::peg::export::container PEG Export Plugin. Write CONTAINER format - + pt::peg::export::json PEG Export Plugin. Write JSON format - + pt::peg::export::peg PEG Export Plugin. Write PEG format - + pt::peg::from::container PEG Conversion. From CONTAINER format - + pt::peg::from::json PEG Conversion. Read JSON format - + pt::peg::from::peg PEG Conversion. Read PEG format - + pt::peg::import PEG Import - + pt::peg::import::container PEG Import Plugin. From CONTAINER format - + pt::peg::import::json PEG Import Plugin. Read JSON format - + pt::peg::import::peg PEG Import Plugin. Read PEG format - + pt::peg::interp Interpreter for parsing expression grammars - + pt::peg::to::container PEG Conversion. Write CONTAINER format - + pt::peg::to::cparam PEG Conversion. Write CPARAM format - + pt::peg::to::json PEG Conversion. Write JSON format - + pt::peg::to::param PEG Conversion. Write PARAM format - + pt::peg::to::peg PEG Conversion. Write PEG format - + pt::peg::to::tclparam PEG Conversion. Write TCLPARAM format - + pt::peg_language PEG Language Tutorial - + pt::pegrammar Introduction to Parsing Expression Grammars - + pt::pgen Parser Generator - + pt::rde Parsing Runtime Support, PARAM based - + pt::tclparam::configuration::snit Tcl/PARAM, Canned configuration, Snit - + pt::tclparam::configuration::tcloo Tcl/PARAM, Canned configuration, Tcloo + +pt::util +General utilities + pt_export_api Parser Tools Export API Index: modules/pt/char.tcl ================================================================== --- modules/pt/char.tcl +++ modules/pt/char.tcl @@ -55,24 +55,25 @@ } return $ch } -proc ::char::quote::tcl {args} { - if {1 == [llength $args]} { return [Tcl {*}$args] } - set res {} - foreach ch $args { lappend res [Tcl $ch] } - return $res +# ### ### ### ######### ######### ######### + +proc ::char::quote::tcl {ch args} { + Arg Tcl $ch {*}$args } proc ::char::quote::Tcl {ch} { - # Converts a Tcl character (internal representation) into a string - # which is accepted by the Tcl parser, will regenerate the - # character in question and is 7bit ASCII. + # Input: A single character + # Output: A string representing the input. + # Properties of the output: + # (1) Contains only ASCII characters (7bit Unicode subset). + # (2) When embedded in a ""-quoted Tcl string in a piece of Tcl + # code the Tcl parser will regenerate the input character. - # Special characters - + # Special character? switch -exact -- $ch { "\n" {return "\\n"} "\r" {return "\\r"} "\t" {return "\\t"} "\\" - "\;" - @@ -88,127 +89,139 @@ } } scan $ch %c chcode - # Control characters: Octal + # Control character? if {[::string is control -strict $ch]} { return \\[format %o $chcode] } - # Beyond 7-bit ASCII: Unicode - + # Unicode beyond 7bit ASCII? if {$chcode > 127} { return \\u[format %04x $chcode] } # Regular character: Is its own representation. - - return $ch -} - -proc ::char::quote::string {args} { - if {1 == [llength $args]} { return [String {*}$args] } - set res {} - foreach ch $args { lappend res [String $ch] } - return $res -} - -proc ::char::quote::String {ch} { - # Converts a Tcl character (internal representation) into a string - # which is accepted by the Tcl parser and will generate a human - # readable representation of the character in question, one which - # when written to a channel (via puts) describes the character - # without using any unprintable characters. It may use backslash- - # quoting. High utf characters are quoted to avoid problems with - # the still prevalent ascii terminals. It is assumed that the - # string will be used in a ""-quoted environment. - - # Special characters - - switch -exact -- $ch { - " " {return ""} - "\n" {return "\\\\n"} - "\r" {return "\\\\r"} - "\t" {return "\\\\t"} - "\"" - "\\" - "\;" - - "(" - ")" - - "\{" - "\}" - - "\[" - "\]" { - return \\$ch - } - } - - scan $ch %c chcode - - # Control characters: Octal - if {[::string is control -strict $ch]} { - return \\\\[format %o $chcode] - } - - # Beyond 7-bit ASCII: Unicode - - if {$chcode > 127} { - return \\\\u[format %04x $chcode] - } - - # Regular character: Is its own representation. - - return $ch -} - -proc ::char::quote::cstring {args} { - if {1 == [llength $args]} { return [CString {*}$args] } - set res {} - foreach ch $args { lappend res [CString $ch] } - return $res -} - -proc ::char::quote::CString {ch} { - # Converts a Tcl character (internal representation) into a string - # which is accepted by the Tcl parser and will generate a human - # readable representation of the character in question, one which - # when written to a channel (via puts) describes the character - # without using any unprintable characters. It may use backslash- - # quoting. High utf characters are quoted to avoid problems with - # the still prevalent ascii terminals. It is assumed that the - # string will be used in a ""-quoted environment. - - # Special characters - - switch -exact -- $ch { - "\n" {return "\\\\n"} - "\r" {return "\\\\r"} - "\t" {return "\\\\t"} - "\"" - "\\" { - return \\$ch + return $ch +} + +# ### ### ### ######### ######### ######### + +proc ::char::quote::string {ch args} { + Arg String $ch {*}$args +} + +proc ::char::quote::String {ch} { + # Input: A single character + # Output: A string representing the input + # Properties of the output + # (1) Human-readable, for use in error messages, or comments. + # (1a) Uses only printable characters. + # (2) NO particular properties with regard to C or Tcl parsers. + + scan $ch %c chcode + + # Map the ascii control characters to proper names. + if {($chcode <= 32) || ($chcode == 127)} { + variable strmap + return [dict get $strmap $chcode] + } + + # Printable ascii characters represent themselves. + if {$chcode < 128} { + return $ch + } + + # Unicode characters. Mostly represent themselves, except if + # control or not printable. Then they are represented by their + # codepoint. + + # Control characters: Octal + if {[::string is control -strict $ch] || + ![::string is print -strict $ch]} { + return + } + + return $ch +} + +namespace eval ::char::quote { + variable strmap { + 0 8 16 24 32 + 1 9 17 25 127 + 2 10 18 26 + 3 11 19 27 + 4 12 20 28 + 5 13 21 29 + 6 14 22 30 + 7 15 23 31 + } +} + +# ### ### ### ######### ######### ######### + +proc ::char::quote::cstring {ch args} { + Arg CString $ch {*}$args +} + +proc ::char::quote::CString {ch} { + # Input: A single character + # Output: A string representing the input. + # Properties of the output: + # (1) Contains only ASCII characters (7bit Unicode subset). + # (2) When embedded in a ""-quoted C string in a piece of + # C code the C parser will regenerate the input character + # in UTF-8 encoding. + + # Special characters (named). + switch -exact -- $ch { + "\n" {return "\\n"} + "\r" {return "\\r"} + "\t" {return "\\t"} + "\"" - "\\" { + return \\$ch + } + "\{" - "\}" { + # The generated C code containing the result of this + # transform may be embedded in Tcl code (Brace-quoted), + # i.e. like for a critcl-based package. To avoid tripping + # the Tcl parser with unbalanced braces we sacrifice + # readability of the generated code a bit and insert + # braces in their octal form. + scan $ch %c chcode + return \\[format %o $chcode] } } scan $ch %c chcode # Control characters: Octal if {[::string is control -strict $ch]} { - return \\\\[format %o $chcode] + return \\[format %o $chcode] } # Beyond 7-bit ASCII: Unicode - if {$chcode > 127} { - return \\\\u[format %04x $chcode] + # Recode the character into the sequence of utf-8 bytes and + # convert each to octal. + foreach x [split [encoding convertto utf-8 $ch] {}] { + scan $x %c x + append res \\[format %o $x] + } + return $res } # Regular character: Is its own representation. return $ch } -proc ::char::quote::comment {args} { - if {1 == [llength $args]} { return [Comment {*}$args] } - set res {} - foreach ch $args { lappend res [Comment $ch] } - return $res +# ### ### ### ######### ######### ######### + +proc ::char::quote::comment {ch args} { + Arg Comment $ch {*}$args } proc ::char::quote::Comment {ch} { # Converts a Tcl character (internal representation) into a string # which is accepted by the Tcl parser when used within a Tcl @@ -243,11 +256,34 @@ # Regular character: Is its own representation. return $ch } + +# ### ### ### ######### ######### ######### +## Internal. Argument processing helper + +proc ::char::quote::Arg {cmdpfx str args} { + # single argument => treat as string, + # process all characters separately. + # return transformed string. + if {![llength $args]} { + set r {} + foreach c [split $str {}] { + append r [uplevel 1 [linsert $cmdpfx end $c]] + } + return $r + } + + # multiple arguments => process each like a single argument, and + # return list of transform results. + set args [linsert $args 0 $str] + foreach str $args { + lappend res [uplevel 1 [list Arg $cmdpfx $str]] + } + return $res +} # ### ### ### ######### ######### ######### ## Ready -package provide char 1 - +package provide char 1.0.1 ADDED modules/pt/char.test Index: modules/pt/char.test ================================================================== --- /dev/null +++ modules/pt/char.test @@ -0,0 +1,36 @@ +# -*- tcl -*- +# char.test: tests for the char package. +# +# Copyright (c) 2014 by Andreas Kupries +# All rights reserved. +# +# RCS: @(#) $Id: char.test,v 1.1 2010/03/26 05:07:24 andreas_kupries Exp $ + +# ------------------------------------------------------------------------- + +source [file join \ + [file dirname [file dirname [file join [pwd] [info script]]]] \ + devtools testutilities.tcl] + +testsNeedTcl 8.5 +testsNeedTcltest 2.0 + +support { +} +testing { + useLocal char.tcl char +} + +# ------------------------------------------------------------------------- + +set mytestdir tests/data + +# ------------------------------------------------------------------------- + +source [localPath tests/char.tests] + +#---------------------------------------------------------------------- + +unset mytestdir +testsuiteCleanup +return Index: modules/pt/include/format/options_cparam_critcl.inc ================================================================== --- modules/pt/include/format/options_cparam_critcl.inc +++ modules/pt/include/format/options_cparam_critcl.inc @@ -1,9 +1,10 @@ [list_begin options] [include options_std.inc] +[comment {= = == === ===== ======== =============}] [opt_def -class string] The value of this option is the name of the class to generate, without leading colons. @@ -13,13 +14,21 @@ For a simple value [var X] without colons, like CLASS, the parser command will be [var X]::[var X]. Whereas for a namespaced value [var X::Y] the parser command will be [var X::Y]. - +[comment {= = == === ===== ======== =============}] [opt_def -package string] The value of this option is the name of the package to generate. The default value is [const PACKAGE]. +[comment {= = == === ===== ======== =============}] +[opt_def -version string] + +The value of this option is the version of the package to generate. + +The default value is [const 1]. + +[comment {= = == === ===== ======== =============}] [list_end] Index: modules/pt/include/format/options_tclparam_oo.inc ================================================================== --- modules/pt/include/format/options_tclparam_oo.inc +++ modules/pt/include/format/options_tclparam_oo.inc @@ -19,7 +19,14 @@ leading colons. Note, it serves double-duty as the name of the class to generate too, if option [option -class] is not specified, see above. The default value is [const PACKAGE], applying if neither option [option -package] nor [option -class] were specified. + +[comment {================================================================================}] +[opt_def -version string] + +The value of this option is the version of the package to generate. + +The default value is [const 1]. [list_end] Index: modules/pt/include/format/options_tclparam_snit.inc ================================================================== --- modules/pt/include/format/options_tclparam_snit.inc +++ modules/pt/include/format/options_tclparam_snit.inc @@ -19,7 +19,14 @@ leading colons. Note, it serves double-duty as the name of the class to generate too, if option [option -class] is not specified, see above. The default value is [const PACKAGE], applying if neither option [option -package] nor [option -class] were specified. + +[comment {================================================================================}] +[opt_def -version string] + +The value of this option is the version of the package to generate. + +The default value is [const 1]. [list_end] Index: modules/pt/include/format/peg.inc ================================================================== --- modules/pt/include/format/peg.inc +++ modules/pt/include/format/peg.inc @@ -37,17 +37,17 @@ / DAPOSTROPH (!DAPOSTROPH Char)* DAPOSTROPH WHITESPACE ; Class <- OPENB (!CLOSEB Range)* CLOSEB WHITESPACE ; Range <- Char TO Char / Char ; StartExpr <- OPEN Expression CLOSE ; -void: Final <- END SEMICOLON WHITESPACE ; +void: Final <- "END" WHITESPACE SEMICOLON WHITESPACE ; # -------------------------------------------------------------------- # Lexing constructs Identifier <- Ident WHITESPACE ; -leaf: Ident <- ('_' / ':' / ) ('_' / ':' / )* ; +leaf: Ident <- ([_:] / ) ([_:] / )* ; Char <- CharSpecial / CharOctalFull / CharOctalPart / CharUnicode / CharUnescaped ; leaf: CharSpecial <- "\\" [nrt'"\[\]\\] ; @@ -61,15 +61,14 @@ void: TO <- '-' ; void: OPENB <- "[" ; void: CLOSEB <- "]" ; void: APOSTROPH <- "'" ; void: DAPOSTROPH <- '"' ; -void: PEG <- "PEG" WHITESPACE ; +void: PEG <- "PEG" !([_:] / ) WHITESPACE ; void: IS <- "<-" WHITESPACE ; leaf: VOID <- "void" WHITESPACE ; # Implies that definition has no semantic value. leaf: LEAF <- "leaf" WHITESPACE ; # Implies that definition has no terminals. -void: END <- "END" WHITESPACE ; void: SEMICOLON <- ";" WHITESPACE ; void: COLON <- ":" WHITESPACE ; void: SLASH <- "/" WHITESPACE ; leaf: AND <- "&" WHITESPACE ; leaf: NOT <- "!" WHITESPACE ; Index: modules/pt/pkgIndex.tcl ================================================================== --- modules/pt/pkgIndex.tcl +++ modules/pt/pkgIndex.tcl @@ -1,26 +1,30 @@ if {![package vsatisfies [package provide Tcl] 8.5]} return # General utilities. -package ifneeded char 1 [list source [file join $dir char.tcl]] +package ifneeded char 1.0.1 [list source [file join $dir char.tcl]] package ifneeded configuration 1 [list source [file join $dir configuration.tcl]] package ifneeded paths 1 [list source [file join $dir paths.tcl]] package ifneeded text::write 1 [list source [file join $dir text_write.tcl]] # AST support package ifneeded pt::ast 1.1 [list source [file join $dir pt_astree.tcl]] +# General parser support. Currently only conversion of structured +# syntax errors (or parts thereof) into a human-readable form. +package ifneeded pt::util 1 [list source [file join $dir pt_util.tcl]] + # Parsing Expression support -package ifneeded pt::pe 1 [list source [file join $dir pt_pexpression.tcl]] -package ifneeded pt::pe::op 1 [list source [file join $dir pt_pexpr_op.tcl]] +package ifneeded pt::pe 1.0.2 [list source [file join $dir pt_pexpression.tcl]] +package ifneeded pt::pe::op 1 [list source [file join $dir pt_pexpr_op.tcl]] # Parsing Expression Grammar support. -package ifneeded pt::peg 1 [list source [file join $dir pt_pegrammar.tcl]] -package ifneeded pt::peg::container 1 [list source [file join $dir pt_peg_container.tcl]] -package ifneeded pt::peg::interp 1 [list source [file join $dir pt_peg_interp.tcl]] -package ifneeded pt::peg::op 1.0.1 [list source [file join $dir pt_peg_op.tcl]] -package ifneeded pt::parse::peg 1 [list source [file join $dir pt_parse_peg.tcl]] +package ifneeded pt::peg 1 [list source [file join $dir pt_pegrammar.tcl]] +package ifneeded pt::peg::container 1 [list source [file join $dir pt_peg_container.tcl]] +package ifneeded pt::peg::interp 1.0.1 [list source [file join $dir pt_peg_interp.tcl]] +package ifneeded pt::peg::op 1.0.1 [list source [file join $dir pt_peg_op.tcl]] +package ifneeded pt::parse::peg 1.0.1 [list source [file join $dir pt_parse_peg.tcl]] # Export/import managers. Assumes an untrusted environment. package ifneeded pt::peg::export 1 [list source [file join $dir pt_peg_export.tcl]] package ifneeded pt::peg::import 1 [list source [file join $dir pt_peg_import.tcl]] @@ -33,30 +37,31 @@ # Import plugins, connecting manager to the core conversion packages. package ifneeded pt::peg::import::json 1 [list source [file join $dir pt_peg_import_json.tcl]] package ifneeded pt::peg::import::peg 1 [list source [file join $dir pt_peg_import_peg.tcl]] # Export core functionality: Conversion from PEG to a specific format. -package ifneeded pt::peg::to::container 1 [list source [file join $dir pt_peg_to_container.tcl]] -package ifneeded pt::peg::to::cparam 1.1.1 [list source [file join $dir pt_peg_to_cparam.tcl]] -package ifneeded pt::peg::to::json 1 [list source [file join $dir pt_peg_to_json.tcl]] -package ifneeded pt::peg::to::param 1 [list source [file join $dir pt_peg_to_param.tcl]] -package ifneeded pt::peg::to::peg 1.0.1 [list source [file join $dir pt_peg_to_peg.tcl]] -package ifneeded pt::peg::to::tclparam 1 [list source [file join $dir pt_peg_to_tclparam.tcl]] +package ifneeded pt::peg::to::container 1 [list source [file join $dir pt_peg_to_container.tcl]] +package ifneeded pt::peg::to::cparam 1.1.3 [list source [file join $dir pt_peg_to_cparam.tcl]] +package ifneeded pt::peg::to::json 1 [list source [file join $dir pt_peg_to_json.tcl]] +package ifneeded pt::peg::to::param 1.0.1 [list source [file join $dir pt_peg_to_param.tcl]] +package ifneeded pt::peg::to::peg 1.0.2 [list source [file join $dir pt_peg_to_peg.tcl]] +package ifneeded pt::peg::to::tclparam 1.0.2 [list source [file join $dir pt_peg_to_tclparam.tcl]] # Import core functionality: Conversion from a specific format to PEG. package ifneeded pt::peg::from::json 1 [list source [file join $dir pt_peg_from_json.tcl]] -package ifneeded pt::peg::from::peg 1.0.2 [list source [file join $dir pt_peg_from_peg.tcl]] +package ifneeded pt::peg::from::peg 1.0.3 [list source [file join $dir pt_peg_from_peg.tcl]] # PARAM runtime. -package ifneeded pt::rde 1.0.2 [list source [file join $dir pt_rdengine.tcl]] -package ifneeded pt::rde::oo 1.0.2 [list source [file join $dir pt_rdengine_oo.tcl]] +package ifneeded pt::rde 1.0.3 [list source [file join $dir pt_rdengine.tcl]] +package ifneeded pt::rde::oo 1.0.3 [list source [file join $dir pt_rdengine_oo.tcl]] # PEG grammar specification, as CONTAINER package ifneeded pt::peg::container::peg 1 [list source [file join $dir pt_peg_container_peg.tcl]] # */PARAM support (canned configurations). -package ifneeded pt::cparam::configuration::critcl 1.0.1 [list source [file join $dir pt_cparam_config_critcl.tcl]] -package ifneeded pt::tclparam::configuration::snit 1.0.1 [list source [file join $dir pt_tclparam_config_snit.tcl]] -package ifneeded pt::tclparam::configuration::tcloo 1.0.3 [list source [file join $dir pt_tclparam_config_tcloo.tcl]] +package ifneeded pt::cparam::configuration::critcl 1.0.2 [list source [file join $dir pt_cparam_config_critcl.tcl]] +package ifneeded pt::cparam::configuration::tea 0.1 [list source [file join $dir pt_cparam_config_tea.tcl]] +package ifneeded pt::tclparam::configuration::snit 1.0.2 [list source [file join $dir pt_tclparam_config_snit.tcl]] +package ifneeded pt::tclparam::configuration::tcloo 1.0.4 [list source [file join $dir pt_tclparam_config_tcloo.tcl]] # Parser generator core. -package ifneeded pt::pgen 1.0.2 [list source [file join $dir pt_pgen.tcl]] +package ifneeded pt::pgen 1.0.3 [list source [file join $dir pt_pgen.tcl]] Index: modules/pt/pt_cparam_config_critcl.man ================================================================== --- modules/pt/pt_cparam_config_critcl.man +++ modules/pt/pt_cparam_config_critcl.man @@ -1,10 +1,11 @@ +[vset VERSION 1.0.2] [comment {-*- text -*- doctools manpage}] -[manpage_begin pt::cparam::configuration::critcl n 1.0.1] +[manpage_begin pt::cparam::configuration::critcl n [vset VERSION]] [include include/module.inc] [titledesc {C/PARAM, Canned configuration, Critcl}] -[require pt::cparam::configuration::critcl [opt 1.0.1]] +[require pt::cparam::configuration::critcl [opt [vset VERSION]]] [description] [include include/ref_intro.inc] This package is an adjunct to [package pt::peg::to::cparam], to make the use of this highly configurable package easier by providing a @@ -20,15 +21,15 @@ [section API] [list_begin definitions] [call [cmd ::pt::cparam::configuration::critcl] [method def] \ - [arg name] [arg cmdprefix]] + [arg name] [arg pkg] [arg version] [arg cmdprefix]] The command applies the configuration provided by this package to the [arg cmdprefix], causing the creation of [package critcl]-based parsers -whose class is [arg name]. +whose class is [arg name], in package [arg pkg] with [arg version]. [para] The use of a command prefix as API allows application of the configuration to not only [package pt::peg::to::cparam] Index: modules/pt/pt_cparam_config_critcl.tcl ================================================================== --- modules/pt/pt_cparam_config_critcl.tcl +++ modules/pt/pt_cparam_config_critcl.tcl @@ -1,7 +1,11 @@ # -*- tcl -*- -# Copyright (c) 2009-2010 Andreas Kupries +# Copyright (c) 2009-2014 Andreas Kupries + +# TODO: Refactor this and pt::cparam::configuration::critcl to avoid +# TODO: duplication of the supporting code (creation of the RDE +# TODO: amalgamation, basic C template). # Canned configuration for the converter to C/PARAM representation, # causing generation of a proper critcl-based parser. # The requirements of the embedded template are not our requirements. @@ -31,39 +35,40 @@ ## Public API # Check that the proposed serialization of an abstract syntax tree is # indeed such. -proc ::pt::cparam::configuration::critcl::def {class pkg cmd} { +proc ::pt::cparam::configuration::critcl::def {class pkg version cmd} { # TODO :: See if we can consolidate the API for converters, # TODO :: plugins, export manager, and container in some way. # TODO :: Container may make exporter manager available through # TODO :: public method. - # class = The namespace/prefix for the generated commands. - # pkg = The name of generated package. + # class = The namespace/prefix for the generated commands. + # pkg = The name of the generated package / parser. + # version = The version of the generated package / parser. if {[string first :: $class] < 0} { set cheader $class set ctrailer $class } else { set cheader [namespace qualifier $class] set ctrailer [namespace tail $class] } + lappend map @@RUNTIME@@ [GetRuntime] + lappend map @@PKG@@ $pkg + lappend map @@VERSION@@ $version + lappend map @@CLASS@@ $class + lappend map @@CHEAD@@ $cheader + lappend map @@CTAIL@@ $ctrailer + lappend map \n\t \n ;# undent the template + {*}$cmd -main MAIN {*}$cmd -indent 8 {*}$cmd -template [string trim \ - [string map \ - [list \ - @@RUNTIME@@ [GetRuntime] \ - @@PKG@@ $pkg \ - @@CLASS@@ $class \ - @@CHEAD@@ $cheader \ - @@CTAIL@@ $ctrailer \ - \n\t \n \ - ] { + [string map $map { ## -*- tcl -*- ## ## Critcl-based C/PARAM implementation of the parsing ## expression grammar ## @@ -76,11 +81,11 @@ ## Requirements package require Tcl 8.4 package require critcl # @sak notprovided @@PKG@@ - package provide @@PKG@@ 1 + package provide @@PKG@@ @@VERSION@@ # Note: The implementation of the PARAM virtual machine # underlying the C/PARAM code used below is inlined # into the generated parser, allowing for direct access # and manipulation of the RDE state, instead of having @@ -92,11 +97,11 @@ namespace eval ::@@CHEAD@@ { # # ## ### ##### ######## ############# ##################### ## Supporting code for the main command. catch { - #critcl::cheaders -g + #critcl::cflags -g #critcl::debug memory symbols } # # ## ### ###### ######## ############# ## RDE runtime, inlined, and made static. @@ -160,11 +165,11 @@ Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; - sprintf (parserg->buf, "@@CTAIL@@%d", parserg->counter); + sprintf (parserg->buf, "@@CTAIL@@%ld", parserg->counter); return parserg->buf; #undef KEY } static void @@ -223,45 +228,52 @@ rde_param_data (p, buf, len); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } + /* See also rde_critcl/m.c, param_COMPLETE() */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) { if (rde_param_query_st (p)) { long int ac; Tcl_Obj** av; rde_param_query_ast (p, &ac, &av); if (ac > 1) { - long int lsc; - long int* lsv; Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); - rde_param_query_ls (p, &lsc, &lsv); - memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); lv [0] = Tcl_NewObj (); - lv [1] = Tcl_NewIntObj (1 + lsv [lsc-1]); + lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); ckfree ((char*) lv); + + } else if (ac == 0) { + /* + * Match, but no AST. This is possible if the grammar + * consists of only the start expression. + */ + Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); } else { Tcl_SetObjResult (interp, av [0]); } return TCL_OK; } else { Tcl_Obj* xv [1]; const ERROR_STATE* er = rde_param_query_er (p); Tcl_Obj* res = rde_param_query_er_tcl (p, er); + /* res = list (location, list(msg)) */ + /* Stick the exception type-tag before the existing elements */ xv [0] = Tcl_NewStringObj ("pt::rde",-1); - Tcl_ListObjReplace(interp, res, 0, 1, 1, xv); + Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); + Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); Tcl_SetObjResult (interp, res); return TCL_ERROR; } } } @@ -397,11 +409,10 @@ return } proc ::pt::cparam::configuration::critcl::GetRuntime {} { - # This is the C code for the RDE, i.e. the implementation of # pt::rde. Only the low-level engine is imported, the Tcl # interface layer is ignored. This generated parser provides its # own layer for that. @@ -475,7 +486,7 @@ namespace eval ::pt::cparam::configuration::critcl {} # # ## ### ##### ######## ############# ##################### ## Ready -package provide pt::cparam::configuration::critcl 1.0.1 +package provide pt::cparam::configuration::critcl 1.0.2 return ADDED modules/pt/pt_cparam_config_tea.man Index: modules/pt/pt_cparam_config_tea.man ================================================================== --- /dev/null +++ modules/pt/pt_cparam_config_tea.man @@ -0,0 +1,48 @@ +[vset VERSION 0.1] +[comment {-*- text -*- doctools manpage}] +[manpage_begin pt::cparam::configuration::tea n [vset VERSION]] +[include include/module.inc] +[titledesc {C/PARAM, Canned configuration, TEA}] +[require pt::cparam::configuration::tea [opt [vset VERSION]]] +[description] +[include include/ref_intro.inc] + +This package is an adjunct to [package pt::peg::to::cparam], to make +the use of this highly configurable package easier by providing a +canned configuration. When applied this configuration causes the +package [package pt::peg::to::cparam] to generate plain parser code +ready for inclusion into a [term TEA]-based C extension. + +[para] + +It is a supporting package in the Core Layer of Parser Tools. +[para][image arch_core_support][para] + +[section API] + +[list_begin definitions] + +[call [cmd ::pt::cparam::configuration::tea] [method def] \ + [arg name] [arg pkg] [arg version] [arg cmdprefix]] + +The command applies the configuration provided by this package to the +[arg cmdprefix], causing the creation of [package tea]-based parsers +whose class is [arg name], in package [arg pkg] with [arg version]. + +[para] + +The use of a command prefix as API allows application of the +configuration to not only [package pt::peg::to::cparam] +([cmd {pt::peg::to::cparam configure}]), but also export manager +instances and PEG containers ([cmd {$export configuration set}] and +[cmd {[$container exporter] configuration set}] respectively). + +[para] + +Or anything other command prefix accepting two arguments, option and +value. + +[list_end] + +[include include/feedback.inc] +[manpage_end] ADDED modules/pt/pt_cparam_config_tea.tcl Index: modules/pt/pt_cparam_config_tea.tcl ================================================================== --- /dev/null +++ modules/pt/pt_cparam_config_tea.tcl @@ -0,0 +1,465 @@ +# -*- tcl -*- +# Copyright (c) 2014 Christian Gollwitzer + +# TODO: Refactor this and pt::cparam::configuration::critcl to avoid +# TODO: duplication of the supporting code (creation of the RDE +# TODO: amalgamation, basic C template). + +# Canned configuration for the converter to C/PARAM representation, +# causing generation of a C-based parser which can be plugged into a +# TEA-based C extension. The supporting files, i.e. configure.in, +# Makefile.in, etc. still have to be written separately, and manually. + +# The generated file can easily be compiled with a single +# +# gcc -dynamiclib -o .dylib .c -DUSE_TCL_STUBS -ltclstub8.5 +# +# or similar, or included in a larger package, if added to the source +# files and by invoking the _Init() function within the init +# function of the main package. +# +# TODO: Put the above note/semi-example into the manpage for this generator. + +# # ## ### ##### ######## ############# ##################### +## Requirements + +package require Tcl 8.5 ; # Required runtime. + +# # ## ### ##### ######## ############# ##################### +## + +namespace eval ::pt::cparam::configuration::tea { + namespace export def + namespace ensemble create + + # @mdgen OWNER: rde_critcl/util.* + # @mdgen OWNER: rde_critcl/stack.* + # @mdgen OWNER: rde_critcl/tc.* + # @mdgen OWNER: rde_critcl/param.* + # Access to the rde_critcl files forming the low-level runtime + variable selfdir [file dirname [file normalize [info script]]] +} + +# # ## ### ##### ######## ############# +## Public API + +# Check that the proposed serialization of an abstract syntax tree is +# indeed such. + +proc ::pt::cparam::configuration::tea::def {class pkg version cmd} { + # TODO :: See if we can consolidate the API for converters, + # TODO :: plugins, export manager, and container in some way. + # TODO :: Container may make exporter manager available through + # TODO :: public method. + + # class = The namespace/prefix for the generated commands. + # pkg = The name of the generated package / parser. + # version = The version of the generated package / parser. + + if {[string first :: $class] < 0} { + set cheader $class + set ctrailer $class + } else { + set cheader [namespace qualifier $class] + set ctrailer [namespace tail $class] + } + + set pkghead [string range $pkg 0 0] + set pkgtail [string range $pkg 1 end] + set pkglowcase "[string toupper $pkghead][string tolower $pkgtail]" + + lappend map @@RUNTIME@@ [GetRuntime] + lappend map @@PKG@@ $pkg + lappend map @@PKGLOWCASE@@ $pkglowcase + lappend map @@VERSION@@ $version + lappend map @@CLASS@@ $class + lappend map @@CHEAD@@ $cheader + lappend map @@CTAIL@@ $ctrailer + lappend map \n\t \n ;# undent the template + + {*}$cmd -main MAIN + {*}$cmd -indent 8 + {*}$cmd -template [string trim \ + [string map $map { + /************************************************************ + ** + ** TEA-based C/PARAM implementation of the parsing + ** expression grammar + ** + ** @name@ + ** + ** Generated from file @file@ + ** for user @user@ + ** + * * ** *** ***** ******** ************* *********************/ + #include + #include + #include + #include + #define SCOPE static + +@@RUNTIME@@ +@code@ + /* -*- c -*- */ + + typedef struct PARSERg { + long int counter; + char buf [50]; + } PARSERg; + + static void + PARSERgRelease (ClientData cd, Tcl_Interp* interp) + { + ckfree((char*) cd); + } + + static const char* + PARSERnewName (Tcl_Interp* interp) + { +#define KEY "tcllib/parser/@@PKG@@/TEA" + + Tcl_InterpDeleteProc* proc = PARSERgRelease; + PARSERg* parserg; + + parserg = Tcl_GetAssocData (interp, KEY, &proc); + if (parserg == NULL) { + parserg = (PARSERg*) ckalloc (sizeof (PARSERg)); + parserg->counter = 0; + + Tcl_SetAssocData (interp, KEY, proc, + (ClientData) parserg); + } + + parserg->counter ++; + sprintf (parserg->buf, "@@CTAIL@@%ld", parserg->counter); + return parserg->buf; +#undef KEY + } + + static void + PARSERdeleteCmd (ClientData clientData) + { + /* + * Release the whole PARSER + * (Low-level engine only actually). + */ + rde_param_del ((RDE_PARAM) clientData); + } + + + /* * ** *** ***** ******** ************* + ** Functions implementing the object methods, and helper. + */ + + static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp); + + static int parser_PARSE (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + int mode; + Tcl_Channel chan; + + if (objc != 3) { + Tcl_WrongNumArgs (interp, 2, objv, "chan"); + return TCL_ERROR; + } + + chan = Tcl_GetChannel(interp, + Tcl_GetString (objv[2]), + &mode); + + if (!chan) { + return TCL_ERROR; + } + + rde_param_reset (p, chan); + MAIN (p) ; /* Entrypoint for the generated code. */ + return COMPLETE (p, interp); + } + + static int parser_PARSET (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + char* buf; + int len; + + if (objc != 3) { + Tcl_WrongNumArgs (interp, 2, objv, "text"); + return TCL_ERROR; + } + + buf = Tcl_GetStringFromObj (objv[2], &len); + + rde_param_reset (p, NULL); + rde_param_data (p, buf, len); + MAIN (p) ; /* Entrypoint for the generated code. */ + return COMPLETE (p, interp); + } + + /* See also rde_critcl/m.c, param_COMPLETE() */ + static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) + { + if (rde_param_query_st (p)) { + long int ac; + Tcl_Obj** av; + + rde_param_query_ast (p, &ac, &av); + + if (ac > 1) { + Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); + + memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); + lv [0] = Tcl_NewObj (); + lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); + lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); + + Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); + ckfree ((char*) lv); + + } else if (ac == 0) { + /* + * Match, but no AST. This is possible if the grammar + * consists of only the start expression. + */ + Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); + } else { + Tcl_SetObjResult (interp, av [0]); + } + + return TCL_OK; + } else { + Tcl_Obj* xv [1]; + const ERROR_STATE* er = rde_param_query_er (p); + Tcl_Obj* res = rde_param_query_er_tcl (p, er); + /* res = list (location, list(msg)) */ + + /* Stick the exception type-tag before the existing elements */ + xv [0] = Tcl_NewStringObj ("pt::rde",-1); + Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); + + Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); + Tcl_SetObjResult (interp, res); + return TCL_ERROR; + } + } + + + /* * ** *** ***** ******** ************* + ** Object command, method dispatch. + */ + static int parser_objcmd (ClientData cd, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + RDE_PARAM p = (RDE_PARAM) cd; + int m, res; + + static CONST char* methods [] = { + "destroy", "parse", "parset", NULL + }; + enum methods { + M_DESTROY, M_PARSE, M_PARSET + }; + + if (objc < 2) { + Tcl_WrongNumArgs (interp, objc, objv, "option ?arg arg ...?"); + return TCL_ERROR; + } else if (Tcl_GetIndexFromObj (interp, objv [1], methods, "option", + 0, &m) != TCL_OK) { + return TCL_ERROR; + } + + /* Dispatch to methods. They check the #args in + * detail before performing the requested + * functionality + */ + + switch (m) { + case M_DESTROY: + if (objc != 2) { + Tcl_WrongNumArgs (interp, 2, objv, NULL); + return TCL_ERROR; + } + + Tcl_DeleteCommandFromToken(interp, (Tcl_Command) rde_param_query_clientdata (p)); + return TCL_OK; + + case M_PARSE: res = parser_PARSE (p, interp, objc, objv); break; + case M_PARSET: res = parser_PARSET (p, interp, objc, objv); break; + default: + /* Not coming to this place */ + ASSERT (0,"Reached unreachable location"); + } + + return res; + } + + /** * ** *** ***** ******** ************* + * Class command, i.e. object construction. + */ + static int ParserClassCmd (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const*objv) { + /* + * Syntax: No arguments beyond the name + */ + + RDE_PARAM parser; + CONST char* name; + Tcl_Obj* fqn; + Tcl_CmdInfo ci; + Tcl_Command c; + +#define USAGE "?name?" + + if ((objc != 2) && (objc != 1)) { + Tcl_WrongNumArgs (interp, 1, objv, USAGE); + return TCL_ERROR; + } + + if (objc < 2) { + name = PARSERnewName (interp); + } else { + name = Tcl_GetString (objv [1]); + } + + if (!Tcl_StringMatch (name, "::*")) { + /* Relative name. Prefix with current namespace */ + + Tcl_Eval (interp, "namespace current"); + fqn = Tcl_GetObjResult (interp); + fqn = Tcl_DuplicateObj (fqn); + Tcl_IncrRefCount (fqn); + + if (!Tcl_StringMatch (Tcl_GetString (fqn), "::")) { + Tcl_AppendToObj (fqn, "::", -1); + } + Tcl_AppendToObj (fqn, name, -1); + } else { + fqn = Tcl_NewStringObj (name, -1); + Tcl_IncrRefCount (fqn); + } + Tcl_ResetResult (interp); + + if (Tcl_GetCommandInfo (interp, + Tcl_GetString (fqn), + &ci)) { + Tcl_Obj* err; + + err = Tcl_NewObj (); + Tcl_AppendToObj (err, "command \"", -1); + Tcl_AppendObjToObj (err, fqn); + Tcl_AppendToObj (err, "\" already exists", -1); + + Tcl_DecrRefCount (fqn); + Tcl_SetObjResult (interp, err); + return TCL_ERROR; + } + + parser = rde_param_new (sizeof(p_string)/sizeof(char*), (char**) p_string); + c = Tcl_CreateObjCommand (interp, Tcl_GetString (fqn), + parser_objcmd, (ClientData) parser, + PARSERdeleteCmd); + rde_param_clientdata (parser, (ClientData) c); + Tcl_SetObjResult (interp, fqn); + Tcl_DecrRefCount (fqn); + return TCL_OK; + } + + int @@PKGLOWCASE@@_Init(Tcl_Interp* interp) { + if (interp == 0) return TCL_ERROR; + + if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { + return TCL_ERROR; + } + + if (Tcl_CreateObjCommand(interp, "@@CLASS@@", ParserClassCmd , NULL, NULL) == NULL) { + Tcl_SetResult(interp, "Can't create constructor", NULL); + return TCL_ERROR; + } + + + Tcl_PkgProvide(interp, "@@PKG@@", "0.1"); + + return TCL_OK; + } + + }]] + + return +} + +proc ::pt::cparam::configuration::tea::GetRuntime {} { + # This is the C code for the RDE, i.e. the implementation of + # pt::rde. Only the low-level engine is imported, the Tcl + # interface layer is ignored. This generated parser provides its + # own layer for that. + + # We are inlining the code (making the functions static) to + # prevent any conflict with the support for pt::rde, should both + # be put into the same shared library. + + variable selfdir + + set code {} + + foreach f { + rde_critcl/util.h + rde_critcl/stack.h + rde_critcl/tc.h + rde_critcl/param.h + rde_critcl/util.c + rde_critcl/stack.c + rde_critcl/tc.c + rde_critcl/param.c + } { + # Load C code. + set c [open $selfdir/$f] + set d [read $c] + close $c + + # Strip include directives and anything explicitly excluded. + set skip 0 + set n {} + foreach l [split $d \n] { + if {[string match {*#include*} $l]} { + continue + } + if {[string match {*SKIP START*} $l]} { + set skip 1 + continue + } + if {[string match {*SKIP END*} $l]} { + set skip 0 + continue + } + if {$skip} continue + lappend n $l + } + set d [join $n \n] + + # Strip comments, trailing whitespace, empty lines. + set d [regsub -all {/\*.*?\*/} $d {}] + set d [regsub -all {//.*?\n} $d {}] + set d [regsub -all {[ ]+$} $d {}] + while {1} { + set n [string map [list \n\n \n] $d] + if {$n eq $d} break + set d $n + } + + # Indent code. + lappend code "#line 1 \"$f\"" + foreach l [split $d \n] { + if {$l ne ""} { set l \t$l } + lappend code $l + } + } + + #lappend code "#line x \"X\"" + return [join $code \n] +} + +# # ## ### ##### ######## ############# + +namespace eval ::pt::cparam::configuration::tea {} + +# # ## ### ##### ######## ############# ##################### +## Ready + +package provide pt::cparam::configuration::tea 0.1 +return ADDED modules/pt/pt_cparam_config_tea.test Index: modules/pt/pt_cparam_config_tea.test ================================================================== --- /dev/null +++ modules/pt/pt_cparam_config_tea.test @@ -0,0 +1,50 @@ +# -*- tcl -*- +# pt_cparam_config_critcl.test: tests for the pt::peg::to::cparam +# converter package configured for critcl. +# +# Copyright (c) 2009 by Andreas Kupries +# All rights reserved. +# +# RCS: @(#) $Id: pt_cparam_config_critcl.test,v 1.1 2010/03/26 05:07:24 andreas_kupries Exp $ + +# ------------------------------------------------------------------------- + +source [file join \ + [file dirname [file dirname [file join [pwd] [info script]]]] \ + devtools testutilities.tcl] + +testsNeedTcl 8.5 +testsNeedTcltest 2 + +support { + useAccel [useTcllibC] struct/sets.tcl struct::set ; # used by pt::pe::op, + TestAccelInit struct::set ; # however not by the + # # commands used here. + + use fileutil/fileutil.tcl fileutil ;# tests/common + use textutil/adjust.tcl textutil::adjust + + useLocal pt_pexpression.tcl pt::pe + useLocal pt_pexpr_op.tcl pt::pe::op + useLocal pt_pegrammar.tcl pt::peg + useLocal text_write.tcl text::write + useLocal char.tcl char + + useLocal pt_peg_to_cparam.tcl pt::peg::to::cparam + + source [localPath tests/common] +} +testing { + useLocal pt_cparam_config_tea.tcl pt::cparam::configuration::tea +} + +set mytestdir tests/data + +# ------------------------------------------------------------------------- + +source [localPath tests/pt_cparam_config_tea.tests] + +# ------------------------------------------------------------------------- +TestAccelExit struct::set +testsuiteCleanup +return Index: modules/pt/pt_parse_peg.tcl ================================================================== --- modules/pt/pt_parse_peg.tcl +++ modules/pt/pt_parse_peg.tcl @@ -1,8 +1,8 @@ # -*- tcl -*- # -# Copyright (c) 2009 by Andreas Kupries +# Copyright (c) 2009-2014 by Andreas Kupries # # ## ### ##### ######## ############# ##################### ## Package description ## Implementation of a parser for PE grammars. We have multiple @@ -175,6 +175,6 @@ namespace eval ::pt { # Export the constructor command. namespace export rde } -package provide pt::parse::peg 1 +package provide pt::parse::peg 1.0.1 Index: modules/pt/pt_parse_peg_c.tcl ================================================================== --- modules/pt/pt_parse_peg_c.tcl +++ modules/pt/pt_parse_peg_c.tcl @@ -12,11 +12,11 @@ ## Requirements package require Tcl 8.4 package require critcl # @sak notprovided pt_parse_peg_c -package provide pt_parse_peg_c 1 +package provide pt_parse_peg_c 1.0.1 # Note: The implementation of the PARAM virtual machine # underlying the C/PARAM code used below is inlined # into the generated parser, allowing for direct access # and manipulation of the RDE state, instead of having @@ -28,11 +28,11 @@ namespace eval ::pt::parse { # # ## ### ##### ######## ############# ##################### ## Supporting code for the main command. catch { - #critcl::cheaders -g + #critcl::cflags -g #critcl::debug memory symbols } # # ## ### ###### ######## ############# ## RDE runtime, inlined, and made static. @@ -384,10 +384,14 @@ int clen; Tcl_UniChar uni; if (len < 0) { len = strlen (string); } + + if (!len) { + return tc->str + base; + } if ((tc->num + len) >= tc->max) { int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); char* str = ckrealloc (tc->str, new * sizeof(char)); ASSERT (str,"Memory allocation failure for token character array"); @@ -413,18 +417,18 @@ } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; - long int* ov; - rde_stack_get (tc->off, &oc, (void***) &ov); + void** ov; + rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); - off = ov [at]; + off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { - end = ov [at+1]; + end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; @@ -432,19 +436,19 @@ } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; - long int* ov; - rde_stack_get (tc->off, &oc, (void***) &ov); + void** ov; + rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); - off = ov [at]; + off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { - end = ov [last+1]; + end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; @@ -479,10 +483,11 @@ typedef int (*UniCharClass) (int); typedef enum test_class_id { tc_alnum, tc_alpha, tc_ascii, + tc_control, tc_ddigit, tc_digit, tc_graph, tc_lower, tc_printable, @@ -492,11 +497,11 @@ tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); - static void error_set (RDE_PARAM p, int s); + static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); @@ -645,13 +650,13 @@ rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void - rde_param_query_amark (RDE_PARAM p, long int* mc, long int** mv) + rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { - rde_stack_get (p->mark, mc, (void***) mv); + rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); @@ -688,25 +693,25 @@ res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; - long int* mv; + void** mv; int lastid; const char* msg; - rde_stack_get (er->msg, &mc, (void***) &mv); + rde_stack_get (er->msg, &mc, &mv); - qsort (mv, mc, sizeof (long int), er_int_compare); + qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); - if (mv [i] == lastid) continue; - lastid = mv [i]; - ASSERT_BOUNDS(mv[i],p->numstr); - msg = p->string [mv[i]]; + if (((long int) mv [i]) == lastid) continue; + lastid = (long int) mv [i]; + ASSERT_BOUNDS((long int) mv[i],p->numstr); + msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } @@ -721,13 +726,18 @@ rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) { rde_stack_get (p->ES, ec, (void***) ev); } SCOPE void - rde_param_query_ls (RDE_PARAM p, long int* lc, long int** lv) + rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) { - rde_stack_get (p->LS, lc, (void***) lv); + rde_stack_get (p->LS, lc, lv); + } + SCOPE long int + rde_param_query_lstop (RDE_PARAM p) + { + (long int) rde_stack_top (p->LS); } SCOPE Tcl_HashTable* rde_param_query_nc (RDE_PARAM p) { return &p->NC; @@ -770,11 +780,11 @@ { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; @@ -783,11 +793,11 @@ rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; @@ -801,11 +811,11 @@ rde_param_i_ast_value_push (RDE_PARAM p) { ENTER ("rde_param_i_ast_value_push"); TRACE (("RDE_PARAM %p",p)); ASSERT(p->SV,"Unable to push undefined semantic value"); - TRACE (("rde_param_i_ast_value_push %p => (%p)/%d", p, p->SV, )); + TRACE (("rde_param_i_ast_value_push %p => (%p)", p, p->SV)); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV->refCount, Tcl_GetString (p->SV))); rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); RETURNVOID; } @@ -818,12 +828,14 @@ rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void - rde_param_i_error_nonterminal (RDE_PARAM p, int s) + rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { + + return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; error_set (p, s); @@ -872,11 +884,11 @@ { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void - error_set (RDE_PARAM p, int s) + error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; @@ -914,20 +926,21 @@ rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void - rde_param_i_input_next (RDE_PARAM p, int m) + rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); - ASSERT_BOUNDS (p->CC_len, TCL_UTF_MAX); + + ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || @@ -960,11 +973,11 @@ rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int - rde_param_i_symbol_restore (RDE_PARAM p, int s) + rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; @@ -983,11 +996,11 @@ TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void - rde_param_i_symbol_save (RDE_PARAM p, int s) + rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; @@ -1049,11 +1062,16 @@ rde_param_i_test_ascii (RDE_PARAM p) { test_class (p, UniCharIsAscii, tc_ascii); } SCOPE void - rde_param_i_test_char (RDE_PARAM p, char* c, int msg) + rde_param_i_test_control (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsControl, tc_control); + } + SCOPE void + rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); @@ -1091,11 +1109,11 @@ rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void - rde_param_i_test_range (RDE_PARAM p, char* s, char* e, int msg) + rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); @@ -1160,11 +1178,11 @@ rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void - rde_param_i_value_leaf (RDE_PARAM p, int s) + rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); @@ -1174,11 +1192,11 @@ newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void - rde_param_i_value_reduce (RDE_PARAM p, int s) + rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; @@ -1206,18 +1224,21 @@ ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { - long int ai = *((long int*) a); - long int bi = *((long int*) b); - if (ai < bi) { return -1; } - if (ai > bi) { return 1; } + + const void** ael = (const void**) a; + const void** bel = (const void**) b; + long int avalue = (long int) *ael; + long int bvalue = (long int) *bel; + if (avalue < bvalue) { return -1; } + if (avalue > bvalue) { return 1; } return 0; } SCOPE int - rde_param_i_symbol_start (RDE_PARAM p, int s) + rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); @@ -1226,11 +1247,11 @@ } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int - rde_param_i_symbol_start_d (RDE_PARAM p, int s) + rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); @@ -1240,26 +1261,26 @@ rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int - rde_param_i_symbol_void_start (RDE_PARAM p, int s) + rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int - rde_param_i_symbol_void_start_d (RDE_PARAM p, int s) + rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void - rde_param_i_symbol_done_d_reduce (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); @@ -1272,11 +1293,11 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_leaf (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); @@ -1288,11 +1309,11 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_d_leaf (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); @@ -1305,126 +1326,133 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_void (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void - rde_param_i_symbol_done_d_void (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void - rde_param_i_next_char (RDE_PARAM p, char* c, int m) + rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void - rde_param_i_next_range (RDE_PARAM p, char* s, char* e, int m) + rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void - rde_param_i_next_alnum (RDE_PARAM p, int m) + rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void - rde_param_i_next_alpha (RDE_PARAM p, int m) + rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void - rde_param_i_next_ascii (RDE_PARAM p, int m) + rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void - rde_param_i_next_ddigit (RDE_PARAM p, int m) + rde_param_i_next_control (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_control (p); + } + SCOPE void + rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void - rde_param_i_next_digit (RDE_PARAM p, int m) + rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void - rde_param_i_next_graph (RDE_PARAM p, int m) + rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void - rde_param_i_next_lower (RDE_PARAM p, int m) + rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void - rde_param_i_next_print (RDE_PARAM p, int m) + rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void - rde_param_i_next_punct (RDE_PARAM p, int m) + rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void - rde_param_i_next_space (RDE_PARAM p, int m) + rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void - rde_param_i_next_upper (RDE_PARAM p, int m) + rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void - rde_param_i_next_wordchar (RDE_PARAM p, int m) + rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void - rde_param_i_next_xdigit (RDE_PARAM p, int m) + rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } @@ -1501,11 +1529,11 @@ rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } @@ -1569,11 +1597,11 @@ if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } @@ -1612,11 +1640,11 @@ rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; @@ -1628,37 +1656,40 @@ if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void - rde_param_i_next_str (RDE_PARAM p, char* str, int m) + rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; + while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { + p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { + p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void - rde_param_i_next_class (RDE_PARAM p, char* class, int m) + rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; @@ -1741,279 +1772,286 @@ static void sym_Definition (RDE_PARAM p); static void sequence_148 (RDE_PARAM p); static void sym_DIGIT (RDE_PARAM p); static void sequence_153 (RDE_PARAM p); static void sym_DOT (RDE_PARAM p); - static void sequence_158 (RDE_PARAM p); - static void sym_END (RDE_PARAM p); - static void notahead_162 (RDE_PARAM p); + static void notahead_157 (RDE_PARAM p); static void sym_EOF (RDE_PARAM p); static void sym_EOL (RDE_PARAM p); - static void sequence_170 (RDE_PARAM p); - static void kleene_172 (RDE_PARAM p); - static void sequence_174 (RDE_PARAM p); + static void sequence_165 (RDE_PARAM p); + static void kleene_167 (RDE_PARAM p); + static void sequence_169 (RDE_PARAM p); static void sym_Expression (RDE_PARAM p); - static void sequence_180 (RDE_PARAM p); + static void sequence_176 (RDE_PARAM p); static void sym_Final (RDE_PARAM p); - static void kleene_186 (RDE_PARAM p); - static void sequence_190 (RDE_PARAM p); + static void kleene_182 (RDE_PARAM p); + static void sequence_186 (RDE_PARAM p); static void sym_Grammar (RDE_PARAM p); - static void sequence_195 (RDE_PARAM p); + static void sequence_191 (RDE_PARAM p); static void sym_GRAPH (RDE_PARAM p); - static void sequence_201 (RDE_PARAM p); + static void sequence_197 (RDE_PARAM p); static void sym_Header (RDE_PARAM p); + static void choice_202 (RDE_PARAM p); static void choice_206 (RDE_PARAM p); - static void choice_210 (RDE_PARAM p); - static void kleene_212 (RDE_PARAM p); - static void sequence_214 (RDE_PARAM p); + static void kleene_208 (RDE_PARAM p); + static void sequence_210 (RDE_PARAM p); static void sym_Ident (RDE_PARAM p); - static void sequence_219 (RDE_PARAM p); + static void sequence_215 (RDE_PARAM p); static void sym_Identifier (RDE_PARAM p); - static void sequence_224 (RDE_PARAM p); + static void sequence_220 (RDE_PARAM p); static void sym_IS (RDE_PARAM p); - static void sequence_229 (RDE_PARAM p); + static void sequence_225 (RDE_PARAM p); static void sym_LEAF (RDE_PARAM p); - static void notahead_234 (RDE_PARAM p); - static void sequence_237 (RDE_PARAM p); - static void kleene_239 (RDE_PARAM p); - static void sequence_243 (RDE_PARAM p); - static void notahead_247 (RDE_PARAM p); - static void sequence_250 (RDE_PARAM p); - static void kleene_252 (RDE_PARAM p); - static void sequence_256 (RDE_PARAM p); - static void choice_258 (RDE_PARAM p); + static void notahead_230 (RDE_PARAM p); + static void sequence_233 (RDE_PARAM p); + static void kleene_235 (RDE_PARAM p); + static void sequence_239 (RDE_PARAM p); + static void notahead_243 (RDE_PARAM p); + static void sequence_246 (RDE_PARAM p); + static void kleene_248 (RDE_PARAM p); + static void sequence_252 (RDE_PARAM p); + static void choice_254 (RDE_PARAM p); static void sym_Literal (RDE_PARAM p); - static void sequence_263 (RDE_PARAM p); + static void sequence_259 (RDE_PARAM p); static void sym_LOWER (RDE_PARAM p); - static void sequence_268 (RDE_PARAM p); + static void sequence_264 (RDE_PARAM p); static void sym_NOT (RDE_PARAM p); - static void sequence_273 (RDE_PARAM p); + static void sequence_269 (RDE_PARAM p); static void sym_OPEN (RDE_PARAM p); static void sym_OPENB (RDE_PARAM p); - static void sequence_280 (RDE_PARAM p); + static void notahead_278 (RDE_PARAM p); + static void sequence_281 (RDE_PARAM p); static void sym_PEG (RDE_PARAM p); - static void sequence_285 (RDE_PARAM p); + static void sequence_286 (RDE_PARAM p); static void sym_PLUS (RDE_PARAM p); - static void choice_290 (RDE_PARAM p); - static void optional_292 (RDE_PARAM p); - static void sequence_295 (RDE_PARAM p); + static void choice_291 (RDE_PARAM p); + static void optional_293 (RDE_PARAM p); + static void sequence_296 (RDE_PARAM p); static void sym_Prefix (RDE_PARAM p); - static void sequence_316 (RDE_PARAM p); - static void choice_321 (RDE_PARAM p); + static void sequence_317 (RDE_PARAM p); + static void choice_322 (RDE_PARAM p); static void sym_Primary (RDE_PARAM p); - static void sequence_326 (RDE_PARAM p); + static void sequence_327 (RDE_PARAM p); static void sym_PRINTABLE (RDE_PARAM p); - static void sequence_331 (RDE_PARAM p); + static void sequence_332 (RDE_PARAM p); static void sym_PUNCT (RDE_PARAM p); - static void sequence_336 (RDE_PARAM p); + static void sequence_337 (RDE_PARAM p); static void sym_QUESTION (RDE_PARAM p); - static void sequence_342 (RDE_PARAM p); - static void choice_345 (RDE_PARAM p); + static void sequence_343 (RDE_PARAM p); + static void choice_346 (RDE_PARAM p); static void sym_Range (RDE_PARAM p); - static void sequence_350 (RDE_PARAM p); + static void sequence_351 (RDE_PARAM p); static void sym_SEMICOLON (RDE_PARAM p); - static void poskleene_354 (RDE_PARAM p); + static void poskleene_355 (RDE_PARAM p); static void sym_Sequence (RDE_PARAM p); - static void sequence_359 (RDE_PARAM p); + static void sequence_360 (RDE_PARAM p); static void sym_SLASH (RDE_PARAM p); - static void sequence_364 (RDE_PARAM p); + static void sequence_365 (RDE_PARAM p); static void sym_SPACE (RDE_PARAM p); - static void sequence_369 (RDE_PARAM p); + static void sequence_370 (RDE_PARAM p); static void sym_STAR (RDE_PARAM p); static void sym_StartExpr (RDE_PARAM p); - static void choice_381 (RDE_PARAM p); - static void optional_383 (RDE_PARAM p); - static void sequence_385 (RDE_PARAM p); + static void choice_382 (RDE_PARAM p); + static void optional_384 (RDE_PARAM p); + static void sequence_386 (RDE_PARAM p); static void sym_Suffix (RDE_PARAM p); static void sym_TO (RDE_PARAM p); - static void sequence_392 (RDE_PARAM p); + static void sequence_393 (RDE_PARAM p); static void sym_UPPER (RDE_PARAM p); - static void sequence_397 (RDE_PARAM p); + static void sequence_398 (RDE_PARAM p); static void sym_VOID (RDE_PARAM p); - static void choice_402 (RDE_PARAM p); - static void kleene_404 (RDE_PARAM p); + static void choice_403 (RDE_PARAM p); + static void kleene_405 (RDE_PARAM p); static void sym_WHITESPACE (RDE_PARAM p); - static void sequence_409 (RDE_PARAM p); + static void sequence_410 (RDE_PARAM p); static void sym_WORDCHAR (RDE_PARAM p); - static void sequence_414 (RDE_PARAM p); + static void sequence_415 (RDE_PARAM p); static void sym_XDIGIT (RDE_PARAM p); /* * Precomputed table of strings (symbols, error messages, etc.). */ - static char const* p_string [170] = { - /* 0 = */ "str ''", - /* 1 = */ "n ALNUM", - /* 2 = */ "ALNUM", - /* 3 = */ "str ''", - /* 4 = */ "n ALPHA", - /* 5 = */ "ALPHA", - /* 6 = */ "t &", - /* 7 = */ "n AND", - /* 8 = */ "AND", - /* 9 = */ "t '", - /* 10 = */ "n APOSTROPH", - /* 11 = */ "APOSTROPH", - /* 12 = */ "str ''", - /* 13 = */ "n ASCII", - /* 14 = */ "ASCII", - /* 15 = */ "n Attribute", - /* 16 = */ "Attribute", - /* 17 = */ "n Char", - /* 18 = */ "Char", - /* 19 = */ "t \134", - /* 20 = */ ".. 0 2", - /* 21 = */ ".. 0 7", - /* 22 = */ "n CharOctalFull", - /* 23 = */ "CharOctalFull", - /* 24 = */ "n CharOctalPart", - /* 25 = */ "CharOctalPart", - /* 26 = */ "cl 'nrt'\42\133\135\134'", - /* 27 = */ "n CharSpecial", - /* 28 = */ "CharSpecial", - /* 29 = */ "dot", - /* 30 = */ "n CharUnescaped", - /* 31 = */ "CharUnescaped", - /* 32 = */ "str '\134u'", - /* 33 = */ "xdigit", - /* 34 = */ "n CharUnicode", - /* 35 = */ "CharUnicode", - /* 36 = */ "n Class", - /* 37 = */ "Class", - /* 38 = */ "t \51", - /* 39 = */ "n CLOSE", - /* 40 = */ "CLOSE", - /* 41 = */ "t \135", - /* 42 = */ "n CLOSEB", - /* 43 = */ "CLOSEB", - /* 44 = */ "t :", - /* 45 = */ "n COLON", - /* 46 = */ "COLON", - /* 47 = */ "t #", - /* 48 = */ "n COMMENT", - /* 49 = */ "COMMENT", - /* 50 = */ "str ''", - /* 51 = */ "n CONTROL", - /* 52 = */ "CONTROL", - /* 53 = */ "t \42", - /* 54 = */ "n DAPOSTROPH", - /* 55 = */ "DAPOSTROPH", - /* 56 = */ "str ''", - /* 57 = */ "n DDIGIT", - /* 58 = */ "DDIGIT", - /* 59 = */ "n Definition", - /* 60 = */ "Definition", - /* 61 = */ "str ''", - /* 62 = */ "n DIGIT", - /* 63 = */ "DIGIT", - /* 64 = */ "t .", - /* 65 = */ "n DOT", - /* 66 = */ "DOT", - /* 67 = */ "str 'END'", - /* 68 = */ "n END", - /* 69 = */ "END", - /* 70 = */ "n EOF", - /* 71 = */ "EOF", - /* 72 = */ "cl '\n\r'", - /* 73 = */ "n EOL", - /* 74 = */ "EOL", - /* 75 = */ "n Expression", - /* 76 = */ "Expression", - /* 77 = */ "n Final", - /* 78 = */ "Final", - /* 79 = */ "n Grammar", - /* 80 = */ "Grammar", - /* 81 = */ "str ''", - /* 82 = */ "n GRAPH", - /* 83 = */ "GRAPH", - /* 84 = */ "n Header", - /* 85 = */ "Header", - /* 86 = */ "cl '_:'", - /* 87 = */ "alpha", - /* 88 = */ "alnum", - /* 89 = */ "n Ident", - /* 90 = */ "Ident", - /* 91 = */ "n Identifier", - /* 92 = */ "Identifier", - /* 93 = */ "str '<-'", - /* 94 = */ "n IS", - /* 95 = */ "IS", - /* 96 = */ "str 'leaf'", - /* 97 = */ "n LEAF", - /* 98 = */ "LEAF", - /* 99 = */ "n Literal", - /* 100 = */ "Literal", - /* 101 = */ "str ''", - /* 102 = */ "n LOWER", - /* 103 = */ "LOWER", - /* 104 = */ "t !", - /* 105 = */ "n NOT", - /* 106 = */ "NOT", - /* 107 = */ "t \50", - /* 108 = */ "n OPEN", - /* 109 = */ "OPEN", - /* 110 = */ "t \133", - /* 111 = */ "n OPENB", - /* 112 = */ "OPENB", - /* 113 = */ "str 'PEG'", - /* 114 = */ "n PEG", - /* 115 = */ "PEG", - /* 116 = */ "t +", - /* 117 = */ "n PLUS", - /* 118 = */ "PLUS", - /* 119 = */ "n Prefix", - /* 120 = */ "Prefix", - /* 121 = */ "n Primary", - /* 122 = */ "Primary", - /* 123 = */ "str ''", - /* 124 = */ "n PRINTABLE", - /* 125 = */ "PRINTABLE", - /* 126 = */ "str ''", - /* 127 = */ "n PUNCT", - /* 128 = */ "PUNCT", - /* 129 = */ "t ?", - /* 130 = */ "n QUESTION", - /* 131 = */ "QUESTION", - /* 132 = */ "n Range", - /* 133 = */ "Range", - /* 134 = */ "t \73", - /* 135 = */ "n SEMICOLON", - /* 136 = */ "SEMICOLON", - /* 137 = */ "n Sequence", - /* 138 = */ "Sequence", - /* 139 = */ "t /", - /* 140 = */ "n SLASH", - /* 141 = */ "SLASH", - /* 142 = */ "str ''", - /* 143 = */ "n SPACE", - /* 144 = */ "SPACE", - /* 145 = */ "t *", - /* 146 = */ "n STAR", - /* 147 = */ "STAR", - /* 148 = */ "n StartExpr", - /* 149 = */ "StartExpr", - /* 150 = */ "n Suffix", - /* 151 = */ "Suffix", - /* 152 = */ "t -", - /* 153 = */ "n TO", - /* 154 = */ "TO", - /* 155 = */ "str ''", - /* 156 = */ "n UPPER", - /* 157 = */ "UPPER", - /* 158 = */ "str 'void'", - /* 159 = */ "n VOID", - /* 160 = */ "VOID", - /* 161 = */ "space", - /* 162 = */ "n WHITESPACE", - /* 163 = */ "WHITESPACE", - /* 164 = */ "str ''", - /* 165 = */ "n WORDCHAR", - /* 166 = */ "WORDCHAR", - /* 167 = */ "str ''", - /* 168 = */ "n XDIGIT", - /* 169 = */ "XDIGIT" + static char const* p_string [178] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "str ", + /* 15 = */ "n ALNUM", + /* 16 = */ "ALNUM", + /* 17 = */ "str ", + /* 18 = */ "n ALPHA", + /* 19 = */ "ALPHA", + /* 20 = */ "t &", + /* 21 = */ "n AND", + /* 22 = */ "AND", + /* 23 = */ "t '", + /* 24 = */ "n APOSTROPH", + /* 25 = */ "APOSTROPH", + /* 26 = */ "str ", + /* 27 = */ "n ASCII", + /* 28 = */ "ASCII", + /* 29 = */ "n Attribute", + /* 30 = */ "Attribute", + /* 31 = */ "n Char", + /* 32 = */ "Char", + /* 33 = */ "t \\\\", + /* 34 = */ ".. 0 2", + /* 35 = */ ".. 0 7", + /* 36 = */ "n CharOctalFull", + /* 37 = */ "CharOctalFull", + /* 38 = */ "n CharOctalPart", + /* 39 = */ "CharOctalPart", + /* 40 = */ "cl nrt'\\\"\\[\\]\\\\", + /* 41 = */ "n CharSpecial", + /* 42 = */ "CharSpecial", + /* 43 = */ "dot", + /* 44 = */ "n CharUnescaped", + /* 45 = */ "CharUnescaped", + /* 46 = */ "str \173\\u\175", + /* 47 = */ "n CharUnicode", + /* 48 = */ "CharUnicode", + /* 49 = */ "n Class", + /* 50 = */ "Class", + /* 51 = */ "t )", + /* 52 = */ "n CLOSE", + /* 53 = */ "CLOSE", + /* 54 = */ "t \\]", + /* 55 = */ "n CLOSEB", + /* 56 = */ "CLOSEB", + /* 57 = */ "t :", + /* 58 = */ "n COLON", + /* 59 = */ "COLON", + /* 60 = */ "t #", + /* 61 = */ "n COMMENT", + /* 62 = */ "COMMENT", + /* 63 = */ "str ", + /* 64 = */ "n CONTROL", + /* 65 = */ "CONTROL", + /* 66 = */ "t \173\"\175", + /* 67 = */ "n DAPOSTROPH", + /* 68 = */ "DAPOSTROPH", + /* 69 = */ "str ", + /* 70 = */ "n DDIGIT", + /* 71 = */ "DDIGIT", + /* 72 = */ "n Definition", + /* 73 = */ "Definition", + /* 74 = */ "str ", + /* 75 = */ "n DIGIT", + /* 76 = */ "DIGIT", + /* 77 = */ "t .", + /* 78 = */ "n DOT", + /* 79 = */ "DOT", + /* 80 = */ "n EOF", + /* 81 = */ "EOF", + /* 82 = */ "cl \173\n\r\175", + /* 83 = */ "n EOL", + /* 84 = */ "EOL", + /* 85 = */ "n Expression", + /* 86 = */ "Expression", + /* 87 = */ "str END", + /* 88 = */ "n Final", + /* 89 = */ "Final", + /* 90 = */ "n Grammar", + /* 91 = */ "Grammar", + /* 92 = */ "str ", + /* 93 = */ "n GRAPH", + /* 94 = */ "GRAPH", + /* 95 = */ "n Header", + /* 96 = */ "Header", + /* 97 = */ "cl _:", + /* 98 = */ "n Ident", + /* 99 = */ "Ident", + /* 100 = */ "n Identifier", + /* 101 = */ "Identifier", + /* 102 = */ "str <-", + /* 103 = */ "n IS", + /* 104 = */ "IS", + /* 105 = */ "str leaf", + /* 106 = */ "n LEAF", + /* 107 = */ "LEAF", + /* 108 = */ "n Literal", + /* 109 = */ "Literal", + /* 110 = */ "str ", + /* 111 = */ "n LOWER", + /* 112 = */ "LOWER", + /* 113 = */ "t !", + /* 114 = */ "n NOT", + /* 115 = */ "NOT", + /* 116 = */ "t (", + /* 117 = */ "n OPEN", + /* 118 = */ "OPEN", + /* 119 = */ "t \173[\175", + /* 120 = */ "n OPENB", + /* 121 = */ "OPENB", + /* 122 = */ "str PEG", + /* 123 = */ "n PEG", + /* 124 = */ "PEG", + /* 125 = */ "t +", + /* 126 = */ "n PLUS", + /* 127 = */ "PLUS", + /* 128 = */ "n Prefix", + /* 129 = */ "Prefix", + /* 130 = */ "n Primary", + /* 131 = */ "Primary", + /* 132 = */ "str ", + /* 133 = */ "n PRINTABLE", + /* 134 = */ "PRINTABLE", + /* 135 = */ "str ", + /* 136 = */ "n PUNCT", + /* 137 = */ "PUNCT", + /* 138 = */ "t ?", + /* 139 = */ "n QUESTION", + /* 140 = */ "QUESTION", + /* 141 = */ "n Range", + /* 142 = */ "Range", + /* 143 = */ "t \173;\175", + /* 144 = */ "n SEMICOLON", + /* 145 = */ "SEMICOLON", + /* 146 = */ "n Sequence", + /* 147 = */ "Sequence", + /* 148 = */ "t /", + /* 149 = */ "n SLASH", + /* 150 = */ "SLASH", + /* 151 = */ "str ", + /* 152 = */ "n SPACE", + /* 153 = */ "SPACE", + /* 154 = */ "t *", + /* 155 = */ "n STAR", + /* 156 = */ "STAR", + /* 157 = */ "n StartExpr", + /* 158 = */ "StartExpr", + /* 159 = */ "n Suffix", + /* 160 = */ "Suffix", + /* 161 = */ "t -", + /* 162 = */ "n TO", + /* 163 = */ "TO", + /* 164 = */ "str ", + /* 165 = */ "n UPPER", + /* 166 = */ "UPPER", + /* 167 = */ "str void", + /* 168 = */ "n VOID", + /* 169 = */ "VOID", + /* 170 = */ "n WHITESPACE", + /* 171 = */ "WHITESPACE", + /* 172 = */ "str ", + /* 173 = */ "n WORDCHAR", + /* 174 = */ "WORDCHAR", + /* 175 = */ "str ", + /* 176 = */ "n XDIGIT", + /* 177 = */ "XDIGIT" }; /* * Grammar Start Expression */ @@ -2032,13 +2070,13 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 2)) return ; + if (rde_param_i_symbol_start (p, 16)) return ; sequence_4 (p); - rde_param_i_symbol_done_leaf (p, 2, 1); + rde_param_i_symbol_done_leaf (p, 16, 15); return; } static void sequence_4 (RDE_PARAM p) { /* @@ -2046,11 +2084,11 @@ * "" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "", 0); + rde_param_i_next_str (p, "", 14); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -2064,13 +2102,13 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 5)) return ; + if (rde_param_i_symbol_start (p, 19)) return ; sequence_9 (p); - rde_param_i_symbol_done_leaf (p, 5, 4); + rde_param_i_symbol_done_leaf (p, 19, 18); return; } static void sequence_9 (RDE_PARAM p) { /* @@ -2078,11 +2116,11 @@ * "" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "", 3); + rde_param_i_next_str (p, "", 17); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -2096,13 +2134,13 @@ * x * '&' * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 8)) return ; + if (rde_param_i_symbol_start (p, 22)) return ; sequence_14 (p); - rde_param_i_symbol_done_leaf (p, 8, 7); + rde_param_i_symbol_done_leaf (p, 22, 21); return; } static void sequence_14 (RDE_PARAM p) { /* @@ -2110,11 +2148,11 @@ * '&' * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_char (p, "&", 6); + rde_param_i_next_char (p, "&", 20); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -2126,13 +2164,13 @@ static void sym_APOSTROPH (RDE_PARAM p) { /* * ''' */ - if (rde_param_i_symbol_void_start (p, 11)) return ; - rde_param_i_next_char (p, "'", 9); - rde_param_i_symbol_done_void (p, 11, 10); + if (rde_param_i_symbol_void_start (p, 25)) return ; + rde_param_i_next_char (p, "'", 23); + rde_param_i_symbol_done_void (p, 25, 24); return; } /* * leaf Symbol 'ASCII' @@ -2143,13 +2181,13 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 14)) return ; + if (rde_param_i_symbol_start (p, 28)) return ; sequence_21 (p); - rde_param_i_symbol_done_leaf (p, 14, 13); + rde_param_i_symbol_done_leaf (p, 28, 27); return; } static void sequence_21 (RDE_PARAM p) { /* @@ -2157,11 +2195,11 @@ * "" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "", 12); + rde_param_i_next_str (p, "", 26); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -2177,13 +2215,13 @@ * (VOID) * (LEAF) * (COLON) */ - if (rde_param_i_symbol_start_d (p, 16)) return ; + if (rde_param_i_symbol_start_d (p, 30)) return ; sequence_29 (p); - rde_param_i_symbol_done_d_reduce (p, 16, 15); + rde_param_i_symbol_done_d_reduce (p, 30, 29); return; } static void sequence_29 (RDE_PARAM p) { /* @@ -2229,13 +2267,13 @@ * (CharOctalPart) * (CharUnicode) * (CharUnescaped) */ - if (rde_param_i_symbol_start_d (p, 18)) return ; + if (rde_param_i_symbol_start_d (p, 32)) return ; choice_37 (p); - rde_param_i_symbol_done_d_reduce (p, 18, 17); + rde_param_i_symbol_done_d_reduce (p, 32, 31); return; } static void choice_37 (RDE_PARAM p) { /* @@ -2272,13 +2310,13 @@ * range (0 .. 2) * range (0 .. 7) * range (0 .. 7) */ - if (rde_param_i_symbol_start (p, 23)) return ; + if (rde_param_i_symbol_start (p, 37)) return ; sequence_44 (p); - rde_param_i_symbol_done_leaf (p, 23, 22); + rde_param_i_symbol_done_leaf (p, 37, 36); return; } static void sequence_44 (RDE_PARAM p) { /* @@ -2288,17 +2326,17 @@ * range (0 .. 7) * range (0 .. 7) */ rde_param_i_state_push_void (p); - rde_param_i_next_char (p, "\134", 19); + rde_param_i_next_char (p, "\\", 33); + if (rde_param_i_seq_void2void(p)) return; + rde_param_i_next_range (p, "0", "2", 34); if (rde_param_i_seq_void2void(p)) return; - rde_param_i_next_range (p, "0", "2", 20); + rde_param_i_next_range (p, "0", "7", 35); if (rde_param_i_seq_void2void(p)) return; - rde_param_i_next_range (p, "0", "7", 21); - if (rde_param_i_seq_void2void(p)) return; - rde_param_i_next_range (p, "0", "7", 21); + rde_param_i_next_range (p, "0", "7", 35); rde_param_i_state_merge_void (p); return; } /* @@ -2312,13 +2350,13 @@ * range (0 .. 7) * ? * range (0 .. 7) */ - if (rde_param_i_symbol_start (p, 25)) return ; + if (rde_param_i_symbol_start (p, 39)) return ; sequence_52 (p); - rde_param_i_symbol_done_leaf (p, 25, 24); + rde_param_i_symbol_done_leaf (p, 39, 38); return; } static void sequence_52 (RDE_PARAM p) { /* @@ -2328,13 +2366,13 @@ * ? * range (0 .. 7) */ rde_param_i_state_push_void (p); - rde_param_i_next_char (p, "\134", 19); + rde_param_i_next_char (p, "\\", 33); if (rde_param_i_seq_void2void(p)) return; - rde_param_i_next_range (p, "0", "7", 21); + rde_param_i_next_range (p, "0", "7", 35); if (rde_param_i_seq_void2void(p)) return; optional_50 (p); rde_param_i_state_merge_void (p); return; } @@ -2344,11 +2382,11 @@ * ? * range (0 .. 7) */ rde_param_i_state_push_2 (p); - rde_param_i_next_range (p, "0", "7", 21); + rde_param_i_next_range (p, "0", "7", 35); rde_param_i_state_merge_ok (p); return; } /* @@ -2357,30 +2395,30 @@ static void sym_CharSpecial (RDE_PARAM p) { /* * x * '\' - * [nrt'"[]\] + * [nrt'\"[]\] */ - if (rde_param_i_symbol_start (p, 28)) return ; + if (rde_param_i_symbol_start (p, 42)) return ; sequence_57 (p); - rde_param_i_symbol_done_leaf (p, 28, 27); + rde_param_i_symbol_done_leaf (p, 42, 41); return; } static void sequence_57 (RDE_PARAM p) { /* * x * '\' - * [nrt'"[]\] + * [nrt'\"[]\] */ rde_param_i_state_push_void (p); - rde_param_i_next_char (p, "\134", 19); + rde_param_i_next_char (p, "\\", 33); if (rde_param_i_seq_void2void(p)) return; - rde_param_i_next_class (p, "nrt'\42\133\135\134", 26); + rde_param_i_next_class (p, "nrt'\"[]\\", 40); rde_param_i_state_merge_void (p); return; } /* @@ -2393,13 +2431,13 @@ * ! * '\' * */ - if (rde_param_i_symbol_start (p, 31)) return ; + if (rde_param_i_symbol_start (p, 45)) return ; sequence_64 (p); - rde_param_i_symbol_done_leaf (p, 31, 30); + rde_param_i_symbol_done_leaf (p, 45, 44); return; } static void sequence_64 (RDE_PARAM p) { /* @@ -2410,11 +2448,11 @@ */ rde_param_i_state_push_void (p); notahead_61 (p); if (rde_param_i_seq_void2void(p)) return; - rde_param_i_input_next (p, 29); + rde_param_i_input_next (p, 43); rde_param_i_state_merge_void (p); return; } static void notahead_61 (RDE_PARAM p) { @@ -2422,11 +2460,11 @@ * ! * '\' */ rde_param_i_loc_push (p); - rde_param_i_next_char (p, "\134", 19); + rde_param_i_next_char (p, "\\", 33); rde_param_i_notahead_exit (p); return; } /* @@ -2446,13 +2484,13 @@ * * ? * */ - if (rde_param_i_symbol_start (p, 35)) return ; + if (rde_param_i_symbol_start (p, 48)) return ; sequence_82 (p); - rde_param_i_symbol_done_leaf (p, 35, 34); + rde_param_i_symbol_done_leaf (p, 48, 47); return; } static void sequence_82 (RDE_PARAM p) { /* @@ -2468,13 +2506,13 @@ * ? * */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "\134u", 32); + rde_param_i_next_str (p, "\\u", 46); if (rde_param_i_seq_void2void(p)) return; - rde_param_i_next_xdigit (p, 33); + rde_param_i_next_xdigit (p, 13); if (rde_param_i_seq_void2void(p)) return; optional_80 (p); rde_param_i_state_merge_void (p); return; } @@ -2507,11 +2545,11 @@ * ? * */ rde_param_i_state_push_void (p); - rde_param_i_next_xdigit (p, 33); + rde_param_i_next_xdigit (p, 13); if (rde_param_i_seq_void2void(p)) return; optional_76 (p); rde_param_i_state_merge_void (p); return; } @@ -2538,11 +2576,11 @@ * ? * */ rde_param_i_state_push_void (p); - rde_param_i_next_xdigit (p, 33); + rde_param_i_next_xdigit (p, 13); if (rde_param_i_seq_void2void(p)) return; optional_72 (p); rde_param_i_state_merge_void (p); return; } @@ -2552,11 +2590,11 @@ * ? * */ rde_param_i_state_push_2 (p); - rde_param_i_next_xdigit (p, 33); + rde_param_i_next_xdigit (p, 13); rde_param_i_state_merge_ok (p); return; } /* @@ -2574,13 +2612,13 @@ * (Range) * (CLOSEB) * (WHITESPACE) */ - if (rde_param_i_symbol_start_d (p, 37)) return ; + if (rde_param_i_symbol_start_d (p, 50)) return ; sequence_96 (p); - rde_param_i_symbol_done_d_reduce (p, 37, 36); + rde_param_i_symbol_done_d_reduce (p, 50, 49); return; } static void sequence_96 (RDE_PARAM p) { /* @@ -2661,13 +2699,13 @@ * x * '\)' * (WHITESPACE) */ - if (rde_param_i_symbol_void_start (p, 40)) return ; + if (rde_param_i_symbol_void_start (p, 53)) return ; sequence_101 (p); - rde_param_i_symbol_done_void (p, 40, 39); + rde_param_i_symbol_done_void (p, 53, 52); return; } static void sequence_101 (RDE_PARAM p) { /* @@ -2675,11 +2713,11 @@ * '\)' * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_char (p, "\51", 38); + rde_param_i_next_char (p, ")", 51); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -2691,13 +2729,13 @@ static void sym_CLOSEB (RDE_PARAM p) { /* * ']' */ - if (rde_param_i_symbol_void_start (p, 43)) return ; - rde_param_i_next_char (p, "\135", 41); - rde_param_i_symbol_done_void (p, 43, 42); + if (rde_param_i_symbol_void_start (p, 56)) return ; + rde_param_i_next_char (p, "]", 54); + rde_param_i_symbol_done_void (p, 56, 55); return; } /* * void Symbol 'COLON' @@ -2708,13 +2746,13 @@ * x * ':' * (WHITESPACE) */ - if (rde_param_i_symbol_void_start (p, 46)) return ; + if (rde_param_i_symbol_void_start (p, 59)) return ; sequence_108 (p); - rde_param_i_symbol_done_void (p, 46, 45); + rde_param_i_symbol_done_void (p, 59, 58); return; } static void sequence_108 (RDE_PARAM p) { /* @@ -2722,11 +2760,11 @@ * ':' * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_char (p, ":", 44); + rde_param_i_next_char (p, ":", 57); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -2745,13 +2783,13 @@ * (EOL) * * (EOL) */ - if (rde_param_i_symbol_void_start (p, 49)) return ; + if (rde_param_i_symbol_void_start (p, 62)) return ; sequence_121 (p); - rde_param_i_symbol_done_void (p, 49, 48); + rde_param_i_symbol_done_void (p, 62, 61); return; } static void sequence_121 (RDE_PARAM p) { /* @@ -2764,11 +2802,11 @@ * * (EOL) */ rde_param_i_state_push_void (p); - rde_param_i_next_char (p, "#", 47); + rde_param_i_next_char (p, "#", 60); if (rde_param_i_seq_void2void(p)) return; kleene_118 (p); if (rde_param_i_seq_void2void(p)) return; sym_EOL (p); rde_param_i_state_merge_void (p); @@ -2801,11 +2839,11 @@ */ rde_param_i_state_push_void (p); notahead_113 (p); if (rde_param_i_seq_void2void(p)) return; - rde_param_i_input_next (p, 29); + rde_param_i_input_next (p, 43); rde_param_i_state_merge_void (p); return; } static void notahead_113 (RDE_PARAM p) { @@ -2829,13 +2867,13 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 52)) return ; + if (rde_param_i_symbol_start (p, 65)) return ; sequence_126 (p); - rde_param_i_symbol_done_leaf (p, 52, 51); + rde_param_i_symbol_done_leaf (p, 65, 64); return; } static void sequence_126 (RDE_PARAM p) { /* @@ -2843,11 +2881,11 @@ * "" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "", 50); + rde_param_i_next_str (p, "", 63); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -2859,13 +2897,13 @@ static void sym_DAPOSTROPH (RDE_PARAM p) { /* * '\"' */ - if (rde_param_i_symbol_void_start (p, 55)) return ; - rde_param_i_next_char (p, "\42", 53); - rde_param_i_symbol_done_void (p, 55, 54); + if (rde_param_i_symbol_void_start (p, 68)) return ; + rde_param_i_next_char (p, "\"", 66); + rde_param_i_symbol_done_void (p, 68, 67); return; } /* * leaf Symbol 'DDIGIT' @@ -2876,13 +2914,13 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 58)) return ; + if (rde_param_i_symbol_start (p, 71)) return ; sequence_133 (p); - rde_param_i_symbol_done_leaf (p, 58, 57); + rde_param_i_symbol_done_leaf (p, 71, 70); return; } static void sequence_133 (RDE_PARAM p) { /* @@ -2890,11 +2928,11 @@ * "" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "", 56); + rde_param_i_next_str (p, "", 69); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -2912,13 +2950,13 @@ * (IS) * (Expression) * (SEMICOLON) */ - if (rde_param_i_symbol_start_d (p, 60)) return ; + if (rde_param_i_symbol_start_d (p, 73)) return ; sequence_143 (p); - rde_param_i_symbol_done_d_reduce (p, 60, 59); + rde_param_i_symbol_done_d_reduce (p, 73, 72); return; } static void sequence_143 (RDE_PARAM p) { /* @@ -2966,13 +3004,13 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 63)) return ; + if (rde_param_i_symbol_start (p, 76)) return ; sequence_148 (p); - rde_param_i_symbol_done_leaf (p, 63, 62); + rde_param_i_symbol_done_leaf (p, 76, 75); return; } static void sequence_148 (RDE_PARAM p) { /* @@ -2980,11 +3018,11 @@ * "" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "", 61); + rde_param_i_next_str (p, "", 74); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -2998,13 +3036,13 @@ * x * '.' * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 66)) return ; + if (rde_param_i_symbol_start (p, 79)) return ; sequence_153 (p); - rde_param_i_symbol_done_leaf (p, 66, 65); + rde_param_i_symbol_done_leaf (p, 79, 78); return; } static void sequence_153 (RDE_PARAM p) { /* @@ -3012,43 +3050,11 @@ * '.' * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_char (p, ".", 64); - if (rde_param_i_seq_void2void(p)) return; - sym_WHITESPACE (p); - rde_param_i_state_merge_void (p); - return; - } - - /* - * void Symbol 'END' - */ - - static void sym_END (RDE_PARAM p) { - /* - * x - * "END" - * (WHITESPACE) - */ - - if (rde_param_i_symbol_void_start (p, 69)) return ; - sequence_158 (p); - rde_param_i_symbol_done_void (p, 69, 68); - return; - } - - static void sequence_158 (RDE_PARAM p) { - /* - * x - * "END" - * (WHITESPACE) - */ - - rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "END", 67); + rde_param_i_next_char (p, ".", 77); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -3061,24 +3067,24 @@ /* * ! * */ - if (rde_param_i_symbol_void_start (p, 71)) return ; - notahead_162 (p); - rde_param_i_symbol_done_void (p, 71, 70); + if (rde_param_i_symbol_void_start (p, 81)) return ; + notahead_157 (p); + rde_param_i_symbol_done_void (p, 81, 80); return; } - static void notahead_162 (RDE_PARAM p) { + static void notahead_157 (RDE_PARAM p) { /* * ! * */ rde_param_i_loc_push (p); - rde_param_i_input_next (p, 29); + rde_param_i_input_next (p, 43); rde_param_i_notahead_exit (p); return; } /* @@ -3085,17 +3091,16 @@ * void Symbol 'EOL' */ static void sym_EOL (RDE_PARAM p) { /* - * [ - * ] + * [\n\r] */ - if (rde_param_i_symbol_void_start (p, 74)) return ; - rde_param_i_next_class (p, "\n\r", 72); - rde_param_i_symbol_done_void (p, 74, 73); + if (rde_param_i_symbol_void_start (p, 84)) return ; + rde_param_i_next_class (p, "\n\r", 82); + rde_param_i_symbol_done_void (p, 84, 83); return; } /* * value Symbol 'Expression' @@ -3109,17 +3114,17 @@ * x * (SLASH) * (Sequence) */ - if (rde_param_i_symbol_start_d (p, 76)) return ; - sequence_174 (p); - rde_param_i_symbol_done_d_reduce (p, 76, 75); + if (rde_param_i_symbol_start_d (p, 86)) return ; + sequence_169 (p); + rde_param_i_symbol_done_d_reduce (p, 86, 85); return; } - static void sequence_174 (RDE_PARAM p) { + static void sequence_169 (RDE_PARAM p) { /* * x * (Sequence) * * * x @@ -3128,32 +3133,32 @@ */ rde_param_i_state_push_value (p); sym_Sequence (p); if (rde_param_i_seq_value2value(p)) return; - kleene_172 (p); + kleene_167 (p); rde_param_i_state_merge_value (p); return; } - static void kleene_172 (RDE_PARAM p) { + static void kleene_167 (RDE_PARAM p) { /* * * * x * (SLASH) * (Sequence) */ while (1) { rde_param_i_state_push_2 (p); - sequence_170 (p); + sequence_165 (p); if (rde_param_i_kleene_close(p)) return; } return; } - static void sequence_170 (RDE_PARAM p) { + static void sequence_165 (RDE_PARAM p) { /* * x * (SLASH) * (Sequence) */ @@ -3171,31 +3176,35 @@ */ static void sym_Final (RDE_PARAM p) { /* * x - * (END) + * "END" + * (WHITESPACE) * (SEMICOLON) * (WHITESPACE) */ - if (rde_param_i_symbol_void_start (p, 78)) return ; - sequence_180 (p); - rde_param_i_symbol_done_void (p, 78, 77); + if (rde_param_i_symbol_void_start (p, 89)) return ; + sequence_176 (p); + rde_param_i_symbol_done_void (p, 89, 88); return; } - static void sequence_180 (RDE_PARAM p) { + static void sequence_176 (RDE_PARAM p) { /* * x - * (END) + * "END" + * (WHITESPACE) * (SEMICOLON) * (WHITESPACE) */ rde_param_i_state_push_void (p); - sym_END (p); + rde_param_i_next_str (p, "END", 87); + if (rde_param_i_seq_void2void(p)) return; + sym_WHITESPACE (p); if (rde_param_i_seq_void2void(p)) return; sym_SEMICOLON (p); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); @@ -3215,17 +3224,17 @@ * (Definition) * (Final) * (EOF) */ - if (rde_param_i_symbol_start_d (p, 80)) return ; - sequence_190 (p); - rde_param_i_symbol_done_d_reduce (p, 80, 79); + if (rde_param_i_symbol_start_d (p, 91)) return ; + sequence_186 (p); + rde_param_i_symbol_done_d_reduce (p, 91, 90); return; } - static void sequence_190 (RDE_PARAM p) { + static void sequence_186 (RDE_PARAM p) { /* * x * (WHITESPACE) * (Header) * * @@ -3237,20 +3246,20 @@ rde_param_i_state_push_void (p); sym_WHITESPACE (p); if (rde_param_i_seq_void2value(p)) return; sym_Header (p); if (rde_param_i_seq_value2value(p)) return; - kleene_186 (p); + kleene_182 (p); if (rde_param_i_seq_value2value(p)) return; sym_Final (p); if (rde_param_i_seq_value2value(p)) return; sym_EOF (p); rde_param_i_state_merge_value (p); return; } - static void kleene_186 (RDE_PARAM p) { + static void kleene_182 (RDE_PARAM p) { /* * * * (Definition) */ @@ -3271,25 +3280,25 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 83)) return ; - sequence_195 (p); - rde_param_i_symbol_done_leaf (p, 83, 82); + if (rde_param_i_symbol_start (p, 94)) return ; + sequence_191 (p); + rde_param_i_symbol_done_leaf (p, 94, 93); return; } - static void sequence_195 (RDE_PARAM p) { + static void sequence_191 (RDE_PARAM p) { /* * x * "" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "", 81); + rde_param_i_next_str (p, "", 92); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -3304,17 +3313,17 @@ * (PEG) * (Identifier) * (StartExpr) */ - if (rde_param_i_symbol_start_d (p, 85)) return ; - sequence_201 (p); - rde_param_i_symbol_done_d_reduce (p, 85, 84); + if (rde_param_i_symbol_start_d (p, 96)) return ; + sequence_197 (p); + rde_param_i_symbol_done_d_reduce (p, 96, 95); return; } - static void sequence_201 (RDE_PARAM p) { + static void sequence_197 (RDE_PARAM p) { /* * x * (PEG) * (Identifier) * (StartExpr) @@ -3344,17 +3353,17 @@ * / * [_:] * */ - if (rde_param_i_symbol_start (p, 90)) return ; - sequence_214 (p); - rde_param_i_symbol_done_leaf (p, 90, 89); + if (rde_param_i_symbol_start (p, 99)) return ; + sequence_210 (p); + rde_param_i_symbol_done_leaf (p, 99, 98); return; } - static void sequence_214 (RDE_PARAM p) { + static void sequence_210 (RDE_PARAM p) { /* * x * / * [_:] * @@ -3363,59 +3372,59 @@ * [_:] * */ rde_param_i_state_push_void (p); - choice_206 (p); + choice_202 (p); if (rde_param_i_seq_void2void(p)) return; - kleene_212 (p); + kleene_208 (p); rde_param_i_state_merge_void (p); return; } - static void choice_206 (RDE_PARAM p) { + static void choice_202 (RDE_PARAM p) { /* * / * [_:] * */ rde_param_i_state_push_void (p); - rde_param_i_next_class (p, "_:", 86); + rde_param_i_next_class (p, "_:", 97); if (rde_param_i_bra_void2void(p)) return; - rde_param_i_next_alpha (p, 87); + rde_param_i_next_alpha (p, 1); rde_param_i_state_merge_void (p); return; } - static void kleene_212 (RDE_PARAM p) { + static void kleene_208 (RDE_PARAM p) { /* * * * / * [_:] * */ while (1) { rde_param_i_state_push_2 (p); - choice_210 (p); + choice_206 (p); if (rde_param_i_kleene_close(p)) return; } return; } - static void choice_210 (RDE_PARAM p) { + static void choice_206 (RDE_PARAM p) { /* * / * [_:] * */ rde_param_i_state_push_void (p); - rde_param_i_next_class (p, "_:", 86); + rde_param_i_next_class (p, "_:", 97); if (rde_param_i_bra_void2void(p)) return; - rde_param_i_next_alnum (p, 88); + rde_param_i_next_alnum (p, 0); rde_param_i_state_merge_void (p); return; } /* @@ -3427,17 +3436,17 @@ * x * (Ident) * (WHITESPACE) */ - if (rde_param_i_symbol_start_d (p, 92)) return ; - sequence_219 (p); - rde_param_i_symbol_done_d_reduce (p, 92, 91); + if (rde_param_i_symbol_start_d (p, 101)) return ; + sequence_215 (p); + rde_param_i_symbol_done_d_reduce (p, 101, 100); return; } - static void sequence_219 (RDE_PARAM p) { + static void sequence_215 (RDE_PARAM p) { /* * x * (Ident) * (WHITESPACE) */ @@ -3459,25 +3468,25 @@ * x * "<-" * (WHITESPACE) */ - if (rde_param_i_symbol_void_start (p, 95)) return ; - sequence_224 (p); - rde_param_i_symbol_done_void (p, 95, 94); + if (rde_param_i_symbol_void_start (p, 104)) return ; + sequence_220 (p); + rde_param_i_symbol_done_void (p, 104, 103); return; } - static void sequence_224 (RDE_PARAM p) { + static void sequence_220 (RDE_PARAM p) { /* * x * "<-" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "<-", 93); + rde_param_i_next_str (p, "<-", 102); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -3491,25 +3500,25 @@ * x * "leaf" * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 98)) return ; - sequence_229 (p); - rde_param_i_symbol_done_leaf (p, 98, 97); + if (rde_param_i_symbol_start (p, 107)) return ; + sequence_225 (p); + rde_param_i_symbol_done_leaf (p, 107, 106); return; } - static void sequence_229 (RDE_PARAM p) { + static void sequence_225 (RDE_PARAM p) { /* * x * "leaf" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "leaf", 96); + rde_param_i_next_str (p, "leaf", 105); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -3539,17 +3548,17 @@ * (Char) * (DAPOSTROPH) * (WHITESPACE) */ - if (rde_param_i_symbol_start_d (p, 100)) return ; - choice_258 (p); - rde_param_i_symbol_done_d_reduce (p, 100, 99); + if (rde_param_i_symbol_start_d (p, 109)) return ; + choice_254 (p); + rde_param_i_symbol_done_d_reduce (p, 109, 108); return; } - static void choice_258 (RDE_PARAM p) { + static void choice_254 (RDE_PARAM p) { /* * / * x * (APOSTROPH) * * @@ -3569,18 +3578,18 @@ * (DAPOSTROPH) * (WHITESPACE) */ rde_param_i_state_push_value (p); - sequence_243 (p); + sequence_239 (p); if (rde_param_i_bra_value2value(p)) return; - sequence_256 (p); + sequence_252 (p); rde_param_i_state_merge_value (p); return; } - static void sequence_243 (RDE_PARAM p) { + static void sequence_239 (RDE_PARAM p) { /* * x * (APOSTROPH) * * * x @@ -3592,20 +3601,20 @@ */ rde_param_i_state_push_void (p); sym_APOSTROPH (p); if (rde_param_i_seq_void2value(p)) return; - kleene_239 (p); + kleene_235 (p); if (rde_param_i_seq_value2value(p)) return; sym_APOSTROPH (p); if (rde_param_i_seq_value2value(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_value (p); return; } - static void kleene_239 (RDE_PARAM p) { + static void kleene_235 (RDE_PARAM p) { /* * * * x * ! * (APOSTROPH) @@ -3612,33 +3621,33 @@ * (Char) */ while (1) { rde_param_i_state_push_2 (p); - sequence_237 (p); + sequence_233 (p); if (rde_param_i_kleene_close(p)) return; } return; } - static void sequence_237 (RDE_PARAM p) { + static void sequence_233 (RDE_PARAM p) { /* * x * ! * (APOSTROPH) * (Char) */ rde_param_i_state_push_void (p); - notahead_234 (p); + notahead_230 (p); if (rde_param_i_seq_void2value(p)) return; sym_Char (p); rde_param_i_state_merge_value (p); return; } - static void notahead_234 (RDE_PARAM p) { + static void notahead_230 (RDE_PARAM p) { /* * ! * (APOSTROPH) */ @@ -3646,11 +3655,11 @@ sym_APOSTROPH (p); rde_param_i_notahead_exit (p); return; } - static void sequence_256 (RDE_PARAM p) { + static void sequence_252 (RDE_PARAM p) { /* * x * (DAPOSTROPH) * * * x @@ -3662,20 +3671,20 @@ */ rde_param_i_state_push_void (p); sym_DAPOSTROPH (p); if (rde_param_i_seq_void2value(p)) return; - kleene_252 (p); + kleene_248 (p); if (rde_param_i_seq_value2value(p)) return; sym_DAPOSTROPH (p); if (rde_param_i_seq_value2value(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_value (p); return; } - static void kleene_252 (RDE_PARAM p) { + static void kleene_248 (RDE_PARAM p) { /* * * * x * ! * (DAPOSTROPH) @@ -3682,33 +3691,33 @@ * (Char) */ while (1) { rde_param_i_state_push_2 (p); - sequence_250 (p); + sequence_246 (p); if (rde_param_i_kleene_close(p)) return; } return; } - static void sequence_250 (RDE_PARAM p) { + static void sequence_246 (RDE_PARAM p) { /* * x * ! * (DAPOSTROPH) * (Char) */ rde_param_i_state_push_void (p); - notahead_247 (p); + notahead_243 (p); if (rde_param_i_seq_void2value(p)) return; sym_Char (p); rde_param_i_state_merge_value (p); return; } - static void notahead_247 (RDE_PARAM p) { + static void notahead_243 (RDE_PARAM p) { /* * ! * (DAPOSTROPH) */ @@ -3727,25 +3736,25 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 103)) return ; - sequence_263 (p); - rde_param_i_symbol_done_leaf (p, 103, 102); + if (rde_param_i_symbol_start (p, 112)) return ; + sequence_259 (p); + rde_param_i_symbol_done_leaf (p, 112, 111); return; } - static void sequence_263 (RDE_PARAM p) { + static void sequence_259 (RDE_PARAM p) { /* * x * "" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "", 101); + rde_param_i_next_str (p, "", 110); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -3759,25 +3768,25 @@ * x * '!' * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 106)) return ; - sequence_268 (p); - rde_param_i_symbol_done_leaf (p, 106, 105); + if (rde_param_i_symbol_start (p, 115)) return ; + sequence_264 (p); + rde_param_i_symbol_done_leaf (p, 115, 114); return; } - static void sequence_268 (RDE_PARAM p) { + static void sequence_264 (RDE_PARAM p) { /* * x * '!' * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_char (p, "!", 104); + rde_param_i_next_char (p, "!", 113); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -3791,25 +3800,25 @@ * x * '\(' * (WHITESPACE) */ - if (rde_param_i_symbol_void_start (p, 109)) return ; - sequence_273 (p); - rde_param_i_symbol_done_void (p, 109, 108); + if (rde_param_i_symbol_void_start (p, 118)) return ; + sequence_269 (p); + rde_param_i_symbol_done_void (p, 118, 117); return; } - static void sequence_273 (RDE_PARAM p) { + static void sequence_269 (RDE_PARAM p) { /* * x * '\(' * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_char (p, "\50", 107); + rde_param_i_next_char (p, "(", 116); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -3821,13 +3830,13 @@ static void sym_OPENB (RDE_PARAM p) { /* * '[' */ - if (rde_param_i_symbol_void_start (p, 112)) return ; - rde_param_i_next_char (p, "\133", 110); - rde_param_i_symbol_done_void (p, 112, 111); + if (rde_param_i_symbol_void_start (p, 121)) return ; + rde_param_i_next_char (p, "[", 119); + rde_param_i_symbol_done_void (p, 121, 120); return; } /* * void Symbol 'PEG' @@ -3835,33 +3844,57 @@ static void sym_PEG (RDE_PARAM p) { /* * x * "PEG" + * ! + * / + * [_:] + * * (WHITESPACE) */ - if (rde_param_i_symbol_void_start (p, 115)) return ; - sequence_280 (p); - rde_param_i_symbol_done_void (p, 115, 114); + if (rde_param_i_symbol_void_start (p, 124)) return ; + sequence_281 (p); + rde_param_i_symbol_done_void (p, 124, 123); return; } - static void sequence_280 (RDE_PARAM p) { + static void sequence_281 (RDE_PARAM p) { /* * x * "PEG" + * ! + * / + * [_:] + * * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "PEG", 113); + rde_param_i_next_str (p, "PEG", 122); + if (rde_param_i_seq_void2void(p)) return; + notahead_278 (p); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } + + static void notahead_278 (RDE_PARAM p) { + /* + * ! + * / + * [_:] + * + */ + + rde_param_i_loc_push (p); + choice_206 (p); + rde_param_i_notahead_exit (p); + return; + } /* * leaf Symbol 'PLUS' */ @@ -3870,25 +3903,25 @@ * x * '+' * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 118)) return ; - sequence_285 (p); - rde_param_i_symbol_done_leaf (p, 118, 117); + if (rde_param_i_symbol_start (p, 127)) return ; + sequence_286 (p); + rde_param_i_symbol_done_leaf (p, 127, 126); return; } - static void sequence_285 (RDE_PARAM p) { + static void sequence_286 (RDE_PARAM p) { /* * x * '+' * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_char (p, "+", 116); + rde_param_i_next_char (p, "+", 125); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -3905,17 +3938,17 @@ * (AND) * (NOT) * (Suffix) */ - if (rde_param_i_symbol_start_d (p, 120)) return ; - sequence_295 (p); - rde_param_i_symbol_done_d_reduce (p, 120, 119); + if (rde_param_i_symbol_start_d (p, 129)) return ; + sequence_296 (p); + rde_param_i_symbol_done_d_reduce (p, 129, 128); return; } - static void sequence_295 (RDE_PARAM p) { + static void sequence_296 (RDE_PARAM p) { /* * x * ? * / * (AND) @@ -3922,32 +3955,32 @@ * (NOT) * (Suffix) */ rde_param_i_state_push_value (p); - optional_292 (p); + optional_293 (p); if (rde_param_i_seq_value2value(p)) return; sym_Suffix (p); rde_param_i_state_merge_value (p); return; } - static void optional_292 (RDE_PARAM p) { + static void optional_293 (RDE_PARAM p) { /* * ? * / * (AND) * (NOT) */ rde_param_i_state_push_2 (p); - choice_290 (p); + choice_291 (p); rde_param_i_state_merge_ok (p); return; } - static void choice_290 (RDE_PARAM p) { + static void choice_291 (RDE_PARAM p) { /* * / * (AND) * (NOT) */ @@ -3989,17 +4022,17 @@ * (Literal) * (Class) * (DOT) */ - if (rde_param_i_symbol_start_d (p, 122)) return ; - choice_321 (p); - rde_param_i_symbol_done_d_reduce (p, 122, 121); + if (rde_param_i_symbol_start_d (p, 131)) return ; + choice_322 (p); + rde_param_i_symbol_done_d_reduce (p, 131, 130); return; } - static void choice_321 (RDE_PARAM p) { + static void choice_322 (RDE_PARAM p) { /* * / * (ALNUM) * (ALPHA) * (ASCII) @@ -4053,11 +4086,11 @@ if (rde_param_i_bra_value2value(p)) return; sym_XDIGIT (p); if (rde_param_i_bra_value2value(p)) return; sym_Identifier (p); if (rde_param_i_bra_value2value(p)) return; - sequence_316 (p); + sequence_317 (p); if (rde_param_i_bra_value2value(p)) return; sym_Literal (p); if (rde_param_i_bra_value2value(p)) return; sym_Class (p); if (rde_param_i_bra_value2value(p)) return; @@ -4064,11 +4097,11 @@ sym_DOT (p); rde_param_i_state_merge_value (p); return; } - static void sequence_316 (RDE_PARAM p) { + static void sequence_317 (RDE_PARAM p) { /* * x * (OPEN) * (Expression) * (CLOSE) @@ -4093,25 +4126,25 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 125)) return ; - sequence_326 (p); - rde_param_i_symbol_done_leaf (p, 125, 124); + if (rde_param_i_symbol_start (p, 134)) return ; + sequence_327 (p); + rde_param_i_symbol_done_leaf (p, 134, 133); return; } - static void sequence_326 (RDE_PARAM p) { + static void sequence_327 (RDE_PARAM p) { /* * x * "" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "", 123); + rde_param_i_next_str (p, "", 132); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -4125,25 +4158,25 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 128)) return ; - sequence_331 (p); - rde_param_i_symbol_done_leaf (p, 128, 127); + if (rde_param_i_symbol_start (p, 137)) return ; + sequence_332 (p); + rde_param_i_symbol_done_leaf (p, 137, 136); return; } - static void sequence_331 (RDE_PARAM p) { + static void sequence_332 (RDE_PARAM p) { /* * x * "" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "", 126); + rde_param_i_next_str (p, "", 135); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -4157,25 +4190,25 @@ * x * '?' * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 131)) return ; - sequence_336 (p); - rde_param_i_symbol_done_leaf (p, 131, 130); + if (rde_param_i_symbol_start (p, 140)) return ; + sequence_337 (p); + rde_param_i_symbol_done_leaf (p, 140, 139); return; } - static void sequence_336 (RDE_PARAM p) { + static void sequence_337 (RDE_PARAM p) { /* * x * '?' * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_char (p, "?", 129); + rde_param_i_next_char (p, "?", 138); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -4192,17 +4225,17 @@ * (TO) * (Char) * (Char) */ - if (rde_param_i_symbol_start_d (p, 133)) return ; - choice_345 (p); - rde_param_i_symbol_done_d_reduce (p, 133, 132); + if (rde_param_i_symbol_start_d (p, 142)) return ; + choice_346 (p); + rde_param_i_symbol_done_d_reduce (p, 142, 141); return; } - static void choice_345 (RDE_PARAM p) { + static void choice_346 (RDE_PARAM p) { /* * / * x * (Char) * (TO) @@ -4209,18 +4242,18 @@ * (Char) * (Char) */ rde_param_i_state_push_value (p); - sequence_342 (p); + sequence_343 (p); if (rde_param_i_bra_value2value(p)) return; sym_Char (p); rde_param_i_state_merge_value (p); return; } - static void sequence_342 (RDE_PARAM p) { + static void sequence_343 (RDE_PARAM p) { /* * x * (Char) * (TO) * (Char) @@ -4245,25 +4278,25 @@ * x * ';' * (WHITESPACE) */ - if (rde_param_i_symbol_void_start (p, 136)) return ; - sequence_350 (p); - rde_param_i_symbol_done_void (p, 136, 135); + if (rde_param_i_symbol_void_start (p, 145)) return ; + sequence_351 (p); + rde_param_i_symbol_done_void (p, 145, 144); return; } - static void sequence_350 (RDE_PARAM p) { + static void sequence_351 (RDE_PARAM p) { /* * x * ';' * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_char (p, "\73", 134); + rde_param_i_next_char (p, ";", 143); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -4276,17 +4309,17 @@ /* * + * (Prefix) */ - if (rde_param_i_symbol_start_d (p, 138)) return ; - poskleene_354 (p); - rde_param_i_symbol_done_d_reduce (p, 138, 137); + if (rde_param_i_symbol_start_d (p, 147)) return ; + poskleene_355 (p); + rde_param_i_symbol_done_d_reduce (p, 147, 146); return; } - static void poskleene_354 (RDE_PARAM p) { + static void poskleene_355 (RDE_PARAM p) { /* * + * (Prefix) */ @@ -4310,25 +4343,25 @@ * x * '/' * (WHITESPACE) */ - if (rde_param_i_symbol_void_start (p, 141)) return ; - sequence_359 (p); - rde_param_i_symbol_done_void (p, 141, 140); + if (rde_param_i_symbol_void_start (p, 150)) return ; + sequence_360 (p); + rde_param_i_symbol_done_void (p, 150, 149); return; } - static void sequence_359 (RDE_PARAM p) { + static void sequence_360 (RDE_PARAM p) { /* * x * '/' * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_char (p, "/", 139); + rde_param_i_next_char (p, "/", 148); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -4342,25 +4375,25 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 144)) return ; - sequence_364 (p); - rde_param_i_symbol_done_leaf (p, 144, 143); + if (rde_param_i_symbol_start (p, 153)) return ; + sequence_365 (p); + rde_param_i_symbol_done_leaf (p, 153, 152); return; } - static void sequence_364 (RDE_PARAM p) { + static void sequence_365 (RDE_PARAM p) { /* * x * "" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "", 142); + rde_param_i_next_str (p, "", 151); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -4374,25 +4407,25 @@ * x * '*' * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 147)) return ; - sequence_369 (p); - rde_param_i_symbol_done_leaf (p, 147, 146); + if (rde_param_i_symbol_start (p, 156)) return ; + sequence_370 (p); + rde_param_i_symbol_done_leaf (p, 156, 155); return; } - static void sequence_369 (RDE_PARAM p) { + static void sequence_370 (RDE_PARAM p) { /* * x * '*' * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_char (p, "*", 145); + rde_param_i_next_char (p, "*", 154); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -4407,13 +4440,13 @@ * (OPEN) * (Expression) * (CLOSE) */ - if (rde_param_i_symbol_start_d (p, 149)) return ; - sequence_316 (p); - rde_param_i_symbol_done_d_reduce (p, 149, 148); + if (rde_param_i_symbol_start_d (p, 158)) return ; + sequence_317 (p); + rde_param_i_symbol_done_d_reduce (p, 158, 157); return; } /* * value Symbol 'Suffix' @@ -4428,17 +4461,17 @@ * (QUESTION) * (STAR) * (PLUS) */ - if (rde_param_i_symbol_start_d (p, 151)) return ; - sequence_385 (p); - rde_param_i_symbol_done_d_reduce (p, 151, 150); + if (rde_param_i_symbol_start_d (p, 160)) return ; + sequence_386 (p); + rde_param_i_symbol_done_d_reduce (p, 160, 159); return; } - static void sequence_385 (RDE_PARAM p) { + static void sequence_386 (RDE_PARAM p) { /* * x * (Primary) * ? * / @@ -4448,31 +4481,31 @@ */ rde_param_i_state_push_value (p); sym_Primary (p); if (rde_param_i_seq_value2value(p)) return; - optional_383 (p); + optional_384 (p); rde_param_i_state_merge_value (p); return; } - static void optional_383 (RDE_PARAM p) { + static void optional_384 (RDE_PARAM p) { /* * ? * / * (QUESTION) * (STAR) * (PLUS) */ rde_param_i_state_push_2 (p); - choice_381 (p); + choice_382 (p); rde_param_i_state_merge_ok (p); return; } - static void choice_381 (RDE_PARAM p) { + static void choice_382 (RDE_PARAM p) { /* * / * (QUESTION) * (STAR) * (PLUS) @@ -4495,13 +4528,13 @@ static void sym_TO (RDE_PARAM p) { /* * '-' */ - if (rde_param_i_symbol_void_start (p, 154)) return ; - rde_param_i_next_char (p, "-", 152); - rde_param_i_symbol_done_void (p, 154, 153); + if (rde_param_i_symbol_void_start (p, 163)) return ; + rde_param_i_next_char (p, "-", 161); + rde_param_i_symbol_done_void (p, 163, 162); return; } /* * leaf Symbol 'UPPER' @@ -4512,25 +4545,25 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 157)) return ; - sequence_392 (p); - rde_param_i_symbol_done_leaf (p, 157, 156); + if (rde_param_i_symbol_start (p, 166)) return ; + sequence_393 (p); + rde_param_i_symbol_done_leaf (p, 166, 165); return; } - static void sequence_392 (RDE_PARAM p) { + static void sequence_393 (RDE_PARAM p) { /* * x * "" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "", 155); + rde_param_i_next_str (p, "", 164); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -4544,25 +4577,25 @@ * x * "void" * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 160)) return ; - sequence_397 (p); - rde_param_i_symbol_done_leaf (p, 160, 159); + if (rde_param_i_symbol_start (p, 169)) return ; + sequence_398 (p); + rde_param_i_symbol_done_leaf (p, 169, 168); return; } - static void sequence_397 (RDE_PARAM p) { + static void sequence_398 (RDE_PARAM p) { /* * x * "void" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "void", 158); + rde_param_i_next_str (p, "void", 167); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -4577,41 +4610,41 @@ * / * * (COMMENT) */ - if (rde_param_i_symbol_void_start (p, 163)) return ; - kleene_404 (p); - rde_param_i_symbol_done_void (p, 163, 162); + if (rde_param_i_symbol_void_start (p, 171)) return ; + kleene_405 (p); + rde_param_i_symbol_done_void (p, 171, 170); return; } - static void kleene_404 (RDE_PARAM p) { + static void kleene_405 (RDE_PARAM p) { /* * * * / * * (COMMENT) */ while (1) { rde_param_i_state_push_2 (p); - choice_402 (p); + choice_403 (p); if (rde_param_i_kleene_close(p)) return; } return; } - static void choice_402 (RDE_PARAM p) { + static void choice_403 (RDE_PARAM p) { /* * / * * (COMMENT) */ rde_param_i_state_push_void (p); - rde_param_i_next_space (p, 161); + rde_param_i_next_space (p, 10); if (rde_param_i_bra_void2void(p)) return; sym_COMMENT (p); rde_param_i_state_merge_void (p); return; } @@ -4625,25 +4658,25 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 166)) return ; - sequence_409 (p); - rde_param_i_symbol_done_leaf (p, 166, 165); + if (rde_param_i_symbol_start (p, 174)) return ; + sequence_410 (p); + rde_param_i_symbol_done_leaf (p, 174, 173); return; } - static void sequence_409 (RDE_PARAM p) { + static void sequence_410 (RDE_PARAM p) { /* * x * "" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "", 164); + rde_param_i_next_str (p, "", 172); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -4657,25 +4690,25 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 169)) return ; - sequence_414 (p); - rde_param_i_symbol_done_leaf (p, 169, 168); + if (rde_param_i_symbol_start (p, 177)) return ; + sequence_415 (p); + rde_param_i_symbol_done_leaf (p, 177, 176); return; } - static void sequence_414 (RDE_PARAM p) { + static void sequence_415 (RDE_PARAM p) { /* * x * "" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "", 167); + rde_param_i_next_str (p, "", 175); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -4718,11 +4751,11 @@ Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; - sprintf (parserg->buf, "peg%d", parserg->counter); + sprintf (parserg->buf, "peg%ld", parserg->counter); return parserg->buf; #undef KEY } static void @@ -4781,45 +4814,52 @@ rde_param_data (p, buf, len); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } + /* See also rde_critcl/m.c, param_COMPLETE() */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) { if (rde_param_query_st (p)) { long int ac; Tcl_Obj** av; rde_param_query_ast (p, &ac, &av); if (ac > 1) { - long int lsc; - long int* lsv; Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); - rde_param_query_ls (p, &lsc, &lsv); - memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); lv [0] = Tcl_NewObj (); - lv [1] = Tcl_NewIntObj (1 + lsv [lsc-1]); + lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); ckfree ((char*) lv); + + } else if (ac == 0) { + /* + * Match, but no AST. This is possible if the grammar + * consists of only the start expression. + */ + Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); } else { Tcl_SetObjResult (interp, av [0]); } return TCL_OK; } else { Tcl_Obj* xv [1]; const ERROR_STATE* er = rde_param_query_er (p); Tcl_Obj* res = rde_param_query_er_tcl (p, er); + /* res = list (location, list(msg)) */ + /* Stick the exception type-tag before the existing elements */ xv [0] = Tcl_NewStringObj ("pt::rde",-1); - Tcl_ListObjReplace(interp, res, 0, 1, 1, xv); + Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); + Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); Tcl_SetObjResult (interp, res); return TCL_ERROR; } } } Index: modules/pt/pt_parse_peg_tcl.tcl ================================================================== --- modules/pt/pt_parse_peg_tcl.tcl +++ modules/pt/pt_parse_peg_tcl.tcl @@ -363,11 +363,11 @@ # proc sym_CharSpecial {} { upvar 1 myparser myparser # x # '\' - # [nrt'"[]\] + # [nrt'\"[]\] $myparser si:void_symbol_start CharSpecial sequence_57 $myparser si:void_leaf_symbol_end CharSpecial return @@ -374,11 +374,11 @@ } proc sequence_57 {} { upvar 1 myparser myparser # x # '\' - # [nrt'"[]\] + # [nrt'\"[]\] $myparser si:void_state_push $myparser si:next_char \134 $myparser si:voidvoid_part $myparser si:next_class nrt'\42\133\135\134 @@ -948,53 +948,25 @@ sym_WHITESPACE $myparser si:void_state_merge return } - # - # void Symbol 'END' - # - - proc sym_END {} { upvar 1 myparser myparser - # x - # "END" - # (WHITESPACE) - - $myparser si:void_void_symbol_start END - sequence_158 - $myparser si:void_clear_symbol_end END - return - } - - proc sequence_158 {} { upvar 1 myparser myparser - # x - # "END" - # (WHITESPACE) - - $myparser si:void_state_push - $myparser si:next_str END - $myparser si:voidvoid_part - sym_WHITESPACE - $myparser si:void_state_merge - return - } - # # void Symbol 'EOF' # proc sym_EOF {} { upvar 1 myparser myparser # ! # $myparser si:void_void_symbol_start EOF - notahead_162 + notahead_157 $myparser si:void_clear_symbol_end EOF return } - proc notahead_162 {} { upvar 1 myparser myparser + proc notahead_157 {} { upvar 1 myparser myparser # ! # $myparser i_loc_push $myparser i_input_next dot @@ -1005,10 +977,11 @@ # # void Symbol 'EOL' # proc sym_EOL {} { upvar 1 myparser myparser + # [\n\r] $myparser si:void_void_symbol_start EOL $myparser si:next_class \n\r $myparser si:void_clear_symbol_end EOL return @@ -1025,16 +998,16 @@ # x # (SLASH) # (Sequence) $myparser si:value_symbol_start Expression - sequence_174 + sequence_169 $myparser si:reduce_symbol_end Expression return } - proc sequence_174 {} { upvar 1 myparser myparser + proc sequence_169 {} { upvar 1 myparser myparser # x # (Sequence) # * # x # (SLASH) @@ -1041,30 +1014,30 @@ # (Sequence) $myparser si:value_state_push sym_Sequence $myparser si:valuevalue_part - kleene_172 + kleene_167 $myparser si:value_state_merge return } - proc kleene_172 {} { upvar 1 myparser myparser + proc kleene_167 {} { upvar 1 myparser myparser # * # x # (SLASH) # (Sequence) while {1} { $myparser si:void2_state_push - sequence_170 + sequence_165 $myparser si:kleene_close } return } - proc sequence_170 {} { upvar 1 myparser myparser + proc sequence_165 {} { upvar 1 myparser myparser # x # (SLASH) # (Sequence) $myparser si:void_state_push @@ -1079,28 +1052,32 @@ # void Symbol 'Final' # proc sym_Final {} { upvar 1 myparser myparser # x - # (END) + # "END" + # (WHITESPACE) # (SEMICOLON) # (WHITESPACE) $myparser si:void_void_symbol_start Final - sequence_180 + sequence_176 $myparser si:void_clear_symbol_end Final return } - proc sequence_180 {} { upvar 1 myparser myparser + proc sequence_176 {} { upvar 1 myparser myparser # x - # (END) + # "END" + # (WHITESPACE) # (SEMICOLON) # (WHITESPACE) $myparser si:void_state_push - sym_END + $myparser si:next_str END + $myparser si:voidvoid_part + sym_WHITESPACE $myparser si:voidvoid_part sym_SEMICOLON $myparser si:voidvoid_part sym_WHITESPACE $myparser si:void_state_merge @@ -1119,16 +1096,16 @@ # (Definition) # (Final) # (EOF) $myparser si:value_symbol_start Grammar - sequence_190 + sequence_186 $myparser si:reduce_symbol_end Grammar return } - proc sequence_190 {} { upvar 1 myparser myparser + proc sequence_186 {} { upvar 1 myparser myparser # x # (WHITESPACE) # (Header) # * # (Definition) @@ -1138,20 +1115,20 @@ $myparser si:void_state_push sym_WHITESPACE $myparser si:voidvalue_part sym_Header $myparser si:valuevalue_part - kleene_186 + kleene_182 $myparser si:valuevalue_part sym_Final $myparser si:valuevalue_part sym_EOF $myparser si:value_state_merge return } - proc kleene_186 {} { upvar 1 myparser myparser + proc kleene_182 {} { upvar 1 myparser myparser # * # (Definition) while {1} { $myparser si:void2_state_push @@ -1169,16 +1146,16 @@ # x # "" # (WHITESPACE) $myparser si:void_symbol_start GRAPH - sequence_195 + sequence_191 $myparser si:void_leaf_symbol_end GRAPH return } - proc sequence_195 {} { upvar 1 myparser myparser + proc sequence_191 {} { upvar 1 myparser myparser # x # "" # (WHITESPACE) $myparser si:void_state_push @@ -1198,16 +1175,16 @@ # (PEG) # (Identifier) # (StartExpr) $myparser si:value_symbol_start Header - sequence_201 + sequence_197 $myparser si:reduce_symbol_end Header return } - proc sequence_201 {} { upvar 1 myparser myparser + proc sequence_197 {} { upvar 1 myparser myparser # x # (PEG) # (Identifier) # (StartExpr) @@ -1234,16 +1211,16 @@ # / # [_:] # $myparser si:void_symbol_start Ident - sequence_214 + sequence_210 $myparser si:void_leaf_symbol_end Ident return } - proc sequence_214 {} { upvar 1 myparser myparser + proc sequence_210 {} { upvar 1 myparser myparser # x # / # [_:] # # * @@ -1250,18 +1227,18 @@ # / # [_:] # $myparser si:void_state_push - choice_206 + choice_202 $myparser si:voidvoid_part - kleene_212 + kleene_208 $myparser si:void_state_merge return } - proc choice_206 {} { upvar 1 myparser myparser + proc choice_202 {} { upvar 1 myparser myparser # / # [_:] # $myparser si:void_state_push @@ -1270,25 +1247,25 @@ $myparser si:next_alpha $myparser si:void_state_merge return } - proc kleene_212 {} { upvar 1 myparser myparser + proc kleene_208 {} { upvar 1 myparser myparser # * # / # [_:] # while {1} { $myparser si:void2_state_push - choice_210 + choice_206 $myparser si:kleene_close } return } - proc choice_210 {} { upvar 1 myparser myparser + proc choice_206 {} { upvar 1 myparser myparser # / # [_:] # $myparser si:void_state_push @@ -1307,16 +1284,16 @@ # x # (Ident) # (WHITESPACE) $myparser si:value_symbol_start Identifier - sequence_219 + sequence_215 $myparser si:reduce_symbol_end Identifier return } - proc sequence_219 {} { upvar 1 myparser myparser + proc sequence_215 {} { upvar 1 myparser myparser # x # (Ident) # (WHITESPACE) $myparser si:value_state_push @@ -1335,16 +1312,16 @@ # x # "<-" # (WHITESPACE) $myparser si:void_void_symbol_start IS - sequence_224 + sequence_220 $myparser si:void_clear_symbol_end IS return } - proc sequence_224 {} { upvar 1 myparser myparser + proc sequence_220 {} { upvar 1 myparser myparser # x # "<-" # (WHITESPACE) $myparser si:void_state_push @@ -1363,16 +1340,16 @@ # x # "leaf" # (WHITESPACE) $myparser si:void_symbol_start LEAF - sequence_229 + sequence_225 $myparser si:void_leaf_symbol_end LEAF return } - proc sequence_229 {} { upvar 1 myparser myparser + proc sequence_225 {} { upvar 1 myparser myparser # x # "leaf" # (WHITESPACE) $myparser si:void_state_push @@ -1407,16 +1384,16 @@ # (Char) # (DAPOSTROPH) # (WHITESPACE) $myparser si:value_symbol_start Literal - choice_258 + choice_254 $myparser si:reduce_symbol_end Literal return } - proc choice_258 {} { upvar 1 myparser myparser + proc choice_254 {} { upvar 1 myparser myparser # / # x # (APOSTROPH) # * # x @@ -1434,18 +1411,18 @@ # (Char) # (DAPOSTROPH) # (WHITESPACE) $myparser si:value_state_push - sequence_243 + sequence_239 $myparser si:valuevalue_branch - sequence_256 + sequence_252 $myparser si:value_state_merge return } - proc sequence_243 {} { upvar 1 myparser myparser + proc sequence_239 {} { upvar 1 myparser myparser # x # (APOSTROPH) # * # x # ! @@ -1455,59 +1432,59 @@ # (WHITESPACE) $myparser si:void_state_push sym_APOSTROPH $myparser si:voidvalue_part - kleene_239 + kleene_235 $myparser si:valuevalue_part sym_APOSTROPH $myparser si:valuevalue_part sym_WHITESPACE $myparser si:value_state_merge return } - proc kleene_239 {} { upvar 1 myparser myparser + proc kleene_235 {} { upvar 1 myparser myparser # * # x # ! # (APOSTROPH) # (Char) while {1} { $myparser si:void2_state_push - sequence_237 + sequence_233 $myparser si:kleene_close } return } - proc sequence_237 {} { upvar 1 myparser myparser + proc sequence_233 {} { upvar 1 myparser myparser # x # ! # (APOSTROPH) # (Char) $myparser si:void_state_push - notahead_234 + notahead_230 $myparser si:voidvalue_part sym_Char $myparser si:value_state_merge return } - proc notahead_234 {} { upvar 1 myparser myparser + proc notahead_230 {} { upvar 1 myparser myparser # ! # (APOSTROPH) $myparser i_loc_push sym_APOSTROPH $myparser si:void_notahead_exit return } - proc sequence_256 {} { upvar 1 myparser myparser + proc sequence_252 {} { upvar 1 myparser myparser # x # (DAPOSTROPH) # * # x # ! @@ -1517,49 +1494,49 @@ # (WHITESPACE) $myparser si:void_state_push sym_DAPOSTROPH $myparser si:voidvalue_part - kleene_252 + kleene_248 $myparser si:valuevalue_part sym_DAPOSTROPH $myparser si:valuevalue_part sym_WHITESPACE $myparser si:value_state_merge return } - proc kleene_252 {} { upvar 1 myparser myparser + proc kleene_248 {} { upvar 1 myparser myparser # * # x # ! # (DAPOSTROPH) # (Char) while {1} { $myparser si:void2_state_push - sequence_250 + sequence_246 $myparser si:kleene_close } return } - proc sequence_250 {} { upvar 1 myparser myparser + proc sequence_246 {} { upvar 1 myparser myparser # x # ! # (DAPOSTROPH) # (Char) $myparser si:void_state_push - notahead_247 + notahead_243 $myparser si:voidvalue_part sym_Char $myparser si:value_state_merge return } - proc notahead_247 {} { upvar 1 myparser myparser + proc notahead_243 {} { upvar 1 myparser myparser # ! # (DAPOSTROPH) $myparser i_loc_push sym_DAPOSTROPH @@ -1575,16 +1552,16 @@ # x # "" # (WHITESPACE) $myparser si:void_symbol_start LOWER - sequence_263 + sequence_259 $myparser si:void_leaf_symbol_end LOWER return } - proc sequence_263 {} { upvar 1 myparser myparser + proc sequence_259 {} { upvar 1 myparser myparser # x # "" # (WHITESPACE) $myparser si:void_state_push @@ -1603,16 +1580,16 @@ # x # '!' # (WHITESPACE) $myparser si:void_symbol_start NOT - sequence_268 + sequence_264 $myparser si:void_leaf_symbol_end NOT return } - proc sequence_268 {} { upvar 1 myparser myparser + proc sequence_264 {} { upvar 1 myparser myparser # x # '!' # (WHITESPACE) $myparser si:void_state_push @@ -1631,16 +1608,16 @@ # x # '\(' # (WHITESPACE) $myparser si:void_void_symbol_start OPEN - sequence_273 + sequence_269 $myparser si:void_clear_symbol_end OPEN return } - proc sequence_273 {} { upvar 1 myparser myparser + proc sequence_269 {} { upvar 1 myparser myparser # x # '\(' # (WHITESPACE) $myparser si:void_state_push @@ -1669,30 +1646,52 @@ # proc sym_PEG {} { upvar 1 myparser myparser # x # "PEG" + # ! + # / + # [_:] + # # (WHITESPACE) $myparser si:void_void_symbol_start PEG - sequence_280 + sequence_281 $myparser si:void_clear_symbol_end PEG return } - proc sequence_280 {} { upvar 1 myparser myparser + proc sequence_281 {} { upvar 1 myparser myparser # x # "PEG" + # ! + # / + # [_:] + # # (WHITESPACE) $myparser si:void_state_push $myparser si:next_str PEG + $myparser si:voidvoid_part + notahead_278 $myparser si:voidvoid_part sym_WHITESPACE $myparser si:void_state_merge return } + + proc notahead_278 {} { upvar 1 myparser myparser + # ! + # / + # [_:] + # + + $myparser i_loc_push + choice_206 + $myparser si:void_notahead_exit + return + } # # leaf Symbol 'PLUS' # @@ -1700,16 +1699,16 @@ # x # '+' # (WHITESPACE) $myparser si:void_symbol_start PLUS - sequence_285 + sequence_286 $myparser si:void_leaf_symbol_end PLUS return } - proc sequence_285 {} { upvar 1 myparser myparser + proc sequence_286 {} { upvar 1 myparser myparser # x # '+' # (WHITESPACE) $myparser si:void_state_push @@ -1731,44 +1730,44 @@ # (AND) # (NOT) # (Suffix) $myparser si:value_symbol_start Prefix - sequence_295 + sequence_296 $myparser si:reduce_symbol_end Prefix return } - proc sequence_295 {} { upvar 1 myparser myparser + proc sequence_296 {} { upvar 1 myparser myparser # x # ? # / # (AND) # (NOT) # (Suffix) $myparser si:value_state_push - optional_292 + optional_293 $myparser si:valuevalue_part sym_Suffix $myparser si:value_state_merge return } - proc optional_292 {} { upvar 1 myparser myparser + proc optional_293 {} { upvar 1 myparser myparser # ? # / # (AND) # (NOT) $myparser si:void2_state_push - choice_290 + choice_291 $myparser si:void_state_merge_ok return } - proc choice_290 {} { upvar 1 myparser myparser + proc choice_291 {} { upvar 1 myparser myparser # / # (AND) # (NOT) $myparser si:value_state_push @@ -1807,16 +1806,16 @@ # (Literal) # (Class) # (DOT) $myparser si:value_symbol_start Primary - choice_321 + choice_322 $myparser si:reduce_symbol_end Primary return } - proc choice_321 {} { upvar 1 myparser myparser + proc choice_322 {} { upvar 1 myparser myparser # / # (ALNUM) # (ALPHA) # (ASCII) # (CONTROL) @@ -1868,11 +1867,11 @@ $myparser si:valuevalue_branch sym_XDIGIT $myparser si:valuevalue_branch sym_Identifier $myparser si:valuevalue_branch - sequence_316 + sequence_317 $myparser si:valuevalue_branch sym_Literal $myparser si:valuevalue_branch sym_Class $myparser si:valuevalue_branch @@ -1879,11 +1878,11 @@ sym_DOT $myparser si:value_state_merge return } - proc sequence_316 {} { upvar 1 myparser myparser + proc sequence_317 {} { upvar 1 myparser myparser # x # (OPEN) # (Expression) # (CLOSE) @@ -1905,16 +1904,16 @@ # x # "" # (WHITESPACE) $myparser si:void_symbol_start PRINTABLE - sequence_326 + sequence_327 $myparser si:void_leaf_symbol_end PRINTABLE return } - proc sequence_326 {} { upvar 1 myparser myparser + proc sequence_327 {} { upvar 1 myparser myparser # x # "" # (WHITESPACE) $myparser si:void_state_push @@ -1933,16 +1932,16 @@ # x # "" # (WHITESPACE) $myparser si:void_symbol_start PUNCT - sequence_331 + sequence_332 $myparser si:void_leaf_symbol_end PUNCT return } - proc sequence_331 {} { upvar 1 myparser myparser + proc sequence_332 {} { upvar 1 myparser myparser # x # "" # (WHITESPACE) $myparser si:void_state_push @@ -1961,16 +1960,16 @@ # x # '?' # (WHITESPACE) $myparser si:void_symbol_start QUESTION - sequence_336 + sequence_337 $myparser si:void_leaf_symbol_end QUESTION return } - proc sequence_336 {} { upvar 1 myparser myparser + proc sequence_337 {} { upvar 1 myparser myparser # x # '?' # (WHITESPACE) $myparser si:void_state_push @@ -1992,32 +1991,32 @@ # (TO) # (Char) # (Char) $myparser si:value_symbol_start Range - choice_345 + choice_346 $myparser si:reduce_symbol_end Range return } - proc choice_345 {} { upvar 1 myparser myparser + proc choice_346 {} { upvar 1 myparser myparser # / # x # (Char) # (TO) # (Char) # (Char) $myparser si:value_state_push - sequence_342 + sequence_343 $myparser si:valuevalue_branch sym_Char $myparser si:value_state_merge return } - proc sequence_342 {} { upvar 1 myparser myparser + proc sequence_343 {} { upvar 1 myparser myparser # x # (Char) # (TO) # (Char) @@ -2039,16 +2038,16 @@ # x # ';' # (WHITESPACE) $myparser si:void_void_symbol_start SEMICOLON - sequence_350 + sequence_351 $myparser si:void_clear_symbol_end SEMICOLON return } - proc sequence_350 {} { upvar 1 myparser myparser + proc sequence_351 {} { upvar 1 myparser myparser # x # ';' # (WHITESPACE) $myparser si:void_state_push @@ -2066,16 +2065,16 @@ proc sym_Sequence {} { upvar 1 myparser myparser # + # (Prefix) $myparser si:value_symbol_start Sequence - poskleene_354 + poskleene_355 $myparser si:reduce_symbol_end Sequence return } - proc poskleene_354 {} { upvar 1 myparser myparser + proc poskleene_355 {} { upvar 1 myparser myparser # + # (Prefix) $myparser i_loc_push sym_Prefix @@ -2096,16 +2095,16 @@ # x # '/' # (WHITESPACE) $myparser si:void_void_symbol_start SLASH - sequence_359 + sequence_360 $myparser si:void_clear_symbol_end SLASH return } - proc sequence_359 {} { upvar 1 myparser myparser + proc sequence_360 {} { upvar 1 myparser myparser # x # '/' # (WHITESPACE) $myparser si:void_state_push @@ -2124,16 +2123,16 @@ # x # "" # (WHITESPACE) $myparser si:void_symbol_start SPACE - sequence_364 + sequence_365 $myparser si:void_leaf_symbol_end SPACE return } - proc sequence_364 {} { upvar 1 myparser myparser + proc sequence_365 {} { upvar 1 myparser myparser # x # "" # (WHITESPACE) $myparser si:void_state_push @@ -2152,16 +2151,16 @@ # x # '*' # (WHITESPACE) $myparser si:void_symbol_start STAR - sequence_369 + sequence_370 $myparser si:void_leaf_symbol_end STAR return } - proc sequence_369 {} { upvar 1 myparser myparser + proc sequence_370 {} { upvar 1 myparser myparser # x # '*' # (WHITESPACE) $myparser si:void_state_push @@ -2181,11 +2180,11 @@ # (OPEN) # (Expression) # (CLOSE) $myparser si:value_symbol_start StartExpr - sequence_316 + sequence_317 $myparser si:reduce_symbol_end StartExpr return } # @@ -2200,16 +2199,16 @@ # (QUESTION) # (STAR) # (PLUS) $myparser si:value_symbol_start Suffix - sequence_385 + sequence_386 $myparser si:reduce_symbol_end Suffix return } - proc sequence_385 {} { upvar 1 myparser myparser + proc sequence_386 {} { upvar 1 myparser myparser # x # (Primary) # ? # / # (QUESTION) @@ -2217,29 +2216,29 @@ # (PLUS) $myparser si:value_state_push sym_Primary $myparser si:valuevalue_part - optional_383 + optional_384 $myparser si:value_state_merge return } - proc optional_383 {} { upvar 1 myparser myparser + proc optional_384 {} { upvar 1 myparser myparser # ? # / # (QUESTION) # (STAR) # (PLUS) $myparser si:void2_state_push - choice_381 + choice_382 $myparser si:void_state_merge_ok return } - proc choice_381 {} { upvar 1 myparser myparser + proc choice_382 {} { upvar 1 myparser myparser # / # (QUESTION) # (STAR) # (PLUS) @@ -2274,16 +2273,16 @@ # x # "" # (WHITESPACE) $myparser si:void_symbol_start UPPER - sequence_392 + sequence_393 $myparser si:void_leaf_symbol_end UPPER return } - proc sequence_392 {} { upvar 1 myparser myparser + proc sequence_393 {} { upvar 1 myparser myparser # x # "" # (WHITESPACE) $myparser si:void_state_push @@ -2302,16 +2301,16 @@ # x # "void" # (WHITESPACE) $myparser si:void_symbol_start VOID - sequence_397 + sequence_398 $myparser si:void_leaf_symbol_end VOID return } - proc sequence_397 {} { upvar 1 myparser myparser + proc sequence_398 {} { upvar 1 myparser myparser # x # "void" # (WHITESPACE) $myparser si:void_state_push @@ -2331,30 +2330,30 @@ # / # # (COMMENT) $myparser si:void_void_symbol_start WHITESPACE - kleene_404 + kleene_405 $myparser si:void_clear_symbol_end WHITESPACE return } - proc kleene_404 {} { upvar 1 myparser myparser + proc kleene_405 {} { upvar 1 myparser myparser # * # / # # (COMMENT) while {1} { $myparser si:void2_state_push - choice_402 + choice_403 $myparser si:kleene_close } return } - proc choice_402 {} { upvar 1 myparser myparser + proc choice_403 {} { upvar 1 myparser myparser # / # # (COMMENT) $myparser si:void_state_push @@ -2373,16 +2372,16 @@ # x # "" # (WHITESPACE) $myparser si:void_symbol_start WORDCHAR - sequence_409 + sequence_410 $myparser si:void_leaf_symbol_end WORDCHAR return } - proc sequence_409 {} { upvar 1 myparser myparser + proc sequence_410 {} { upvar 1 myparser myparser # x # "" # (WHITESPACE) $myparser si:void_state_push @@ -2401,16 +2400,16 @@ # x # "" # (WHITESPACE) $myparser si:void_symbol_start XDIGIT - sequence_414 + sequence_415 $myparser si:void_leaf_symbol_end XDIGIT return } - proc sequence_414 {} { upvar 1 myparser myparser + proc sequence_415 {} { upvar 1 myparser myparser # x # "" # (WHITESPACE) $myparser si:void_state_push @@ -2426,7 +2425,7 @@ } # # ## ### ##### ######## ############# ##################### ## Ready -package provide pt::parse::peg_tcl 1 +package provide pt::parse::peg_tcl 1.0.1 return Index: modules/pt/pt_peg_from_peg.man ================================================================== --- modules/pt/pt_peg_from_peg.man +++ modules/pt/pt_peg_from_peg.man @@ -1,7 +1,7 @@ [comment {--- doctools ---}] [vset PACKAGE peg] [vset NAME PEG] [vset REQUIRE peg] [vset CONFIG peg] -[vset VERSION 1.0.2] +[vset VERSION 1.0.3] [include include/import/from.inc] Index: modules/pt/pt_peg_from_peg.tcl ================================================================== --- modules/pt/pt_peg_from_peg.tcl +++ modules/pt/pt_peg_from_peg.tcl @@ -1,10 +1,10 @@ # pt_peg_from_peg.tcl -- # # Conversion from PEG (Human readable text) to PEG. # -# Copyright (c) 2009 Andreas Kupries +# Copyright (c) 2009-2014 Andreas Kupries # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # # RCS: @(#) $Id: pt_peg_from_peg.tcl,v 1.1 2010/03/26 05:07:24 andreas_kupries Exp $ @@ -195,11 +195,11 @@ return [pt::pe choice {*}$args] ; # <- Chars and Ranges } } proc pt::peg::from::peg::GEN::CONTROL {s e} { - return [pt::pe ddigit] + return [pt::pe control] } proc pt::peg::from::peg::GEN::DDIGIT {s e} { return [pt::pe ddigit] } @@ -388,7 +388,7 @@ } # ### ### ### ######### ######### ######### ## Ready -package provide pt::peg::from::peg 1.0.2 +package provide pt::peg::from::peg 1.0.3 return Index: modules/pt/pt_peg_interp.man ================================================================== --- modules/pt/pt_peg_interp.man +++ modules/pt/pt_peg_interp.man @@ -1,7 +1,7 @@ [comment {-*- tcl -*- doctools manpage}] -[vset PACKAGE_VERSION 1] +[vset PACKAGE_VERSION 1.0.1] [manpage_begin pt::peg::interp n [vset PACKAGE_VERSION]] [include include/module.inc] [titledesc {Interpreter for parsing expression grammars}] [require pt::peg::interp [opt [vset PACKAGE_VERSION]]] [require pt::rde [opt 1]] Index: modules/pt/pt_peg_interp.tcl ================================================================== --- modules/pt/pt_peg_interp.tcl +++ modules/pt/pt_peg_interp.tcl @@ -1,8 +1,8 @@ # -*- tcl -*- # -# Copyright (c) 2009 by Andreas Kupries +# Copyright (c) 2009-2014 by Andreas Kupries # Interpreter for parsing expression grammars. In essence a recursive # descent parser configurable with a parsing expression grammar. # ### ### ### ######### ######### ######### @@ -114,13 +114,12 @@ # Parse and consume one specific character. This fails if the # character at the location is not in the specified character # class. Does not consume input on failure. foreach operator { - alnum alpha ascii ddigit digit graph - lower print punct space upper wordchar - xdigit + alnum alpha ascii control ddigit digit graph + lower print punct space upper wordchar xdigit } { method $operator {} [string map [list @ $operator] { $self Next $myparser i:fail_return $myparser i_test_@ @@ -381,6 +380,6 @@ } # ### ### ### ######### ######### ######### ## Package Management -package provide pt::peg::interp 1 +package provide pt::peg::interp 1.0.1 Index: modules/pt/pt_peg_to_cparam.man ================================================================== --- modules/pt/pt_peg_to_cparam.man +++ modules/pt/pt_peg_to_cparam.man @@ -1,7 +1,7 @@ [comment {--- doctools ---}] [vset PACKAGE cparam] [vset NAME CPARAM] [vset REQUIRE cparam] [vset CONFIG cparam] -[vset VERSION 1.1.1] +[vset VERSION 1.1.2] [include include/export/to.inc] Index: modules/pt/pt_peg_to_cparam.tcl ================================================================== --- modules/pt/pt_peg_to_cparam.tcl +++ modules/pt/pt_peg_to_cparam.tcl @@ -1,10 +1,10 @@ # peg_to_param.tcl -- # # Conversion of PEG to C PARAM, customizable text blocks. # -# Copyright (c) 2009 Andreas Kupries +# Copyright (c) 2009-2014 Andreas Kupries # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # # RCS: @(#) $Id: pt_peg_to_cparam.tcl,v 1.2 2010/04/07 19:40:54 andreas_kupries Exp $ @@ -39,24 +39,25 @@ # ### ### ### ######### ######### ######### ## API. proc ::pt::peg::to::cparam::reset {} { - variable template @code@ ; # -template - variable name a_pe_grammar ; # -name - variable file unknown ; # -file - variable user unknown ; # -user - variable self {} ; # -self-command - variable ns {} ; # -namespace - variable def static ; # -fun-qualifier - variable main __main ; # -main - variable indent 0 ; # -indent - variable comments 1 ; # -comments - variable prelude {} ; # -prelude - variable statedecl {RDE_PARAM p} ; # -state-decl - variable stateref {p} ; # -state-ref - variable strings p_string ; # -string-varname + variable insertcmd {} ; # -insert-command (hook) + variable template @code@ ; # -template + variable name a_pe_grammar ; # -name + variable file unknown ; # -file + variable user unknown ; # -user + variable self {} ; # -self-command + variable ns {} ; # -namespace + variable def static ; # -fun-qualifier + variable main __main ; # -main + variable indent 0 ; # -indent + variable comments 1 ; # -comments + variable prelude {} ; # -prelude + variable statedecl {RDE_PARAM p} ; # -state-decl + variable stateref {p} ; # -state-ref + variable strings p_string ; # -string-varname return } proc ::pt::peg::to::cparam::configure {args} { variable template @@ -67,10 +68,11 @@ variable ns variable def variable main variable omap variable indent + variable insertcmd variable comments variable prelude variable statedecl variable stateref variable strings @@ -79,10 +81,11 @@ return [list \ -comments $comments \ -file $file \ -fun-qualifier $def \ -indent $indent \ + -insert-command $insertcmd \ -main $main \ -name $name \ -namespace $ns \ -self-command $self \ -state-decl $statedecl \ @@ -95,17 +98,19 @@ lassign $args option set variable [string range $option 1 end] if {[info exists omap($variable)]} { return [set $omap($variable)] } else { - return -code error "Expected one of -comments, -file, -fun-qualifier, -indent, -main, -name, -namespace, -self-command, -state-decl, -state-ref, -string-varname, -template, or -user, got \"$option\"" + # TODO: compute this string dynamically. + return -code error "Expected one of -comments, -file, -fun-qualifier, -indent, -insert-cmd, -main, -name, -namespace, -self-command, -state-decl, -state-ref, -string-varname, -template, or -user, got \"$option\"" } } elseif {[llength $args] % 2 == 0} { foreach {option value} $args { set variable [string range $option 1 end] if {![info exists omap($variable)]} { - return -code error "Expected one of -comments, -file, -fun-qualifier, -indent, -main, -name, -namespace, -self-command, -state-decl, -state-ref, -string-varname, -template, or -user, got \"$option\"" + # TODO: compute this string dynamically. + return -code error "Expected one of -comments, -file, -fun-qualifier, -indent, -insert-cmd, -main, -name, -namespace, -self-command, -state-decl, -state-ref, -string-varname, -template, or -user, got \"$option\"" } } foreach {option value} $args { set variable $omap([string range $option 1 end]) switch -exact -- $variable { @@ -122,10 +127,11 @@ comments { if {![string is boolean -strict $value]} { return -code error "Expected boolean, got \"$value\"" } } + insert-cmd - statedecl - stateref - strings - self - def - @@ -151,10 +157,11 @@ variable self variable ns variable def variable main variable indent + variable insertcmd variable prelude variable statedecl variable stateref variable strings @@ -172,10 +179,32 @@ lassign $symdef _ is _ mode lappend modes $symbol $mode } text::write reset + + # Fixed elements of the string table as needed by the lower level + # PARAM functions (class tests, see param.c, enum test_class). + # ** Keep in sync ** + # + # Maybe move the interning into the lower level, i.e. PARAM ? + + Op::Asm::String alnum + Op::Asm::String alpha + Op::Asm::String ascii + Op::Asm::String control + Op::Asm::String ddigit + Op::Asm::String digit + Op::Asm::String graph + Op::Asm::String lower + Op::Asm::String print + Op::Asm::String punct + Op::Asm::String space + Op::Asm::String upper + Op::Asm::String wordchar + Op::Asm::String xdigit + Op::Asm::Header {Declaring the parse functions} text::write /line text::write store FORWARD text::write clear @@ -240,27 +269,36 @@ } set xprelude $prelude ; if {$xprelude ne {}} { set xprelude " $xprelude" } set xself $self ; if {$xself ne {}} { append xself { } } - set code [string map \ - [list \ - @user@ $user \ - @format@ C/PARAM \ - @file@ $file \ - @name@ $name \ - @code@ $code] $template] - set code [string map \ - [list \ - @statedecl@ $statedecl \ - @stateref@ $stateref \ - @strings@ $strings \ - { @prelude@} $xprelude \ - {@self@ } $xself \ - @def@ $def \ - @ns@ $ns \ - @main@ $main] $code] + # I. run code through the insertcmd hook (if specified) to prepare it for embedding + if {[llength $insertcmd]} { + set code [{*}$insertcmd $code] + } + + # II. Phase 1 merge of code into the template. + # (Placeholders only in the template) + lappend map @user@ $user + lappend map @format@ C/PARAM + lappend map @file@ $file + lappend map @name@ $name + lappend map @code@ $code + set code [string map $map $template] + unset map + + # III. Phase 2 merge of code into the template. + # (Placeholders in generated code, and template). + lappend map @statedecl@ $statedecl + lappend map @stateref@ $stateref + lappend map @strings@ $strings + lappend map { @prelude@} $xprelude + lappend map {@self@ } $xself + lappend map @def@ $def + lappend map @ns@ $ns + lappend map @main@ $main + set code [string map $map $code] return $code # ### ### ### ######### ######### ######### } @@ -277,11 +315,10 @@ [list [namespace current]::Op $modes] \ $expression] } proc ::pt::peg::to::cparam::Symbol {symbol mode rhs modes} { - set expression [Expression $rhs $modes] text::write clear Op::Asm::Header "$mode Symbol '$symbol'" text::write store FUN_HEADER @@ -292,13 +329,14 @@ Op::Asm::PE $rhs set gen [dict get $result gen] Op::Asm::Function sym_$symbol { - - set msg [Op::Asm::String [list n $symbol]] - set symbol [Op::Asm::String $symbol] + # Message is Tcl list. Quote for C embedding. + set msg [Op::Asm::String [char quote cstring [list n $symbol]]] + # Quote for C embedding. + set symbol [Op::Asm::String [char quote cstring $symbol]] # We have six possibilites for the combination of AST node # generation by the rhs and AST generation by the symbol. Two # of these (leaf/0, value/0 coincide, leaving 5). This # controls the use of AS/ARS instructions. @@ -484,11 +522,11 @@ Op::Asm::Done } namespace eval ::pt::peg::to::cparam::Op { namespace export \ - alpha alnum ascii digit graph lower print \ + alpha alnum ascii control digit graph lower print \ punct space upper wordchar xdigit ddigit \ dot epsilon t .. n ? * + & ! x / } proc ::pt::peg::to::cparam::Op {modes pe op arguments} { @@ -512,11 +550,11 @@ } Asm::Done } foreach test { - alpha alnum ascii digit graph lower print + alpha alnum ascii control digit graph lower print punct space upper wordchar xdigit ddigit } { proc ::pt::peg::to::cparam::Op::$test {modes} \ [string map [list @OP@ $test] { Asm::Start @@ -534,49 +572,57 @@ proc ::pt::peg::to::cparam::Op::t {modes char} { Asm::Start Asm::ReTerminal t $char Asm::Direct { - set c [char quote tcl $char] - set m [Asm::String "t $c"] + # Message is Tcl list. Quote for C embedding. + set msg [Asm::String [char quote cstring [list t $char]]] + # Quote for C embedding. + set char [char quote cstring $char] - #Asm::Ins input_next $m + #Asm::Ins input_next $msg #Asm::CStmt if (!rde_param_query_st(@stateref@)) return - #Asm::Ins test_char \"$c\" $m - Asm::Ins next_char \"$c\" $m + #Asm::Ins test_char \"$char\" $msg + Asm::Ins next_char \"$char\" $msg } Asm::Done } -proc ::pt::peg::to::cparam::Op::.. {modes chstart chend} { +proc ::pt::peg::to::cparam::Op::.. {modes chs che} { Asm::Start - Asm::ReTerminal .. $chstart $chend + Asm::ReTerminal .. $chs $che Asm::Direct { - set s [char quote tcl $chstart] - set e [char quote tcl $chend] - set m [Asm::String ".. $s $e"] + # Message is Tcl list. Quote for C embedding. + set msg [Asm::String [char quote cstring [list .. $chs $che]]] - #Asm::Ins input_next $m + # Quote for C embedding + set chs [char quote cstring $chs] + set che [char quote cstring $che] + + #Asm::Ins input_next $msg #Asm::CStmt if (!rde_param_query_st(@stateref@)) return - #Asm::Ins test_range \"$s\" \"$e\" $m - Asm::Ins next_range \"$s\" \"$e\" $m + #Asm::Ins test_range \"$chs\" \"$che\" $msg + Asm::Ins next_range \"$chs\" \"$che\" $msg } Asm::Done } proc ::pt::peg::to::cparam::Op::str {modes args} { Asm::Start Asm::ReTerminal str {*}$args Asm::Direct { - set str [join [char quote tcl {*}$args] {}] - set m [Asm::String "str '$str'"] + set str [join $args {}] + # Message is Tcl list. Quote for C embedding. + set msg [Asm::String [char quote cstring [list str $str]]] + # Quote for C embedding + set str [char quote cstring $str] # Without fusing this would be rendered as a sequence of # characters, with associated stack churn for each # character/part (See Op::x, void/all). - Asm::Ins next_str \"$str\" $m + Asm::Ins next_str \"$str\" $msg } Asm::Done } proc ::pt::peg::to::cparam::Op::cl {modes args} { @@ -586,14 +632,17 @@ Asm::Direct { # Without fusing this would be rendered as a choice of # characters, with associated stack churn for each # character/branch (See Op::/, void/all). - set cl [join [Ranges {*}$args] {}] - set m [Asm::String "cl '$cl'"] + set cl [join [Ranges {*}$args] {}] + # Message is Tcl list. Quote for C embedding. + set msg [Asm::String [char quote cstring [list cl $cl]]] + # Quote for C embedding + set cl [char quote cstring $cl] - Asm::Ins next_class \"$cl\" $m + Asm::Ins next_class \"$cl\" $msg } Asm::Done } proc ::pt::peg::to::cparam::Op::Ranges {args} { @@ -624,11 +673,11 @@ for {set i $s} {$i <= $e} {incr i} { append res [format %c $i] } return $res } else { - return [char quote tcl $rorc] + return $rorc ;#[char quote tcl $rorc] } } proc ::pt::peg::to::cparam::Op::n {modes symbol} { # symbol mode determines AST generation @@ -1564,10 +1613,11 @@ variable omap ; array set omap { comments comments file file fun-qualifier def indent indent + insert-cmd insertcmd main main name name namespace ns prelude prelude self-command self @@ -1576,10 +1626,12 @@ string-varname strings template template user user } + variable insertcmd {} + variable comments 1 variable self {} variable ns {} variable def static variable main __main variable indent 0 @@ -1586,13 +1638,14 @@ variable prelude {} variable statedecl {RDE_PARAM p} variable stateref p variable strings p_string - variable template @code@ ; # A string. Specifies how to - # embed the generated code into a - # larger frame- work (the + variable template @code@ ; # A string. Together with the + # insertcmd (if any) it specifies + # how to embed the generated code + # into a larger framework (the # template). variable name a_pe_grammar ; # String. Name of the grammar. variable file unknown ; # String. Name of the file or # other entity the grammar came # from. @@ -1602,7 +1655,7 @@ } # ### ### ### ######### ######### ######### ## Ready -package provide pt::peg::to::cparam 1.1.1 +package provide pt::peg::to::cparam 1.1.3 return Index: modules/pt/pt_peg_to_param.tcl ================================================================== --- modules/pt/pt_peg_to_param.tcl +++ modules/pt/pt_peg_to_param.tcl @@ -1,10 +1,10 @@ # peg_to_param.tcl -- # # Conversion of PEG to PARAM assembler. # -# Copyright (c) 2009 Andreas Kupries +# Copyright (c) 2009-2014 Andreas Kupries # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # # RCS: @(#) $Id: pt_peg_to_param.tcl,v 1.1 2010/03/26 05:07:24 andreas_kupries Exp $ @@ -370,18 +370,18 @@ variable ::pt::peg::to::param::inline Asm::Start Asm::ReTerminal t $char if {$inline} { Asm::Direct { - set c [char quote cstring $char] + set c [char quote string $char] Asm::Ins input_next "\"t $c\"" Asm::Ins ok! test_char \"$c\" } } else { Asm::Function [Asm::NewBlock char ] { - set c [char quote cstring $char] + set c [char quote string $char] Asm::Ins input_next "\"t $c\"" Asm::Ins ok! test_char \"$c\" } } @@ -392,20 +392,20 @@ variable ::pt::peg::to::param::inline Asm::Start Asm::ReTerminal .. $chstart $chend if {$inline} { Asm::Direct { - set s [char quote cstring $chstart] - set e [char quote cstring $chend] + set s [char quote string $chstart] + set e [char quote string $chend] Asm::Ins input_next "\".. $s $e\"" Asm::Ins ok! test_range \"$s\" \"$e\" } } else { Asm::Function [Asm::NewBlock range] { - set s [char quote cstring $chstart] - set e [char quote cstring $chend] + set s [char quote string $chstart] + set e [char quote string $chend] Asm::Ins input_next "\".. $s $e\"" Asm::Ins ok! test_range \"$s\" \"$e\" } } @@ -1023,7 +1023,7 @@ } # ### ### ### ######### ######### ######### ## Ready -package provide pt::peg::to::param 1 +package provide pt::peg::to::param 1.0.1 return Index: modules/pt/pt_peg_to_peg.man ================================================================== --- modules/pt/pt_peg_to_peg.man +++ modules/pt/pt_peg_to_peg.man @@ -1,7 +1,7 @@ [comment {--- doctools ---}] [vset PACKAGE peg] [vset NAME PEG] [vset REQUIRE peg] [vset CONFIG peg] -[vset VERSION 1.0.1] +[vset VERSION 1.0.2] [include include/export/to.inc] Index: modules/pt/pt_peg_to_peg.tcl ================================================================== --- modules/pt/pt_peg_to_peg.tcl +++ modules/pt/pt_peg_to_peg.tcl @@ -1,10 +1,10 @@ # peg_to_peg.tcl -- # # Conversion from PEG to PEG (Human readable text). # -# Copyright (c) 2009 Andreas Kupries +# Copyright (c) 2009-2014 Andreas Kupries # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # # RCS: @(#) $Id: pt_peg_to_peg.tcl,v 1.1 2010/03/26 05:07:24 andreas_kupries Exp $ @@ -205,11 +205,11 @@ # For the inner nodes the each of arguments are a pair of # generated text, and the sub-expression it came from, in this # order. switch -exact -- $operator { - alpha - alnum - ascii - digit - graph - lower - print - + alpha - alnum - ascii - control - digit - graph - lower - print - punct - space - upper - wordchar - xdigit - ddigit { # Special forms ... return [list <$operator> $pe] } dot { @@ -400,14 +400,14 @@ x 1 n 4 digit 4 wordchar 4 & 2 .. 4 graph 4 xdigit 4 ! 2 dot 4 lower 4 ddigit 4 + 3 epsilon 4 print 4 str 4 * 3 alnum 4 punct 4 cl 4 - ? 3 alpha 4 space 4 + ? 3 alpha 4 space 4 control 4 } } # ### ### ### ######### ######### ######### ## Ready -package provide pt::peg::to::peg 1.0.1 +package provide pt::peg::to::peg 1.0.2 return Index: modules/pt/pt_peg_to_tclparam.man ================================================================== --- modules/pt/pt_peg_to_tclparam.man +++ modules/pt/pt_peg_to_tclparam.man @@ -1,7 +1,7 @@ [comment {--- doctools ---}] [vset PACKAGE tclparam] [vset NAME TCLPARAM] [vset REQUIRE tclparam] [vset CONFIG tclparam] -[vset VERSION 1] +[vset VERSION 1.0.1] [include include/export/to.inc] Index: modules/pt/pt_peg_to_tclparam.tcl ================================================================== --- modules/pt/pt_peg_to_tclparam.tcl +++ modules/pt/pt_peg_to_tclparam.tcl @@ -1,10 +1,10 @@ # peg_to_param.tcl -- # # Conversion of PEG to Tcl/C PARAM, customizable text blocks. # -# Copyright (c) 2009 Andreas Kupries +# Copyright (c) 2009-2014 Andreas Kupries # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # # RCS: @(#) $Id: pt_peg_to_tclparam.tcl,v 1.1 2010/03/26 05:07:24 andreas_kupries Exp $ @@ -373,11 +373,11 @@ Op::Asm::Done } namespace eval ::pt::peg::to::tclparam::Op { namespace export \ - alpha alnum ascii digit graph lower print \ + alpha alnum ascii control digit graph lower print \ punct space upper wordchar xdigit ddigit \ dot epsilon t .. n ? * + & ! x / str cl } proc ::pt::peg::to::tclparam::Op {modes pe op arguments} { @@ -401,11 +401,11 @@ } Asm::Done } foreach test { - alpha alnum ascii digit graph lower print + alpha alnum ascii control digit graph lower print punct space upper wordchar xdigit ddigit } { proc ::pt::peg::to::tclparam::Op::$test {modes} \ [string map [list @ $test] { Asm::Start @@ -423,47 +423,48 @@ proc ::pt::peg::to::tclparam::Op::t {modes char} { Asm::Start Asm::ReTerminal t $char Asm::Direct { - set c [char quote tcl $char] + set char [char quote tcl $char] - #Asm::Ins i_input_next "\{t $c\}" + #Asm::Ins i_input_next "\{t $char\}" #Asm::Ins i:fail_return - #Asm::Ins i_test_char $c + #Asm::Ins i_test_char $char - Asm::Ins si:next_char $c + Asm::Ins si:next_char $char } Asm::Done } -proc ::pt::peg::to::tclparam::Op::.. {modes chstart chend} { +proc ::pt::peg::to::tclparam::Op::.. {modes chs che} { Asm::Start - Asm::ReTerminal .. $chstart $chend + Asm::ReTerminal .. $chs $che Asm::Direct { - set s [char quote tcl $chstart] - set e [char quote tcl $chend] + set chs [char quote tcl $chs] + set che [char quote tcl $che] - #Asm::Ins i_input_next "\{.. $s $e\}" + #Asm::Ins i_input_next "\{.. $chs $che\}" #Asm::Ins i:fail_return - #Asm::Ins i_test_range $s $e + #Asm::Ins i_test_range $chs $che - Asm::Ins si:next_range $s $e + Asm::Ins si:next_range $chs $che } Asm::Done } proc ::pt::peg::to::tclparam::Op::str {modes args} { Asm::Start Asm::ReTerminal str {*}$args Asm::Direct { - set str [join [struct::list map $args {char quote tcl}] {}] - # Without fusing this would be rendered as a sequence of # characters, with associated stack churn for each character/part # (See Op::x, void/all). + set str [join $args {}] + set str [char quote tcl $str] + Asm::Ins si:next_str $str } Asm::Done } @@ -474,16 +475,23 @@ Asm::Direct { # Without fusing this would be rendered as a choice of # characters, with associated stack churn for each # character/branch (See Op::/, void/all). - set cl [join [struct::list map $args [namespace current]::Range] {}] + set cl [join [Ranges {*}$args] {}] + set cl [char quote tcl $cl] Asm::Ins si:next_class $cl } Asm::Done } + +proc ::pt::peg::to::tclparam::Op::Ranges {args} { + set res {} + foreach rorc $args { lappend res [Range $rorc] } + return $res +} proc ::pt::peg::to::tclparam::Op::Range {rorc} { # See also pt::peg::to::peg # We use string ops here to distinguish terminals and ranges. The @@ -505,11 +513,11 @@ for {set i $s} {$i <= $e} {incr i} { append res [format %c $i] } return $res } else { - return [char quote tcl $rorc] + return $rorc ;#[char quote tcl $rorc] } } proc ::pt::peg::to::tclparam::Op::n {modes symbol} { # symbol mode determines AST generation @@ -1259,7 +1267,7 @@ } # ### ### ### ######### ######### ######### ## Ready -package provide pt::peg::to::tclparam 1 +package provide pt::peg::to::tclparam 1.0.2 return Index: modules/pt/pt_pegrammar.tcl ================================================================== --- modules/pt/pt_pegrammar.tcl +++ modules/pt/pt_pegrammar.tcl @@ -345,11 +345,11 @@ namespace eval ::pt::peg { # # ## ### ##### ######## ############# variable ourcode pt::grammar::peg variable ourprefix {error in serialization:} - # # Test cases (grammar-peg-structure-) + # # Test cases (grammar-peg-structure-) variable ourshort { dictionary too short, expected exactly one key} ; # variable ourtag { bad type tag "%s"} ; # variable ourcbadlen { dictionary of bad length, expected exactly two keys} ; # variable ourmiss { missing expected key "%s"} ; # variable oursmiss { symbol "%s", missing expected key "%s"} ; # Index: modules/pt/pt_pexpression.man ================================================================== --- modules/pt/pt_pexpression.man +++ modules/pt/pt_pexpression.man @@ -1,10 +1,11 @@ +[vset VERSION 1.0.1] [comment {-*- text -*- doctools manpage}] -[manpage_begin pt::pe n 1] +[manpage_begin pt::pe n [vset VERSION]] [include include/module.inc] [titledesc {Parsing Expression Serialization}] -[require pt::pe [opt 1]] +[require pt::pe [opt [vset VERSION]]] [require char] [description] [include include/ref_intro.inc] This package provides commands to work with the serializations of Index: modules/pt/pt_pexpression.tcl ================================================================== --- modules/pt/pt_pexpression.tcl +++ modules/pt/pt_pexpression.tcl @@ -1,7 +1,7 @@ # -*- tcl -*- -# Copyright (c) 2009 Andreas Kupries +# Copyright (c) 2009-2014 Andreas Kupries # Verification of serialized parsing expressions, conversion # between such and other data structures, and their construction. # # ## ### ##### ######## ############# ##################### @@ -17,14 +17,14 @@ namespace export \ verify verify-as-canonical canonicalize \ bottomup topdown print equal \ \ epsilon dot alnum alpha ascii digit graph lower printable \ - punct space upper wordchar xdigit ddigit \ + control punct space upper wordchar xdigit ddigit \ nonterminal optional repeat0 repeat1 ahead notahead \ choice sequence \ - terminal range + terminal range class str namespace ensemble create } # # ## ### ##### ######## ############# @@ -129,11 +129,11 @@ } proc ::pt::pe::Print {pe op arguments} { switch -exact -- $op { epsilon - alpha - alnum - ascii - digit - graph - lower - print - \ - punct - space - upper - wordchar - xdigit - ddigit - dot { + control - punct - space - upper - wordchar - xdigit - ddigit - dot { return [list <$op>] } str { return [list "\"[join [char quote comment {*}$arguments] {}]\""] } cl { return [list "\[[join [char quote comment {*}$arguments] {}]\]"] } n { return [list "([lindex $arguments 0])"] } @@ -218,10 +218,11 @@ proc ::pt::pe::epsilon {} { return epsilon } proc ::pt::pe::dot {} { return dot } proc ::pt::pe::alnum {} { return alnum } proc ::pt::pe::alpha {} { return alpha } proc ::pt::pe::ascii {} { return ascii } +proc ::pt::pe::control {} { return control } proc ::pt::pe::digit {} { return digit } proc ::pt::pe::graph {} { return graph } proc ::pt::pe::lower {} { return lower } proc ::pt::pe::printable {} { return print } proc ::pt::pe::punct {} { return punct } @@ -239,17 +240,33 @@ proc ::pt::pe::notahead {pe} { list ! $pe } proc ::pt::pe::choice {pe args} { linsert $args 0 / $pe } proc ::pt::pe::sequence {pe args} { linsert $args 0 x $pe } -proc ::pt::pe::terminal {t} { list t $t } -proc ::pt::pe::range {ta tb} { +proc ::pt::pe::terminal {t} { + list t $t +} +proc ::pt::pe::range {ta tb} { if {$ta eq $tb} { list t $ta } else { list .. $ta $tb } +} +proc ::pt::pe::class {set} { + if {[string length $set] > 1} { + list cl $set + } else { + list t $set + } +} +proc ::pt::pe::str {str} { + if {[string length $str] > 1} { + list str $str + } else { + list t $str + } } namespace eval ::pt::pe { # # ## ### ##### ######## ############# ## Strings for error messages. @@ -267,10 +284,11 @@ array set ourarity { epsilon {0 0} alpha {0 0} alnum {0 0} ascii {0 0} + control {0 0} digit {0 0} graph {0 0} lower {0 0} print {0 0} punct {0 0} @@ -297,7 +315,7 @@ } # # ## ### ##### ######## ############# ##################### ## Ready -package provide pt::pe 1 +package provide pt::pe 1.0.2 return Index: modules/pt/pt_pgen.tcl ================================================================== --- modules/pt/pt_pgen.tcl +++ modules/pt/pt_pgen.tcl @@ -1,8 +1,8 @@ # -*- tcl -*- # -# Copyright (c) 2009 by Andreas Kupries +# Copyright (c) 2009-2014 by Andreas Kupries # Grammars / Parsing Expression Grammars / Parser Generator # ### ### ### ######### ######### ######### ## Package description @@ -19,13 +19,14 @@ package require pt::peg::to::json ; # param assembler, package require pt::peg::to::peg ; # package require pt::peg::to::param ; # PARAM assembly, raw package require pt::peg::to::tclparam ; # PARAM assembly, embedded into Tcl package require pt::peg::to::cparam ; # PARAM assembly, embedded into C -package require pt::tclparam::configuration::snit ; # PARAM/Tcl, snit::type -package require pt::tclparam::configuration::tcloo ; # PARAM/Tcl, TclOO class -package require pt::cparam::configuration::critcl ; # PARAM/C, in critcl +package require pt::tclparam::configuration::snit 1.0.2 ; # PARAM/Tcl, snit::type +package require pt::tclparam::configuration::tcloo 1.0.4 ; # PARAM/Tcl, TclOO class +package require pt::cparam::configuration::critcl 1.0.2 ; # PARAM/C, in critcl +package require pt::cparam::configuration::tea ; # PARAM/C, in TEA # ### ### ### ######### ######### ######### ## Implementation namespace eval ::pt::pgen { @@ -53,11 +54,11 @@ # # ## ### ##### ######## ############# ## Internals - Generating the parser. namespace eval ::pt::pgen::Write { - namespace export json peg container param snit oo critcl c + namespace export json peg container param snit oo critcl c tea namespace ensemble create } proc ::pt::pgen::Write::json {args} { # args = (option value)... grammar @@ -83,41 +84,57 @@ return [pt::peg::to::param convert [lindex $args end]] } proc ::pt::pgen::Write::snit {args} { # args = (option value)... grammar - pt::peg::to::tclparam configure {*}[Package [Class [lrange $args 0 end-1]]] + pt::peg::to::tclparam configure {*}[Package [Version [Class [lrange $args 0 end-1]]]] ClassPackageDefaults pt::tclparam::configuration::snit def \ - $class $package \ + $class $package $version \ {pt::peg::to::tclparam configure} return [pt::peg::to::tclparam convert [lindex $args end]] } proc ::pt::pgen::Write::oo {args} { # args = (option value)... grammar - pt::peg::to::tclparam configure {*}[Package [Class [lrange $args 0 end-1]]] + pt::peg::to::tclparam configure {*}[Package [Version [Class [lrange $args 0 end-1]]]] ClassPackageDefaults pt::tclparam::configuration::tcloo def \ - $class $package \ + $class $package $version \ {pt::peg::to::tclparam configure} return [pt::peg::to::tclparam convert [lindex $args end]] } + +proc ::pt::pgen::Write::tea {args} { + # args = (option value)... grammar + # Class -> touches/defines variable 'class' + # Package -> touches/defines variable 'package' + # Version -> touches/defines variable 'version' + pt::peg::to::cparam configure {*}[Package [Version [Class [lrange $args 0 end-1]]]] + ClassPackageDefaults + + pt::cparam::configuration::tea def \ + $class $package $version \ + {pt::peg::to::cparam configure} + + return [pt::peg::to::cparam convert [lindex $args end]] +} proc ::pt::pgen::Write::critcl {args} { # args = (option value)... grammar # Class -> touches/defines variable 'class' # Package -> touches/defines variable 'package' - pt::peg::to::cparam configure {*}[Package [Class [lrange $args 0 end-1]]] + # Version -> touches/defines variable 'version' + pt::peg::to::cparam configure {*}[Package [Version [Class [lrange $args 0 end-1]]]] ClassPackageDefaults pt::cparam::configuration::critcl def \ - $class $package \ + $class $package $version \ {pt::peg::to::cparam configure} return [pt::peg::to::cparam convert [lindex $args end]] } @@ -129,12 +146,13 @@ # ### ### ### ######### ######### ######### ## Internals: Special option handling handling. proc ::pt::pgen::Write::ClassPackageDefaults {} { - upvar 1 class class + upvar 1 class class upvar 1 package package + upvar 1 version version # Initialize undefined class and package names from each other, # i.e. from whichever of the two was specified, or fallback to # hardwired defaults if neither was specified. @@ -144,12 +162,21 @@ set class $package } elseif {![info exists package] && ![info exists class]} { set class CLASS set package PACKAGE } + + # Initialize undefined version information. + + if {![info exists version]} { + set version 1 + } return } + +# Class, Package, Version - identical modulo option and variable name. +# TODO: Refactor into some common code. proc ::pt::pgen::Write::Class {optiondict} { upvar 1 class class set res {} foreach {option value} $optiondict { @@ -172,10 +199,23 @@ } lappend res $option $value } return $res } + +proc ::pt::pgen::Write::Version {optiondict} { + upvar 1 version version + set res {} + foreach {option value} $optiondict { + if {$option eq "-version"} { + set version $value + continue + } + lappend res $option $value + } + return $res +} # ### ### ### ######### ######### ######### ## Package Management -package provide pt::pgen 1.0.2 +package provide pt::pgen 1.0.3 ADDED modules/pt/pt_pgen.test Index: modules/pt/pt_pgen.test ================================================================== --- /dev/null +++ modules/pt/pt_pgen.test @@ -0,0 +1,128 @@ +# -*- tcl -*- +# pt_pgen.test: Testing the parser generator, and the generated parsers. +# Mainly for testing generated parsers for good and bad inputs. +# +# Copyright (c) 2014 by Andreas Kupries +# All rights reserved. +# +# RCS: @(#) $Id: pt_parse_peg.test,v 1.1 2010/03/26 05:07:24 andreas_kupries Exp $ + +# ------------------------------------------------------------------------- + +source [file join \ + [file dirname [file dirname [file join [pwd] [info script]]]] \ + devtools testutilities.tcl] + +testsNeedTcl 8.5 +testsNeedTcltest 2 + +# Check if we have critcl available. +tcltest::testConstraint critcl [expr {![catch {package require critcl}]}] + + +support { + useAccel [useTcllibC] struct/stack.tcl struct::stack ; # User: pt::rde + TestAccelInit struct::stack ; # (tcl) + + useAccel [useTcllibC] struct/sets.tcl struct::set + TestAccelInit struct::set + + if {![package vsatisfies [package present Tcl] 8.6]} { + # Pull in try emulation for 8.5. Tcl 8.6 has it builtin. + use try/try.tcl try + } + use snit/snit.tcl snit + use fileutil/fileutil.tcl fileutil ;# tests/common + use textutil/adjust.tcl textutil::adjust + + useLocal pt_util.tcl pt::util + useLocal pt_astree.tcl pt::ast + useLocal pt_pexpression.tcl pt::pe + useLocal pt_pexpr_op.tcl pt::pe::op + useLocal pt_pegrammar.tcl pt::peg + useLocal pt_peg_container.tcl pt::peg::container + + useAccel [useTcllibC] pt/pt_rdengine.tcl pt::rde ; # User: pt::parse::peg + TestAccelInit pt::rde ; # and: pt:peg::interp + + useLocal pt_rdengine_oo.tcl pt::rde::oo + useLocal pt_peg_interp.tcl pt::peg::interp + + useAccel [useTcllibC] pt/pt_parse_peg.tcl pt::parse::peg ; # User: pt::peg::from::peg + TestAccelInit pt::parse::peg + + useLocal pt_peg_from_json.tcl pt::peg::from::json ; # Frontends: json, and PEG text form + useLocal pt_peg_from_peg.tcl pt::peg::from::peg ; # + useLocal pt_peg_to_container.tcl pt::peg::to::container ; # Backends: json, peg, container code, + useLocal pt_peg_to_json.tcl pt::peg::to::json ; # param assembler, + useLocal pt_peg_to_peg.tcl pt::peg::to::peg ; # + useLocal pt_peg_to_param.tcl pt::peg::to::param ; # PARAM assembly, raw + useLocal pt_peg_to_tclparam.tcl pt::peg::to::tclparam ; # PARAM assembly, embedded into Tcl + useLocal pt_peg_to_cparam.tcl pt::peg::to::cparam ; # PARAM assembly, embedded into C + useLocal pt_tclparam_config_snit.tcl pt::tclparam::configuration::snit ; # PARAM/Tcl, snit::type + useLocal pt_tclparam_config_tcloo.tcl pt::tclparam::configuration::tcloo ; # PARAM/Tcl, TclOO class + useLocal pt_cparam_config_critcl.tcl pt::cparam::configuration::critcl ; # PARAM/C, in critcl + + # Get the parser used by the converter, either the grammar + # interpreter, or snit-based and spcialized to PEG. + #useLocal pt_peg_container_peg.tcl pt::peg::container::peg + #useLocal pt_peg_interp.tcl pt::peg::interp + + source [localPath tests/common] +} +testing { + useLocal pt_pgen.tcl pt::pgen ;# Generator +} + +set mytestdir tests/data + +# Table of test cases ... +# Id PEG InText Error detail Readable char +set chars {} +lappend chars 0 \{ \{ [list t \{] \{ +lappend chars 1 \[ \[ [list t \[] \[ +lappend chars 2 \" \" [list t \"] \" +lappend chars 3 \\033 \033 [list t \33] +lappend chars 4 \\n \n [list t \n] +lappend chars 5 \\r \r [list t \r] +lappend chars 6 \\t \t [list t \t] +# \b, \f, \v - Extend PEG grammar to recognize. Also \e = \33 +lappend chars 7 \\010 \b [list t \b] +lappend chars 8 \\014 \f [list t \f] +lappend chars 9 \\013 \v [list t \v] +lappend chars 10 \\007 \a [list t \a] +lappend chars 11 { } { } [list t { }] +lappend chars 12 \\\\ \\ [list t \\] \\ + # math symbol, circled asterix +lappend chars 13 \\u229b \u229b [list t \u229b] \u229b +# test all control characters ... (and DEL) +# more characters: above ascii = unicode BMP. + +# Grammar for all test cases below, with the actual character mapped +# in (replacing @). +set gtemplate "PEG a_pe_grammar ('@') END;" +set etemplate "Parse error at position 0 (Line 0, column 0).\n... X ...\n ^\nExpected one of\n* The character '@'\n" + +# ------------------------------------------------------------------------- +# While some of the C pieces are usually not required at runtime (like +# C stack when RDE is also C), we are calling on the parser generator +# here, which still may use a different implementation. So, no +# shurtcuts, and full 16x expansion (2^4). + +TestAccelDo struct::set setimpl { + TestAccelDo pt::parse::peg parseimpl { + TestAccelDo pt::rde rdeimpl { + TestAccelDo struct::stack stackimpl { + source [localPath tests/pt_pgen.tests] + } + } + } +} + +# ------------------------------------------------------------------------- +TestAccelExit struct::stack +TestAccelExit pt::rde +TestAccelExit pt::parse::peg +TestAccelExit struct::set +testsuiteCleanup +return Index: modules/pt/pt_rdengine.man ================================================================== --- modules/pt/pt_rdengine.man +++ modules/pt/pt_rdengine.man @@ -1,10 +1,11 @@ +[vset VERSION 1.0.3] [comment {-*- text -*- doctools manpage}] -[manpage_begin pt::rde n 1.0.2] +[manpage_begin pt::rde n [vset VERSION]] [include include/module.inc] [titledesc {Parsing Runtime Support, PARAM based}] -[require pt::rde [opt 1.0.2]] +[require pt::rde [opt [vset VERSION]]] [require snit] [require struct::stack 1.4] [require pt::ast 1.1] [description] [include include/ref_intro.inc] Index: modules/pt/pt_rdengine.tcl ================================================================== --- modules/pt/pt_rdengine.tcl +++ modules/pt/pt_rdengine.tcl @@ -1,8 +1,8 @@ # -*- tcl -*- # -# Copyright (c) 2009 by Andreas Kupries +# Copyright (c) 2009-2014 by Andreas Kupries # # ## ### ##### ######## ############# ##################### ## Package description ## Implementation of the PackRat Machine (PARAM), a virtual machine on @@ -182,6 +182,6 @@ namespace eval ::pt { # Export the constructor command. namespace export rde } -package provide pt::rde 1.0.2 +package provide pt::rde 1.0.3 Index: modules/pt/pt_rdengine_c.tcl ================================================================== --- modules/pt/pt_rdengine_c.tcl +++ modules/pt/pt_rdengine_c.tcl @@ -1,8 +1,8 @@ # -*- tcl -*- # -# Copyright (c) 2009 by Andreas Kupries +# Copyright (c) 2009-2014 by Andreas Kupries # # ## ### ##### ######## ############# ##################### ## Package description ## Implementation of the PackRat Machine (PARAM), a virtual machine on @@ -16,11 +16,11 @@ ## Requisites package require Tcl 8.4 package require critcl # @sak notprovided pt_rde_critcl -package provide pt_rde_critcl 1.3.2 +package provide pt_rde_critcl 1.3.3 # # ## ### ##### ######## ############# ##################### ## Implementation namespace eval ::pt { @@ -74,11 +74,11 @@ Tcl_SetAssocData (interp, KEY, proc, (ClientData) paramg); } paramg->counter ++; - sprintf (paramg->buf, "rde%d", paramg->counter); + sprintf (paramg->buf, "rde%ld", paramg->counter); return paramg->buf; #undef KEY } @@ -162,7 +162,7 @@ } # # ## ### ##### ######## ############# ##################### ## Ready -package provide pt::rde::critcl 1 +package provide pt::rde::critcl 1.0.3 return Index: modules/pt/pt_rdengine_oo.tcl ================================================================== --- modules/pt/pt_rdengine_oo.tcl +++ modules/pt/pt_rdengine_oo.tcl @@ -1,8 +1,8 @@ # -*- tcl -*- # -# Copyright (c) 2009 by Andreas Kupries +# Copyright (c) 2009-2014 by Andreas Kupries # # ## ### ##### ######## ############# ##################### ## Package description ## Implementation of the PackRat Machine (PARAM), a virtual machine on @@ -70,16 +70,20 @@ if {$n > 1} { set pos [$mystackloc peek] incr pos set children [lreverse [$mystackast peek [$mystackast size]]] ; # SaveToMark return [pt::ast new {} $pos $myloc {*}$children] ; # Reduce ALL + } elseif {$n == 0} { + # Match, but no AST. This is possible if the grammar + # consists of only the start expression. + return {} } else { return [$mystackast peek] } } else { lassign $myerror loc messages - return -code error [list pt::rde $loc [$self position $loc] $messages] + return -code error [list pt::rde $loc $messages] } } # # ## ### ##### ######## ############# ##################### ## API - State accessors @@ -357,11 +361,11 @@ if {$myok} { $mystackloc pop return -code return } set myloc [$mystackloc peek] - $mystackerr push {} + $mystackerr push $myerror return } method si:voidvalue_branch {} { # i_error_pop_merge @@ -588,11 +592,11 @@ set max [string length $mytoken] incr myloc if {($last >= $max) && ![my ExtendTCN [expr {$last - $max + 1}]]} { set myok 0 - set myerror [list $myloc [list [list t $tok]]] + set myerror [list $myloc [list [list str $tok]]] # i:fail_return return } set lex [string range $mytoken $myloc $last] set mycurrent [string index $mytoken $last] @@ -601,11 +605,11 @@ if {$myok} { set myloc $last set myerror {} } else { - set myerror [list $myloc [list [list t $tok]]] + set myerror [list $myloc [list [list str $tok]]] incr myloc -1 } return } @@ -617,11 +621,11 @@ # i_test_ incr myloc if {($myloc >= [string length $mytoken]) && ![my ExtendTC]} { set myok 0 - set myerror [list $myloc [list [list t $tok]]] + set myerror [list $myloc [list [list cl $tok]]] # i:fail_return return } set mycurrent [string index $mytoken $myloc] @@ -631,11 +635,11 @@ set myok [expr {[string first $mycurrent $tok] >= 0}] if {$myok} { set myerror {} } else { - set myerror [list $myloc [list [list t $tok]]] + set myerror [list $myloc [list [list cl $tok]]] incr myloc -1 } return } @@ -756,10 +760,34 @@ set myok [string is ascii -strict $mycurrent] if {!$myok} { set myerror [list $myloc [list ascii]] incr myloc -1 + } else { + set myerror {} + } + return + } + + method si:next_control {} { ; #TRACE puts "[format %8d [incr count]] RDE si:next_control" + #Asm::Ins i_input_next control + #Asm::Ins i:fail_return + #Asm::Ins i_test_control + + incr myloc + if {($myloc >= [string length $mytoken]) && ![my ExtendTC]} { + set myok 0 + set myerror [list $myloc [list control]] + # i:fail_return + return + } + set mycurrent [string index $mytoken $myloc] + + set myok [string is control -strict $mycurrent] + if {!$myok} { + set myerror [list $myloc [list control]] + incr myloc -1 } else { set myerror {} } return } @@ -1113,18 +1141,19 @@ } set k [list $at $symbol] set mysymbol($k) [list $myloc $myok $myerror $mysvalue] - if {[llength $myerror]} { + # si:reduce_symbol_end / i_error_nonterminal -- inlined -- disabled + if {0} {if {[llength $myerror]} { set pos $at incr pos lassign $myerror loc messages if {$loc == $pos} { set myerror [list $loc [list [list n $symbol]]] } - } + }} $mystackast trim* [$mystackmark pop] if {$myok} { $mystackast push $mysvalue } @@ -1156,18 +1185,19 @@ } set k [list $at $symbol] set mysymbol($k) [list $myloc $myok $myerror $mysvalue] - if {[llength $myerror]} { + # si:void_leaf_symbol_end / i_error_nonterminal -- inlined -- disabled + if {0} {if {[llength $myerror]} { set pos $at incr pos lassign $myerror loc messages if {$loc == $pos} { set myerror [list $loc [list [list n $symbol]]] } - } + }} if {$myok} { $mystackast push $mysvalue } return @@ -1199,18 +1229,19 @@ } set k [list $at $symbol] set mysymbol($k) [list $myloc $myok $myerror $mysvalue] - if {[llength $myerror]} { + # si:value_leaf_symbol_end / i_error_nonterminal -- inlined -- disabled + if {0} {if {[llength $myerror]} { set pos $at incr pos lassign $myerror loc messages if {$loc == $pos} { set myerror [list $loc [list [list n $symbol]]] } - } + }} $mystackast trim* [$mystackmark pop] if {$myok} { $mystackast push $mysvalue } @@ -1228,18 +1259,19 @@ set at [$mystackloc pop] set k [list $at $symbol] set mysymbol($k) [list $myloc $myok $myerror $mysvalue] - if {[llength $myerror]} { + # si:value_clear_symbol_end / i_error_nonterminal -- inlined -- disabled + if {0} {if {[llength $myerror]} { set pos $at incr pos lassign $myerror loc messages if {$loc == $pos} { set myerror [list $loc [list [list n $symbol]]] } - } + }} $mystackast trim* [$mystackmark pop] return } @@ -1253,18 +1285,19 @@ set at [$mystackloc pop] set k [list $at $symbol] set mysymbol($k) [list $myloc $myok $myerror $mysvalue] - if {[llength $myerror]} { + # si:void_clear_symbol_end / i_error_nonterminal -- inlined -- disabled + if {0} {if {[llength $myerror]} { set pos $at incr pos lassign $myerror loc messages if {$loc == $pos} { set myerror [list $loc [list [list n $symbol]]] } - } + }} return } # # ## ### ##### ######## ############# ##################### ## API - Instructions - Control flow @@ -1348,10 +1381,17 @@ set myerror [list $loe [lsort -uniq [list {*}$msgse {*}$msgsn]]] return } method i_error_nonterminal {symbol} { + # i_error_nonterminal -- Disabled. Generate only low-level + # i_error_nonterminal -- errors until we have worked out how + # i_error_nonterminal -- to integrate symbol information with + # i_error_nonterminal -- them. Do not forget where this + # i_error_nonterminal -- instruction is inlined. + return + # Inlined: Errors, Expected. if {![llength $myerror]} return set pos [$mystackloc peek] incr pos lassign $myerror loc messages @@ -1548,10 +1588,16 @@ method i_test_ascii {} { set myok [string is ascii -strict $mycurrent] my OkFail [pt::pe ascii] return } + + method i_test_control {} { + set myok [string is control -strict $mycurrent] + my OkFail [pt::pe control] + return + } method i_test_char {tok} { set myok [expr {$tok eq $mycurrent}] my OkFail [pt::pe terminal $tok] return @@ -1692,7 +1738,7 @@ } # # ## ### ##### ######## ############# ##################### ## Ready -package provide pt::rde::oo 1.0.2 +package provide pt::rde::oo 1.0.3 return Index: modules/pt/pt_rdengine_tcl.tcl ================================================================== --- modules/pt/pt_rdengine_tcl.tcl +++ modules/pt/pt_rdengine_tcl.tcl @@ -1,8 +1,8 @@ # -*- tcl -*- # -# Copyright (c) 2009 by Andreas Kupries +# Copyright (c) 2009-2014 by Andreas Kupries # # ## ### ##### ######## ############# ##################### ## Package description ## Implementation of the PackRat Machine (PARAM), a virtual machine on @@ -19,10 +19,11 @@ package require Tcl 8.5 package require snit package require struct::stack 1.5 ; # Requiring peekr, getr, trim* methods package require pt::ast package require pt::pe +package require char ; # quoting # # ## ### ##### ######## ############# ##################### ## Implementation snit::type ::pt::rde_tcl { @@ -37,12 +38,14 @@ set mystackmark [struct::stack ${selfns}::MARK] ; # s.a. return } #TRACE variable count 0 + #variable count 0 - method reset {{chan {}}} { ; #TRACE puts "[format %8d [incr count]] RDE reset" + method reset {{chan {}}} { ; #set count 0 + ; #TRACE puts "[format %8d [incr count]] RDE reset" set mychan $chan ; # IN set mycurrent {} ; # CC set myloc -1 ; # CL set myok 0 ; # ST set msvalue {} ; # SV @@ -63,16 +66,22 @@ if {$n > 1} { set pos [$mystackloc peek] incr pos set children [$mystackast peekr [$mystackast size]] ; # SaveToMark return [pt::ast new {} $pos $myloc {*}$children] ; # Reduce ALL + } elseif {$n == 0} { + # Match, but no AST. This is possible if the grammar + # consists of only the start expression. + return {} } else { return [$mystackast peek] } } else { lassign $myerror loc messages - return -code error [list pt::rde $loc $messages] + return -code error \ + -errorcode {PT RDE SYNTAX} \ + [list pt::rde $loc $messages] } } # # ## ### ##### ######## ############# ##################### ## API - State accessors @@ -125,28 +134,28 @@ } # # ## ### ##### ######## ############# ##################### ## Common instruction sequences - method si:void_state_push {} { + method si:void_state_push {} { ; #TRACE puts "[format %8d [incr count]] RDE si:void_state_push" # i_loc_push # i_error_clear_push $mystackloc push $myloc set myerror {} $mystackerr push {} return } - method si:void2_state_push {} { + method si:void2_state_push {} { ; #TRACE puts "[format %8d [incr count]] RDE si:void2_state_push" # i_loc_push # i_error_push $mystackloc push $myloc $mystackerr push {} return } - method si:value_state_push {} { + method si:value_state_push {} { ; #TRACE puts "[format %8d [incr count]] RDE si:value_state_push" # i_ast_push # i_loc_push # i_error_clear_push $mystackmark push [$mystackast size] $mystackloc push $myloc @@ -155,11 +164,11 @@ return } # - -- --- ----- -------- ------------- --------------------- - method si:void_state_merge {} { + method si:void_state_merge {} { ; #TRACE puts "[format %8d [incr count]] RDE si:void_state_merge" # i_error_pop_merge # i_loc_pop_rewind/discard set olderror [$mystackerr pop] # We have either old or new error data, keep it. @@ -184,11 +193,11 @@ if {$myok} return set myloc $last return } - method si:void_state_merge_ok {} { + method si:void_state_merge_ok {} { ; #TRACE puts "[format %8d [incr count]] RDE si:void_state_merge_ok" # i_error_pop_merge # i_loc_pop_rewind/discard # i_status_ok set olderror [$mystackerr pop] @@ -215,11 +224,11 @@ set myloc $last set myok 1 return } - method si:value_state_merge {} { + method si:value_state_merge {} { ; #TRACE puts "[format %8d [incr count]] RDE si:value_state_merge" # i_error_pop_merge # i_ast_pop_rewind/discard # i_loc_pop_rewind/discard set olderror [$mystackerr pop] @@ -249,29 +258,29 @@ return } # - -- --- ----- -------- ------------- --------------------- - method si:value_notahead_start {} { + method si:value_notahead_start {} { ; #TRACE puts "[format %8d [incr count]] RDE si:value_notahead_start" # i_loc_push # i_ast_push $mystackloc push $myloc $mystackmark push [$mystackast size] return } - method si:void_notahead_exit {} { + method si:void_notahead_exit {} { ; #TRACE puts "[format %8d [incr count]] RDE si:void_notahead_exit" # i_loc_pop_rewind # i_status_negate set myloc [$mystackloc pop] set myok [expr {!$myok}] return } - method si:value_notahead_exit {} { + method si:value_notahead_exit {} { ; #TRACE puts "[format %8d [incr count]] RDE si:value_notahead_exit" # i_ast_pop_discard/rewind # i_loc_pop_rewind # i_status_negate set mark [$mystackmark pop] @@ -283,21 +292,21 @@ return } # - -- --- ----- -------- ------------- --------------------- - method si:kleene_abort {} { + method si:kleene_abort {} { ; #TRACE puts "[format %8d [incr count]] RDE si:kleene_abort" # i_loc_pop_rewind/discard # i:fail_return set last [$mystackloc pop] if {$myok} return set myloc $last return -code return } - method si:kleene_close {} { + method si:kleene_close {} { ; #TRACE puts "[format %8d [incr count]] RDE si:kleene_close" # i_error_pop_merge # i_loc_pop_rewind/discard # i:fail_status_ok # i:fail_return @@ -327,11 +336,11 @@ return -code return } # - -- --- ----- -------- ------------- --------------------- - method si:voidvoid_branch {} { + method si:voidvoid_branch {} { ; #TRACE puts "[format %8d [incr count]] RDE si:voidvoid_branch" # i_error_pop_merge # i:ok_loc_pop_discard # i:ok_return # i_loc_rewind # i_error_push @@ -358,15 +367,15 @@ if {$myok} { $mystackloc pop return -code return } set myloc [$mystackloc peek] - $mystackerr push {} + $mystackerr push $myerror return } - method si:voidvalue_branch {} { + method si:voidvalue_branch {} { ; #TRACE puts "[format %8d [incr count]] RDE si:voidvalue_branch" # i_error_pop_merge # i:ok_loc_pop_discard # i:ok_return # i_ast_push # i_loc_rewind @@ -399,11 +408,11 @@ set myloc [$mystackloc peek] $mystackerr push {} return } - method si:valuevoid_branch {} { + method si:valuevoid_branch {} { ; #TRACE puts "[format %8d [incr count]] RDE si:valuevoid_branch" # i_error_pop_merge # i_ast_pop_rewind/discard # i:ok_loc_pop_discard # i:ok_return # i_loc_rewind @@ -436,11 +445,11 @@ set myloc [$mystackloc peek] $mystackerr push {} return } - method si:valuevalue_branch {} { + method si:valuevalue_branch {} { ; #TRACE puts "[format %8d [incr count]] RDE si:valuevalue_branch" # i_error_pop_merge # i_ast_pop_discard # i:ok_loc_pop_discard # i:ok_return # i_ast_rewind @@ -476,11 +485,11 @@ return } # - -- --- ----- -------- ------------- --------------------- - method si:voidvoid_part {} { + method si:voidvoid_part {} { ; #TRACE puts "[format %8d [incr count]] RDE si:voidvoid_part" # i_error_pop_merge # i:fail_loc_pop_rewind # i:fail_return # i_error_push @@ -508,11 +517,11 @@ } $mystackerr push $myerror return } - method si:voidvalue_part {} { + method si:voidvalue_part {} { ; #TRACE puts "[format %8d [incr count]] RDE si:voidvalue_part" # i_error_pop_merge # i:fail_loc_pop_rewind # i:fail_return # i_ast_push # i_error_push @@ -542,11 +551,11 @@ $mystackmark push [$mystackast size] $mystackerr push $myerror return } - method si:valuevalue_part {} { + method si:valuevalue_part {} { ; #TRACE puts "[format %8d [incr count]] RDE si:valuevalue_part" # i_error_pop_merge # i:fail_ast_pop_rewind # i:fail_loc_pop_rewind # i:fail_return # i_error_push @@ -578,51 +587,59 @@ return } # - -- --- ----- -------- ------------- --------------------- - method si:next_str {tok} { - # String = sequence of characters. No need for all the intermediate - # stack churn. + method si:next_str {tok} { ; #TRACE puts "[format %8d [incr count]] RDE si:next_str ($tok)" + # String = sequence of characters. + # No need for all the intermediate stack churn. set n [string length $tok] set last [expr {$myloc + $n}] set max [string length $mytoken] incr myloc if {($last >= $max) && ![ExtendTCN [expr {$last - $max + 1}]]} { set myok 0 - set myerror [list $myloc [list [list t $tok]]] + set myerror [list $myloc [list [pt::pe str $tok]]] # i:fail_return return } set lex [string range $mytoken $myloc $last] set mycurrent [string index $mytoken $last] + + # ATTENTION: The error output of this instruction is different + # from a regular sequence of si:next_char instructions. The + # error location will be the start of the string token we + # wanted to match, and the message will contain the entire + # string token. In the regular sequence we would see the exact + # point of the mismatch instead, with the message containing + # the expected character. set myok [expr {$tok eq $lex}] if {$myok} { set myloc $last set myerror {} } else { - set myerror [list $myloc [list [list t $tok]]] + set myerror [list $myloc [list [pt::pe str $tok]]] incr myloc -1 } return } - method si:next_class {tok} { + method si:next_class {tok} { ; #TRACE puts "[format %8d [incr count]] RDE si:next_class ($tok)" # Class = Choice of characters. No need for stack churn. # i_input_next "\{t $c\}" # i:fail_return # i_test_ incr myloc if {($myloc >= [string length $mytoken]) && ![ExtendTC]} { set myok 0 - set myerror [list $myloc [list [list t $tok]]] + set myerror [list $myloc [list [pt::pe class $tok]]] # i:fail_return return } set mycurrent [string index $mytoken $myloc] @@ -632,49 +649,49 @@ set myok [expr {[string first $mycurrent $tok] >= 0}] if {$myok} { set myerror {} } else { - set myerror [list $myloc [list [list t $tok]]] + set myerror [list $myloc [list [pt::pe class $tok]]] incr myloc -1 } return } - method si:next_char {tok} { + method si:next_char {tok} { ; #TRACE puts "[format %8d [incr count]] RDE si:next_char ($tok)" # i_input_next "\{t $c\}" # i:fail_return # i_test_char $c incr myloc if {($myloc >= [string length $mytoken]) && ![ExtendTC]} { set myok 0 - set myerror [list $myloc [list [list t $tok]]] + set myerror [list $myloc [list [pt::pe terminal $tok]]] # i:fail_return return } set mycurrent [string index $mytoken $myloc] set myok [expr {$tok eq $mycurrent}] if {$myok} { set myerror {} } else { - set myerror [list $myloc [list [list t $tok]]] + set myerror [list $myloc [list [pt::pe terminal $tok]]] incr myloc -1 } return } - method si:next_range {toks toke} { + method si:next_range {toks toke} { ; #TRACE puts "[format %8d [incr count]] RDE si:next_range ($toks $toke)" #Asm::Ins i_input_next "\{.. $s $e\}" #Asm::Ins i:fail_return #Asm::Ins i_test_range $s $e incr myloc if {($myloc >= [string length $mytoken]) && ![ExtendTC]} { set myok 0 - set myerror [list $myloc [list [list .. $toks $toke]]] + set myerror [list $myloc [list [pt::pe range $toks $toke]]] # i:fail_return return } set mycurrent [string index $mytoken $myloc] @@ -757,10 +774,34 @@ set myok [string is ascii -strict $mycurrent] if {!$myok} { set myerror [list $myloc [list ascii]] incr myloc -1 + } else { + set myerror {} + } + return + } + + method si:next_control {} { ; #TRACE puts "[format %8d [incr count]] RDE si:next_control" + #Asm::Ins i_input_next control + #Asm::Ins i:fail_return + #Asm::Ins i_test_control + + incr myloc + if {($myloc >= [string length $mytoken]) && ![ExtendTC]} { + set myok 0 + set myerror [list $myloc [list control]] + # i:fail_return + return + } + set mycurrent [string index $mytoken $myloc] + + set myok [string is control -strict $mycurrent] + if {!$myok} { + set myerror [list $myloc [list control]] + incr myloc -1 } else { set myerror {} } return } @@ -1005,11 +1046,11 @@ return } # - -- --- ----- -------- ------------- --------------------- - method si:value_symbol_start {symbol} { + method si:value_symbol_start {symbol} { ; #TRACE puts "[format %8d [incr count]] RDE si:value_symbol_start ($symbol)" # if @runtime@ i_symbol_restore $symbol # i:found:ok_ast_value_push # i:found_return # i_loc_push # i_ast_push @@ -1025,11 +1066,11 @@ $mystackloc push $myloc $mystackmark push [$mystackast size] return } - method si:value_void_symbol_start {symbol} { + method si:value_void_symbol_start {symbol} { ; #TRACE puts "[format %8d [incr count]] RDE si:value_void_symbol_start ($symbol)" # if @runtime@ i_symbol_restore $symbol # i:found_return # i_loc_push # i_ast_push @@ -1041,11 +1082,11 @@ $mystackloc push $myloc $mystackmark push [$mystackast size] return } - method si:void_symbol_start {symbol} { + method si:void_symbol_start {symbol} { ; #TRACE puts "[format %8d [incr count]] RDE si:void_symbol_start ($symbol)" # if @runtime@ i_symbol_restore $symbol # i:found:ok_ast_value_push # i:found_return # i_loc_push @@ -1059,11 +1100,11 @@ } $mystackloc push $myloc return } - method si:void_void_symbol_start {symbol} { + method si:void_void_symbol_start {symbol} { ; #TRACE puts "[format %8d [incr count]] RDE si:void_void_symbol_start ($symbol)" # if @runtime@ i_symbol_restore $symbol # i:found_return # i_loc_push set k [list $myloc $symbol] @@ -1073,11 +1114,11 @@ } $mystackloc push $myloc return } - method si:reduce_symbol_end {symbol} { + method si:reduce_symbol_end {symbol} { ; #TRACE puts "[format %8d [incr count]] RDE si:reduce_symbol_end ($symbol)" # i_value_clear/reduce $symbol # i_symbol_save $symbol # i_error_nonterminal $symbol # i_ast_pop_rewind # i_loc_pop_discard @@ -1114,27 +1155,28 @@ } set k [list $at $symbol] set mysymbol($k) [list $myloc $myok $myerror $mysvalue] - if {[llength $myerror]} { + # si:reduce_symbol_end / i_error_nonterminal -- inlined -- disabled + if {0} {if {[llength $myerror]} { set pos $at incr pos lassign $myerror loc messages if {$loc == $pos} { set myerror [list $loc [list [list n $symbol]]] } - } + }} $mystackast trim* [$mystackmark pop] if {$myok} { $mystackast push $mysvalue } return } - method si:void_leaf_symbol_end {symbol} { + method si:void_leaf_symbol_end {symbol} { ; #TRACE puts "[format %8d [incr count]] RDE si:void_leaf_symbol_end ($symbol)" # i_value_clear/leaf $symbol # i_symbol_save $symbol # i_error_nonterminal $symbol # i_loc_pop_discard # i:ok_ast_value_push @@ -1157,26 +1199,27 @@ } set k [list $at $symbol] set mysymbol($k) [list $myloc $myok $myerror $mysvalue] - if {[llength $myerror]} { + # si:void_leaf_symbol_end / i_error_nonterminal -- inlined -- disabled + if {0} {if {[llength $myerror]} { set pos $at incr pos lassign $myerror loc messages if {$loc == $pos} { set myerror [list $loc [list [list n $symbol]]] } - } + }} if {$myok} { $mystackast push $mysvalue } return } - method si:value_leaf_symbol_end {symbol} { + method si:value_leaf_symbol_end {symbol} { ; #TRACE puts "[format %8d [incr count]] RDE si:value_leaf_symbol_end ($symbol)" # i_value_clear/leaf $symbol # i_symbol_save $symbol # i_error_nonterminal $symbol # i_loc_pop_discard # i_ast_pop_rewind @@ -1200,27 +1243,28 @@ } set k [list $at $symbol] set mysymbol($k) [list $myloc $myok $myerror $mysvalue] - if {[llength $myerror]} { + # si:value_leaf_symbol_end / i_error_nonterminal -- inlined -- disabled + if {0} {if {[llength $myerror]} { set pos $at incr pos lassign $myerror loc messages if {$loc == $pos} { set myerror [list $loc [list [list n $symbol]]] } - } + }} $mystackast trim* [$mystackmark pop] if {$myok} { $mystackast push $mysvalue } return } - method si:value_clear_symbol_end {symbol} { + method si:value_clear_symbol_end {symbol} { ; #TRACE puts "[format %8d [incr count]] RDE si:value_clear_symbol_end ($symbol)" # i_value_clear # i_symbol_save $symbol # i_error_nonterminal $symbol # i_loc_pop_discard # i_ast_pop_rewind @@ -1229,24 +1273,25 @@ set at [$mystackloc pop] set k [list $at $symbol] set mysymbol($k) [list $myloc $myok $myerror $mysvalue] - if {[llength $myerror]} { + # si:value_clear_symbol_end / i_error_nonterminal -- inlined -- disabled + if {0} {if {[llength $myerror]} { set pos $at incr pos lassign $myerror loc messages if {$loc == $pos} { set myerror [list $loc [list [list n $symbol]]] } - } + }} $mystackast trim* [$mystackmark pop] return } - method si:void_clear_symbol_end {symbol} { + method si:void_clear_symbol_end {symbol} { ; #TRACE puts "[format %8d [incr count]] RDE si:void_clear_symbol_end ($symbol)" # i_value_clear # i_symbol_save $symbol # i_error_nonterminal $symbol # i_loc_pop_discard @@ -1254,18 +1299,19 @@ set at [$mystackloc pop] set k [list $at $symbol] set mysymbol($k) [list $myloc $myok $myerror $mysvalue] - if {[llength $myerror]} { + # si:void_clear_symbol_end / i_error_nonterminal -- inlined -- disabled + if {0} {if {[llength $myerror]} { set pos $at incr pos lassign $myerror loc messages if {$loc == $pos} { set myerror [list $loc [list [list n $symbol]]] } - } + }} return } # # ## ### ##### ######## ############# ##################### ## API - Instructions - Control flow @@ -1314,22 +1360,22 @@ method i_error_clear {} { ; #TRACE puts "[format %8d [incr count]] RDE i_error_clear" set myerror {} return } - method i_error_push {} { ; #TRACE puts "[format %8d [incr count]] RDE i_error_push" + method i_error_push {} { ; #TRACE puts "[format %8d [incr count]] RDE i_error_push ($myerror)" $mystackerr push $myerror return } - method i_error_clear_push {} { ; #TRACE puts "[format %8d [incr count]] RDE i_error_clear_push" + method i_error_clear_push {} { ; #TRACE puts "[format %8d [incr count]] RDE i_error_clear_push ()" set myerror {} $mystackerr push {} return } - method i_error_pop_merge {} { ; #TRACE puts "[format %8d [incr count]] RDE i_error_pop_merge" + method i_error_pop_merge {} { ; #TRACE puts "[format %8d [incr count]] RDE i_error_pop_merge ($myerror)-/-([$mystackerr peek])" set olderror [$mystackerr pop] # We have either old or new error data, keep it. if {![llength $myerror]} { set myerror $olderror ; return } @@ -1347,18 +1393,32 @@ # Equal locations, merge the message lists, set-like. set myerror [list $loe [lsort -uniq [list {*}$msgse {*}$msgsn]]] return } - method i_error_nonterminal {symbol} { ; #TRACE puts "[format %8d [incr count]] RDE i_error_nonterminal" + method i_error_nonterminal {symbol} { ; #TRACE puts "[format %8d [incr count]] RDE i_error_nonterminal ($symbol)" + # i_error_nonterminal -- Disabled. Generate only low-level + # i_error_nonterminal -- errors until we have worked out how + # i_error_nonterminal -- to integrate symbol information with + # i_error_nonterminal -- them. Do not forget where this + # i_error_nonterminal -- instruction is inlined. + return + # Inlined: Errors, Expected. - if {![llength $myerror]} return + if {![llength $myerror]} { + #TRACE puts "[format %8d $count] RDE i_error_nonterminal ($symbol) no error" + return + } set pos [$mystackloc peek] incr pos lassign $myerror loc messages - if {$loc != $pos} return + if {$loc != $pos} { + #TRACE puts "[format %8d $count] RDE i_error_nonterminal ($symbol) -- $myerror != $pos" + return + } set myerror [list $loc [list [list n $symbol]]] + TRACE puts "[format %8d $count] RDE i_error_nonterminal ($symbol) := $myerror" return } # # ## ### ##### ######## ############# ##################### ## API - Instructions - Basic input handling and tracking @@ -1499,11 +1559,11 @@ method i_value_clear {} { ; #TRACE puts "[format %8d [incr count]] RDE i_value_clear" set mysvalue {} return } - method i_value_clear/leaf {symbol} { ; #TRACE puts "[format %8d [incr count]] RDE i_value_clear/leaf (ok $myok ([expr {[$mystackloc peek]+1}])-@$myloc)" + method i_value_clear/leaf {symbol} { ; #TRACE puts "[format %8d [incr count]] RDE i_value_clear/leaf ($symbol ok $myok ([expr {[$mystackloc peek]+1}])-@$myloc)" # not quite value_lead (guarded, and clear on fail) # Inlined clear, reduce, and optimized. # Clear ; if {$ok} {Reduce $symbol} set mysvalue {} if {!$myok} return @@ -1520,11 +1580,11 @@ set mysvalue [pt::ast new $symbol $pos $myloc] } return } - method i_value_clear/reduce {symbol} { ; #TRACE puts "[format %8d [incr count]] RDE i_value_clear/reduce" + method i_value_clear/reduce {symbol} { ; #TRACE puts "[format %8d [incr count]] RDE i_value_clear/reduce ($symbol)" set mysvalue {} if {!$myok} return set mark [$mystackmark peek];# Old size of stack before current nt pushed more. set newa [expr {[$mystackast size] - $mark}] @@ -1555,11 +1615,11 @@ } # # ## ### ##### ######## ############# ##################### ## API - Instructions - Terminal matching - method i_input_next {msg} { ; #TRACE puts "[format %8d [incr count]] RDE i_input_next" + method i_input_next {msg} { ; #TRACE puts "[format %8d [incr count]] RDE i_input_next ($msg)" # Inlined: Getch, Expected, ClearErrors # Satisfy from input cache if possible. incr myloc # May read from the input (ExtendTC), and remember the @@ -1586,11 +1646,11 @@ incr myloc -1 } return } - method i_test_range {toks toke} { ; #TRACE puts "[format %8d [incr count]] RDE i_test_range" + method i_test_range {toks toke} { ; #TRACE puts "[format %8d [incr count]] RDE i_test_range ($toks $toke)" set myok [expr { ([string compare $toks $mycurrent] <= 0) && ([string compare $mycurrent $toke] <= 0) }] ; # {} if {$myok} { @@ -1617,10 +1677,16 @@ method i_test_ascii {} { ; #TRACE puts "[format %8d [incr count]] RDE i_test_ascii" set myok [string is ascii -strict $mycurrent] OkFail ascii return } + + method i_test_control {} { ; #TRACE puts "[format %8d [incr count]] RDE i_test_control" + set myok [string is control -strict $mycurrent] + OkFail control + return + } method i_test_ddigit {} { ; #TRACE puts "[format %8d [incr count]] RDE i_test_ddigit" set myok [string match {[0-9]} $mycurrent] OkFail ddigit return @@ -1769,10 +1835,11 @@ typeconstructor { set ourmsg(alnum) [pt::pe alnum] set ourmsg(alpha) [pt::pe alpha] set ourmsg(ascii) [pt::pe ascii] + set ourmsg(control) [pt::pe control] set ourmsg(ddigit) [pt::pe ddigit] set ourmsg(digit) [pt::pe digit] set ourmsg(graph) [pt::pe graph] set ourmsg(lower) [pt::pe lower] set ourmsg(print) [pt::pe printable] Index: modules/pt/pt_tclparam_config_snit.man ================================================================== --- modules/pt/pt_tclparam_config_snit.man +++ modules/pt/pt_tclparam_config_snit.man @@ -1,10 +1,11 @@ +[vset VERSION 1.0.2] [comment {-*- text -*- doctools manpage}] -[manpage_begin pt::tclparam::configuration::snit n 1.0.1] +[manpage_begin pt::tclparam::configuration::snit n [vset VERSION]] [include include/module.inc] [titledesc {Tcl/PARAM, Canned configuration, Snit}] -[require pt::tclparam::configuration::snit [opt 1.0.1]] +[require pt::tclparam::configuration::snit [opt [vset VERSION]]] [description] [include include/ref_intro.inc] This package is an adjunct to [package pt::peg::to::tclparam], to make the use of this highly configurable package easier by providing a @@ -20,15 +21,15 @@ [section API] [list_begin definitions] [call [cmd ::pt::tclparam::configuration::snit] [method def] \ - [arg name] [arg cmdprefix]] + [arg name] [arg pkg] [arg version] [arg cmdprefix]] The command applies the configuration provided by this package to the [arg cmdprefix], causing the creation of [package snit]-based parsers -whose class is [arg name]. +whose class is [arg name], in package [arg pkg] with [arg version]. [para] The use of a command prefix as API allows application of the configuration to not only [package pt::peg::to::tclparam] Index: modules/pt/pt_tclparam_config_snit.tcl ================================================================== --- modules/pt/pt_tclparam_config_snit.tcl +++ modules/pt/pt_tclparam_config_snit.tcl @@ -1,7 +1,7 @@ # -*- tcl -*- -# Copyright (c) 2009-2010 Andreas Kupries +# Copyright (c) 2009-2014 Andreas Kupries # Canned configuration for the converter to Tcl/PARAM representation, # causing generation of a proper snit class. # The requirements of the embedded template are not our requirements. @@ -25,11 +25,11 @@ ## Public API # Check that the proposed serialization of an abstract syntax tree is # indeed such. -proc ::pt::tclparam::configuration::snit::def {class pkg cmd} { +proc ::pt::tclparam::configuration::snit::def {class pkg version cmd} { # TODO :: See if we can consolidate the API for converters, # TODO :: plugins, export manager, and container in some way. # TODO :: Container may make exporter manager available through # TODO :: public method. @@ -36,10 +36,15 @@ # class : is actually the name of the package to generate, and # will be prefixed with :: to make it a proper absolute # class and Tcl namespace name. + lappend map @@PKG@@ $pkg + lappend map @@VERSION@@ $version + lappend map @@CLASS@@ $class + lappend map \n\t \n ;# undent the template + {*}$cmd -runtime-command {$myparser} #{*}$cmd -self-command {$self} #{*}$cmd -proc-command method {*}$cmd -self-command {} {*}$cmd -proc-command proc @@ -46,16 +51,11 @@ {*}$cmd -prelude {upvar 1 myparser myparser} {*}$cmd -namespace {} {*}$cmd -main MAIN {*}$cmd -indent 4 {*}$cmd -template [string trim \ - [string map \ - [list \ - @@PKG@@ $pkg \ - @@CLASS@@ $class \ - \n\t \n \ - ] { + [string map $map { ## -*- tcl -*- ## ## Snit-based Tcl/PARAM implementation of the parsing ## expression grammar ## @@ -121,11 +121,11 @@ } # # ## ### ##### ######## ############# ##################### ## Ready - package provide @@PKG@@ 1 + package provide @@PKG@@ @@VERSION@@ return }]] return } @@ -135,7 +135,7 @@ namespace eval ::pt::tclparam::configuration::snit {} # # ## ### ##### ######## ############# ##################### ## Ready -package provide pt::tclparam::configuration::snit 1.0.1 +package provide pt::tclparam::configuration::snit 1.0.2 return Index: modules/pt/pt_tclparam_config_tcloo.man ================================================================== --- modules/pt/pt_tclparam_config_tcloo.man +++ modules/pt/pt_tclparam_config_tcloo.man @@ -1,10 +1,11 @@ +[vset VERSION 1.0.4] [comment {-*- text -*- doctools manpage}] -[manpage_begin pt::tclparam::configuration::tcloo n 1.0.3] +[manpage_begin pt::tclparam::configuration::tcloo n [vset VERSION]] [include include/module.inc] [titledesc {Tcl/PARAM, Canned configuration, Tcloo}] -[require pt::tclparam::configuration::tcloo [opt 1.0.3]] +[require pt::tclparam::configuration::tcloo [opt [vset VERSION]]] [description] [include include/ref_intro.inc] This package is an adjunct to [package pt::peg::to::tclparam], to make the use of this highly configurable package easier by providing a @@ -20,15 +21,15 @@ [section API] [list_begin definitions] [call [cmd ::pt::tclparam::configuration::tcloo] [method def] \ - [arg name] [arg cmdprefix]] + [arg name] [arg pkg] [arg version] [arg cmdprefix]] The command applies the configuration provided by this package to the [arg cmdprefix], causing the creation of [package OO]-based parsers -whose class is [arg name]. +whose class is [arg name], in package [arg pkg] with [arg version]. [para] The use of a command prefix as API allows application of the configuration to not only [package pt::peg::to::tclparam] Index: modules/pt/pt_tclparam_config_tcloo.tcl ================================================================== --- modules/pt/pt_tclparam_config_tcloo.tcl +++ modules/pt/pt_tclparam_config_tcloo.tcl @@ -1,7 +1,7 @@ # -*- tcl -*- -# Copyright (c) 2009-2010 Andreas Kupries +# Copyright (c) 2009-2014 Andreas Kupries # Canned configuration for the converter to Tcl/PARAM representation, # causing generation of a proper TclOO class. # The requirements of the embedded template are not our requirements. @@ -25,31 +25,31 @@ ## Public API # Check that the proposed serialization of an abstract syntax tree is # indeed such. -proc ::pt::tclparam::configuration::tcloo::def {class pkg cmd} { +proc ::pt::tclparam::configuration::tcloo::def {class pkg version cmd} { # TODO :: See if we can consolidate the API for converters, # TODO :: plugins, export manager, and container in some way. # TODO :: Container may make exporter manager available through # TODO :: public method. + lappend map @@PKG@@ $pkg + lappend map @@VERSION@@ $version + lappend map @@CLASS@@ $class + lappend map \n\t \n ;# undent the template + {*}$cmd -runtime-command my {*}$cmd -self-command my {*}$cmd -proc-command method {*}$cmd -prelude {} {*}$cmd -namespace {} {*}$cmd -main MAIN {*}$cmd -indent 4 {*}$cmd -template [string trim \ - [string map \ - [list \ - @@PKG@@ $pkg \ - @@CLASS@@ $class \ - \n\t \n \ - ] { + [string map $map { ## -*- tcl -*- ## ## OO-based Tcl/PARAM implementation of the parsing ## expression grammar ## @@ -101,11 +101,11 @@ } # # ## ### ##### ######## ############# ##################### ## Ready - package provide @@PKG@@ 1 + package provide @@PKG@@ @@VERSION@@ return }]] return } @@ -115,7 +115,7 @@ namespace eval ::pt::tclparam::configuration::tcloo {} # # ## ### ##### ######## ############# ##################### ## Ready -package provide pt::tclparam::configuration::tcloo 1.0.3 +package provide pt::tclparam::configuration::tcloo 1.0.4 return ADDED modules/pt/pt_util.man Index: modules/pt/pt_util.man ================================================================== --- /dev/null +++ modules/pt/pt_util.man @@ -0,0 +1,54 @@ +[vset VERSION 1] +[comment {-*- text -*- doctools manpage}] +[manpage_begin pt::util n [vset VERSION]] +[include include/module.inc] +[titledesc {General utilities}] +[require pt::ast [opt [vset VERSION]]] +[description] +[include include/ref_intro.inc] + +This package provides general utility commands. + +[para] + +This is a supporting package in the Core Layer of Parser Tools. +[para][image arch_core_support][para] + +[section API] + +[list_begin definitions] +[comment {= = == === ===== ======== ============= =====================}] +[call [cmd ::pt::util] [method error2readable] \ + [arg error] [arg text]] + +This command takes the structured form of a syntax [arg error] as +thrown by parser runtimes and the input [arg text] to the parser which +caused that error and returns a string describing the error in a +human-readable form. + +[para] The input [arg text] is required to convert the character +position of the error into a more readable line/column format, and to +provide excerpts of the input around the error position. + +[comment {= = == === ===== ======== ============= =====================}] +[call [cmd ::pt::util] [method error2position] \ + [arg error] [arg text]] + +This command takes the structured form of a syntax [arg error] as +thrown by parser runtimes and the input [arg text] to the parser which +caused that error and returns a 2-element list containing the line +number and column index for the error's character position in the +input, in this order. + +[comment {= = == === ===== ======== ============= =====================}] +[call [cmd ::pt::util] [method error2text] [arg error]] + +This command takes the structured form of a syntax [arg error] as +thrown by parser runtimes and returns a list of strings, each +describing a possible expected input in a human-readable form. + +[comment {= = == === ===== ======== ============= =====================}] +[list_end] + +[include include/feedback.inc] +[manpage_end] ADDED modules/pt/pt_util.tcl Index: modules/pt/pt_util.tcl ================================================================== --- /dev/null +++ modules/pt/pt_util.tcl @@ -0,0 +1,160 @@ +# -*- tcl -*- +# Copyright (c) 2014 Andreas Kupries + +# Utility commands for parser syntax errors. + +# # ## ### ##### ######## ############# ##################### +## Requirements + +package require Tcl 8.5 ; # Required runtime. +package require char + +# # ## ### ##### ######## ############# ##################### +## + +namespace eval ::pt::util { + namespace export error2readable error2position error2text + namespace ensemble create + + namespace import ::char::quote +} + +# # ## ### ##### ######## ############# +## Public API + +proc ::pt::util::error2readable {error text} { + lassign $error _ location msgs + lassign [Position $location $text] l c + + lappend map \n \\n + lappend map \r \\r + lappend map \t \\t + + # Get 10 chars before and after the failure point. Depending on + # the relative position of input beginning and end we may get less + # back of either. Special characters in the input (line endings, + # tabs) are quoted to keep this on a single line. + set prefix [string map $map [string range $text ${location}-10 $location]] + set suffix [string map $map [string range $text ${location}+1 ${location}+10]] + + # Construct a line pointing to the failure position. By using the + # transformed prefix as our source (length) no complex + # calculations are required. It is implicit in the prefix/suffix + # separation above. + set n [string length $prefix] + incr n -1 + set point [string repeat - $n] + append point ^ + + # Print our results. + lappend lines "Parse error at position $location (Line $l, column $c)." + lappend lines "... ${prefix}${suffix} ..." + lappend lines " $point" + lappend lines "Expected one of" + lappend lines "* [join [Readables $msgs] "\n* "]" + lappend lines "" + + return [join $lines \n] +} + +proc ::pt::util::error2position {error text} { + lassign $error _ location msgs + return [Position $location $text] +} + +proc ::pt::util::error2text {error} { + lassign $error _ location msgs + return [Readables $msgs] +} + +# # ## ### ##### ######## ############# +## Internals + +proc ::pt::util::Position {location text} { + incr location -1 + + # Computing the line/col of a position is quite easy. Split the + # part before the location into lines (at eol), count them, and + # look at the length of the last line in that. + + set prefix [string range $text 0 $location] + set lines [split $prefix \n] + set line [llength $lines] + set col [string length [lindex $lines end]] + + return [list $line $col] +} + +proc ::pt::util::Readables {msgs} { + set cl {} + set r {} + foreach pe $msgs { + switch -exact -- [lindex $pe 0] { + t { + # Fuse to multiple 't'-tags into a single 'cl'-tag. + lappend cl [lindex $pe 1] + } + cl { + # Fuse multiple 'cl'-tags into one. + foreach c [split $details] { lappend cl $c } + } + default { + lappend r [Readable $pe] + } + } + } + if {[set n [llength $cl]]} { + if {$n > 1} { + lappend r [Readable [list cl [join [lsort -dict $cl] {}]]] + } else { + lappend r [Readable [list t [lindex $cl 0]]] + } + } + return [lsort -dict $r] +} + +proc ::pt::util::Readable {pe} { + set details [lassign $pe tag] + switch -exact -- $tag { + t { + set details [quote string {*}$details] + set m "The character '$details'" + } + n { set m "The symbol $details" } + .. { + set details [quote string {*}$details] + set m "A character in range '[join $details '-']'" + } + str { + set details [join [quote string {*}[split $details {}]] {}] + set m "A string \"$details\"" + } + cl { + set details [join [quote string {*}[split $details {}]] {}] + set m "A character in set \{$details\}" + } + alpha { set m "A unicode alphabetical character" } + alnum { set m "A unicode alphanumerical character" } + ascii { set m "An ascii character" } + digit { set m "A unicode digit character" } + graph { set m "A unicode printing character, but not space" } + lower { set m "A unicode lower-case alphabetical character" } + print { set m "A unicode printing character, including space" } + control { set m "A unicode control character" } + punct { set m "A unicode punctuation character" } + space { set m "A unicode space character" } + upper { set m "A unicode upper-case alphabetical character" } + wordchar { set m "A unicode word character (alphanumerics + connectors)" } + xdigit { set m "A hexadecimal digit" } + ddigit { set m "A decimal digit" } + dot { set m "Any character" } + default { set m [string totitle $tag] } + } + return $m +} + +# # ## ### ##### ######## ############# ##################### +## Ready + +package provide pt::util 1 +return Index: modules/pt/rde_critcl/m.c ================================================================== --- modules/pt/rde_critcl/m.c +++ modules/pt/rde_critcl/m.c @@ -17,12 +17,12 @@ { /* Syntax: rde amarked * [0] [1] */ - long int mc, i; - long int* mv; + long int mc, i; + void** mv; Tcl_Obj** ov; if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; @@ -31,11 +31,11 @@ rde_param_query_amark (p->p, &mc, &mv); ov = NALLOC (mc, Tcl_Obj*); for (i=0; i < mc; i++) { - ov [i] = Tcl_NewIntObj (mv [i]); + ov [i] = Tcl_NewIntObj ((long int) mv [i]); } Tcl_SetObjResult (interp, Tcl_NewListObj (mc, ov)); @@ -108,11 +108,12 @@ } int param_COMPLETE (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { - /* Syntax: rde complete + /* See also pt_cparam_config_critcl.tcl, COMPLETE(). + * Syntax: rde complete * [0] [1] */ if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); @@ -124,23 +125,25 @@ Tcl_Obj** av; rde_param_query_ast (p->p, &ac, &av); if (ac > 1) { - long int lsc; - long int* lsv; Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); - rde_param_query_ls (p->p, &lsc, &lsv); - memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); lv [0] = Tcl_NewObj (); - lv [1] = Tcl_NewIntObj (1 + lsv [lsc-1]); + lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p->p)); lv [2] = Tcl_NewIntObj (rde_param_query_cl (p->p)); Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); ckfree ((char*) lv); + } else if (ac == 0) { + /* + * Match, but no AST. This is possible if the grammar consists of + * only the start expression. + */ + Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); } else { Tcl_SetObjResult (interp, av [0]); } return TCL_OK; @@ -147,14 +150,17 @@ } else { Tcl_Obj* xv [1]; const ERROR_STATE* er = rde_param_query_er (p->p); Tcl_Obj* res = rde_param_query_er_tcl (p->p, er); + /* res = list (location, list(msg)) */ + /* Stick the exception type-tag before the existing elements */ xv [0] = Tcl_NewStringObj ("pt::rde",-1); - Tcl_ListObjReplace(interp, res, 0, 1, 1, xv); + Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); + Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); Tcl_SetObjResult (interp, res); return TCL_ERROR; } } @@ -272,11 +278,11 @@ /* Syntax: rde lmarked * [0] [1] */ long int lc, i; - long int* lv; + void** lv; Tcl_Obj** ov; if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; @@ -285,11 +291,11 @@ rde_param_query_ls (p->p, &lc, &lv); ov = NALLOC (lc, Tcl_Obj*); for (i=0; i < lc; i++) { - ov [i] = Tcl_NewIntObj (lv [i]); + ov [i] = Tcl_NewIntObj ((long int) lv [i]); } Tcl_SetObjResult (interp, Tcl_NewListObj (lc, ov)); ckfree ((char*) ov); @@ -395,20 +401,20 @@ he != NULL; he = Tcl_NextHashEntry(&hs)) { Tcl_HashSearch hsc; Tcl_HashEntry* hec; - int loc = (int) Tcl_GetHashKey (nc, he); + long int loc = (long int) Tcl_GetHashKey (nc, he); kv [0] = Tcl_NewIntObj (loc); tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (he); for(hec = Tcl_FirstHashEntry(tablePtr, &hsc); hec != NULL; hec = Tcl_NextHashEntry(&hsc)) { - int symid = (int) Tcl_GetHashKey (tablePtr, hec); + long int symid = (long int) Tcl_GetHashKey (tablePtr, hec); const char* sym = rde_param_query_string (p->p, symid); kv [1] = Tcl_NewStringObj (sym,-1); Tcl_ListObjAppendElement (interp, res, @@ -447,21 +453,21 @@ he != NULL; he = Tcl_NextHashEntry(&hs)) { Tcl_HashSearch hsc; Tcl_HashEntry* hec; - int loc = (int) Tcl_GetHashKey (nc, he); + long int loc = (long int) Tcl_GetHashKey (nc, he); kv [0] = Tcl_NewIntObj (loc); tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (he); for(hec = Tcl_FirstHashEntry(tablePtr, &hsc); hec != NULL; hec = Tcl_NextHashEntry(&hsc)) { NC_STATE* scs = Tcl_GetHashValue (hec); - int symid = (int) Tcl_GetHashKey (tablePtr, hec); + long int symid = (long int) Tcl_GetHashKey (tablePtr, hec); const char* sym = rde_param_query_string (p->p, symid); kv [1] = Tcl_NewStringObj (sym,-1); vv [0] = Tcl_NewIntObj (scs->CL); @@ -724,11 +730,11 @@ { /* Syntax: rde i_error_nonterminal SYMBOL * [0] [1] [2] */ - int sym; + long int sym; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "symbol"); return TCL_ERROR; } @@ -740,11 +746,11 @@ * i_symbol_save/restore, and i_value_leaf/reduce, and derivatives. This * here is the only point between these where we save the string id in the * Tcl_Obj*. */ - sym = rde_ot_intern (objv [2], p, "n", NULL); + sym = rde_ot_intern1 (p, "n", objv [2]); rde_param_i_error_nonterminal (p->p, sym); return TCL_OK; } @@ -1081,11 +1087,12 @@ { /* Syntax: rde i_symbol_restore SYMBOL * [0] [1] [2] */ - int sym, found; + long int sym; + int found; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "symbol"); return TCL_ERROR; } @@ -1108,11 +1115,11 @@ { /* Syntax: rde i_symbol_save SYMBOL * [0] [1] [2] */ - int sym; + long int sym; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "symbol"); return TCL_ERROR; } @@ -1142,11 +1149,11 @@ } if (!rde_param_query_st (p->p)) { rde_param_i_value_clear (p->p); } else { - int sym; + long int sym; /* * We cannot save the interned string id in the Tcl_Obj*, because this * is already taken by the argument of param_I_er_nt aka * i_error_nonterminal, due to literal sharing in procedure bodies. @@ -1189,11 +1196,11 @@ } if (!rde_param_query_st (p->p)) { rde_param_i_value_clear (p->p); } else { - int sym; + long int sym; /* * We cannot save the interned string id in the Tcl_Obj*, because this * is already taken by the argument of param_I_er_nt aka * i_error_nonterminal, due to literal sharing in procedure bodies. @@ -1211,11 +1218,11 @@ { /* Syntax: rde i_input_next MSG * [0] [1] [2] */ - int msg; + long int msg; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "msg"); return TCL_ERROR; } @@ -1222,11 +1229,11 @@ /* * interning: msg as is. Already has PE operator in the message. */ - msg = rde_ot_intern (objv [2], p, NULL, NULL); + msg = rde_ot_intern0 (p, objv [2]); rde_param_i_input_next (p->p, msg); return TCL_OK; } @@ -1282,11 +1289,11 @@ } int param_I_test_char (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { - int msg; + long int msg; char* ch; /* Syntax: rde i_test_char CHAR * [0] [1] [2] */ @@ -1299,13 +1306,30 @@ /* * interning: t + space + char */ ch = Tcl_GetString (objv [2]); - msg = rde_ot_intern (objv [2], p, "t", NULL); + msg = rde_ot_intern1 (p, "t", objv [2]); rde_param_i_test_char (p->p, ch, msg); + return TCL_OK; +} + +int +param_I_test_control (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) +{ + /* Syntax: rde i_test_control + * [0] [1] + */ + + if (objc != 2) { + Tcl_WrongNumArgs (interp, 2, objv, NULL); + return TCL_ERROR; + } + + rde_param_i_test_control (p->p); + return TCL_OK; } int param_I_test_ddigit (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) @@ -1410,11 +1434,11 @@ } int param_I_test_range (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { - int msg; + long int msg; char* chs; char* che; /* Syntax: rde i_test_range START END * [0] [1] [2] [3] @@ -1428,12 +1452,12 @@ /* * interning: .. + space + char + space + char */ chs = Tcl_GetString (objv [2]); - che = Tcl_GetString (objv [2]); - msg = rde_ot_intern (objv [2], p, "..", che); + che = Tcl_GetString (objv [3]); + msg = rde_ot_intern2 (p, "..", objv [2], objv[3]); rde_param_i_test_range (p->p, chs, che, msg); return TCL_OK; } @@ -1757,11 +1781,11 @@ } int param_SI_next_char (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { - int msg; + long int msg; char* ch; /* Syntax: rde i_next_char CHAR * [0] [1] [2] */ @@ -1774,11 +1798,11 @@ /* * interning: t + space + char */ ch = Tcl_GetString (objv [2]); - msg = rde_ot_intern (objv [2], p, "t", NULL); + msg = rde_ot_intern1 (p, "t", objv [2]); rde_param_i_input_next (p->p, msg); if (rde_param_query_st (p->p)) { rde_param_i_test_char (p->p, ch, msg); } @@ -1786,11 +1810,11 @@ } int param_SI_next_range (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { - int msg; + long int msg; char* chs; char* che; /* Syntax: rde i_next_range START END * [0] [1] [2] [3] @@ -1804,12 +1828,12 @@ /* * interning: .. + space + char + space + char */ chs = Tcl_GetString (objv [2]); - che = Tcl_GetString (objv [2]); - msg = rde_ot_intern (objv [2], p, "..", che); + che = Tcl_GetString (objv [3]); + msg = rde_ot_intern2 (p, "..", objv [2], objv[3]); rde_param_i_input_next (p->p, msg); if (rde_param_query_st (p->p)) { rde_param_i_test_range (p->p, chs, che, msg); } @@ -1821,11 +1845,11 @@ { /* Syntax: rde si:next_alnum * [0] [1] */ - int msg; + long int msg; if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } @@ -1844,11 +1868,11 @@ { /* Syntax: rde si:next_alpha * [0] [1] */ - int msg; + long int msg; if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } @@ -1867,11 +1891,11 @@ { /* Syntax: rde si:next_ascii * [0] [1] */ - int msg; + long int msg; if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } @@ -1882,19 +1906,42 @@ if (rde_param_query_st (p->p)) { rde_param_i_test_ascii (p->p); } return TCL_OK; } + +int +param_SI_next_control (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) +{ + /* Syntax: rde si:next_control + * [0] [1] + */ + + long int msg; + + if (objc != 2) { + Tcl_WrongNumArgs (interp, 2, objv, NULL); + return TCL_ERROR; + } + + msg = param_intern (p, "control"); + + rde_param_i_input_next (p->p, msg); + if (rde_param_query_st (p->p)) { + rde_param_i_test_control (p->p); + } + return TCL_OK; +} int param_SI_next_ddigit (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:next_ddigit * [0] [1] */ - int msg; + long int msg; if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } @@ -1913,11 +1960,11 @@ { /* Syntax: rde si:next_digit * [0] [1] */ - int msg; + long int msg; if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } @@ -1936,11 +1983,11 @@ { /* Syntax: rde si:next_graph * [0] [1] */ - int msg; + long int msg; if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } @@ -1959,11 +2006,11 @@ { /* Syntax: rde si:next_lower * [0] [1] */ - int msg; + long int msg; if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } @@ -1982,11 +2029,11 @@ { /* Syntax: rde si:next_print * [0] [1] */ - int msg; + long int msg; if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } @@ -2005,11 +2052,11 @@ { /* Syntax: rde si:next_punct * [0] [1] */ - int msg; + long int msg; if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } @@ -2028,11 +2075,11 @@ { /* Syntax: rde si:next_space * [0] [1] */ - int msg; + long int msg; if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } @@ -2051,11 +2098,11 @@ { /* Syntax: rde si:next_upper * [0] [1] */ - int msg; + long int msg; if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } @@ -2074,11 +2121,11 @@ { /* Syntax: rde si:next_wordchar * [0] [1] */ - int msg; + long int msg; if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } @@ -2097,11 +2144,11 @@ { /* Syntax: rde si:next_xdigit * [0] [1] */ - int msg; + long int msg; if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } @@ -2264,11 +2311,12 @@ { /* Syntax: rde si:value_symbol_start SYMBOL * [0] [1] [2] */ - int sym, found; + long int sym; + int found; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "symbol"); return TCL_ERROR; } @@ -2299,11 +2347,12 @@ { /* Syntax: rde si:value_void_symbol_start SYMBOL * [0] [1] [2] */ - int sym, found; + long int sym; + int found; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "symbol"); return TCL_ERROR; } @@ -2331,11 +2380,12 @@ { /* Syntax: rde si:void_symbol_start SYMBOL * [0] [1] [2] */ - int sym, found; + long int sym; + int found; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "symbol"); return TCL_ERROR; } @@ -2365,11 +2415,12 @@ { /* Syntax: rde si:void_void_symbol_start SYMBOL * [0] [1] [2] */ - int sym, found; + long int sym; + int found; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "symbol"); return TCL_ERROR; } @@ -2396,11 +2447,11 @@ { /* Syntax: rde si:reduce_symbol_end SYMBOL * [0] [1] [2] */ - int sym, msg; + long int sym, msg; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "symbol"); return TCL_ERROR; } @@ -2428,11 +2479,11 @@ * i_symbol_save/restore, and i_value_leaf/reduce, and derivatives. This * here is the only point between these where we save the string id in the * Tcl_Obj*. */ - msg = rde_ot_intern (objv [2], p, "n", NULL); + msg = rde_ot_intern1 (p, "n", objv [2]); rde_param_i_error_nonterminal (p->p, msg); rde_param_i_ast_pop_rewind (p->p); rde_param_i_loc_pop_discard (p->p); @@ -2448,11 +2499,11 @@ { /* Syntax: rde si:void_leaf_symbol_end SYMBOL * [0] [1] [2] */ - int sym, msg; + long int sym, msg; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "symbol"); return TCL_ERROR; } @@ -2480,11 +2531,11 @@ * i_symbol_save/restore, and i_value_leaf/reduce, and derivatives. This * here is the only point between these where we save the string id in the * Tcl_Obj*. */ - msg = rde_ot_intern (objv [2], p, "n", NULL); + msg = rde_ot_intern1 (p, "n", objv [2]); rde_param_i_error_nonterminal (p->p, msg); rde_param_i_loc_pop_discard (p->p); if (rde_param_query_st (p->p)) { @@ -2499,11 +2550,11 @@ { /* Syntax: rde si:value_leaf_symbol_end SYMBOL * [0] [1] [2] */ - int sym, msg; + long int sym, msg; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "symbol"); return TCL_ERROR; } @@ -2531,11 +2582,11 @@ * i_symbol_save/restore, and i_value_leaf/reduce, and derivatives. This * here is the only point between these where we save the string id in the * Tcl_Obj*. */ - msg = rde_ot_intern (objv [2], p, "n", NULL); + msg = rde_ot_intern1 (p, "n", objv [2]); rde_param_i_error_nonterminal (p->p, msg); rde_param_i_ast_pop_rewind (p->p); rde_param_i_loc_pop_discard (p->p); @@ -2551,11 +2602,11 @@ { /* Syntax: rde si:value_clear_symbol_end SYMBOL * [0] [1] [2] */ - int sym, msg; + long int sym, msg; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "symbol"); return TCL_ERROR; } @@ -2578,11 +2629,11 @@ * i_symbol_save/restore, and i_value_leaf/reduce, and derivatives. This * here is the only point between these where we save the string id in the * Tcl_Obj*. */ - msg = rde_ot_intern (objv [2], p, "n", NULL); + msg = rde_ot_intern1 (p, "n", objv [2]); rde_param_i_error_nonterminal (p->p, msg); rde_param_i_ast_pop_rewind (p->p); rde_param_i_loc_pop_discard (p->p); @@ -2594,11 +2645,11 @@ { /* Syntax: rde si:void_clear_symbol_end SYMBOL * [0] [1] [2] */ - int sym, msg; + long int sym, msg; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "symbol"); return TCL_ERROR; } @@ -2621,11 +2672,11 @@ * i_symbol_save/restore, and i_value_leaf/reduce, and derivatives. This * here is the only point between these where we save the string id in the * Tcl_Obj*. */ - msg = rde_ot_intern (objv [2], p, "n", NULL); + msg = rde_ot_intern1 (p, "n", objv [2]); rde_param_i_error_nonterminal (p->p, msg); rde_param_i_loc_pop_discard (p->p); return TCL_OK; @@ -2632,11 +2683,12 @@ } int param_SI_next_str (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { - int msg, len, i; + long int msg; + int len, i; char* str; /* Syntax: rde i_next_char CHAR * [0] [1] [2] */ @@ -2649,20 +2701,21 @@ /* * interning: str + space + char */ str = Tcl_GetStringFromObj (objv [2], &len); - msg = rde_ot_intern (objv [2], p, "str", NULL); + msg = rde_ot_intern1 (p, "str", objv [2]); rde_param_i_next_str (p->p, str, msg); return TCL_OK; } int param_SI_next_class (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { - int msg, len, i; + long int msg; + int len, i; char* class; /* Syntax: rde i_next_char CHAR * [0] [1] [2] */ @@ -2675,11 +2728,11 @@ /* * interning: cl + space + char */ class = Tcl_GetStringFromObj (objv [2], &len); - msg = rde_ot_intern (objv [2], p, "cl", NULL); + msg = rde_ot_intern1 (p, "cl", objv [2]); rde_param_i_next_class (p->p, class, msg); return TCL_OK; } Index: modules/pt/rde_critcl/m.h ================================================================== --- modules/pt/rde_critcl/m.h +++ modules/pt/rde_critcl/m.h @@ -74,10 +74,11 @@ int param_I_test_alnum (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv); int param_I_test_alpha (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv); int param_I_test_ascii (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv); int param_I_test_char (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv); +int param_I_test_control (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv); int param_I_test_ddigit (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv); int param_I_test_digit (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv); int param_I_test_graph (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv); int param_I_test_lower (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv); int param_I_test_print (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv); @@ -103,10 +104,11 @@ int param_SI_next_char (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv); int param_SI_next_range (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv); int param_SI_next_alnum (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv); int param_SI_next_alpha (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv); int param_SI_next_ascii (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv); +int param_SI_next_control (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv); int param_SI_next_ddigit (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv); int param_SI_next_digit (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv); int param_SI_next_graph (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv); int param_SI_next_lower (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv); int param_SI_next_print (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv); Index: modules/pt/rde_critcl/ms.c ================================================================== --- modules/pt/rde_critcl/ms.c +++ modules/pt/rde_critcl/ms.c @@ -44,11 +44,11 @@ "i_loc_pop_rewind/discard", "i_loc_pop_rewind", "i_loc_push", "i:fail_ast_pop_rewind", "i_ast_pop_discard", "i_ast_pop_discard/rewind", "i_ast_pop_rewind/discard", "i_ast_pop_rewind", "i_ast_push", "i:ok_ast_value_push", "i_symbol_restore", "i_symbol_save", "i_value_clear/leaf", "i_value_clear", "i_value_clear/reduce", - "i_input_next", "i_test_alnum", "i_test_alpha", "i_test_ascii", "i_test_char", + "i_input_next", "i_test_alnum", "i_test_alpha", "i_test_ascii", "i_test_char", "i_test_control", "i_test_ddigit","i_test_digit", "i_test_graph", "i_test_lower", "i_test_print", "i_test_punct", "i_test_range", "i_test_space", "i_test_upper", "i_test_wordchar", "i_test_xdigit", "i:ok_ast_pop_discard", "i_ast_rewind", "i:ok_loc_pop_discard", "i_loc_rewind", @@ -64,11 +64,11 @@ "si:voidvoid_part", "si:voidvalue_part", "si:valuevalue_part", "si:next_char", "si:next_range", - "si:next_alnum", "si:next_alpha", "si:next_ascii", + "si:next_alnum", "si:next_alpha", "si:next_ascii", "si:next_control", "si:next_ddigit","si:next_digit", "si:next_graph", "si:next_lower", "si:next_print", "si:next_punct", "si:next_space", "si:next_upper", "si:next_wordchar", "si:next_xdigit", "si:void2_state_push", @@ -102,11 +102,11 @@ M_I_er_popmerge, M_I_er_push, M_F_loc_pop_rewind, M_I_loc_pop_discard, M_I_loc_pop_rewdis, M_I_loc_pop_rewind, M_I_loc_push, M_F_ast_pop_rewind, M_I_ast_pop_discard, M_I_ast_pop_disrew, M_I_ast_pop_rewdis, M_I_ast_pop_rewind, M_I_ast_push, M_O_ast_value_push, M_I_symbol_restore, M_I_symbol_save, M_I_value_cleaf, M_I_value_clear, M_I_value_creduce, - M_I_input_next, M_I_test_alnum, M_I_test_alpha, M_I_test_ascii, M_I_test_char, + M_I_input_next, M_I_test_alnum, M_I_test_alpha, M_I_test_ascii, M_I_test_char, M_I_test_control, M_I_test_ddigit, M_I_test_digit, M_I_test_graph, M_I_test_lower, M_I_test_print, M_I_test_punct, M_I_test_range, M_I_test_space, M_I_test_upper, M_I_test_wordchar, M_I_test_xdigit, M_O_ast_pop_discard, @@ -130,10 +130,11 @@ M_SI_next_char, M_SI_next_range, M_SI_next_alnum, M_SI_next_alpha, M_SI_next_ascii, + M_SI_next_control, M_SI_next_ddigit, M_SI_next_digit, M_SI_next_graph, M_SI_next_lower, M_SI_next_print, @@ -235,10 +236,11 @@ case M_I_input_next: res = param_I_input_next (p, interp, objc, objv); break; case M_I_test_alnum: res = param_I_test_alnum (p, interp, objc, objv); break; case M_I_test_alpha: res = param_I_test_alpha (p, interp, objc, objv); break; case M_I_test_ascii: res = param_I_test_ascii (p, interp, objc, objv); break; case M_I_test_char: res = param_I_test_char (p, interp, objc, objv); break; + case M_I_test_control: res = param_I_test_control (p, interp, objc, objv); break; case M_I_test_ddigit: res = param_I_test_ddigit (p, interp, objc, objv); break; case M_I_test_digit: res = param_I_test_digit (p, interp, objc, objv); break; case M_I_test_graph: res = param_I_test_graph (p, interp, objc, objv); break; case M_I_test_lower: res = param_I_test_lower (p, interp, objc, objv); break; case M_I_test_print: res = param_I_test_print (p, interp, objc, objv); break; @@ -264,10 +266,11 @@ case M_SI_next_char: res = param_SI_next_char (p, interp, objc, objv); break; case M_SI_next_range: res = param_SI_next_range (p, interp, objc, objv); break; case M_SI_next_alnum: res = param_SI_next_alnum (p, interp, objc, objv); break; case M_SI_next_alpha: res = param_SI_next_alpha (p, interp, objc, objv); break; case M_SI_next_ascii: res = param_SI_next_ascii (p, interp, objc, objv); break; + case M_SI_next_control: res = param_SI_next_control (p, interp, objc, objv); break; case M_SI_next_ddigit: res = param_SI_next_ddigit (p, interp, objc, objv); break; case M_SI_next_digit: res = param_SI_next_digit (p, interp, objc, objv); break; case M_SI_next_graph: res = param_SI_next_graph (p, interp, objc, objv); break; case M_SI_next_lower: res = param_SI_next_lower (p, interp, objc, objv); break; case M_SI_next_print: res = param_SI_next_print (p, interp, objc, objv); break; Index: modules/pt/rde_critcl/ot.c ================================================================== --- modules/pt/rde_critcl/ot.c +++ modules/pt/rde_critcl/ot.c @@ -23,89 +23,137 @@ ot_free_rep, ot_dup_rep, ot_string_rep, ot_from_any }; + +static int IsCached (RDE_STATE p, Tcl_Obj* obj, long int* id); +static long int Make (RDE_STATE p, Tcl_Obj* obj, const char* str); + /* * = = == === ===== ======== ============= ===================== */ -int -rde_ot_intern (Tcl_Obj* obj, RDE_STATE p, char* pfx, char* sfx) -{ - int id; - RDE_STRING* rs; - - TRACE (("rde_ot_intern (%p, '%s','%s' of %p = '%s')", p, pfx, sfx, obj, Tcl_GetString(obj))); - +long int +rde_ot_intern0 (RDE_STATE p, + Tcl_Obj* detail) +{ + long int id; + + TRACE (("rde_ot_intern0 (%p, %p = '%s')", p, detail, Tcl_GetString(detail))); + if (IsCached (p, detail, &id)) { + return id; + } + + TRACE (("INTERNALIZE")); + return Make (p, detail, Tcl_GetString (detail)); +} + +long int +rde_ot_intern1 (RDE_STATE p, + const char* operator, + Tcl_Obj* detail) +{ + long int id; + Tcl_DString buf; + + TRACE (("rde_ot_intern1 (%p, '%s' %p = '%s')", p, operator, detail, Tcl_GetString(detail))); + if (IsCached (p, detail, &id)) { + return id; + } + + TRACE (("INTERNALIZE")); + + /* Create a list of operator + detail. + * Using a DString. + */ + + Tcl_DStringInit (&buf); + Tcl_DStringAppendElement (&buf, operator); + Tcl_DStringAppendElement (&buf, Tcl_GetString (detail)); + + id = Make (p, detail, Tcl_DStringValue (&buf)); + + Tcl_DStringFree (&buf); + return id; +} + +long int +rde_ot_intern2 (RDE_STATE p, + const char* operator, + Tcl_Obj* detail1, + Tcl_Obj* detail2) +{ + long int id; + Tcl_DString buf; + + TRACE (("rde_ot_intern2 (%p, '%s' %p = '%s', %p = '%s')", p, operator, + detail1, Tcl_GetString(detail1) + detail2, Tcl_GetString(detail2))); + if (IsCached (p, detail1, &id)) { + return id; + } + + TRACE (("INTERNALIZE")); + + /* Create a list of operator + detail1 + detail2. + * Using a DString. + */ + + Tcl_DStringInit (&buf); + Tcl_DStringAppendElement (&buf, operator); + Tcl_DStringAppendElement (&buf, Tcl_GetString (detail1)); + Tcl_DStringAppendElement (&buf, Tcl_GetString (detail2)); + + id = Make (p, detail1, Tcl_DStringValue (&buf)); + + Tcl_DStringFree (&buf); + return id; +} + +/* + * = = == === ===== ======== ============= ===================== + */ + +static int +IsCached (RDE_STATE p, Tcl_Obj* obj, long int* id) +{ /* * Quick exit if we have a cached and valid value. */ if ((obj->typePtr == &ot_type) && (obj->internalRep.twoPtrValue.ptr1 == p)) { - rs = (RDE_STRING*) obj->internalRep.twoPtrValue.ptr2; - TRACE (("CACHED %p = %d", rs, rs->id)); - return rs->id; - } - - TRACE (("INTERNALIZE")); - - /* - * Drop any previous internal rep. But generate the string rep first, if - * it is missing. - */ - - if (!obj->bytes) { - Tcl_GetString (obj); - } - if (obj->typePtr != NULL && obj->typePtr->freeIntRepProc != NULL) { - obj->typePtr->freeIntRepProc(obj); - } - - /* - * Compute the new int-rep, interning the prefix-modified string. - */ - - if (!pfx && !sfx) { - id = param_intern (p, obj->bytes); - - } else if (pfx && sfx) { - int plen = strlen(pfx); - int slen = strlen(sfx); - char* buf = NALLOC (plen + slen + obj->length + 3, char); - - sprintf (buf, "%s %s %s", pfx, obj->bytes, sfx); - - id = param_intern (p, buf); - ckfree(buf); - - } else if (pfx) { - int plen = strlen(pfx); - char* buf = NALLOC (plen + obj->length + 2, char); - - sprintf (buf, "%s %s", pfx, obj->bytes); - - id = param_intern (p, buf); - ckfree(buf); - - } else /* sfx */ { - int slen = strlen(sfx); - char* buf = NALLOC (slen + obj->length + 2, char); - - sprintf (buf, "%s %s", obj->bytes, sfx); - - id = param_intern (p, buf); - ckfree(buf); - } - - rs = ALLOC (RDE_STRING); + RDE_STRING* rs = (RDE_STRING*) obj->internalRep.twoPtrValue.ptr2; + TRACE (("CACHED %p = %d", rs, rs->id)); + *id = rs->id; + return 1; + } + + return 0; +} + +static long int +Make (RDE_STATE p, Tcl_Obj* obj, const char* str) +{ + long int id = param_intern (p, str); + RDE_STRING* rs = ALLOC (RDE_STRING); + rs->next = p->sfirst; rs->self = obj; rs->id = id; p->sfirst = rs; + + /* Invalidate previous int.rep before setting our own. + * Inlined copy of TclFreeIntRep() macro (tclInt.h) + */ + + if ((obj)->typePtr && + (obj)->typePtr->freeIntRepProc) { + (obj)->typePtr->freeIntRepProc(obj); + } obj->internalRep.twoPtrValue.ptr1 = p; obj->internalRep.twoPtrValue.ptr2 = rs; obj->typePtr = &ot_type; @@ -131,12 +179,14 @@ iter = iter->next; } iter->next = rs->next; } - /* Nothing to release. */ + /* Drop the now un-tracked structure */ ckfree ((char*) rs); + + /* Nothing to release in the obj itself, just resetting references. */ obj->internalRep.twoPtrValue.ptr1 = NULL; obj->internalRep.twoPtrValue.ptr2 = NULL; } static void Index: modules/pt/rde_critcl/ot.h ================================================================== --- modules/pt/rde_critcl/ot.h +++ modules/pt/rde_critcl/ot.h @@ -7,11 +7,21 @@ #define _RDE_DS_OT_H 1 #include "tcl.h" #include /* State declarations */ -int rde_ot_intern (Tcl_Obj* obj, RDE_STATE p, char* pfx, char* sfx); +long int rde_ot_intern0 (RDE_STATE p, + Tcl_Obj* detail); + +long int rde_ot_intern1 (RDE_STATE p, + const char* operator, + Tcl_Obj* detail); + +long int rde_ot_intern2 (RDE_STATE p, + const char* operator, + Tcl_Obj* detail1, + Tcl_Obj* detail2); #endif /* _RDE_DS_OT_H */ /* * Local Variables: Index: modules/pt/rde_critcl/p.c ================================================================== --- modules/pt/rde_critcl/p.c +++ modules/pt/rde_critcl/p.c @@ -35,22 +35,25 @@ p->p = rde_param_new (p->numstr, p->string); /* * Fixed elements of the string table, as needed by the lower level PARAM * functions (class tests, see param.c, enum test_class). + * Further pt_peg_to_cparam.tcl, [::pt::peg::to::cparam::convert] + * ** Keep in sync ** * * Maybe move the interning into the lower level, i.e. PARAM ? */ param_intern (p, "alnum"); param_intern (p, "alpha"); param_intern (p, "ascii"); + param_intern (p, "control"); param_intern (p, "ddigit"); param_intern (p, "digit"); param_intern (p, "graph"); param_intern (p, "lower"); - param_intern (p, "printable"); + param_intern (p, "print"); param_intern (p, "punct"); param_intern (p, "space"); param_intern (p, "upper"); param_intern (p, "wordchar"); param_intern (p, "xdigit"); @@ -107,34 +110,35 @@ p->c = c; RETURNVOID; } -int -param_intern (RDE_STATE p, char* literal) +long int +param_intern (RDE_STATE p, const char* literal) { - int res, isnew; + long int res; + int isnew; Tcl_HashEntry* hPtr; ENTER ("param_intern"); TRACE (("RDE_STATE %p",p)); TRACE (("CHAR* '%s'",literal)); hPtr = Tcl_FindHashEntry (&p->str, literal); if (hPtr) { - res = (int) Tcl_GetHashValue (hPtr); + res = (long int) Tcl_GetHashValue (hPtr); RETURN("CACHED %d",res); } hPtr = Tcl_CreateHashEntry(&p->str, literal, &isnew); ASSERT (isnew, "Should have found entry"); Tcl_SetHashValue (hPtr, p->numstr); if (p->numstr >= p->maxnum) { - int new; - char** str; + long int new; + char** str; new = 2 * (p->maxnum ? p->maxnum : 8); TRACE (("extend to %d strings",new)); str = (char**) ckrealloc ((char*) p->string, new * sizeof(char*)); Index: modules/pt/rde_critcl/pInt.h ================================================================== --- modules/pt/rde_critcl/pInt.h +++ modules/pt/rde_critcl/pInt.h @@ -26,20 +26,20 @@ */ /* And the counter mapping from ids to strings, this is handed to the * PARAM for use. */ - int maxnum; /* NOTE -- */ - int numstr; /* This is, essentially, an RDE_STACK (char* elements) */ - char** string; /* Convert over to that instead of replicating the code */ + long int maxnum; /* NOTE -- */ + long int numstr; /* This is, essentially, an RDE_STACK (char* elements) */ + char** string; /* Convert over to that instead of replicating the code */ #ifdef RDE_TRACE int icount; /* Instruction counter, when tracing */ #endif } RDE_STATE_; -int param_intern (RDE_STATE p, char* literal); +long int param_intern (RDE_STATE p, const char* literal); #endif /* _P_H */ /* * Local Variables: Index: modules/pt/rde_critcl/param.c ================================================================== --- modules/pt/rde_critcl/param.c +++ modules/pt/rde_critcl/param.c @@ -60,14 +60,18 @@ } RDE_PARAM_; typedef int (*UniCharClass) (int); +/* See also p.c, param_new(), table of param_intern() calls. + * ** Keep in sync ** + */ typedef enum test_class_id { tc_alnum, tc_alpha, tc_ascii, + tc_control, tc_ddigit, tc_digit, tc_graph, tc_lower, tc_printable, @@ -82,11 +86,11 @@ * = = == === ===== ======== ============= ===================== */ static void ast_node_free (void* n); static void error_state_free (void* es); -static void error_set (RDE_PARAM p, int s); +static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); @@ -297,13 +301,13 @@ { return p->clientData; } SCOPE void -rde_param_query_amark (RDE_PARAM p, long int* mc, long int** mv) +rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { - rde_stack_get (p->mark, mc, (void***) mv); + rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { @@ -350,41 +354,41 @@ res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; - long int* mv; + void** mv; int lastid; const char* msg; - rde_stack_get (er->msg, &mc, (void***) &mv); + rde_stack_get (er->msg, &mc, &mv); /* * Note: We are peeking inside the (message) stack here and are - * modifying it in place. This doesn't matter, we using the stack code - * for convenience, not for the ordering. + * modifying it in place. This doesn't matter, we are using the stack + * code for convenience, not for the ordering. */ - qsort (mv, mc, sizeof (long int), er_int_compare); + qsort (mv, mc, sizeof (void*), er_int_compare); /* * Convert message ids to strings. We ignore duplicates, by comparing * to the last processed id. Here the sorting (see above) comes into - * play, we know that duplicates are bunched together in runs, this - * makes it easy. + * play, we know that duplicates are bunched together in runs, making + * it easy to drop them. */ mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); - if (mv [i] == lastid) continue; - lastid = mv [i]; + if (((long int) mv [i]) == lastid) continue; + lastid = (long int) mv [i]; - ASSERT_BOUNDS(mv[i],p->numstr); - msg = p->string [mv[i]]; /* inlined query_string */ + ASSERT_BOUNDS((long int) mv[i],p->numstr); + msg = p->string [(long int) mv[i]]; /* inlined query_string */ ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } @@ -409,13 +413,19 @@ { rde_stack_get (p->ES, ec, (void***) ev); } SCOPE void -rde_param_query_ls (RDE_PARAM p, long int* lc, long int** lv) +rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) { - rde_stack_get (p->LS, lc, (void***) lv); + rde_stack_get (p->LS, lc, lv); +} + +SCOPE long int +rde_param_query_lstop (RDE_PARAM p) +{ + (long int) rde_stack_top (p->LS); } SCOPE Tcl_HashTable* rde_param_query_nc (RDE_PARAM p) { @@ -474,11 +484,11 @@ ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); @@ -491,11 +501,11 @@ long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); @@ -539,12 +549,20 @@ { ER_CLEAR (p); } SCOPE void -rde_param_i_error_nonterminal (RDE_PARAM p, int s) +rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { + /* + * Disabled. Generate only low-level errors until we have worked out how + * to integrate symbol information with them. Do not forget where this + * instruction is inlined - No such exist, places using the instruction + * directly call on this function. + */ + return; + long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; error_set (p, s); @@ -638,11 +656,11 @@ rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void -error_set (RDE_PARAM p, int s) +error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; @@ -700,11 +718,11 @@ /* * = = == === ===== ======== ============= ===================== */ SCOPE void -rde_param_i_input_next (RDE_PARAM p, int m) +rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); @@ -715,16 +733,19 @@ /* * We are at a known position, we can and do take the associated * character out of the token cache. * * FUTURE :: keep track of what location the data stored in CC is - * for. If the location is identical now extraction is required. This + * for. If the location is identical no extraction is required. This * may help when a choice repeatedly tests the same character. */ rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); - ASSERT_BOUNDS (p->CC_len, TCL_UTF_MAX); + /* Note: BOUNDS(n) <=> [0..(n-1)]. + * cc_len in [1..utfmax] <=> cc_len-1 in [0...utfmax-1] <=> BOUNDS(utfmax) + */ + ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } @@ -782,11 +803,11 @@ /* * = = == === ===== ======== ============= ===================== */ SCOPE int -rde_param_i_symbol_restore (RDE_PARAM p, int s) +rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; @@ -821,11 +842,11 @@ return 1; } SCOPE void -rde_param_i_symbol_save (RDE_PARAM p, int s) +rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; @@ -919,11 +940,17 @@ { test_class (p, UniCharIsAscii, tc_ascii); } SCOPE void -rde_param_i_test_char (RDE_PARAM p, char* c, int msg) +rde_param_i_test_control (RDE_PARAM p) +{ + test_class (p, Tcl_UniCharIsControl, tc_control); +} + +SCOPE void +rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; @@ -970,11 +997,11 @@ { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void -rde_param_i_test_range (RDE_PARAM p, char* s, char* e, int msg) +rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && @@ -1061,11 +1088,11 @@ { SV_CLEAR (p); } SCOPE void -rde_param_i_value_leaf (RDE_PARAM p, int s) +rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); @@ -1081,11 +1108,11 @@ SV_SET (p, newsv); } SCOPE void -rde_param_i_value_reduce (RDE_PARAM p, int s) +rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; @@ -1127,25 +1154,33 @@ */ static int er_int_compare (const void* a, const void* b) { - long int ai = *((long int*) a); - long int bi = *((long int*) b); + /* a, b = pointers to element, as void*. + * Actual element type is (void*), and + * actually stored data is (long int). + */ - if (ai < bi) { return -1; } - if (ai > bi) { return 1; } + const void** ael = (const void**) a; + const void** bel = (const void**) b; + + long int avalue = (long int) *ael; + long int bvalue = (long int) *bel; + + if (avalue < bvalue) { return -1; } + if (avalue > bvalue) { return 1; } return 0; } /* * = = == === ===== ======== ============= ===================== * == Super Instructions. */ SCOPE int -rde_param_i_symbol_start (RDE_PARAM p, int s) +rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); @@ -1156,11 +1191,11 @@ rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int -rde_param_i_symbol_start_d (RDE_PARAM p, int s) +rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); @@ -1172,30 +1207,30 @@ rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int -rde_param_i_symbol_void_start (RDE_PARAM p, int s) +rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int -rde_param_i_symbol_void_start_d (RDE_PARAM p, int s) +rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void -rde_param_i_symbol_done_d_reduce (RDE_PARAM p, int s, int m) +rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); @@ -1212,11 +1247,11 @@ Tcl_IncrRefCount (p->SV); } } SCOPE void -rde_param_i_symbol_done_leaf (RDE_PARAM p, int s, int m) +rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); @@ -1232,11 +1267,11 @@ Tcl_IncrRefCount (p->SV); } } SCOPE void -rde_param_i_symbol_done_d_leaf (RDE_PARAM p, int s, int m) +rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); @@ -1253,21 +1288,21 @@ Tcl_IncrRefCount (p->SV); } } SCOPE void -rde_param_i_symbol_done_void (RDE_PARAM p, int s, int m) +rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void -rde_param_i_symbol_done_d_void (RDE_PARAM p, int s, int m) +rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); @@ -1278,123 +1313,131 @@ /* * = = == === ===== ======== ============= ===================== */ SCOPE void -rde_param_i_next_char (RDE_PARAM p, char* c, int m) +rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void -rde_param_i_next_range (RDE_PARAM p, char* s, char* e, int m) +rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void -rde_param_i_next_alnum (RDE_PARAM p, int m) +rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void -rde_param_i_next_alpha (RDE_PARAM p, int m) +rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void -rde_param_i_next_ascii (RDE_PARAM p, int m) +rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void -rde_param_i_next_ddigit (RDE_PARAM p, int m) +rde_param_i_next_control (RDE_PARAM p, long int m) +{ + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_control (p); +} + +SCOPE void +rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void -rde_param_i_next_digit (RDE_PARAM p, int m) +rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void -rde_param_i_next_graph (RDE_PARAM p, int m) +rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void -rde_param_i_next_lower (RDE_PARAM p, int m) +rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void -rde_param_i_next_print (RDE_PARAM p, int m) +rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void -rde_param_i_next_punct (RDE_PARAM p, int m) +rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void -rde_param_i_next_space (RDE_PARAM p, int m) +rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void -rde_param_i_next_upper (RDE_PARAM p, int m) +rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void -rde_param_i_next_wordchar (RDE_PARAM p, int m) +rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void -rde_param_i_next_xdigit (RDE_PARAM p, int m) +rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } @@ -1491,11 +1534,11 @@ { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } @@ -1580,11 +1623,11 @@ return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } @@ -1638,11 +1681,11 @@ rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } @@ -1659,11 +1702,11 @@ if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } @@ -1675,33 +1718,45 @@ /* * = = == === ===== ======== ============= ===================== */ SCOPE void -rde_param_i_next_str (RDE_PARAM p, char* str, int m) +rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; + + /* Future: Place match string into a shared table of constants, like error + * messages, indexed by code. Precomputed length information. + * + * NOTE how we are modifying the error location after the fact. The + * message contains the entire string, so the location should be the + * start of the string in the input, not somewhere in the middle. This + * matches the Tcl runtimes. Here we have to adjust the stored location + * due to our progress through the pattern. + */ while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { + p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { + p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void -rde_param_i_next_class (RDE_PARAM p, char* class, int m) +rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { Index: modules/pt/rde_critcl/param.h ================================================================== --- modules/pt/rde_critcl/param.h +++ modules/pt/rde_critcl/param.h @@ -43,19 +43,20 @@ /* Accessors */ SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p); -SCOPE void rde_param_query_amark (RDE_PARAM p, long int* mc, long int** mv); +SCOPE void rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv); SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av); SCOPE const char* rde_param_query_in (RDE_PARAM p); SCOPE const char* rde_param_query_cc (RDE_PARAM p, long int* len); SCOPE int rde_param_query_cl (RDE_PARAM p); SCOPE const ERROR_STATE* rde_param_query_er (RDE_PARAM p); SCOPE Tcl_Obj* rde_param_query_er_tcl (RDE_PARAM p, const ERROR_STATE* er); SCOPE void rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev); -SCOPE void rde_param_query_ls (RDE_PARAM p, long int* lc, long int** lv); +SCOPE void rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv); +SCOPE long int rde_param_query_lstop (RDE_PARAM p); SCOPE Tcl_HashTable* rde_param_query_nc (RDE_PARAM p); SCOPE int rde_param_query_st (RDE_PARAM p); SCOPE Tcl_Obj* rde_param_query_sv (RDE_PARAM p); SCOPE long int rde_param_query_tc_size (RDE_PARAM p); SCOPE void rde_param_query_tc_get_s (RDE_PARAM p, long int at, long int last, char** ch, long int* len); @@ -69,34 +70,35 @@ SCOPE void rde_param_i_ast_push (RDE_PARAM p); SCOPE void rde_param_i_ast_rewind (RDE_PARAM p); SCOPE void rde_param_i_ast_value_push (RDE_PARAM p); SCOPE void rde_param_i_error_clear (RDE_PARAM p); -SCOPE void rde_param_i_error_nonterminal (RDE_PARAM p, int s); +SCOPE void rde_param_i_error_nonterminal (RDE_PARAM p, long int s); SCOPE void rde_param_i_error_pop_merge (RDE_PARAM p); SCOPE void rde_param_i_error_push (RDE_PARAM p); SCOPE void rde_param_i_loc_pop_discard (RDE_PARAM p); SCOPE void rde_param_i_loc_pop_rewind (RDE_PARAM p); SCOPE void rde_param_i_loc_push (RDE_PARAM p); SCOPE void rde_param_i_loc_rewind (RDE_PARAM p); -SCOPE void rde_param_i_input_next (RDE_PARAM p, int m); +SCOPE void rde_param_i_input_next (RDE_PARAM p, long int m); SCOPE void rde_param_i_status_fail (RDE_PARAM p); SCOPE void rde_param_i_status_ok (RDE_PARAM p); SCOPE void rde_param_i_status_negate (RDE_PARAM p); -SCOPE int rde_param_i_symbol_restore (RDE_PARAM p, int s); -SCOPE void rde_param_i_symbol_save (RDE_PARAM p, int s); +SCOPE int rde_param_i_symbol_restore (RDE_PARAM p, long int s); +SCOPE void rde_param_i_symbol_save (RDE_PARAM p, long int s); -SCOPE void rde_param_i_test_char (RDE_PARAM p, char* c, int m); -SCOPE void rde_param_i_test_range (RDE_PARAM p, char* s, char* e, int m); +SCOPE void rde_param_i_test_char (RDE_PARAM p, const char* c, long int m); +SCOPE void rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int m); SCOPE void rde_param_i_test_alnum (RDE_PARAM p); SCOPE void rde_param_i_test_alpha (RDE_PARAM p); SCOPE void rde_param_i_test_ascii (RDE_PARAM p); +SCOPE void rde_param_i_test_control (RDE_PARAM p); SCOPE void rde_param_i_test_ddigit (RDE_PARAM p); SCOPE void rde_param_i_test_digit (RDE_PARAM p); SCOPE void rde_param_i_test_graph (RDE_PARAM p); SCOPE void rde_param_i_test_lower (RDE_PARAM p); SCOPE void rde_param_i_test_print (RDE_PARAM p); @@ -105,43 +107,44 @@ SCOPE void rde_param_i_test_upper (RDE_PARAM p); SCOPE void rde_param_i_test_wordchar (RDE_PARAM p); SCOPE void rde_param_i_test_xdigit (RDE_PARAM p); SCOPE void rde_param_i_value_clear (RDE_PARAM p); -SCOPE void rde_param_i_value_leaf (RDE_PARAM p, int s); -SCOPE void rde_param_i_value_reduce (RDE_PARAM p, int s); +SCOPE void rde_param_i_value_leaf (RDE_PARAM p, long int s); +SCOPE void rde_param_i_value_reduce (RDE_PARAM p, long int s); /* Super Instructions - Aggregated common instruction sequences. */ -SCOPE int rde_param_i_symbol_start (RDE_PARAM p, int s); -SCOPE int rde_param_i_symbol_start_d (RDE_PARAM p, int s); -SCOPE int rde_param_i_symbol_void_start (RDE_PARAM p, int s); -SCOPE int rde_param_i_symbol_void_start_d (RDE_PARAM p, int s); - -SCOPE void rde_param_i_symbol_done_d_reduce (RDE_PARAM p, int s, int m); -SCOPE void rde_param_i_symbol_done_leaf (RDE_PARAM p, int s, int m); -SCOPE void rde_param_i_symbol_done_d_leaf (RDE_PARAM p, int s, int m); -SCOPE void rde_param_i_symbol_done_void (RDE_PARAM p, int s, int m); -SCOPE void rde_param_i_symbol_done_d_void (RDE_PARAM p, int s, int m); - -SCOPE void rde_param_i_next_char (RDE_PARAM p, char* c, int m); -SCOPE void rde_param_i_next_range (RDE_PARAM p, char* s, char* e, int m); - -SCOPE void rde_param_i_next_alnum (RDE_PARAM p, int m); -SCOPE void rde_param_i_next_alpha (RDE_PARAM p, int m); -SCOPE void rde_param_i_next_ascii (RDE_PARAM p, int m); -SCOPE void rde_param_i_next_ddigit (RDE_PARAM p, int m); -SCOPE void rde_param_i_next_digit (RDE_PARAM p, int m); -SCOPE void rde_param_i_next_graph (RDE_PARAM p, int m); -SCOPE void rde_param_i_next_lower (RDE_PARAM p, int m); -SCOPE void rde_param_i_next_print (RDE_PARAM p, int m); -SCOPE void rde_param_i_next_punct (RDE_PARAM p, int m); -SCOPE void rde_param_i_next_space (RDE_PARAM p, int m); -SCOPE void rde_param_i_next_upper (RDE_PARAM p, int m); -SCOPE void rde_param_i_next_wordchar (RDE_PARAM p, int m); -SCOPE void rde_param_i_next_xdigit (RDE_PARAM p, int m); +SCOPE int rde_param_i_symbol_start (RDE_PARAM p, long int s); +SCOPE int rde_param_i_symbol_start_d (RDE_PARAM p, long int s); +SCOPE int rde_param_i_symbol_void_start (RDE_PARAM p, long int s); +SCOPE int rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s); + +SCOPE void rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m); +SCOPE void rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m); +SCOPE void rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m); +SCOPE void rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m); +SCOPE void rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m); + +SCOPE void rde_param_i_next_char (RDE_PARAM p, const char* c, long int m); +SCOPE void rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m); + +SCOPE void rde_param_i_next_alnum (RDE_PARAM p, long int m); +SCOPE void rde_param_i_next_alpha (RDE_PARAM p, long int m); +SCOPE void rde_param_i_next_ascii (RDE_PARAM p, long int m); +SCOPE void rde_param_i_next_control (RDE_PARAM p, long int m); +SCOPE void rde_param_i_next_ddigit (RDE_PARAM p, long int m); +SCOPE void rde_param_i_next_digit (RDE_PARAM p, long int m); +SCOPE void rde_param_i_next_graph (RDE_PARAM p, long int m); +SCOPE void rde_param_i_next_lower (RDE_PARAM p, long int m); +SCOPE void rde_param_i_next_print (RDE_PARAM p, long int m); +SCOPE void rde_param_i_next_punct (RDE_PARAM p, long int m); +SCOPE void rde_param_i_next_space (RDE_PARAM p, long int m); +SCOPE void rde_param_i_next_upper (RDE_PARAM p, long int m); +SCOPE void rde_param_i_next_wordchar (RDE_PARAM p, long int m); +SCOPE void rde_param_i_next_xdigit (RDE_PARAM p, long int m); SCOPE void rde_param_i_notahead_start_d (RDE_PARAM p); SCOPE void rde_param_i_notahead_exit_d (RDE_PARAM p); SCOPE void rde_param_i_notahead_exit (RDE_PARAM p); @@ -163,12 +166,12 @@ SCOPE int rde_param_i_bra_void2void (RDE_PARAM p); SCOPE int rde_param_i_bra_void2value (RDE_PARAM p); SCOPE int rde_param_i_bra_value2void (RDE_PARAM p); SCOPE int rde_param_i_bra_value2value (RDE_PARAM p); -SCOPE void rde_param_i_next_str (RDE_PARAM p, char* str, int m); -SCOPE void rde_param_i_next_class (RDE_PARAM p, char* class, int m); +SCOPE void rde_param_i_next_str (RDE_PARAM p, const char* str, long int m); +SCOPE void rde_param_i_next_class (RDE_PARAM p, const char* class, long int m); /* SKIP END */ #endif /* _RDE_DS_PARAM_H */ /* Index: modules/pt/rde_critcl/tc.c ================================================================== --- modules/pt/rde_critcl/tc.c +++ modules/pt/rde_critcl/tc.c @@ -70,10 +70,18 @@ Tcl_UniChar uni; if (len < 0) { len = strlen (string); } + + /* + * Nothing to append, nothing to do. Bail immediately. + */ + + if (!len) { + return tc->str + base; + } /* * Extend character buffer to hold the new string, and copy the string in. */ @@ -113,21 +121,21 @@ SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; - long int* ov; + void** ov; - rde_stack_get (tc->off, &oc, (void***) &ov); + rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); - off = ov [at]; + off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { - end = ov [at+1]; + end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); @@ -139,22 +147,22 @@ SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; - long int* ov; + void** ov; - rde_stack_get (tc->off, &oc, (void***) &ov); + rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); - off = ov [at]; + off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { - end = ov [last+1]; + end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ADDED modules/pt/tests/char.tests Index: modules/pt/tests/char.tests ================================================================== --- /dev/null +++ modules/pt/tests/char.tests @@ -0,0 +1,210 @@ +# -*- tcl -*- +# Testsuite for char. +# Called by the ../char.test driver file. + +test char-1.0 {char, wrong#args} -body { + char +} -returnCodes error \ + -result {wrong # args: should be "char subcommand ?argument ...?"} + +test char-1.1 {char, bogus method} -body { + char bogus +} -returnCodes error \ + -result {unknown or ambiguous subcommand "bogus": must be quote, or unquote} + +test char-1.2 {char, wrong#args} -body { + char quote +} -returnCodes error \ + -result {wrong # args: should be "char quote subcommand ?argument ...?"} + +test char-1.3 {char, bogus method} -body { + char quote bogus +} -returnCodes error \ + -result {unknown or ambiguous subcommand "bogus": must be comment, cstring, string, or tcl} + +#---------------------------------------------------------------------- + +test char-2.0 {char tcl, wrong#args} -body { + char quote tcl +} -returnCodes error -result {wrong # args: should be "char quote tcl ch ..."} + +test char-2.1 {char tcl, single char} -body { + char quote tcl A +} -result A + +test char-2.2 {char tcl, multi char} -body { + char quote tcl A B +} -result {A B} + +foreach {n label input expected} { + 0 obrace \{ \\173 + 1 obrckt \[ \\133 + 2 dquote \" \\42 + 3 escape \033 \\33 + 4 lf \n \\n + 5 space { } \\40 + 6 backslash \\ \\134 + 7 A A A + 8 del \177 \\177 + 9 circast \u229b \\u229b +} { + test char-2.3.$n "char tcl, map $label" -body { + char quote tcl $input + } -result $expected + + # collect table columns for string and multi-arg tests. + lappend ll $label + lappend li $input + lappend le $expected +} + +test char-2.4 "char tcl, map string" -body { + char quote tcl [join $li {}] +} -result [join $le {}] + +test char-2.5 "char tcl, map multiple" -body { + char quote tcl {*}$li +} -result $le + +unset -nocomplain n label input expected ll li le + +#---------------------------------------------------------------------- + +test char-3.0 {char string, wrong#args} -body { + char quote string +} -returnCodes error -result {wrong # args: should be "char quote string ch ..."} + +test char-3.1 {char string, single char} -body { + char quote string A +} -result A + +test char-3.2 {char string, multi char} -body { + char quote string A B +} -result {A B} + +foreach {n label input expected} { + 0 obrace \{ \{ + 1 obrckt \[ \[ + 2 dquote \" \" + 3 escape \033 + 4 lf \n + 5 space { } + 6 backslash \\ \\ + 7 A A A + 8 del \177 + 9 circast \u229b \u229b +} { + test char-3.3.$n "char string, map $label" -body { + char quote string $input + } -result $expected + + # collect table columns for string and multi-arg tests. + lappend ll $label + lappend li $input + lappend le $expected +} + +test char-3.4 "char string, map string" -body { + char quote string [join $li {}] +} -result [join $le {}] + +test char-3.5 "char string, map multiple" -body { + char quote string {*}$li +} -result $le + +unset -nocomplain n label input expected ll li le + +#---------------------------------------------------------------------- + +test char-4.0 {char cstring, wrong#args} -body { + char quote cstring +} -returnCodes error -result {wrong # args: should be "char quote cstring ch ..."} + +test char-4.1 {char cstring, single char} -body { + char quote cstring A +} -result A + +test char-4.2 {char cstring, multi char} -body { + char quote cstring A B +} -result {A B} + +foreach {n label input expected} { + 0 obrace \{ \\173 + 1 obrckt \[ \[ + 2 dquote \" \\\" + 3 escape \033 \\33 + 4 lf \n \\n + 5 space { } { } + 6 backslash \\ \\\\ + 7 A A A + 8 del \177 \\177 + 9 circast \u229b \\342\\212\\233 +} { + test char-4.3.$n "char cstring, map $label" -body { + char quote cstring $input + } -result $expected + + # collect table columns for string and multi-arg tests. + lappend ll $label + lappend li $input + lappend le $expected +} + +test char-4.4 "char cstring, map string" -body { + char quote cstring [join $li {}] +} -result [join $le {}] + +test char-4.5 "char cstring, map multiple" -body { + char quote cstring {*}$li +} -result $le + +unset -nocomplain n label input expected ll li le + +#---------------------------------------------------------------------- + +test char-5.0 {char comment, wrong#args} -body { + char quote comment +} -returnCodes error -result {wrong # args: should be "char quote comment ch ..."} + +test char-5.1 {char comment, single char} -body { + char quote comment A +} -result A + +test char-5.2 {char comment, multi char} -body { + char quote comment A B +} -result {A B} + +foreach {n label input expected} { + 0 obrace \{ \\\{ + 1 obrckt \[ \[ + 2 dquote \" \\\" + 3 escape \033 \\33 + 4 lf \n \\n + 5 space { } + 6 backslash \\ \\ + 7 A A A + 8 del \177 \\177 + 9 circast \u229b \\u229b +} { + test char-5.3.$n "char comment, map $label" -body { + char quote comment $input + } -result $expected + + # collect table columns for string and multi-arg tests. + lappend ll $label + lappend li $input + lappend le $expected +} + +test char-5.4 "char comment, map string" -body { + char quote comment [join $li {}] +} -result [join $le {}] + +test char-5.5 "char comment, map multiple" -body { + char quote comment {*}$li +} -result $le + +unset -nocomplain n label input expected ll li le + +#---------------------------------------------------------------------- +return Index: modules/pt/tests/common ================================================================== --- modules/pt/tests/common +++ modules/pt/tests/common @@ -1,9 +1,9 @@ # -*- tcl -*- # Code common to the various control files. # -# Copyright (c) 2009 by Andreas Kupries +# Copyright (c) 2009-2014 by Andreas Kupries # All rights reserved. # # RCS: @(#) $Id: common,v 1.1 2010/03/26 05:07:24 andreas_kupries Exp $ # ------------------------------------------------------------------------- @@ -10,17 +10,18 @@ # Similar to TestFiles in devtools/testutilities.tcl, but not # identical. Here we do not expect source'able test suites, but data # files, organized in sections under a main directory. -proc TestFilesProcess {maindir section inset outset -> nv lv iv dv ev script} { +proc TestFilesProcess {maindir section inset outset -> nv lv iv dv ev script {optionalok 0}} { upvar 1 $nv n $lv label $dv data $ev expected $iv inputfile set pattern $maindir/$section/$inset/* set files [TestFilesGlob $pattern] if {![llength $files]} { + if {$optionalok} return return -code error "No files matching \"$pattern\"" } foreach src $files { if {[string match *README* $src]} continue if {[file isdirectory $src]} continue @@ -34,10 +35,39 @@ @line @line \ {@ %d} {@ %d} \ {@ %p} {@ %p} \ @ $::tcltest::testsDirectory] $expected] + regexp -- {^([0-9]+)} $srcname -> n + regsub -all -- {^[0-9]+} $srcname {} label + + scan $n %d n + set label [string trim [string map {_ { }} $label]] + set inputfile $src + + uplevel 1 $script + } + return +} + + +proc TestFilesProcessIn {maindir section inset -> nv lv iv dv script} { + upvar 1 $nv n $lv label $dv data $iv inputfile + + set pattern $maindir/$section/$inset/* + + set files [TestFilesGlob $pattern] + if {![llength $files]} { + return -code error "No files matching \"$pattern\"" + } + foreach src $files { + if {[string match *README* $src]} continue + if {[file isdirectory $src]} continue + + set srcname [file tail $src] + set data [fileutil::cat -translation binary -encoding utf-8 $src] + regexp -- {^([0-9]+)} $srcname -> n regsub -all -- {^[0-9]+} $srcname {} label scan $n %d n set label [string trim [string map {_ { }} $label]] @@ -238,8 +268,144 @@ foreach ca [$ta children $a] cb [$tb children $b] { match_node $ta $ca $tb $cb } return } + +# ------------------------------------------------------------------------- +## Dynamically create a parser for a PE grammar stored in a string. +## Different types: +## - critcl -- Run through critcl tool for compilation at test time. +## - oo +## - container -- interpreter loaded from a container +## - snit + +proc make-parser {format glabel grammar} { + global pcounter + if {![info exist pcounter]} { set pcounter 0 } + + set debug 0 + set keep 0 + + # should be preloaded by test suite. + if {[catch { + package present pt::pgen + }]} { + error "pt::pgen package required and not loaded. Please fix your testsuite." + } + + # Options per format. + # container : -name + # critcl : -class -name + # oo : -class -name + # snit : -class -name + + set gc GC[incr pcounter] + lappend cmd pt::pgen peg $grammar $format -name G + if {$format ne "container"} { + lappend cmd -class $gc + } + + try { + set code [eval $cmd] + } trap {PT RDE SYNTAX} {e o} { + error [pt::util error2readable $e $grammar] + } + + # debugging generator output + if {$debug} { + set k [expr {$keep ? [open $gc$format w] : "stdout"}] + puts $k "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% $format ($glabel)" + puts $k $code + puts $k "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% $format ($glabel)" + if {$keep} { close $k } + } + + # Now do format-specific post-processing of the generated code to + # get a proper parser object. + + switch -exact -- $format { + container { + # should be preloaded by test suite. + if {[catch { + package present pt::peg::interp + }]} { + error "pt::peg::interp package required and not loaded. Please fix your testsuite." + } + + # Instantiate container class (transient). + eval $code + # Instantiate container (transient). + set c [G %AUTO%] + + # Instantiate PEG interpreter, and configure with grammar in container. + set p [pt::peg::interp %AUTO%] + $p use $c + + # Clean up the transient pieces (container class and instance). + $c destroy + G destroy + } + snit { + # Instantiate the parser class. + # ATTENTION: We chop the last 2 lines of the code first, + # unwanted "package provide" and "return" commands. + eval [join [lrange [split $code \n] 0 end-2] \n] + + # Instantiate a parser based on the class. + set p [$gc %AUTO%] + # Note: Cannot destroy class now, would destroy instance as well. + } + oo { + # Instantiate the parser class. + # ATTENTION: We chop the last 2 lines of the code first, + # unwanted "package provide" and "return" commands. + eval [join [lrange [split $code \n] 0 end-2] \n] + + # Instantiate a parser based on the class. + set p [$gc new] + # Note: Cannot destroy class now, would destroy instance as well. + } + critcl { + # Instantiate the parser class. + # ATTENTION: We chop the last line of the code first, + # unwanted "return" command. + # + # ATTENTION: We muck with [info script] to distinguish the + # multiple parsers going through this file and procedure + # from each other. Without doing this they would all map + # to the same file and critcl bailing on us for code + # redefinition after a compile & link for that file. + + set here [info script] + info script $gc + + eval [join [lrange [split $code \n] 0 end-1] \n] + + # Above invoked critcl's collection of the C fragments. + # We have made sure (in "pt_pgen.test" and + # "tests/pt_pgen.tests") that the critcl package is + # available (we use it in run&compile mode). + + # Hidden in the execution of the command instantiating the + # parser is the compilation, link and load of the C + # pieces, via $auto_index() and [unknown]. + set p [${gc}::${gc}_critcl] + + info script $here + } + } + + # Provide parser instance. + if {$debug} { + puts "P = ($p)" + puts "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% $format ($glabel)" + puts "** [join [info loaded] "\n** "]" + puts "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% $format ($glabel)" + puts %% + puts %%% + } + return $p +} # ------------------------------------------------------------------------- return ADDED modules/pt/tests/data/gr/README.txt Index: modules/pt/tests/data/gr/README.txt ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/README.txt @@ -0,0 +1,50 @@ +This directory contains the test cases for + pt_pgen.test, +via tests/pt_pgen.tests + +Organization: + +* def/_ + Primary test cases. + +Per primary test case FOO we have + +* ok-FOO + Test inputs which result in a sucessful parse. + We must have files here. + +* ok-FOO-res + Per test input file TIF in ok-FOO we have an associated result + file here, also named TIF, containing the output of the + parser, i.e. the generated AST, in raw form, on that input. + +* fail-FOO + Test inputs which result in a failed parse. + This directory can be empty or missing. + Because some expressions (X*, X?) cannot fail. + + NOTE: If an expression can fail, please create test cases + which demonstrate this. + +* fail-FOO--res + Per test input file TIF in fail-FOO we have an associated + result file here, also named TIF, containing the error thrown + by the parser (implemented via ) on that input. + +Possible s are: + + container Parser is the PEG interpreter. Plain Tcl, + possibly accelerated through C-level + implementations for stacks and the like. + + critcl Fully C-based parser, embedded in Critcl. + + oo Premade parser with a Tcl runtime using the + TclOO object system. Possibly accelerated + through C-level implementations for stacks and + the like. + + snit Premade parser with a Tcl runtime using the + snit object system. Possibly accelerated + through C-level implementations for stacks and + the like. ADDED modules/pt/tests/data/gr/TODO Index: modules/pt/tests/data/gr/TODO ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/TODO @@ -0,0 +1,36 @@ +Constructions not yet covered by the test suite ... + +Operator Covered Notes +-------- ------- ----- +. dot y +.. range y char range +alnum y +alpha y +ascii y +cl y general char class, fused char choice +control y +ddigit y +digit y +graph y +lower y +n nonterminal y +printable y +punct y +space y +str y fused char sequence +t terminal y general terminal char +upper y +wordchar y +xdigit y +/ choice y +x sequence y +* repeat0 y kleene ++ repeat1 y pos.kleene +? optional y +! notahead lookahead predicate, assert non-match +-------- ------- ----- +& ahead lookahead predicate, assert match +-------- ------- ----- +epsilon n internal, not directly accessible + only indirectly through "?" +-------- ------- ADDED modules/pt/tests/data/gr/def/0_sequence Index: modules/pt/tests/data/gr/def/0_sequence ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/0_sequence @@ -0,0 +1,2 @@ +PEG a_pe_grammar ('a' 'b' 'c') +END; ADDED modules/pt/tests/data/gr/def/10_kleene Index: modules/pt/tests/data/gr/def/10_kleene ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/10_kleene @@ -0,0 +1,2 @@ +PEG a_pe_grammar ('a'* 'b') +END; ADDED modules/pt/tests/data/gr/def/11_sym-kleene Index: modules/pt/tests/data/gr/def/11_sym-kleene ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/11_sym-kleene @@ -0,0 +1,3 @@ +PEG a_pe_grammar (N) + N <- 'a'* 'b'; +END; ADDED modules/pt/tests/data/gr/def/12_alnum Index: modules/pt/tests/data/gr/def/12_alnum ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/12_alnum @@ -0,0 +1,2 @@ +PEG a_pe_grammar () +END; ADDED modules/pt/tests/data/gr/def/13_sym-alnum Index: modules/pt/tests/data/gr/def/13_sym-alnum ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/13_sym-alnum @@ -0,0 +1,3 @@ +PEG a_pe_grammar (N) + N <- ; +END; ADDED modules/pt/tests/data/gr/def/14_alpha Index: modules/pt/tests/data/gr/def/14_alpha ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/14_alpha @@ -0,0 +1,2 @@ +PEG a_pe_grammar () +END; ADDED modules/pt/tests/data/gr/def/15_sym-alpha Index: modules/pt/tests/data/gr/def/15_sym-alpha ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/15_sym-alpha @@ -0,0 +1,3 @@ +PEG a_pe_grammar (N) + N <- ; +END; ADDED modules/pt/tests/data/gr/def/16_ascii Index: modules/pt/tests/data/gr/def/16_ascii ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/16_ascii @@ -0,0 +1,2 @@ +PEG a_pe_grammar () +END; ADDED modules/pt/tests/data/gr/def/17_sym-ascii Index: modules/pt/tests/data/gr/def/17_sym-ascii ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/17_sym-ascii @@ -0,0 +1,3 @@ +PEG a_pe_grammar (N) + N <- ; +END; ADDED modules/pt/tests/data/gr/def/18_control Index: modules/pt/tests/data/gr/def/18_control ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/18_control @@ -0,0 +1,2 @@ +PEG a_pe_grammar () +END; ADDED modules/pt/tests/data/gr/def/19_sym-control Index: modules/pt/tests/data/gr/def/19_sym-control ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/19_sym-control @@ -0,0 +1,3 @@ +PEG a_pe_grammar (N) + N <- ; +END; ADDED modules/pt/tests/data/gr/def/1_sym-sequence Index: modules/pt/tests/data/gr/def/1_sym-sequence ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/1_sym-sequence @@ -0,0 +1,3 @@ +PEG a_pe_grammar (N) + N <- 'a' 'b' 'c'; +END; ADDED modules/pt/tests/data/gr/def/20_ddigit Index: modules/pt/tests/data/gr/def/20_ddigit ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/20_ddigit @@ -0,0 +1,2 @@ +PEG a_pe_grammar () +END; ADDED modules/pt/tests/data/gr/def/21_sym-ddigit Index: modules/pt/tests/data/gr/def/21_sym-ddigit ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/21_sym-ddigit @@ -0,0 +1,3 @@ +PEG a_pe_grammar (N) + N <- ; +END; ADDED modules/pt/tests/data/gr/def/22_digit Index: modules/pt/tests/data/gr/def/22_digit ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/22_digit @@ -0,0 +1,2 @@ +PEG a_pe_grammar () +END; ADDED modules/pt/tests/data/gr/def/23_sym-digit Index: modules/pt/tests/data/gr/def/23_sym-digit ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/23_sym-digit @@ -0,0 +1,3 @@ +PEG a_pe_grammar (N) + N <- ; +END; ADDED modules/pt/tests/data/gr/def/24_graph Index: modules/pt/tests/data/gr/def/24_graph ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/24_graph @@ -0,0 +1,2 @@ +PEG a_pe_grammar () +END; ADDED modules/pt/tests/data/gr/def/25_sym-graph Index: modules/pt/tests/data/gr/def/25_sym-graph ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/25_sym-graph @@ -0,0 +1,3 @@ +PEG a_pe_grammar (N) + N <- ; +END; ADDED modules/pt/tests/data/gr/def/26_lower Index: modules/pt/tests/data/gr/def/26_lower ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/26_lower @@ -0,0 +1,2 @@ +PEG a_pe_grammar () +END; ADDED modules/pt/tests/data/gr/def/27_sym-lower Index: modules/pt/tests/data/gr/def/27_sym-lower ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/27_sym-lower @@ -0,0 +1,3 @@ +PEG a_pe_grammar (N) + N <- ; +END; ADDED modules/pt/tests/data/gr/def/28_print Index: modules/pt/tests/data/gr/def/28_print ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/28_print @@ -0,0 +1,2 @@ +PEG a_pe_grammar () +END; ADDED modules/pt/tests/data/gr/def/29_sym-print Index: modules/pt/tests/data/gr/def/29_sym-print ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/29_sym-print @@ -0,0 +1,3 @@ +PEG a_pe_grammar (N) + N <- ; +END; ADDED modules/pt/tests/data/gr/def/2_choice Index: modules/pt/tests/data/gr/def/2_choice ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/2_choice @@ -0,0 +1,2 @@ +PEG a_pe_grammar ('alpha' / 'anumeric' / 'digit') +END; ADDED modules/pt/tests/data/gr/def/30_punct Index: modules/pt/tests/data/gr/def/30_punct ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/30_punct @@ -0,0 +1,2 @@ +PEG a_pe_grammar () +END; ADDED modules/pt/tests/data/gr/def/31_sym-punct Index: modules/pt/tests/data/gr/def/31_sym-punct ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/31_sym-punct @@ -0,0 +1,3 @@ +PEG a_pe_grammar (N) + N <- ; +END; ADDED modules/pt/tests/data/gr/def/32_space Index: modules/pt/tests/data/gr/def/32_space ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/32_space @@ -0,0 +1,2 @@ +PEG a_pe_grammar () +END; ADDED modules/pt/tests/data/gr/def/33_sym-space Index: modules/pt/tests/data/gr/def/33_sym-space ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/33_sym-space @@ -0,0 +1,3 @@ +PEG a_pe_grammar (N) + N <- ; +END; ADDED modules/pt/tests/data/gr/def/34_upper Index: modules/pt/tests/data/gr/def/34_upper ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/34_upper @@ -0,0 +1,2 @@ +PEG a_pe_grammar () +END; ADDED modules/pt/tests/data/gr/def/35_sym-upper Index: modules/pt/tests/data/gr/def/35_sym-upper ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/35_sym-upper @@ -0,0 +1,3 @@ +PEG a_pe_grammar (N) + N <- ; +END; ADDED modules/pt/tests/data/gr/def/36_wordchar Index: modules/pt/tests/data/gr/def/36_wordchar ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/36_wordchar @@ -0,0 +1,2 @@ +PEG a_pe_grammar () +END; ADDED modules/pt/tests/data/gr/def/37_sym-wordchar Index: modules/pt/tests/data/gr/def/37_sym-wordchar ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/37_sym-wordchar @@ -0,0 +1,3 @@ +PEG a_pe_grammar (N) + N <- ; +END; ADDED modules/pt/tests/data/gr/def/38_xdigit Index: modules/pt/tests/data/gr/def/38_xdigit ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/38_xdigit @@ -0,0 +1,2 @@ +PEG a_pe_grammar () +END; ADDED modules/pt/tests/data/gr/def/39_sym-xdigit Index: modules/pt/tests/data/gr/def/39_sym-xdigit ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/39_sym-xdigit @@ -0,0 +1,3 @@ +PEG a_pe_grammar (N) + N <- ; +END; ADDED modules/pt/tests/data/gr/def/3_sym-choice Index: modules/pt/tests/data/gr/def/3_sym-choice ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/3_sym-choice @@ -0,0 +1,3 @@ +PEG a_pe_grammar (N) + N <- 'alpha' / 'anumeric' / 'digit'; +END; ADDED modules/pt/tests/data/gr/def/40_dot Index: modules/pt/tests/data/gr/def/40_dot ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/40_dot @@ -0,0 +1,2 @@ +PEG a_pe_grammar (.) +END; ADDED modules/pt/tests/data/gr/def/41_sym-dot Index: modules/pt/tests/data/gr/def/41_sym-dot ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/41_sym-dot @@ -0,0 +1,3 @@ +PEG a_pe_grammar (N) + N <- .; +END; ADDED modules/pt/tests/data/gr/def/42_optional Index: modules/pt/tests/data/gr/def/42_optional ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/42_optional @@ -0,0 +1,2 @@ +PEG a_pe_grammar ("have"? "not") +END; ADDED modules/pt/tests/data/gr/def/43_sym-optional Index: modules/pt/tests/data/gr/def/43_sym-optional ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/43_sym-optional @@ -0,0 +1,3 @@ +PEG a_pe_grammar (N) + N <- "have"? "not"; +END; ADDED modules/pt/tests/data/gr/def/44_notahead Index: modules/pt/tests/data/gr/def/44_notahead ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/44_notahead @@ -0,0 +1,3 @@ +# An identifier is an alphanumeric string which is not a keyword. +PEG a_pe_grammar (!("serial"!) ( + !)) +END; ADDED modules/pt/tests/data/gr/def/45_sym-notahead Index: modules/pt/tests/data/gr/def/45_sym-notahead ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/45_sym-notahead @@ -0,0 +1,4 @@ +# An identifier is an alphanumeric string which is not a keyword. +PEG a_pe_grammar (N) + N <- !("serial"!) ( + !); +END; ADDED modules/pt/tests/data/gr/def/46_ahead Index: modules/pt/tests/data/gr/def/46_ahead ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/46_ahead @@ -0,0 +1,2 @@ +PEG a_pe_grammar ( + &'=') +END; ADDED modules/pt/tests/data/gr/def/47_sym-ahead Index: modules/pt/tests/data/gr/def/47_sym-ahead ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/47_sym-ahead @@ -0,0 +1,3 @@ +PEG a_pe_grammar (N) + N <- + &'='; +END; ADDED modules/pt/tests/data/gr/def/4_class Index: modules/pt/tests/data/gr/def/4_class ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/4_class @@ -0,0 +1,2 @@ +PEG a_pe_grammar ([axe]) +END; ADDED modules/pt/tests/data/gr/def/5_sym-class Index: modules/pt/tests/data/gr/def/5_sym-class ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/5_sym-class @@ -0,0 +1,3 @@ +PEG a_pe_grammar (N) + N <- [axe]; +END; ADDED modules/pt/tests/data/gr/def/6_range Index: modules/pt/tests/data/gr/def/6_range ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/6_range @@ -0,0 +1,2 @@ +PEG a_pe_grammar ("0x" [A-F]) +END; ADDED modules/pt/tests/data/gr/def/7_sym-range Index: modules/pt/tests/data/gr/def/7_sym-range ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/7_sym-range @@ -0,0 +1,3 @@ +PEG a_pe_grammar (N) + N <- "0x" [A-F]; +END; ADDED modules/pt/tests/data/gr/def/8_pkleene Index: modules/pt/tests/data/gr/def/8_pkleene ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/8_pkleene @@ -0,0 +1,2 @@ +PEG a_pe_grammar ('a'+ 'b') +END; ADDED modules/pt/tests/data/gr/def/9_sym-pkleene Index: modules/pt/tests/data/gr/def/9_sym-pkleene ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/def/9_sym-pkleene @@ -0,0 +1,3 @@ +PEG a_pe_grammar (N) + N <- 'a'+ 'b'; +END; ADDED modules/pt/tests/data/gr/fail-ahead-container-res/0_notmatch Index: modules/pt/tests/data/gr/fail-ahead-container-res/0_notmatch ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-ahead-container-res/0_notmatch @@ -0,0 +1,1 @@ +1 {pt::rde 4 {alnum {t =}}} ADDED modules/pt/tests/data/gr/fail-ahead-critcl-res/0_notmatch Index: modules/pt/tests/data/gr/fail-ahead-critcl-res/0_notmatch ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-ahead-critcl-res/0_notmatch @@ -0,0 +1,1 @@ +1 {pt::rde 4 {alnum {t =}}} ADDED modules/pt/tests/data/gr/fail-ahead-oo-res/0_notmatch Index: modules/pt/tests/data/gr/fail-ahead-oo-res/0_notmatch ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-ahead-oo-res/0_notmatch @@ -0,0 +1,1 @@ +1 {pt::rde 4 {alnum {t =}}} ADDED modules/pt/tests/data/gr/fail-ahead-snit-res/0_notmatch Index: modules/pt/tests/data/gr/fail-ahead-snit-res/0_notmatch ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-ahead-snit-res/0_notmatch @@ -0,0 +1,1 @@ +1 {pt::rde 4 {alnum {t =}}} ADDED modules/pt/tests/data/gr/fail-ahead/0_notmatch Index: modules/pt/tests/data/gr/fail-ahead/0_notmatch ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-ahead/0_notmatch @@ -0,0 +1,1 @@ +abba, ADDED modules/pt/tests/data/gr/fail-alnum-container-res/0_outside Index: modules/pt/tests/data/gr/fail-alnum-container-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-alnum-container-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 alnum} ADDED modules/pt/tests/data/gr/fail-alnum-critcl-res/0_outside Index: modules/pt/tests/data/gr/fail-alnum-critcl-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-alnum-critcl-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 alnum} ADDED modules/pt/tests/data/gr/fail-alnum-oo-res/0_outside Index: modules/pt/tests/data/gr/fail-alnum-oo-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-alnum-oo-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 alnum} ADDED modules/pt/tests/data/gr/fail-alnum-snit-res/0_outside Index: modules/pt/tests/data/gr/fail-alnum-snit-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-alnum-snit-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 alnum} ADDED modules/pt/tests/data/gr/fail-alnum/0_outside Index: modules/pt/tests/data/gr/fail-alnum/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-alnum/0_outside @@ -0,0 +1,1 @@ += ADDED modules/pt/tests/data/gr/fail-alpha-container-res/0_outside Index: modules/pt/tests/data/gr/fail-alpha-container-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-alpha-container-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 alpha} ADDED modules/pt/tests/data/gr/fail-alpha-critcl-res/0_outside Index: modules/pt/tests/data/gr/fail-alpha-critcl-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-alpha-critcl-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 alpha} ADDED modules/pt/tests/data/gr/fail-alpha-oo-res/0_outside Index: modules/pt/tests/data/gr/fail-alpha-oo-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-alpha-oo-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 alpha} ADDED modules/pt/tests/data/gr/fail-alpha-snit-res/0_outside Index: modules/pt/tests/data/gr/fail-alpha-snit-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-alpha-snit-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 alpha} ADDED modules/pt/tests/data/gr/fail-alpha/0_outside Index: modules/pt/tests/data/gr/fail-alpha/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-alpha/0_outside @@ -0,0 +1,1 @@ += ADDED modules/pt/tests/data/gr/fail-ascii-container-res/0_outside Index: modules/pt/tests/data/gr/fail-ascii-container-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-ascii-container-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 ascii} ADDED modules/pt/tests/data/gr/fail-ascii-critcl-res/0_outside Index: modules/pt/tests/data/gr/fail-ascii-critcl-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-ascii-critcl-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 ascii} ADDED modules/pt/tests/data/gr/fail-ascii-oo-res/0_outside Index: modules/pt/tests/data/gr/fail-ascii-oo-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-ascii-oo-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 ascii} ADDED modules/pt/tests/data/gr/fail-ascii-snit-res/0_outside Index: modules/pt/tests/data/gr/fail-ascii-snit-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-ascii-snit-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 ascii} ADDED modules/pt/tests/data/gr/fail-ascii/0_outside Index: modules/pt/tests/data/gr/fail-ascii/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-ascii/0_outside @@ -0,0 +1,1 @@ + ADDED modules/pt/tests/data/gr/fail-choice-container-res/0_aleph Index: modules/pt/tests/data/gr/fail-choice-container-res/0_aleph ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-choice-container-res/0_aleph @@ -0,0 +1,1 @@ +1 {pt::rde 2 {{t p}}} ADDED modules/pt/tests/data/gr/fail-choice-container-res/1_anumber Index: modules/pt/tests/data/gr/fail-choice-container-res/1_anumber ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-choice-container-res/1_anumber @@ -0,0 +1,1 @@ +1 {pt::rde 4 {{t e}}} ADDED modules/pt/tests/data/gr/fail-choice-container-res/2_digup Index: modules/pt/tests/data/gr/fail-choice-container-res/2_digup ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-choice-container-res/2_digup @@ -0,0 +1,1 @@ +1 {pt::rde 3 {{t i}}} ADDED modules/pt/tests/data/gr/fail-choice-container-res/3_other Index: modules/pt/tests/data/gr/fail-choice-container-res/3_other ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-choice-container-res/3_other @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{t a} {t d}}} ADDED modules/pt/tests/data/gr/fail-choice-critcl-res/0_aleph Index: modules/pt/tests/data/gr/fail-choice-critcl-res/0_aleph ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-choice-critcl-res/0_aleph @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str alpha} {str anumeric} {str digit}}} ADDED modules/pt/tests/data/gr/fail-choice-critcl-res/1_anumber Index: modules/pt/tests/data/gr/fail-choice-critcl-res/1_anumber ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-choice-critcl-res/1_anumber @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str alpha} {str anumeric} {str digit}}} ADDED modules/pt/tests/data/gr/fail-choice-critcl-res/2_digup Index: modules/pt/tests/data/gr/fail-choice-critcl-res/2_digup ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-choice-critcl-res/2_digup @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str alpha} {str anumeric} {str digit}}} ADDED modules/pt/tests/data/gr/fail-choice-critcl-res/3_other Index: modules/pt/tests/data/gr/fail-choice-critcl-res/3_other ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-choice-critcl-res/3_other @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str alpha} {str anumeric} {str digit}}} ADDED modules/pt/tests/data/gr/fail-choice-oo-res/0_aleph Index: modules/pt/tests/data/gr/fail-choice-oo-res/0_aleph ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-choice-oo-res/0_aleph @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str alpha} {str anumeric} {str digit}}} ADDED modules/pt/tests/data/gr/fail-choice-oo-res/1_anumber Index: modules/pt/tests/data/gr/fail-choice-oo-res/1_anumber ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-choice-oo-res/1_anumber @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str alpha} {str anumeric} {str digit}}} ADDED modules/pt/tests/data/gr/fail-choice-oo-res/2_digup Index: modules/pt/tests/data/gr/fail-choice-oo-res/2_digup ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-choice-oo-res/2_digup @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str alpha} {str anumeric} {str digit}}} ADDED modules/pt/tests/data/gr/fail-choice-oo-res/3_other Index: modules/pt/tests/data/gr/fail-choice-oo-res/3_other ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-choice-oo-res/3_other @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str alpha} {str anumeric} {str digit}}} ADDED modules/pt/tests/data/gr/fail-choice-snit-res/0_aleph Index: modules/pt/tests/data/gr/fail-choice-snit-res/0_aleph ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-choice-snit-res/0_aleph @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str alpha} {str anumeric} {str digit}}} ADDED modules/pt/tests/data/gr/fail-choice-snit-res/1_anumber Index: modules/pt/tests/data/gr/fail-choice-snit-res/1_anumber ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-choice-snit-res/1_anumber @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str alpha} {str anumeric} {str digit}}} ADDED modules/pt/tests/data/gr/fail-choice-snit-res/2_digup Index: modules/pt/tests/data/gr/fail-choice-snit-res/2_digup ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-choice-snit-res/2_digup @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str alpha} {str anumeric} {str digit}}} ADDED modules/pt/tests/data/gr/fail-choice-snit-res/3_other Index: modules/pt/tests/data/gr/fail-choice-snit-res/3_other ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-choice-snit-res/3_other @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str alpha} {str anumeric} {str digit}}} ADDED modules/pt/tests/data/gr/fail-choice/0_aleph Index: modules/pt/tests/data/gr/fail-choice/0_aleph ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-choice/0_aleph @@ -0,0 +1,1 @@ +aleph ADDED modules/pt/tests/data/gr/fail-choice/1_anumber Index: modules/pt/tests/data/gr/fail-choice/1_anumber ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-choice/1_anumber @@ -0,0 +1,1 @@ +anumber ADDED modules/pt/tests/data/gr/fail-choice/2_digup Index: modules/pt/tests/data/gr/fail-choice/2_digup ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-choice/2_digup @@ -0,0 +1,1 @@ +digup ADDED modules/pt/tests/data/gr/fail-choice/3_other Index: modules/pt/tests/data/gr/fail-choice/3_other ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-choice/3_other @@ -0,0 +1,1 @@ +other ADDED modules/pt/tests/data/gr/fail-class-container-res/0_beta Index: modules/pt/tests/data/gr/fail-class-container-res/0_beta ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-class-container-res/0_beta @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{t a} {t e} {t x}}} ADDED modules/pt/tests/data/gr/fail-class-critcl-res/0_beta Index: modules/pt/tests/data/gr/fail-class-critcl-res/0_beta ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-class-critcl-res/0_beta @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{cl axe}}} ADDED modules/pt/tests/data/gr/fail-class-oo-res/0_beta Index: modules/pt/tests/data/gr/fail-class-oo-res/0_beta ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-class-oo-res/0_beta @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{cl axe}}} ADDED modules/pt/tests/data/gr/fail-class-snit-res/0_beta Index: modules/pt/tests/data/gr/fail-class-snit-res/0_beta ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-class-snit-res/0_beta @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{cl axe}}} ADDED modules/pt/tests/data/gr/fail-class/0_beta Index: modules/pt/tests/data/gr/fail-class/0_beta ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-class/0_beta @@ -0,0 +1,1 @@ +beta ADDED modules/pt/tests/data/gr/fail-control-container-res/0_outside Index: modules/pt/tests/data/gr/fail-control-container-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-control-container-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 control} ADDED modules/pt/tests/data/gr/fail-control-critcl-res/0_outside Index: modules/pt/tests/data/gr/fail-control-critcl-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-control-critcl-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 control} ADDED modules/pt/tests/data/gr/fail-control-oo-res/0_outside Index: modules/pt/tests/data/gr/fail-control-oo-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-control-oo-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 control} ADDED modules/pt/tests/data/gr/fail-control-snit-res/0_outside Index: modules/pt/tests/data/gr/fail-control-snit-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-control-snit-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 control} ADDED modules/pt/tests/data/gr/fail-control/0_outside Index: modules/pt/tests/data/gr/fail-control/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-control/0_outside @@ -0,0 +1,1 @@ +A ADDED modules/pt/tests/data/gr/fail-ddigit-container-res/0_outside Index: modules/pt/tests/data/gr/fail-ddigit-container-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-ddigit-container-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 ddigit} ADDED modules/pt/tests/data/gr/fail-ddigit-critcl-res/0_outside Index: modules/pt/tests/data/gr/fail-ddigit-critcl-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-ddigit-critcl-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 ddigit} ADDED modules/pt/tests/data/gr/fail-ddigit-oo-res/0_outside Index: modules/pt/tests/data/gr/fail-ddigit-oo-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-ddigit-oo-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 ddigit} ADDED modules/pt/tests/data/gr/fail-ddigit-snit-res/0_outside Index: modules/pt/tests/data/gr/fail-ddigit-snit-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-ddigit-snit-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 ddigit} ADDED modules/pt/tests/data/gr/fail-ddigit/0_outside Index: modules/pt/tests/data/gr/fail-ddigit/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-ddigit/0_outside @@ -0,0 +1,1 @@ +F ADDED modules/pt/tests/data/gr/fail-digit-container-res/0_outside Index: modules/pt/tests/data/gr/fail-digit-container-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-digit-container-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 digit} ADDED modules/pt/tests/data/gr/fail-digit-critcl-res/0_outside Index: modules/pt/tests/data/gr/fail-digit-critcl-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-digit-critcl-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 digit} ADDED modules/pt/tests/data/gr/fail-digit-oo-res/0_outside Index: modules/pt/tests/data/gr/fail-digit-oo-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-digit-oo-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 digit} ADDED modules/pt/tests/data/gr/fail-digit-snit-res/0_outside Index: modules/pt/tests/data/gr/fail-digit-snit-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-digit-snit-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 digit} ADDED modules/pt/tests/data/gr/fail-digit/0_outside Index: modules/pt/tests/data/gr/fail-digit/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-digit/0_outside @@ -0,0 +1,1 @@ +F ADDED modules/pt/tests/data/gr/fail-dot-container-res/0_none Index: modules/pt/tests/data/gr/fail-dot-container-res/0_none ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-dot-container-res/0_none @@ -0,0 +1,1 @@ +1 {pt::rde 0 dot} ADDED modules/pt/tests/data/gr/fail-dot-critcl-res/0_none Index: modules/pt/tests/data/gr/fail-dot-critcl-res/0_none ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-dot-critcl-res/0_none @@ -0,0 +1,1 @@ +1 {pt::rde 0 dot} ADDED modules/pt/tests/data/gr/fail-dot-oo-res/0_none Index: modules/pt/tests/data/gr/fail-dot-oo-res/0_none ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-dot-oo-res/0_none @@ -0,0 +1,1 @@ +1 {pt::rde 0 dot} ADDED modules/pt/tests/data/gr/fail-dot-snit-res/0_none Index: modules/pt/tests/data/gr/fail-dot-snit-res/0_none ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-dot-snit-res/0_none @@ -0,0 +1,1 @@ +1 {pt::rde 0 dot} ADDED modules/pt/tests/data/gr/fail-dot/0_none Index: modules/pt/tests/data/gr/fail-dot/0_none ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-dot/0_none ADDED modules/pt/tests/data/gr/fail-graph-container-res/0_outside Index: modules/pt/tests/data/gr/fail-graph-container-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-graph-container-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 graph} ADDED modules/pt/tests/data/gr/fail-graph-critcl-res/0_outside Index: modules/pt/tests/data/gr/fail-graph-critcl-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-graph-critcl-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 graph} ADDED modules/pt/tests/data/gr/fail-graph-oo-res/0_outside Index: modules/pt/tests/data/gr/fail-graph-oo-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-graph-oo-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 graph} ADDED modules/pt/tests/data/gr/fail-graph-snit-res/0_outside Index: modules/pt/tests/data/gr/fail-graph-snit-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-graph-snit-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 graph} ADDED modules/pt/tests/data/gr/fail-graph/0_outside Index: modules/pt/tests/data/gr/fail-graph/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-graph/0_outside @@ -0,0 +1,1 @@ + ADDED modules/pt/tests/data/gr/fail-lower-container-res/0_outside Index: modules/pt/tests/data/gr/fail-lower-container-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-lower-container-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 lower} ADDED modules/pt/tests/data/gr/fail-lower-critcl-res/0_outside Index: modules/pt/tests/data/gr/fail-lower-critcl-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-lower-critcl-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 lower} ADDED modules/pt/tests/data/gr/fail-lower-oo-res/0_outside Index: modules/pt/tests/data/gr/fail-lower-oo-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-lower-oo-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 lower} ADDED modules/pt/tests/data/gr/fail-lower-snit-res/0_outside Index: modules/pt/tests/data/gr/fail-lower-snit-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-lower-snit-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 lower} ADDED modules/pt/tests/data/gr/fail-lower/0_outside Index: modules/pt/tests/data/gr/fail-lower/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-lower/0_outside @@ -0,0 +1,1 @@ +A ADDED modules/pt/tests/data/gr/fail-notahead-container-res/0_keyword Index: modules/pt/tests/data/gr/fail-notahead-container-res/0_keyword ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-notahead-container-res/0_keyword @@ -0,0 +1,1 @@ +1 {pt::rde 6 alnum} ADDED modules/pt/tests/data/gr/fail-notahead-critcl-res/0_keyword Index: modules/pt/tests/data/gr/fail-notahead-critcl-res/0_keyword ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-notahead-critcl-res/0_keyword @@ -0,0 +1,1 @@ +1 {pt::rde 6 alnum} ADDED modules/pt/tests/data/gr/fail-notahead-oo-res/0_keyword Index: modules/pt/tests/data/gr/fail-notahead-oo-res/0_keyword ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-notahead-oo-res/0_keyword @@ -0,0 +1,1 @@ +1 {pt::rde 6 alnum} ADDED modules/pt/tests/data/gr/fail-notahead-snit-res/0_keyword Index: modules/pt/tests/data/gr/fail-notahead-snit-res/0_keyword ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-notahead-snit-res/0_keyword @@ -0,0 +1,1 @@ +1 {pt::rde 6 alnum} ADDED modules/pt/tests/data/gr/fail-notahead/0_keyword Index: modules/pt/tests/data/gr/fail-notahead/0_keyword ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-notahead/0_keyword @@ -0,0 +1,1 @@ +serial ADDED modules/pt/tests/data/gr/fail-pkleene-container-res/0_b Index: modules/pt/tests/data/gr/fail-pkleene-container-res/0_b ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-pkleene-container-res/0_b @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{t a}}} ADDED modules/pt/tests/data/gr/fail-pkleene-critcl-res/0_b Index: modules/pt/tests/data/gr/fail-pkleene-critcl-res/0_b ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-pkleene-critcl-res/0_b @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{t a}}} ADDED modules/pt/tests/data/gr/fail-pkleene-oo-res/0_b Index: modules/pt/tests/data/gr/fail-pkleene-oo-res/0_b ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-pkleene-oo-res/0_b @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{t a}}} ADDED modules/pt/tests/data/gr/fail-pkleene-snit-res/0_b Index: modules/pt/tests/data/gr/fail-pkleene-snit-res/0_b ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-pkleene-snit-res/0_b @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{t a}}} ADDED modules/pt/tests/data/gr/fail-pkleene/0_b Index: modules/pt/tests/data/gr/fail-pkleene/0_b ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-pkleene/0_b @@ -0,0 +1,1 @@ +b ADDED modules/pt/tests/data/gr/fail-print-container-res/0_outside Index: modules/pt/tests/data/gr/fail-print-container-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-print-container-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 print} ADDED modules/pt/tests/data/gr/fail-print-critcl-res/0_outside Index: modules/pt/tests/data/gr/fail-print-critcl-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-print-critcl-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 print} ADDED modules/pt/tests/data/gr/fail-print-oo-res/0_outside Index: modules/pt/tests/data/gr/fail-print-oo-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-print-oo-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 print} ADDED modules/pt/tests/data/gr/fail-print-snit-res/0_outside Index: modules/pt/tests/data/gr/fail-print-snit-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-print-snit-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 print} ADDED modules/pt/tests/data/gr/fail-print/0_outside Index: modules/pt/tests/data/gr/fail-print/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-print/0_outside @@ -0,0 +1,1 @@ + ADDED modules/pt/tests/data/gr/fail-punct-container-res/0_outside Index: modules/pt/tests/data/gr/fail-punct-container-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-punct-container-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 punct} ADDED modules/pt/tests/data/gr/fail-punct-critcl-res/0_outside Index: modules/pt/tests/data/gr/fail-punct-critcl-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-punct-critcl-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 punct} ADDED modules/pt/tests/data/gr/fail-punct-oo-res/0_outside Index: modules/pt/tests/data/gr/fail-punct-oo-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-punct-oo-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 punct} ADDED modules/pt/tests/data/gr/fail-punct-snit-res/0_outside Index: modules/pt/tests/data/gr/fail-punct-snit-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-punct-snit-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 punct} ADDED modules/pt/tests/data/gr/fail-punct/0_outside Index: modules/pt/tests/data/gr/fail-punct/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-punct/0_outside @@ -0,0 +1,1 @@ += ADDED modules/pt/tests/data/gr/fail-range-container-res/0_beta Index: modules/pt/tests/data/gr/fail-range-container-res/0_beta ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-range-container-res/0_beta @@ -0,0 +1,1 @@ +1 {pt::rde 2 {{.. A F}}} ADDED modules/pt/tests/data/gr/fail-range-critcl-res/0_beta Index: modules/pt/tests/data/gr/fail-range-critcl-res/0_beta ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-range-critcl-res/0_beta @@ -0,0 +1,1 @@ +1 {pt::rde 2 {{.. A F}}} ADDED modules/pt/tests/data/gr/fail-range-oo-res/0_beta Index: modules/pt/tests/data/gr/fail-range-oo-res/0_beta ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-range-oo-res/0_beta @@ -0,0 +1,1 @@ +1 {pt::rde 2 {{.. A F}}} ADDED modules/pt/tests/data/gr/fail-range-snit-res/0_beta Index: modules/pt/tests/data/gr/fail-range-snit-res/0_beta ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-range-snit-res/0_beta @@ -0,0 +1,1 @@ +1 {pt::rde 2 {{.. A F}}} ADDED modules/pt/tests/data/gr/fail-range/0_beta Index: modules/pt/tests/data/gr/fail-range/0_beta ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-range/0_beta @@ -0,0 +1,1 @@ +0xbeta ADDED modules/pt/tests/data/gr/fail-sequence-container-res/0_abe Index: modules/pt/tests/data/gr/fail-sequence-container-res/0_abe ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sequence-container-res/0_abe @@ -0,0 +1,1 @@ +1 {pt::rde 2 {{t c}}} ADDED modules/pt/tests/data/gr/fail-sequence-container-res/1_b Index: modules/pt/tests/data/gr/fail-sequence-container-res/1_b ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sequence-container-res/1_b @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{t a}}} ADDED modules/pt/tests/data/gr/fail-sequence-critcl-res/0_abe Index: modules/pt/tests/data/gr/fail-sequence-critcl-res/0_abe ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sequence-critcl-res/0_abe @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str abc}}} ADDED modules/pt/tests/data/gr/fail-sequence-critcl-res/1_b Index: modules/pt/tests/data/gr/fail-sequence-critcl-res/1_b ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sequence-critcl-res/1_b @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str abc}}} ADDED modules/pt/tests/data/gr/fail-sequence-oo-res/0_abe Index: modules/pt/tests/data/gr/fail-sequence-oo-res/0_abe ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sequence-oo-res/0_abe @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str abc}}} ADDED modules/pt/tests/data/gr/fail-sequence-oo-res/1_b Index: modules/pt/tests/data/gr/fail-sequence-oo-res/1_b ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sequence-oo-res/1_b @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str abc}}} ADDED modules/pt/tests/data/gr/fail-sequence-snit-res/0_abe Index: modules/pt/tests/data/gr/fail-sequence-snit-res/0_abe ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sequence-snit-res/0_abe @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str abc}}} ADDED modules/pt/tests/data/gr/fail-sequence-snit-res/1_b Index: modules/pt/tests/data/gr/fail-sequence-snit-res/1_b ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sequence-snit-res/1_b @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str abc}}} ADDED modules/pt/tests/data/gr/fail-sequence/0_abe Index: modules/pt/tests/data/gr/fail-sequence/0_abe ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sequence/0_abe @@ -0,0 +1,1 @@ +abe ADDED modules/pt/tests/data/gr/fail-sequence/1_b Index: modules/pt/tests/data/gr/fail-sequence/1_b ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sequence/1_b @@ -0,0 +1,1 @@ +b ADDED modules/pt/tests/data/gr/fail-space-container-res/0_outside Index: modules/pt/tests/data/gr/fail-space-container-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-space-container-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 space} ADDED modules/pt/tests/data/gr/fail-space-critcl-res/0_outside Index: modules/pt/tests/data/gr/fail-space-critcl-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-space-critcl-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 space} ADDED modules/pt/tests/data/gr/fail-space-oo-res/0_outside Index: modules/pt/tests/data/gr/fail-space-oo-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-space-oo-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 space} ADDED modules/pt/tests/data/gr/fail-space-snit-res/0_outside Index: modules/pt/tests/data/gr/fail-space-snit-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-space-snit-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 space} ADDED modules/pt/tests/data/gr/fail-space/0_outside Index: modules/pt/tests/data/gr/fail-space/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-space/0_outside @@ -0,0 +1,1 @@ +X ADDED modules/pt/tests/data/gr/fail-sym-ahead-container-res/0_notmatch Index: modules/pt/tests/data/gr/fail-sym-ahead-container-res/0_notmatch ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-ahead-container-res/0_notmatch @@ -0,0 +1,1 @@ +1 {pt::rde 4 {alnum {t =}}} ADDED modules/pt/tests/data/gr/fail-sym-ahead-critcl-res/0_notmatch Index: modules/pt/tests/data/gr/fail-sym-ahead-critcl-res/0_notmatch ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-ahead-critcl-res/0_notmatch @@ -0,0 +1,1 @@ +1 {pt::rde 4 {alnum {t =}}} ADDED modules/pt/tests/data/gr/fail-sym-ahead-oo-res/0_notmatch Index: modules/pt/tests/data/gr/fail-sym-ahead-oo-res/0_notmatch ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-ahead-oo-res/0_notmatch @@ -0,0 +1,1 @@ +1 {pt::rde 4 {alnum {t =}}} ADDED modules/pt/tests/data/gr/fail-sym-ahead-snit-res/0_notmatch Index: modules/pt/tests/data/gr/fail-sym-ahead-snit-res/0_notmatch ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-ahead-snit-res/0_notmatch @@ -0,0 +1,1 @@ +1 {pt::rde 4 {alnum {t =}}} ADDED modules/pt/tests/data/gr/fail-sym-ahead/0_notmatch Index: modules/pt/tests/data/gr/fail-sym-ahead/0_notmatch ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-ahead/0_notmatch @@ -0,0 +1,1 @@ +abba, ADDED modules/pt/tests/data/gr/fail-sym-alnum-container-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-alnum-container-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-alnum-container-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 alnum} ADDED modules/pt/tests/data/gr/fail-sym-alnum-critcl-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-alnum-critcl-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-alnum-critcl-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 alnum} ADDED modules/pt/tests/data/gr/fail-sym-alnum-oo-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-alnum-oo-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-alnum-oo-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 alnum} ADDED modules/pt/tests/data/gr/fail-sym-alnum-snit-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-alnum-snit-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-alnum-snit-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 alnum} ADDED modules/pt/tests/data/gr/fail-sym-alnum/0_outside Index: modules/pt/tests/data/gr/fail-sym-alnum/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-alnum/0_outside @@ -0,0 +1,1 @@ += ADDED modules/pt/tests/data/gr/fail-sym-alpha-container-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-alpha-container-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-alpha-container-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 alpha} ADDED modules/pt/tests/data/gr/fail-sym-alpha-critcl-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-alpha-critcl-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-alpha-critcl-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 alpha} ADDED modules/pt/tests/data/gr/fail-sym-alpha-oo-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-alpha-oo-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-alpha-oo-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 alpha} ADDED modules/pt/tests/data/gr/fail-sym-alpha-snit-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-alpha-snit-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-alpha-snit-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 alpha} ADDED modules/pt/tests/data/gr/fail-sym-alpha/0_outside Index: modules/pt/tests/data/gr/fail-sym-alpha/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-alpha/0_outside @@ -0,0 +1,1 @@ += ADDED modules/pt/tests/data/gr/fail-sym-ascii-container-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-ascii-container-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-ascii-container-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 ascii} ADDED modules/pt/tests/data/gr/fail-sym-ascii-critcl-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-ascii-critcl-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-ascii-critcl-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 ascii} ADDED modules/pt/tests/data/gr/fail-sym-ascii-oo-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-ascii-oo-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-ascii-oo-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 ascii} ADDED modules/pt/tests/data/gr/fail-sym-ascii-snit-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-ascii-snit-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-ascii-snit-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 ascii} ADDED modules/pt/tests/data/gr/fail-sym-ascii/0_outside Index: modules/pt/tests/data/gr/fail-sym-ascii/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-ascii/0_outside @@ -0,0 +1,1 @@ + ADDED modules/pt/tests/data/gr/fail-sym-choice-container-res/0_aleph Index: modules/pt/tests/data/gr/fail-sym-choice-container-res/0_aleph ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-choice-container-res/0_aleph @@ -0,0 +1,1 @@ +1 {pt::rde 2 {{t p}}} ADDED modules/pt/tests/data/gr/fail-sym-choice-container-res/1_anumber Index: modules/pt/tests/data/gr/fail-sym-choice-container-res/1_anumber ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-choice-container-res/1_anumber @@ -0,0 +1,1 @@ +1 {pt::rde 4 {{t e}}} ADDED modules/pt/tests/data/gr/fail-sym-choice-container-res/2_digup Index: modules/pt/tests/data/gr/fail-sym-choice-container-res/2_digup ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-choice-container-res/2_digup @@ -0,0 +1,1 @@ +1 {pt::rde 3 {{t i}}} ADDED modules/pt/tests/data/gr/fail-sym-choice-container-res/3_other Index: modules/pt/tests/data/gr/fail-sym-choice-container-res/3_other ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-choice-container-res/3_other @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{t a} {t d}}} ADDED modules/pt/tests/data/gr/fail-sym-choice-critcl-res/0_aleph Index: modules/pt/tests/data/gr/fail-sym-choice-critcl-res/0_aleph ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-choice-critcl-res/0_aleph @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str alpha} {str anumeric} {str digit}}} ADDED modules/pt/tests/data/gr/fail-sym-choice-critcl-res/1_anumber Index: modules/pt/tests/data/gr/fail-sym-choice-critcl-res/1_anumber ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-choice-critcl-res/1_anumber @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str alpha} {str anumeric} {str digit}}} ADDED modules/pt/tests/data/gr/fail-sym-choice-critcl-res/2_digup Index: modules/pt/tests/data/gr/fail-sym-choice-critcl-res/2_digup ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-choice-critcl-res/2_digup @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str alpha} {str anumeric} {str digit}}} ADDED modules/pt/tests/data/gr/fail-sym-choice-critcl-res/3_other Index: modules/pt/tests/data/gr/fail-sym-choice-critcl-res/3_other ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-choice-critcl-res/3_other @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str alpha} {str anumeric} {str digit}}} ADDED modules/pt/tests/data/gr/fail-sym-choice-oo-res/0_aleph Index: modules/pt/tests/data/gr/fail-sym-choice-oo-res/0_aleph ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-choice-oo-res/0_aleph @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str alpha} {str anumeric} {str digit}}} ADDED modules/pt/tests/data/gr/fail-sym-choice-oo-res/1_anumber Index: modules/pt/tests/data/gr/fail-sym-choice-oo-res/1_anumber ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-choice-oo-res/1_anumber @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str alpha} {str anumeric} {str digit}}} ADDED modules/pt/tests/data/gr/fail-sym-choice-oo-res/2_digup Index: modules/pt/tests/data/gr/fail-sym-choice-oo-res/2_digup ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-choice-oo-res/2_digup @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str alpha} {str anumeric} {str digit}}} ADDED modules/pt/tests/data/gr/fail-sym-choice-oo-res/3_other Index: modules/pt/tests/data/gr/fail-sym-choice-oo-res/3_other ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-choice-oo-res/3_other @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str alpha} {str anumeric} {str digit}}} ADDED modules/pt/tests/data/gr/fail-sym-choice-snit-res/0_aleph Index: modules/pt/tests/data/gr/fail-sym-choice-snit-res/0_aleph ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-choice-snit-res/0_aleph @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str alpha} {str anumeric} {str digit}}} ADDED modules/pt/tests/data/gr/fail-sym-choice-snit-res/1_anumber Index: modules/pt/tests/data/gr/fail-sym-choice-snit-res/1_anumber ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-choice-snit-res/1_anumber @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str alpha} {str anumeric} {str digit}}} ADDED modules/pt/tests/data/gr/fail-sym-choice-snit-res/2_digup Index: modules/pt/tests/data/gr/fail-sym-choice-snit-res/2_digup ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-choice-snit-res/2_digup @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str alpha} {str anumeric} {str digit}}} ADDED modules/pt/tests/data/gr/fail-sym-choice-snit-res/3_other Index: modules/pt/tests/data/gr/fail-sym-choice-snit-res/3_other ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-choice-snit-res/3_other @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str alpha} {str anumeric} {str digit}}} ADDED modules/pt/tests/data/gr/fail-sym-choice/0_aleph Index: modules/pt/tests/data/gr/fail-sym-choice/0_aleph ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-choice/0_aleph @@ -0,0 +1,1 @@ +aleph ADDED modules/pt/tests/data/gr/fail-sym-choice/1_anumber Index: modules/pt/tests/data/gr/fail-sym-choice/1_anumber ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-choice/1_anumber @@ -0,0 +1,1 @@ +anumber ADDED modules/pt/tests/data/gr/fail-sym-choice/2_digup Index: modules/pt/tests/data/gr/fail-sym-choice/2_digup ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-choice/2_digup @@ -0,0 +1,1 @@ +digup ADDED modules/pt/tests/data/gr/fail-sym-choice/3_other Index: modules/pt/tests/data/gr/fail-sym-choice/3_other ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-choice/3_other @@ -0,0 +1,1 @@ +other ADDED modules/pt/tests/data/gr/fail-sym-class-container-res/0_beta Index: modules/pt/tests/data/gr/fail-sym-class-container-res/0_beta ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-class-container-res/0_beta @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{t a} {t e} {t x}}} ADDED modules/pt/tests/data/gr/fail-sym-class-critcl-res/0_beta Index: modules/pt/tests/data/gr/fail-sym-class-critcl-res/0_beta ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-class-critcl-res/0_beta @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{cl axe}}} ADDED modules/pt/tests/data/gr/fail-sym-class-oo-res/0_beta Index: modules/pt/tests/data/gr/fail-sym-class-oo-res/0_beta ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-class-oo-res/0_beta @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{cl axe}}} ADDED modules/pt/tests/data/gr/fail-sym-class-snit-res/0_beta Index: modules/pt/tests/data/gr/fail-sym-class-snit-res/0_beta ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-class-snit-res/0_beta @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{cl axe}}} ADDED modules/pt/tests/data/gr/fail-sym-class/0_beta Index: modules/pt/tests/data/gr/fail-sym-class/0_beta ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-class/0_beta @@ -0,0 +1,1 @@ +beta ADDED modules/pt/tests/data/gr/fail-sym-control-container-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-control-container-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-control-container-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 control} ADDED modules/pt/tests/data/gr/fail-sym-control-critcl-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-control-critcl-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-control-critcl-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 control} ADDED modules/pt/tests/data/gr/fail-sym-control-oo-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-control-oo-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-control-oo-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 control} ADDED modules/pt/tests/data/gr/fail-sym-control-snit-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-control-snit-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-control-snit-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 control} ADDED modules/pt/tests/data/gr/fail-sym-control/0_outside Index: modules/pt/tests/data/gr/fail-sym-control/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-control/0_outside @@ -0,0 +1,1 @@ +A ADDED modules/pt/tests/data/gr/fail-sym-ddigit-container-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-ddigit-container-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-ddigit-container-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 ddigit} ADDED modules/pt/tests/data/gr/fail-sym-ddigit-critcl-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-ddigit-critcl-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-ddigit-critcl-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 ddigit} ADDED modules/pt/tests/data/gr/fail-sym-ddigit-oo-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-ddigit-oo-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-ddigit-oo-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 ddigit} ADDED modules/pt/tests/data/gr/fail-sym-ddigit-snit-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-ddigit-snit-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-ddigit-snit-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 ddigit} ADDED modules/pt/tests/data/gr/fail-sym-ddigit/0_outside Index: modules/pt/tests/data/gr/fail-sym-ddigit/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-ddigit/0_outside @@ -0,0 +1,1 @@ +F ADDED modules/pt/tests/data/gr/fail-sym-digit-container-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-digit-container-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-digit-container-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 digit} ADDED modules/pt/tests/data/gr/fail-sym-digit-critcl-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-digit-critcl-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-digit-critcl-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 digit} ADDED modules/pt/tests/data/gr/fail-sym-digit-oo-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-digit-oo-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-digit-oo-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 digit} ADDED modules/pt/tests/data/gr/fail-sym-digit-snit-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-digit-snit-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-digit-snit-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 digit} ADDED modules/pt/tests/data/gr/fail-sym-digit/0_outside Index: modules/pt/tests/data/gr/fail-sym-digit/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-digit/0_outside @@ -0,0 +1,1 @@ +F ADDED modules/pt/tests/data/gr/fail-sym-dot-container-res/0_none Index: modules/pt/tests/data/gr/fail-sym-dot-container-res/0_none ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-dot-container-res/0_none @@ -0,0 +1,1 @@ +1 {pt::rde 0 dot} ADDED modules/pt/tests/data/gr/fail-sym-dot-critcl-res/0_none Index: modules/pt/tests/data/gr/fail-sym-dot-critcl-res/0_none ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-dot-critcl-res/0_none @@ -0,0 +1,1 @@ +1 {pt::rde 0 dot} ADDED modules/pt/tests/data/gr/fail-sym-dot-oo-res/0_none Index: modules/pt/tests/data/gr/fail-sym-dot-oo-res/0_none ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-dot-oo-res/0_none @@ -0,0 +1,1 @@ +1 {pt::rde 0 dot} ADDED modules/pt/tests/data/gr/fail-sym-dot-snit-res/0_none Index: modules/pt/tests/data/gr/fail-sym-dot-snit-res/0_none ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-dot-snit-res/0_none @@ -0,0 +1,1 @@ +1 {pt::rde 0 dot} ADDED modules/pt/tests/data/gr/fail-sym-dot/0_none Index: modules/pt/tests/data/gr/fail-sym-dot/0_none ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-dot/0_none ADDED modules/pt/tests/data/gr/fail-sym-graph-container-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-graph-container-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-graph-container-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 graph} ADDED modules/pt/tests/data/gr/fail-sym-graph-critcl-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-graph-critcl-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-graph-critcl-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 graph} ADDED modules/pt/tests/data/gr/fail-sym-graph-oo-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-graph-oo-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-graph-oo-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 graph} ADDED modules/pt/tests/data/gr/fail-sym-graph-snit-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-graph-snit-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-graph-snit-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 graph} ADDED modules/pt/tests/data/gr/fail-sym-graph/0_outside Index: modules/pt/tests/data/gr/fail-sym-graph/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-graph/0_outside @@ -0,0 +1,1 @@ + ADDED modules/pt/tests/data/gr/fail-sym-lower-container-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-lower-container-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-lower-container-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 lower} ADDED modules/pt/tests/data/gr/fail-sym-lower-critcl-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-lower-critcl-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-lower-critcl-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 lower} ADDED modules/pt/tests/data/gr/fail-sym-lower-oo-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-lower-oo-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-lower-oo-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 lower} ADDED modules/pt/tests/data/gr/fail-sym-lower-snit-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-lower-snit-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-lower-snit-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 lower} ADDED modules/pt/tests/data/gr/fail-sym-lower/0_outside Index: modules/pt/tests/data/gr/fail-sym-lower/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-lower/0_outside @@ -0,0 +1,1 @@ +A ADDED modules/pt/tests/data/gr/fail-sym-notahead-container-res/0_keyword Index: modules/pt/tests/data/gr/fail-sym-notahead-container-res/0_keyword ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-notahead-container-res/0_keyword @@ -0,0 +1,1 @@ +1 {pt::rde 6 alnum} ADDED modules/pt/tests/data/gr/fail-sym-notahead-critcl-res/0_keyword Index: modules/pt/tests/data/gr/fail-sym-notahead-critcl-res/0_keyword ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-notahead-critcl-res/0_keyword @@ -0,0 +1,1 @@ +1 {pt::rde 6 alnum} ADDED modules/pt/tests/data/gr/fail-sym-notahead-oo-res/0_keyword Index: modules/pt/tests/data/gr/fail-sym-notahead-oo-res/0_keyword ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-notahead-oo-res/0_keyword @@ -0,0 +1,1 @@ +1 {pt::rde 6 alnum} ADDED modules/pt/tests/data/gr/fail-sym-notahead-snit-res/0_keyword Index: modules/pt/tests/data/gr/fail-sym-notahead-snit-res/0_keyword ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-notahead-snit-res/0_keyword @@ -0,0 +1,1 @@ +1 {pt::rde 6 alnum} ADDED modules/pt/tests/data/gr/fail-sym-notahead/0_keyword Index: modules/pt/tests/data/gr/fail-sym-notahead/0_keyword ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-notahead/0_keyword @@ -0,0 +1,1 @@ +serial ADDED modules/pt/tests/data/gr/fail-sym-pkleene-container-res/0_b Index: modules/pt/tests/data/gr/fail-sym-pkleene-container-res/0_b ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-pkleene-container-res/0_b @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{t a}}} ADDED modules/pt/tests/data/gr/fail-sym-pkleene-critcl-res/0_b Index: modules/pt/tests/data/gr/fail-sym-pkleene-critcl-res/0_b ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-pkleene-critcl-res/0_b @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{t a}}} ADDED modules/pt/tests/data/gr/fail-sym-pkleene-oo-res/0_b Index: modules/pt/tests/data/gr/fail-sym-pkleene-oo-res/0_b ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-pkleene-oo-res/0_b @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{t a}}} ADDED modules/pt/tests/data/gr/fail-sym-pkleene-snit-res/0_b Index: modules/pt/tests/data/gr/fail-sym-pkleene-snit-res/0_b ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-pkleene-snit-res/0_b @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{t a}}} ADDED modules/pt/tests/data/gr/fail-sym-pkleene/0_b Index: modules/pt/tests/data/gr/fail-sym-pkleene/0_b ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-pkleene/0_b @@ -0,0 +1,1 @@ +b ADDED modules/pt/tests/data/gr/fail-sym-print-container-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-print-container-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-print-container-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 print} ADDED modules/pt/tests/data/gr/fail-sym-print-critcl-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-print-critcl-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-print-critcl-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 print} ADDED modules/pt/tests/data/gr/fail-sym-print-oo-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-print-oo-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-print-oo-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 print} ADDED modules/pt/tests/data/gr/fail-sym-print-snit-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-print-snit-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-print-snit-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 print} ADDED modules/pt/tests/data/gr/fail-sym-print/0_outside Index: modules/pt/tests/data/gr/fail-sym-print/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-print/0_outside @@ -0,0 +1,1 @@ + ADDED modules/pt/tests/data/gr/fail-sym-punct-container-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-punct-container-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-punct-container-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 punct} ADDED modules/pt/tests/data/gr/fail-sym-punct-critcl-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-punct-critcl-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-punct-critcl-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 punct} ADDED modules/pt/tests/data/gr/fail-sym-punct-oo-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-punct-oo-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-punct-oo-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 punct} ADDED modules/pt/tests/data/gr/fail-sym-punct-snit-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-punct-snit-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-punct-snit-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 punct} ADDED modules/pt/tests/data/gr/fail-sym-punct/0_outside Index: modules/pt/tests/data/gr/fail-sym-punct/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-punct/0_outside @@ -0,0 +1,1 @@ += ADDED modules/pt/tests/data/gr/fail-sym-range-container-res/0_beta Index: modules/pt/tests/data/gr/fail-sym-range-container-res/0_beta ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-range-container-res/0_beta @@ -0,0 +1,1 @@ +1 {pt::rde 2 {{.. A F}}} ADDED modules/pt/tests/data/gr/fail-sym-range-critcl-res/0_beta Index: modules/pt/tests/data/gr/fail-sym-range-critcl-res/0_beta ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-range-critcl-res/0_beta @@ -0,0 +1,1 @@ +1 {pt::rde 2 {{.. A F}}} ADDED modules/pt/tests/data/gr/fail-sym-range-oo-res/0_beta Index: modules/pt/tests/data/gr/fail-sym-range-oo-res/0_beta ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-range-oo-res/0_beta @@ -0,0 +1,1 @@ +1 {pt::rde 2 {{.. A F}}} ADDED modules/pt/tests/data/gr/fail-sym-range-snit-res/0_beta Index: modules/pt/tests/data/gr/fail-sym-range-snit-res/0_beta ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-range-snit-res/0_beta @@ -0,0 +1,1 @@ +1 {pt::rde 2 {{.. A F}}} ADDED modules/pt/tests/data/gr/fail-sym-range/0_beta Index: modules/pt/tests/data/gr/fail-sym-range/0_beta ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-range/0_beta @@ -0,0 +1,1 @@ +0xbeta ADDED modules/pt/tests/data/gr/fail-sym-sequence-container-res/0_abe Index: modules/pt/tests/data/gr/fail-sym-sequence-container-res/0_abe ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-sequence-container-res/0_abe @@ -0,0 +1,1 @@ +1 {pt::rde 2 {{t c}}} ADDED modules/pt/tests/data/gr/fail-sym-sequence-container-res/1_b Index: modules/pt/tests/data/gr/fail-sym-sequence-container-res/1_b ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-sequence-container-res/1_b @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{t a}}} ADDED modules/pt/tests/data/gr/fail-sym-sequence-critcl-res/0_abe Index: modules/pt/tests/data/gr/fail-sym-sequence-critcl-res/0_abe ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-sequence-critcl-res/0_abe @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str abc}}} ADDED modules/pt/tests/data/gr/fail-sym-sequence-critcl-res/1_b Index: modules/pt/tests/data/gr/fail-sym-sequence-critcl-res/1_b ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-sequence-critcl-res/1_b @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str abc}}} ADDED modules/pt/tests/data/gr/fail-sym-sequence-oo-res/0_abe Index: modules/pt/tests/data/gr/fail-sym-sequence-oo-res/0_abe ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-sequence-oo-res/0_abe @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str abc}}} ADDED modules/pt/tests/data/gr/fail-sym-sequence-oo-res/1_b Index: modules/pt/tests/data/gr/fail-sym-sequence-oo-res/1_b ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-sequence-oo-res/1_b @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str abc}}} ADDED modules/pt/tests/data/gr/fail-sym-sequence-snit-res/0_abe Index: modules/pt/tests/data/gr/fail-sym-sequence-snit-res/0_abe ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-sequence-snit-res/0_abe @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str abc}}} ADDED modules/pt/tests/data/gr/fail-sym-sequence-snit-res/1_b Index: modules/pt/tests/data/gr/fail-sym-sequence-snit-res/1_b ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-sequence-snit-res/1_b @@ -0,0 +1,1 @@ +1 {pt::rde 0 {{str abc}}} ADDED modules/pt/tests/data/gr/fail-sym-sequence/0_abe Index: modules/pt/tests/data/gr/fail-sym-sequence/0_abe ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-sequence/0_abe @@ -0,0 +1,1 @@ +abe ADDED modules/pt/tests/data/gr/fail-sym-sequence/1_b Index: modules/pt/tests/data/gr/fail-sym-sequence/1_b ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-sequence/1_b @@ -0,0 +1,1 @@ +b ADDED modules/pt/tests/data/gr/fail-sym-space-container-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-space-container-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-space-container-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 space} ADDED modules/pt/tests/data/gr/fail-sym-space-critcl-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-space-critcl-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-space-critcl-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 space} ADDED modules/pt/tests/data/gr/fail-sym-space-oo-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-space-oo-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-space-oo-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 space} ADDED modules/pt/tests/data/gr/fail-sym-space-snit-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-space-snit-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-space-snit-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 space} ADDED modules/pt/tests/data/gr/fail-sym-space/0_outside Index: modules/pt/tests/data/gr/fail-sym-space/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-space/0_outside @@ -0,0 +1,1 @@ +X ADDED modules/pt/tests/data/gr/fail-sym-upper-container-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-upper-container-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-upper-container-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 upper} ADDED modules/pt/tests/data/gr/fail-sym-upper-critcl-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-upper-critcl-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-upper-critcl-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 upper} ADDED modules/pt/tests/data/gr/fail-sym-upper-oo-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-upper-oo-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-upper-oo-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 upper} ADDED modules/pt/tests/data/gr/fail-sym-upper-snit-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-upper-snit-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-upper-snit-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 upper} ADDED modules/pt/tests/data/gr/fail-sym-upper/0_outside Index: modules/pt/tests/data/gr/fail-sym-upper/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-upper/0_outside @@ -0,0 +1,1 @@ +a ADDED modules/pt/tests/data/gr/fail-sym-wordchar-container-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-wordchar-container-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-wordchar-container-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 wordchar} ADDED modules/pt/tests/data/gr/fail-sym-wordchar-critcl-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-wordchar-critcl-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-wordchar-critcl-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 wordchar} ADDED modules/pt/tests/data/gr/fail-sym-wordchar-oo-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-wordchar-oo-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-wordchar-oo-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 wordchar} ADDED modules/pt/tests/data/gr/fail-sym-wordchar-snit-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-wordchar-snit-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-wordchar-snit-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 wordchar} ADDED modules/pt/tests/data/gr/fail-sym-wordchar/0_outside Index: modules/pt/tests/data/gr/fail-sym-wordchar/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-wordchar/0_outside @@ -0,0 +1,1 @@ +: ADDED modules/pt/tests/data/gr/fail-sym-xdigit-container-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-xdigit-container-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-xdigit-container-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 xdigit} ADDED modules/pt/tests/data/gr/fail-sym-xdigit-critcl-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-xdigit-critcl-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-xdigit-critcl-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 xdigit} ADDED modules/pt/tests/data/gr/fail-sym-xdigit-oo-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-xdigit-oo-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-xdigit-oo-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 xdigit} ADDED modules/pt/tests/data/gr/fail-sym-xdigit-snit-res/0_outside Index: modules/pt/tests/data/gr/fail-sym-xdigit-snit-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-xdigit-snit-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 xdigit} ADDED modules/pt/tests/data/gr/fail-sym-xdigit/0_outside Index: modules/pt/tests/data/gr/fail-sym-xdigit/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-sym-xdigit/0_outside @@ -0,0 +1,1 @@ +g ADDED modules/pt/tests/data/gr/fail-upper-container-res/0_outside Index: modules/pt/tests/data/gr/fail-upper-container-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-upper-container-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 upper} ADDED modules/pt/tests/data/gr/fail-upper-critcl-res/0_outside Index: modules/pt/tests/data/gr/fail-upper-critcl-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-upper-critcl-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 upper} ADDED modules/pt/tests/data/gr/fail-upper-oo-res/0_outside Index: modules/pt/tests/data/gr/fail-upper-oo-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-upper-oo-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 upper} ADDED modules/pt/tests/data/gr/fail-upper-snit-res/0_outside Index: modules/pt/tests/data/gr/fail-upper-snit-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-upper-snit-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 upper} ADDED modules/pt/tests/data/gr/fail-upper/0_outside Index: modules/pt/tests/data/gr/fail-upper/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-upper/0_outside @@ -0,0 +1,1 @@ +a ADDED modules/pt/tests/data/gr/fail-wordchar-container-res/0_outside Index: modules/pt/tests/data/gr/fail-wordchar-container-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-wordchar-container-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 wordchar} ADDED modules/pt/tests/data/gr/fail-wordchar-critcl-res/0_outside Index: modules/pt/tests/data/gr/fail-wordchar-critcl-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-wordchar-critcl-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 wordchar} ADDED modules/pt/tests/data/gr/fail-wordchar-oo-res/0_outside Index: modules/pt/tests/data/gr/fail-wordchar-oo-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-wordchar-oo-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 wordchar} ADDED modules/pt/tests/data/gr/fail-wordchar-snit-res/0_outside Index: modules/pt/tests/data/gr/fail-wordchar-snit-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-wordchar-snit-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 wordchar} ADDED modules/pt/tests/data/gr/fail-wordchar/0_outside Index: modules/pt/tests/data/gr/fail-wordchar/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-wordchar/0_outside @@ -0,0 +1,1 @@ +: ADDED modules/pt/tests/data/gr/fail-xdigit-container-res/0_outside Index: modules/pt/tests/data/gr/fail-xdigit-container-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-xdigit-container-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 xdigit} ADDED modules/pt/tests/data/gr/fail-xdigit-critcl-res/0_outside Index: modules/pt/tests/data/gr/fail-xdigit-critcl-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-xdigit-critcl-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 xdigit} ADDED modules/pt/tests/data/gr/fail-xdigit-oo-res/0_outside Index: modules/pt/tests/data/gr/fail-xdigit-oo-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-xdigit-oo-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 xdigit} ADDED modules/pt/tests/data/gr/fail-xdigit-snit-res/0_outside Index: modules/pt/tests/data/gr/fail-xdigit-snit-res/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-xdigit-snit-res/0_outside @@ -0,0 +1,1 @@ +1 {pt::rde 0 xdigit} ADDED modules/pt/tests/data/gr/fail-xdigit/0_outside Index: modules/pt/tests/data/gr/fail-xdigit/0_outside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/fail-xdigit/0_outside @@ -0,0 +1,1 @@ +g ADDED modules/pt/tests/data/gr/ok-ahead-res/0_match Index: modules/pt/tests/data/gr/ok-ahead-res/0_match ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-ahead-res/0_match ADDED modules/pt/tests/data/gr/ok-ahead/0_match Index: modules/pt/tests/data/gr/ok-ahead/0_match ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-ahead/0_match @@ -0,0 +1,1 @@ +abba= ADDED modules/pt/tests/data/gr/ok-alnum-res/0_inside Index: modules/pt/tests/data/gr/ok-alnum-res/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-alnum-res/0_inside ADDED modules/pt/tests/data/gr/ok-alnum/0_inside Index: modules/pt/tests/data/gr/ok-alnum/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-alnum/0_inside @@ -0,0 +1,1 @@ +A ADDED modules/pt/tests/data/gr/ok-alpha-res/0_inside Index: modules/pt/tests/data/gr/ok-alpha-res/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-alpha-res/0_inside ADDED modules/pt/tests/data/gr/ok-alpha/0_inside Index: modules/pt/tests/data/gr/ok-alpha/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-alpha/0_inside @@ -0,0 +1,1 @@ +X ADDED modules/pt/tests/data/gr/ok-ascii-res/0_inside Index: modules/pt/tests/data/gr/ok-ascii-res/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-ascii-res/0_inside ADDED modules/pt/tests/data/gr/ok-ascii/0_inside Index: modules/pt/tests/data/gr/ok-ascii/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-ascii/0_inside @@ -0,0 +1,1 @@ +X ADDED modules/pt/tests/data/gr/ok-choice-res/0_alpha Index: modules/pt/tests/data/gr/ok-choice-res/0_alpha ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-choice-res/0_alpha ADDED modules/pt/tests/data/gr/ok-choice-res/1_digit Index: modules/pt/tests/data/gr/ok-choice-res/1_digit ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-choice-res/1_digit ADDED modules/pt/tests/data/gr/ok-choice-res/2_anumeric Index: modules/pt/tests/data/gr/ok-choice-res/2_anumeric ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-choice-res/2_anumeric ADDED modules/pt/tests/data/gr/ok-choice/0_alpha Index: modules/pt/tests/data/gr/ok-choice/0_alpha ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-choice/0_alpha @@ -0,0 +1,1 @@ +alpha ADDED modules/pt/tests/data/gr/ok-choice/1_digit Index: modules/pt/tests/data/gr/ok-choice/1_digit ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-choice/1_digit @@ -0,0 +1,1 @@ +digit ADDED modules/pt/tests/data/gr/ok-choice/2_anumeric Index: modules/pt/tests/data/gr/ok-choice/2_anumeric ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-choice/2_anumeric @@ -0,0 +1,1 @@ +anumeric ADDED modules/pt/tests/data/gr/ok-class-res/0_a Index: modules/pt/tests/data/gr/ok-class-res/0_a ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-class-res/0_a ADDED modules/pt/tests/data/gr/ok-class-res/1_x Index: modules/pt/tests/data/gr/ok-class-res/1_x ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-class-res/1_x ADDED modules/pt/tests/data/gr/ok-class-res/2_e Index: modules/pt/tests/data/gr/ok-class-res/2_e ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-class-res/2_e ADDED modules/pt/tests/data/gr/ok-class/0_a Index: modules/pt/tests/data/gr/ok-class/0_a ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-class/0_a @@ -0,0 +1,1 @@ +a ADDED modules/pt/tests/data/gr/ok-class/1_x Index: modules/pt/tests/data/gr/ok-class/1_x ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-class/1_x @@ -0,0 +1,1 @@ +x ADDED modules/pt/tests/data/gr/ok-class/2_e Index: modules/pt/tests/data/gr/ok-class/2_e ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-class/2_e @@ -0,0 +1,1 @@ +e ADDED modules/pt/tests/data/gr/ok-control-res/0_inside Index: modules/pt/tests/data/gr/ok-control-res/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-control-res/0_inside ADDED modules/pt/tests/data/gr/ok-control/0_inside Index: modules/pt/tests/data/gr/ok-control/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-control/0_inside @@ -0,0 +1,1 @@ + ADDED modules/pt/tests/data/gr/ok-ddigit-res/0_inside Index: modules/pt/tests/data/gr/ok-ddigit-res/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-ddigit-res/0_inside ADDED modules/pt/tests/data/gr/ok-ddigit/0_inside Index: modules/pt/tests/data/gr/ok-ddigit/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-ddigit/0_inside @@ -0,0 +1,1 @@ +5 ADDED modules/pt/tests/data/gr/ok-digit-res/0_inside Index: modules/pt/tests/data/gr/ok-digit-res/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-digit-res/0_inside ADDED modules/pt/tests/data/gr/ok-digit/0_inside Index: modules/pt/tests/data/gr/ok-digit/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-digit/0_inside @@ -0,0 +1,1 @@ +5 ADDED modules/pt/tests/data/gr/ok-dot-res/0_any Index: modules/pt/tests/data/gr/ok-dot-res/0_any ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-dot-res/0_any ADDED modules/pt/tests/data/gr/ok-dot/0_any Index: modules/pt/tests/data/gr/ok-dot/0_any ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-dot/0_any @@ -0,0 +1,1 @@ +% ADDED modules/pt/tests/data/gr/ok-graph-res/0_inside Index: modules/pt/tests/data/gr/ok-graph-res/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-graph-res/0_inside ADDED modules/pt/tests/data/gr/ok-graph/0_inside Index: modules/pt/tests/data/gr/ok-graph/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-graph/0_inside @@ -0,0 +1,1 @@ +X ADDED modules/pt/tests/data/gr/ok-kleene-res/0_aaab Index: modules/pt/tests/data/gr/ok-kleene-res/0_aaab ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-kleene-res/0_aaab ADDED modules/pt/tests/data/gr/ok-kleene-res/1_aab Index: modules/pt/tests/data/gr/ok-kleene-res/1_aab ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-kleene-res/1_aab ADDED modules/pt/tests/data/gr/ok-kleene-res/2_ab Index: modules/pt/tests/data/gr/ok-kleene-res/2_ab ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-kleene-res/2_ab ADDED modules/pt/tests/data/gr/ok-kleene-res/3_b Index: modules/pt/tests/data/gr/ok-kleene-res/3_b ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-kleene-res/3_b ADDED modules/pt/tests/data/gr/ok-kleene/0_aaab Index: modules/pt/tests/data/gr/ok-kleene/0_aaab ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-kleene/0_aaab @@ -0,0 +1,1 @@ +aaab ADDED modules/pt/tests/data/gr/ok-kleene/1_aab Index: modules/pt/tests/data/gr/ok-kleene/1_aab ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-kleene/1_aab @@ -0,0 +1,1 @@ +aab ADDED modules/pt/tests/data/gr/ok-kleene/2_ab Index: modules/pt/tests/data/gr/ok-kleene/2_ab ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-kleene/2_ab @@ -0,0 +1,1 @@ +ab ADDED modules/pt/tests/data/gr/ok-kleene/3_b Index: modules/pt/tests/data/gr/ok-kleene/3_b ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-kleene/3_b @@ -0,0 +1,1 @@ +b ADDED modules/pt/tests/data/gr/ok-lower-res/0_inside Index: modules/pt/tests/data/gr/ok-lower-res/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-lower-res/0_inside ADDED modules/pt/tests/data/gr/ok-lower/0_inside Index: modules/pt/tests/data/gr/ok-lower/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-lower/0_inside @@ -0,0 +1,1 @@ +a ADDED modules/pt/tests/data/gr/ok-notahead-res/0_ident Index: modules/pt/tests/data/gr/ok-notahead-res/0_ident ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-notahead-res/0_ident ADDED modules/pt/tests/data/gr/ok-notahead-res/1_identifierb Index: modules/pt/tests/data/gr/ok-notahead-res/1_identifierb ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-notahead-res/1_identifierb ADDED modules/pt/tests/data/gr/ok-notahead/0_ident Index: modules/pt/tests/data/gr/ok-notahead/0_ident ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-notahead/0_ident @@ -0,0 +1,1 @@ +identifier ADDED modules/pt/tests/data/gr/ok-notahead/1_identifierb Index: modules/pt/tests/data/gr/ok-notahead/1_identifierb ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-notahead/1_identifierb @@ -0,0 +1,1 @@ +serialized ADDED modules/pt/tests/data/gr/ok-optional-res/0_have Index: modules/pt/tests/data/gr/ok-optional-res/0_have ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-optional-res/0_have ADDED modules/pt/tests/data/gr/ok-optional-res/1_havenot Index: modules/pt/tests/data/gr/ok-optional-res/1_havenot ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-optional-res/1_havenot ADDED modules/pt/tests/data/gr/ok-optional/0_have Index: modules/pt/tests/data/gr/ok-optional/0_have ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-optional/0_have @@ -0,0 +1,1 @@ +havenot ADDED modules/pt/tests/data/gr/ok-optional/1_havenot Index: modules/pt/tests/data/gr/ok-optional/1_havenot ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-optional/1_havenot @@ -0,0 +1,1 @@ +not ADDED modules/pt/tests/data/gr/ok-pkleene-res/0_aaab Index: modules/pt/tests/data/gr/ok-pkleene-res/0_aaab ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-pkleene-res/0_aaab ADDED modules/pt/tests/data/gr/ok-pkleene-res/1_aab Index: modules/pt/tests/data/gr/ok-pkleene-res/1_aab ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-pkleene-res/1_aab ADDED modules/pt/tests/data/gr/ok-pkleene-res/2_ab Index: modules/pt/tests/data/gr/ok-pkleene-res/2_ab ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-pkleene-res/2_ab ADDED modules/pt/tests/data/gr/ok-pkleene/0_aaab Index: modules/pt/tests/data/gr/ok-pkleene/0_aaab ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-pkleene/0_aaab @@ -0,0 +1,1 @@ +aaab ADDED modules/pt/tests/data/gr/ok-pkleene/1_aab Index: modules/pt/tests/data/gr/ok-pkleene/1_aab ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-pkleene/1_aab @@ -0,0 +1,1 @@ +aab ADDED modules/pt/tests/data/gr/ok-pkleene/2_ab Index: modules/pt/tests/data/gr/ok-pkleene/2_ab ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-pkleene/2_ab @@ -0,0 +1,1 @@ +ab ADDED modules/pt/tests/data/gr/ok-print-res/0_inside Index: modules/pt/tests/data/gr/ok-print-res/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-print-res/0_inside ADDED modules/pt/tests/data/gr/ok-print/0_inside Index: modules/pt/tests/data/gr/ok-print/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-print/0_inside @@ -0,0 +1,1 @@ += ADDED modules/pt/tests/data/gr/ok-punct-res/0_inside Index: modules/pt/tests/data/gr/ok-punct-res/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-punct-res/0_inside ADDED modules/pt/tests/data/gr/ok-punct/0_inside Index: modules/pt/tests/data/gr/ok-punct/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-punct/0_inside @@ -0,0 +1,1 @@ +. ADDED modules/pt/tests/data/gr/ok-range-res/0_a Index: modules/pt/tests/data/gr/ok-range-res/0_a ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-range-res/0_a ADDED modules/pt/tests/data/gr/ok-range/0_a Index: modules/pt/tests/data/gr/ok-range/0_a ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-range/0_a @@ -0,0 +1,1 @@ +0xA ADDED modules/pt/tests/data/gr/ok-sequence-res/0_abc Index: modules/pt/tests/data/gr/ok-sequence-res/0_abc ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sequence-res/0_abc ADDED modules/pt/tests/data/gr/ok-sequence/0_abc Index: modules/pt/tests/data/gr/ok-sequence/0_abc ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sequence/0_abc @@ -0,0 +1,1 @@ +abc ADDED modules/pt/tests/data/gr/ok-space-res/0_inside Index: modules/pt/tests/data/gr/ok-space-res/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-space-res/0_inside ADDED modules/pt/tests/data/gr/ok-space/0_inside Index: modules/pt/tests/data/gr/ok-space/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-space/0_inside @@ -0,0 +1,1 @@ + ADDED modules/pt/tests/data/gr/ok-sym-ahead-res/0_match Index: modules/pt/tests/data/gr/ok-sym-ahead-res/0_match ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-ahead-res/0_match @@ -0,0 +1,1 @@ +N 0 3 ADDED modules/pt/tests/data/gr/ok-sym-ahead/0_match Index: modules/pt/tests/data/gr/ok-sym-ahead/0_match ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-ahead/0_match @@ -0,0 +1,1 @@ +abba= ADDED modules/pt/tests/data/gr/ok-sym-alnum-res/0_inside Index: modules/pt/tests/data/gr/ok-sym-alnum-res/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-alnum-res/0_inside @@ -0,0 +1,1 @@ +N 0 0 ADDED modules/pt/tests/data/gr/ok-sym-alnum/0_inside Index: modules/pt/tests/data/gr/ok-sym-alnum/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-alnum/0_inside @@ -0,0 +1,1 @@ +A ADDED modules/pt/tests/data/gr/ok-sym-alpha-res/0_inside Index: modules/pt/tests/data/gr/ok-sym-alpha-res/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-alpha-res/0_inside @@ -0,0 +1,1 @@ +N 0 0 ADDED modules/pt/tests/data/gr/ok-sym-alpha/0_inside Index: modules/pt/tests/data/gr/ok-sym-alpha/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-alpha/0_inside @@ -0,0 +1,1 @@ +X ADDED modules/pt/tests/data/gr/ok-sym-ascii-res/0_inside Index: modules/pt/tests/data/gr/ok-sym-ascii-res/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-ascii-res/0_inside @@ -0,0 +1,1 @@ +N 0 0 ADDED modules/pt/tests/data/gr/ok-sym-ascii/0_inside Index: modules/pt/tests/data/gr/ok-sym-ascii/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-ascii/0_inside @@ -0,0 +1,1 @@ +X ADDED modules/pt/tests/data/gr/ok-sym-choice-res/0_alpha Index: modules/pt/tests/data/gr/ok-sym-choice-res/0_alpha ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-choice-res/0_alpha @@ -0,0 +1,1 @@ +N 0 4 ADDED modules/pt/tests/data/gr/ok-sym-choice-res/1_digit Index: modules/pt/tests/data/gr/ok-sym-choice-res/1_digit ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-choice-res/1_digit @@ -0,0 +1,1 @@ +N 0 4 ADDED modules/pt/tests/data/gr/ok-sym-choice-res/2_anumeric Index: modules/pt/tests/data/gr/ok-sym-choice-res/2_anumeric ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-choice-res/2_anumeric @@ -0,0 +1,1 @@ +N 0 7 ADDED modules/pt/tests/data/gr/ok-sym-choice/0_alpha Index: modules/pt/tests/data/gr/ok-sym-choice/0_alpha ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-choice/0_alpha @@ -0,0 +1,1 @@ +alpha ADDED modules/pt/tests/data/gr/ok-sym-choice/1_digit Index: modules/pt/tests/data/gr/ok-sym-choice/1_digit ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-choice/1_digit @@ -0,0 +1,1 @@ +digit ADDED modules/pt/tests/data/gr/ok-sym-choice/2_anumeric Index: modules/pt/tests/data/gr/ok-sym-choice/2_anumeric ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-choice/2_anumeric @@ -0,0 +1,1 @@ +anumeric ADDED modules/pt/tests/data/gr/ok-sym-class-res/0_a Index: modules/pt/tests/data/gr/ok-sym-class-res/0_a ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-class-res/0_a @@ -0,0 +1,1 @@ +N 0 0 ADDED modules/pt/tests/data/gr/ok-sym-class-res/1_x Index: modules/pt/tests/data/gr/ok-sym-class-res/1_x ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-class-res/1_x @@ -0,0 +1,1 @@ +N 0 0 ADDED modules/pt/tests/data/gr/ok-sym-class-res/2_e Index: modules/pt/tests/data/gr/ok-sym-class-res/2_e ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-class-res/2_e @@ -0,0 +1,1 @@ +N 0 0 ADDED modules/pt/tests/data/gr/ok-sym-class/0_a Index: modules/pt/tests/data/gr/ok-sym-class/0_a ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-class/0_a @@ -0,0 +1,1 @@ +a ADDED modules/pt/tests/data/gr/ok-sym-class/1_x Index: modules/pt/tests/data/gr/ok-sym-class/1_x ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-class/1_x @@ -0,0 +1,1 @@ +x ADDED modules/pt/tests/data/gr/ok-sym-class/2_e Index: modules/pt/tests/data/gr/ok-sym-class/2_e ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-class/2_e @@ -0,0 +1,1 @@ +e ADDED modules/pt/tests/data/gr/ok-sym-control-res/0_inside Index: modules/pt/tests/data/gr/ok-sym-control-res/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-control-res/0_inside @@ -0,0 +1,1 @@ +N 0 0 ADDED modules/pt/tests/data/gr/ok-sym-control/0_inside Index: modules/pt/tests/data/gr/ok-sym-control/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-control/0_inside @@ -0,0 +1,1 @@ + ADDED modules/pt/tests/data/gr/ok-sym-ddigit-res/0_inside Index: modules/pt/tests/data/gr/ok-sym-ddigit-res/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-ddigit-res/0_inside @@ -0,0 +1,1 @@ +N 0 0 ADDED modules/pt/tests/data/gr/ok-sym-ddigit/0_inside Index: modules/pt/tests/data/gr/ok-sym-ddigit/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-ddigit/0_inside @@ -0,0 +1,1 @@ +5 ADDED modules/pt/tests/data/gr/ok-sym-digit-res/0_inside Index: modules/pt/tests/data/gr/ok-sym-digit-res/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-digit-res/0_inside @@ -0,0 +1,1 @@ +N 0 0 ADDED modules/pt/tests/data/gr/ok-sym-digit/0_inside Index: modules/pt/tests/data/gr/ok-sym-digit/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-digit/0_inside @@ -0,0 +1,1 @@ +5 ADDED modules/pt/tests/data/gr/ok-sym-dot-res/0_any Index: modules/pt/tests/data/gr/ok-sym-dot-res/0_any ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-dot-res/0_any @@ -0,0 +1,1 @@ +N 0 0 ADDED modules/pt/tests/data/gr/ok-sym-dot/0_any Index: modules/pt/tests/data/gr/ok-sym-dot/0_any ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-dot/0_any @@ -0,0 +1,1 @@ +% ADDED modules/pt/tests/data/gr/ok-sym-graph-res/0_inside Index: modules/pt/tests/data/gr/ok-sym-graph-res/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-graph-res/0_inside @@ -0,0 +1,1 @@ +N 0 0 ADDED modules/pt/tests/data/gr/ok-sym-graph/0_inside Index: modules/pt/tests/data/gr/ok-sym-graph/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-graph/0_inside @@ -0,0 +1,1 @@ +X ADDED modules/pt/tests/data/gr/ok-sym-kleene-res/0_aaab Index: modules/pt/tests/data/gr/ok-sym-kleene-res/0_aaab ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-kleene-res/0_aaab @@ -0,0 +1,1 @@ +N 0 3 ADDED modules/pt/tests/data/gr/ok-sym-kleene-res/1_aab Index: modules/pt/tests/data/gr/ok-sym-kleene-res/1_aab ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-kleene-res/1_aab @@ -0,0 +1,1 @@ +N 0 2 ADDED modules/pt/tests/data/gr/ok-sym-kleene-res/2_ab Index: modules/pt/tests/data/gr/ok-sym-kleene-res/2_ab ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-kleene-res/2_ab @@ -0,0 +1,1 @@ +N 0 1 ADDED modules/pt/tests/data/gr/ok-sym-kleene-res/3_b Index: modules/pt/tests/data/gr/ok-sym-kleene-res/3_b ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-kleene-res/3_b @@ -0,0 +1,1 @@ +N 0 0 ADDED modules/pt/tests/data/gr/ok-sym-kleene/0_aaab Index: modules/pt/tests/data/gr/ok-sym-kleene/0_aaab ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-kleene/0_aaab @@ -0,0 +1,1 @@ +aaab ADDED modules/pt/tests/data/gr/ok-sym-kleene/1_aab Index: modules/pt/tests/data/gr/ok-sym-kleene/1_aab ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-kleene/1_aab @@ -0,0 +1,1 @@ +aab ADDED modules/pt/tests/data/gr/ok-sym-kleene/2_ab Index: modules/pt/tests/data/gr/ok-sym-kleene/2_ab ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-kleene/2_ab @@ -0,0 +1,1 @@ +ab ADDED modules/pt/tests/data/gr/ok-sym-kleene/3_b Index: modules/pt/tests/data/gr/ok-sym-kleene/3_b ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-kleene/3_b @@ -0,0 +1,1 @@ +b ADDED modules/pt/tests/data/gr/ok-sym-lower-res/0_inside Index: modules/pt/tests/data/gr/ok-sym-lower-res/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-lower-res/0_inside @@ -0,0 +1,1 @@ +N 0 0 ADDED modules/pt/tests/data/gr/ok-sym-lower/0_inside Index: modules/pt/tests/data/gr/ok-sym-lower/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-lower/0_inside @@ -0,0 +1,1 @@ +a ADDED modules/pt/tests/data/gr/ok-sym-notahead-res/0_ident Index: modules/pt/tests/data/gr/ok-sym-notahead-res/0_ident ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-notahead-res/0_ident @@ -0,0 +1,1 @@ +N 0 9 ADDED modules/pt/tests/data/gr/ok-sym-notahead-res/1_identifierb Index: modules/pt/tests/data/gr/ok-sym-notahead-res/1_identifierb ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-notahead-res/1_identifierb @@ -0,0 +1,1 @@ +N 0 9 ADDED modules/pt/tests/data/gr/ok-sym-notahead/0_ident Index: modules/pt/tests/data/gr/ok-sym-notahead/0_ident ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-notahead/0_ident @@ -0,0 +1,1 @@ +identifier ADDED modules/pt/tests/data/gr/ok-sym-notahead/1_identifierb Index: modules/pt/tests/data/gr/ok-sym-notahead/1_identifierb ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-notahead/1_identifierb @@ -0,0 +1,1 @@ +serialized ADDED modules/pt/tests/data/gr/ok-sym-optional-res/0_have Index: modules/pt/tests/data/gr/ok-sym-optional-res/0_have ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-optional-res/0_have @@ -0,0 +1,1 @@ +N 0 6 ADDED modules/pt/tests/data/gr/ok-sym-optional-res/1_havenot Index: modules/pt/tests/data/gr/ok-sym-optional-res/1_havenot ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-optional-res/1_havenot @@ -0,0 +1,1 @@ +N 0 2 ADDED modules/pt/tests/data/gr/ok-sym-optional/0_have Index: modules/pt/tests/data/gr/ok-sym-optional/0_have ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-optional/0_have @@ -0,0 +1,1 @@ +havenot ADDED modules/pt/tests/data/gr/ok-sym-optional/1_havenot Index: modules/pt/tests/data/gr/ok-sym-optional/1_havenot ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-optional/1_havenot @@ -0,0 +1,1 @@ +not ADDED modules/pt/tests/data/gr/ok-sym-pkleene-res/0_aaab Index: modules/pt/tests/data/gr/ok-sym-pkleene-res/0_aaab ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-pkleene-res/0_aaab @@ -0,0 +1,1 @@ +N 0 3 ADDED modules/pt/tests/data/gr/ok-sym-pkleene-res/1_aab Index: modules/pt/tests/data/gr/ok-sym-pkleene-res/1_aab ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-pkleene-res/1_aab @@ -0,0 +1,1 @@ +N 0 2 ADDED modules/pt/tests/data/gr/ok-sym-pkleene-res/2_ab Index: modules/pt/tests/data/gr/ok-sym-pkleene-res/2_ab ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-pkleene-res/2_ab @@ -0,0 +1,1 @@ +N 0 1 ADDED modules/pt/tests/data/gr/ok-sym-pkleene/0_aaab Index: modules/pt/tests/data/gr/ok-sym-pkleene/0_aaab ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-pkleene/0_aaab @@ -0,0 +1,1 @@ +aaab ADDED modules/pt/tests/data/gr/ok-sym-pkleene/1_aab Index: modules/pt/tests/data/gr/ok-sym-pkleene/1_aab ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-pkleene/1_aab @@ -0,0 +1,1 @@ +aab ADDED modules/pt/tests/data/gr/ok-sym-pkleene/2_ab Index: modules/pt/tests/data/gr/ok-sym-pkleene/2_ab ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-pkleene/2_ab @@ -0,0 +1,1 @@ +ab ADDED modules/pt/tests/data/gr/ok-sym-print-res/0_inside Index: modules/pt/tests/data/gr/ok-sym-print-res/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-print-res/0_inside @@ -0,0 +1,1 @@ +N 0 0 ADDED modules/pt/tests/data/gr/ok-sym-print/0_inside Index: modules/pt/tests/data/gr/ok-sym-print/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-print/0_inside @@ -0,0 +1,1 @@ += ADDED modules/pt/tests/data/gr/ok-sym-punct-res/0_inside Index: modules/pt/tests/data/gr/ok-sym-punct-res/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-punct-res/0_inside @@ -0,0 +1,1 @@ +N 0 0 ADDED modules/pt/tests/data/gr/ok-sym-punct/0_inside Index: modules/pt/tests/data/gr/ok-sym-punct/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-punct/0_inside @@ -0,0 +1,1 @@ +. ADDED modules/pt/tests/data/gr/ok-sym-range-res/0_a Index: modules/pt/tests/data/gr/ok-sym-range-res/0_a ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-range-res/0_a @@ -0,0 +1,1 @@ +N 0 2 ADDED modules/pt/tests/data/gr/ok-sym-range/0_a Index: modules/pt/tests/data/gr/ok-sym-range/0_a ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-range/0_a @@ -0,0 +1,1 @@ +0xA ADDED modules/pt/tests/data/gr/ok-sym-sequence-res/0_abc Index: modules/pt/tests/data/gr/ok-sym-sequence-res/0_abc ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-sequence-res/0_abc @@ -0,0 +1,1 @@ +N 0 2 ADDED modules/pt/tests/data/gr/ok-sym-sequence/0_abc Index: modules/pt/tests/data/gr/ok-sym-sequence/0_abc ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-sequence/0_abc @@ -0,0 +1,1 @@ +abc ADDED modules/pt/tests/data/gr/ok-sym-space-res/0_inside Index: modules/pt/tests/data/gr/ok-sym-space-res/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-space-res/0_inside @@ -0,0 +1,1 @@ +N 0 0 ADDED modules/pt/tests/data/gr/ok-sym-space/0_inside Index: modules/pt/tests/data/gr/ok-sym-space/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-space/0_inside @@ -0,0 +1,1 @@ + ADDED modules/pt/tests/data/gr/ok-sym-upper-res/0_inside Index: modules/pt/tests/data/gr/ok-sym-upper-res/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-upper-res/0_inside @@ -0,0 +1,1 @@ +N 0 0 ADDED modules/pt/tests/data/gr/ok-sym-upper/0_inside Index: modules/pt/tests/data/gr/ok-sym-upper/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-upper/0_inside @@ -0,0 +1,1 @@ +A ADDED modules/pt/tests/data/gr/ok-sym-wordchar-res/0_inside Index: modules/pt/tests/data/gr/ok-sym-wordchar-res/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-wordchar-res/0_inside @@ -0,0 +1,1 @@ +N 0 0 ADDED modules/pt/tests/data/gr/ok-sym-wordchar/0_inside Index: modules/pt/tests/data/gr/ok-sym-wordchar/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-wordchar/0_inside @@ -0,0 +1,1 @@ +_ ADDED modules/pt/tests/data/gr/ok-sym-xdigit-res/0_inside Index: modules/pt/tests/data/gr/ok-sym-xdigit-res/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-xdigit-res/0_inside @@ -0,0 +1,1 @@ +N 0 0 ADDED modules/pt/tests/data/gr/ok-sym-xdigit/0_inside Index: modules/pt/tests/data/gr/ok-sym-xdigit/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-sym-xdigit/0_inside @@ -0,0 +1,1 @@ +f ADDED modules/pt/tests/data/gr/ok-upper-res/0_inside Index: modules/pt/tests/data/gr/ok-upper-res/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-upper-res/0_inside ADDED modules/pt/tests/data/gr/ok-upper/0_inside Index: modules/pt/tests/data/gr/ok-upper/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-upper/0_inside @@ -0,0 +1,1 @@ +A ADDED modules/pt/tests/data/gr/ok-wordchar-res/0_inside Index: modules/pt/tests/data/gr/ok-wordchar-res/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-wordchar-res/0_inside ADDED modules/pt/tests/data/gr/ok-wordchar/0_inside Index: modules/pt/tests/data/gr/ok-wordchar/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-wordchar/0_inside @@ -0,0 +1,1 @@ +_ ADDED modules/pt/tests/data/gr/ok-xdigit-res/0_inside Index: modules/pt/tests/data/gr/ok-xdigit-res/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-xdigit-res/0_inside ADDED modules/pt/tests/data/gr/ok-xdigit/0_inside Index: modules/pt/tests/data/gr/ok-xdigit/0_inside ================================================================== --- /dev/null +++ modules/pt/tests/data/gr/ok-xdigit/0_inside @@ -0,0 +1,1 @@ +f Index: modules/pt/tests/data/ok/peg_container-bulk/3_peg_itself ================================================================== --- modules/pt/tests/data/ok/peg_container-bulk/3_peg_itself +++ modules/pt/tests/data/ok/peg_container-bulk/3_peg_itself @@ -1,10 +1,10 @@ snit::type a_pe_grammar { constructor {} { install myg using pt::peg::container ${selfns}::G $myg start {n Grammar} - $myg add ALNUM ALPHA AND APOSTROPH ASCII Attribute Char CharOctalFull CharOctalPart CharSpecial CharUnescaped CharUnicode Class CLOSE CLOSEB COLON COMMENT CONTROL DAPOSTROPH DDIGIT Definition DIGIT DOT END EOF EOL Expression Final Grammar GRAPH Header Ident Identifier IS LEAF Literal LOWER NOT OPEN OPENB PEG PLUS Prefix Primary PRINTABLE PUNCT QUESTION Range SEMICOLON Sequence SLASH SPACE STAR StartExpr Suffix TO UPPER VOID WHITESPACE WORDCHAR XDIGIT + $myg add ALNUM ALPHA AND APOSTROPH ASCII Attribute Char CharOctalFull CharOctalPart CharSpecial CharUnescaped CharUnicode Class CLOSE CLOSEB COLON COMMENT CONTROL DAPOSTROPH DDIGIT Definition DIGIT DOT EOF EOL Expression Final Grammar GRAPH Header Ident Identifier IS LEAF Literal LOWER NOT OPEN OPENB PEG PLUS Prefix Primary PRINTABLE PUNCT QUESTION Range SEMICOLON Sequence SLASH SPACE STAR StartExpr Suffix TO UPPER VOID WHITESPACE WORDCHAR XDIGIT $myg modes { ALNUM leaf ALPHA leaf AND leaf APOSTROPH void @@ -25,11 +25,10 @@ DAPOSTROPH void DDIGIT leaf Definition value DIGIT leaf DOT leaf - END void EOF void EOL void Expression value Final void Grammar value @@ -88,15 +87,14 @@ DAPOSTROPH {t \42} DDIGIT {x {t <} {t d} {t d} {t i} {t g} {t i} {t t} {t >} {n WHITESPACE}} Definition {x {? {n Attribute}} {n Identifier} {n IS} {n Expression} {n SEMICOLON}} DIGIT {x {t <} {t d} {t i} {t g} {t i} {t t} {t >} {n WHITESPACE}} DOT {x {t .} {n WHITESPACE}} - END {x {t E} {t N} {t D} {n WHITESPACE}} EOF {! dot} EOL {/ {t \n} {t \r}} Expression {x {n Sequence} {* {x {n SLASH} {n Sequence}}}} - Final {x {n END} {n SEMICOLON} {n WHITESPACE}} + Final {x {t E} {t N} {t D} {n WHITESPACE} {n SEMICOLON} {n WHITESPACE}} Grammar {x {n WHITESPACE} {n Header} {* {n Definition}} {n Final} {n EOF}} GRAPH {x {t <} {t g} {t r} {t a} {t p} {t h} {t >} {n WHITESPACE}} Header {x {n PEG} {n Identifier} {n StartExpr}} Ident {x {/ {t _} {t :} alpha} {* {/ {t _} {t :} alnum}}} Identifier {x {n Ident} {n WHITESPACE}} @@ -105,11 +103,11 @@ Literal {/ {x {n APOSTROPH} {* {x {! {n APOSTROPH}} {n Char}}} {n APOSTROPH} {n WHITESPACE}} {x {n DAPOSTROPH} {* {x {! {n DAPOSTROPH}} {n Char}}} {n DAPOSTROPH} {n WHITESPACE}}} LOWER {x {t <} {t l} {t o} {t w} {t e} {t r} {t >} {n WHITESPACE}} NOT {x {t !} {n WHITESPACE}} OPEN {x {t \50} {n WHITESPACE}} OPENB {t \133} - PEG {x {t P} {t E} {t G} {n WHITESPACE}} + PEG {x {t P} {t E} {t G} {! {/ {t _} {t :} alnum}} {n WHITESPACE}} PLUS {x {t +} {n WHITESPACE}} Prefix {x {? {/ {n AND} {n NOT}}} {n Suffix}} Primary {/ {n ALNUM} {n ALPHA} {n ASCII} {n CONTROL} {n DDIGIT} {n DIGIT} {n GRAPH} {n LOWER} {n PRINTABLE} {n PUNCT} {n SPACE} {n UPPER} {n WORDCHAR} {n XDIGIT} {n Identifier} {x {n OPEN} {n Expression} {n CLOSE}} {n Literal} {n Class} {n DOT}} PRINTABLE {x {t <} {t p} {t r} {t i} {t n} {t t} {t >} {n WHITESPACE}} PUNCT {x {t <} {t p} {t u} {t n} {t c} {t t} {t >} {n WHITESPACE}} Index: modules/pt/tests/data/ok/peg_container-incremental/3_peg_itself ================================================================== --- modules/pt/tests/data/ok/peg_container-incremental/3_peg_itself +++ modules/pt/tests/data/ok/peg_container-incremental/3_peg_itself @@ -93,14 +93,10 @@ $myg add DOT $myg mode DOT leaf $myg rule DOT {x {t .} {n WHITESPACE}} - $myg add END - $myg mode END void - $myg rule END {x {t E} {t N} {t D} {n WHITESPACE}} - $myg add EOF $myg mode EOF void $myg rule EOF {! dot} $myg add EOL @@ -111,11 +107,11 @@ $myg mode Expression value $myg rule Expression {x {n Sequence} {* {x {n SLASH} {n Sequence}}}} $myg add Final $myg mode Final void - $myg rule Final {x {n END} {n SEMICOLON} {n WHITESPACE}} + $myg rule Final {x {t E} {t N} {t D} {n WHITESPACE} {n SEMICOLON} {n WHITESPACE}} $myg add Grammar $myg mode Grammar value $myg rule Grammar {x {n WHITESPACE} {n Header} {* {n Definition}} {n Final} {n EOF}} @@ -163,11 +159,11 @@ $myg mode OPENB void $myg rule OPENB {t \133} $myg add PEG $myg mode PEG void - $myg rule PEG {x {t P} {t E} {t G} {n WHITESPACE}} + $myg rule PEG {x {t P} {t E} {t G} {! {/ {t _} {t :} alnum}} {n WHITESPACE}} $myg add PLUS $myg mode PLUS leaf $myg rule PLUS {x {t +} {n WHITESPACE}} Index: modules/pt/tests/data/ok/peg_container-templated-bulk/3_peg_itself ================================================================== --- modules/pt/tests/data/ok/peg_container-templated-bulk/3_peg_itself +++ modules/pt/tests/data/ok/peg_container-templated-bulk/3_peg_itself @@ -8,11 +8,11 @@ snit::type TEMPLATE { constructor {} { install myg using pt::peg::container ${selfns}::G $myg start {n Grammar} - $myg add ALNUM ALPHA AND APOSTROPH ASCII Attribute Char CharOctalFull CharOctalPart CharSpecial CharUnescaped CharUnicode Class CLOSE CLOSEB COLON COMMENT CONTROL DAPOSTROPH DDIGIT Definition DIGIT DOT END EOF EOL Expression Final Grammar GRAPH Header Ident Identifier IS LEAF Literal LOWER NOT OPEN OPENB PEG PLUS Prefix Primary PRINTABLE PUNCT QUESTION Range SEMICOLON Sequence SLASH SPACE STAR StartExpr Suffix TO UPPER VOID WHITESPACE WORDCHAR XDIGIT + $myg add ALNUM ALPHA AND APOSTROPH ASCII Attribute Char CharOctalFull CharOctalPart CharSpecial CharUnescaped CharUnicode Class CLOSE CLOSEB COLON COMMENT CONTROL DAPOSTROPH DDIGIT Definition DIGIT DOT EOF EOL Expression Final Grammar GRAPH Header Ident Identifier IS LEAF Literal LOWER NOT OPEN OPENB PEG PLUS Prefix Primary PRINTABLE PUNCT QUESTION Range SEMICOLON Sequence SLASH SPACE STAR StartExpr Suffix TO UPPER VOID WHITESPACE WORDCHAR XDIGIT $myg modes { ALNUM leaf ALPHA leaf AND leaf APOSTROPH void @@ -33,11 +33,10 @@ DAPOSTROPH void DDIGIT leaf Definition value DIGIT leaf DOT leaf - END void EOF void EOL void Expression value Final void Grammar value @@ -96,15 +95,14 @@ DAPOSTROPH {t \42} DDIGIT {x {t <} {t d} {t d} {t i} {t g} {t i} {t t} {t >} {n WHITESPACE}} Definition {x {? {n Attribute}} {n Identifier} {n IS} {n Expression} {n SEMICOLON}} DIGIT {x {t <} {t d} {t i} {t g} {t i} {t t} {t >} {n WHITESPACE}} DOT {x {t .} {n WHITESPACE}} - END {x {t E} {t N} {t D} {n WHITESPACE}} EOF {! dot} EOL {/ {t \n} {t \r}} Expression {x {n Sequence} {* {x {n SLASH} {n Sequence}}}} - Final {x {n END} {n SEMICOLON} {n WHITESPACE}} + Final {x {t E} {t N} {t D} {n WHITESPACE} {n SEMICOLON} {n WHITESPACE}} Grammar {x {n WHITESPACE} {n Header} {* {n Definition}} {n Final} {n EOF}} GRAPH {x {t <} {t g} {t r} {t a} {t p} {t h} {t >} {n WHITESPACE}} Header {x {n PEG} {n Identifier} {n StartExpr}} Ident {x {/ {t _} {t :} alpha} {* {/ {t _} {t :} alnum}}} Identifier {x {n Ident} {n WHITESPACE}} @@ -113,11 +111,11 @@ Literal {/ {x {n APOSTROPH} {* {x {! {n APOSTROPH}} {n Char}}} {n APOSTROPH} {n WHITESPACE}} {x {n DAPOSTROPH} {* {x {! {n DAPOSTROPH}} {n Char}}} {n DAPOSTROPH} {n WHITESPACE}}} LOWER {x {t <} {t l} {t o} {t w} {t e} {t r} {t >} {n WHITESPACE}} NOT {x {t !} {n WHITESPACE}} OPEN {x {t \50} {n WHITESPACE}} OPENB {t \133} - PEG {x {t P} {t E} {t G} {n WHITESPACE}} + PEG {x {t P} {t E} {t G} {! {/ {t _} {t :} alnum}} {n WHITESPACE}} PLUS {x {t +} {n WHITESPACE}} Prefix {x {? {/ {n AND} {n NOT}}} {n Suffix}} Primary {/ {n ALNUM} {n ALPHA} {n ASCII} {n CONTROL} {n DDIGIT} {n DIGIT} {n GRAPH} {n LOWER} {n PRINTABLE} {n PUNCT} {n SPACE} {n UPPER} {n WORDCHAR} {n XDIGIT} {n Identifier} {x {n OPEN} {n Expression} {n CLOSE}} {n Literal} {n Class} {n DOT}} PRINTABLE {x {t <} {t p} {t r} {t i} {t n} {t t} {t >} {n WHITESPACE}} PUNCT {x {t <} {t p} {t u} {t n} {t c} {t t} {t >} {n WHITESPACE}} Index: modules/pt/tests/data/ok/peg_container-templated-incremental/3_peg_itself ================================================================== --- modules/pt/tests/data/ok/peg_container-templated-incremental/3_peg_itself +++ modules/pt/tests/data/ok/peg_container-templated-incremental/3_peg_itself @@ -101,14 +101,10 @@ $myg add DOT $myg mode DOT leaf $myg rule DOT {x {t .} {n WHITESPACE}} - $myg add END - $myg mode END void - $myg rule END {x {t E} {t N} {t D} {n WHITESPACE}} - $myg add EOF $myg mode EOF void $myg rule EOF {! dot} $myg add EOL @@ -119,11 +115,11 @@ $myg mode Expression value $myg rule Expression {x {n Sequence} {* {x {n SLASH} {n Sequence}}}} $myg add Final $myg mode Final void - $myg rule Final {x {n END} {n SEMICOLON} {n WHITESPACE}} + $myg rule Final {x {t E} {t N} {t D} {n WHITESPACE} {n SEMICOLON} {n WHITESPACE}} $myg add Grammar $myg mode Grammar value $myg rule Grammar {x {n WHITESPACE} {n Header} {* {n Definition}} {n Final} {n EOF}} @@ -171,11 +167,11 @@ $myg mode OPENB void $myg rule OPENB {t \133} $myg add PEG $myg mode PEG void - $myg rule PEG {x {t P} {t E} {t G} {n WHITESPACE}} + $myg rule PEG {x {t P} {t E} {t G} {! {/ {t _} {t :} alnum}} {n WHITESPACE}} $myg add PLUS $myg mode PLUS leaf $myg rule PLUS {x {t +} {n WHITESPACE}} Index: modules/pt/tests/data/ok/peg_cparam-critcl/0_basic_arithmetic ================================================================== --- modules/pt/tests/data/ok/peg_cparam-critcl/0_basic_arithmetic +++ modules/pt/tests/data/ok/peg_cparam-critcl/0_basic_arithmetic @@ -28,11 +28,11 @@ namespace eval ::PARSER { # # ## ### ##### ######## ############# ##################### ## Supporting code for the main command. catch { - #critcl::cheaders -g + #critcl::cflags -g #critcl::debug memory symbols } # # ## ### ###### ######## ############# ## RDE runtime, inlined, and made static. @@ -384,10 +384,14 @@ int clen; Tcl_UniChar uni; if (len < 0) { len = strlen (string); } + + if (!len) { + return tc->str + base; + } if ((tc->num + len) >= tc->max) { int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); char* str = ckrealloc (tc->str, new * sizeof(char)); ASSERT (str,"Memory allocation failure for token character array"); @@ -413,18 +417,18 @@ } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; - long int* ov; - rde_stack_get (tc->off, &oc, (void***) &ov); + void** ov; + rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); - off = ov [at]; + off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { - end = ov [at+1]; + end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; @@ -432,19 +436,19 @@ } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; - long int* ov; - rde_stack_get (tc->off, &oc, (void***) &ov); + void** ov; + rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); - off = ov [at]; + off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { - end = ov [last+1]; + end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; @@ -479,10 +483,11 @@ typedef int (*UniCharClass) (int); typedef enum test_class_id { tc_alnum, tc_alpha, tc_ascii, + tc_control, tc_ddigit, tc_digit, tc_graph, tc_lower, tc_printable, @@ -492,11 +497,11 @@ tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); - static void error_set (RDE_PARAM p, int s); + static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); @@ -645,13 +650,13 @@ rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void - rde_param_query_amark (RDE_PARAM p, long int* mc, long int** mv) + rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { - rde_stack_get (p->mark, mc, (void***) mv); + rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); @@ -688,25 +693,25 @@ res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; - long int* mv; + void** mv; int lastid; const char* msg; - rde_stack_get (er->msg, &mc, (void***) &mv); + rde_stack_get (er->msg, &mc, &mv); - qsort (mv, mc, sizeof (long int), er_int_compare); + qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); - if (mv [i] == lastid) continue; - lastid = mv [i]; - ASSERT_BOUNDS(mv[i],p->numstr); - msg = p->string [mv[i]]; + if (((long int) mv [i]) == lastid) continue; + lastid = (long int) mv [i]; + ASSERT_BOUNDS((long int) mv[i],p->numstr); + msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } @@ -721,13 +726,18 @@ rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) { rde_stack_get (p->ES, ec, (void***) ev); } SCOPE void - rde_param_query_ls (RDE_PARAM p, long int* lc, long int** lv) + rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) { - rde_stack_get (p->LS, lc, (void***) lv); + rde_stack_get (p->LS, lc, lv); + } + SCOPE long int + rde_param_query_lstop (RDE_PARAM p) + { + (long int) rde_stack_top (p->LS); } SCOPE Tcl_HashTable* rde_param_query_nc (RDE_PARAM p) { return &p->NC; @@ -770,11 +780,11 @@ { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; @@ -783,11 +793,11 @@ rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; @@ -818,12 +828,14 @@ rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void - rde_param_i_error_nonterminal (RDE_PARAM p, int s) + rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { + + return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; error_set (p, s); @@ -872,11 +884,11 @@ { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void - error_set (RDE_PARAM p, int s) + error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; @@ -914,20 +926,21 @@ rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void - rde_param_i_input_next (RDE_PARAM p, int m) + rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); - ASSERT_BOUNDS (p->CC_len, TCL_UTF_MAX); + + ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || @@ -960,11 +973,11 @@ rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int - rde_param_i_symbol_restore (RDE_PARAM p, int s) + rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; @@ -983,11 +996,11 @@ TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void - rde_param_i_symbol_save (RDE_PARAM p, int s) + rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; @@ -1049,11 +1062,16 @@ rde_param_i_test_ascii (RDE_PARAM p) { test_class (p, UniCharIsAscii, tc_ascii); } SCOPE void - rde_param_i_test_char (RDE_PARAM p, char* c, int msg) + rde_param_i_test_control (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsControl, tc_control); + } + SCOPE void + rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); @@ -1091,11 +1109,11 @@ rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void - rde_param_i_test_range (RDE_PARAM p, char* s, char* e, int msg) + rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); @@ -1160,11 +1178,11 @@ rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void - rde_param_i_value_leaf (RDE_PARAM p, int s) + rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); @@ -1174,11 +1192,11 @@ newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void - rde_param_i_value_reduce (RDE_PARAM p, int s) + rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; @@ -1206,18 +1224,21 @@ ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { - long int ai = *((long int*) a); - long int bi = *((long int*) b); - if (ai < bi) { return -1; } - if (ai > bi) { return 1; } + + const void** ael = (const void**) a; + const void** bel = (const void**) b; + long int avalue = (long int) *ael; + long int bvalue = (long int) *bel; + if (avalue < bvalue) { return -1; } + if (avalue > bvalue) { return 1; } return 0; } SCOPE int - rde_param_i_symbol_start (RDE_PARAM p, int s) + rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); @@ -1226,11 +1247,11 @@ } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int - rde_param_i_symbol_start_d (RDE_PARAM p, int s) + rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); @@ -1240,26 +1261,26 @@ rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int - rde_param_i_symbol_void_start (RDE_PARAM p, int s) + rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int - rde_param_i_symbol_void_start_d (RDE_PARAM p, int s) + rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void - rde_param_i_symbol_done_d_reduce (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); @@ -1272,11 +1293,11 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_leaf (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); @@ -1288,11 +1309,11 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_d_leaf (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); @@ -1305,126 +1326,133 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_void (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void - rde_param_i_symbol_done_d_void (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void - rde_param_i_next_char (RDE_PARAM p, char* c, int m) + rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void - rde_param_i_next_range (RDE_PARAM p, char* s, char* e, int m) + rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void - rde_param_i_next_alnum (RDE_PARAM p, int m) + rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void - rde_param_i_next_alpha (RDE_PARAM p, int m) + rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void - rde_param_i_next_ascii (RDE_PARAM p, int m) + rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void - rde_param_i_next_ddigit (RDE_PARAM p, int m) + rde_param_i_next_control (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_control (p); + } + SCOPE void + rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void - rde_param_i_next_digit (RDE_PARAM p, int m) + rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void - rde_param_i_next_graph (RDE_PARAM p, int m) + rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void - rde_param_i_next_lower (RDE_PARAM p, int m) + rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void - rde_param_i_next_print (RDE_PARAM p, int m) + rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void - rde_param_i_next_punct (RDE_PARAM p, int m) + rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void - rde_param_i_next_space (RDE_PARAM p, int m) + rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void - rde_param_i_next_upper (RDE_PARAM p, int m) + rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void - rde_param_i_next_wordchar (RDE_PARAM p, int m) + rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void - rde_param_i_next_xdigit (RDE_PARAM p, int m) + rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } @@ -1501,11 +1529,11 @@ rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } @@ -1569,11 +1597,11 @@ if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } @@ -1612,11 +1640,11 @@ rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; @@ -1628,37 +1656,40 @@ if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void - rde_param_i_next_str (RDE_PARAM p, char* str, int m) + rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; + while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { + p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { + p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void - rde_param_i_next_class (RDE_PARAM p, char* class, int m) + rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; @@ -1707,32 +1738,46 @@ /* * Precomputed table of strings (symbols, error messages, etc.). */ - static char const* p_string [21] = { - /* 0 = */ "cl '-+'", - /* 1 = */ "n AddOp", - /* 2 = */ "AddOp", - /* 3 = */ "cl '0123456789'", - /* 4 = */ "n Digit", - /* 5 = */ "Digit", - /* 6 = */ "t \50", - /* 7 = */ "t \51", - /* 8 = */ "n Expression", - /* 9 = */ "Expression", - /* 10 = */ "n Factor", - /* 11 = */ "Factor", - /* 12 = */ "cl '*/'", - /* 13 = */ "n MulOp", - /* 14 = */ "MulOp", - /* 15 = */ "n Number", - /* 16 = */ "Number", - /* 17 = */ "n Sign", - /* 18 = */ "Sign", - /* 19 = */ "n Term", - /* 20 = */ "Term" + static char const* p_string [35] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "cl -+", + /* 15 = */ "n AddOp", + /* 16 = */ "AddOp", + /* 17 = */ "cl 0123456789", + /* 18 = */ "n Digit", + /* 19 = */ "Digit", + /* 20 = */ "t (", + /* 21 = */ "t )", + /* 22 = */ "n Expression", + /* 23 = */ "Expression", + /* 24 = */ "n Factor", + /* 25 = */ "Factor", + /* 26 = */ "cl */", + /* 27 = */ "n MulOp", + /* 28 = */ "MulOp", + /* 29 = */ "n Number", + /* 30 = */ "Number", + /* 31 = */ "n Sign", + /* 32 = */ "Sign", + /* 33 = */ "n Term", + /* 34 = */ "Term" }; /* * Grammar Start Expression */ @@ -1749,13 +1794,13 @@ static void sym_AddOp (RDE_PARAM p) { /* * [-+] */ - if (rde_param_i_symbol_start (p, 2)) return ; - rde_param_i_next_class (p, "-+", 0); - rde_param_i_symbol_done_leaf (p, 2, 1); + if (rde_param_i_symbol_start (p, 16)) return ; + rde_param_i_next_class (p, "-+", 14); + rde_param_i_symbol_done_leaf (p, 16, 15); return; } /* * value Symbol 'Digit' @@ -1764,13 +1809,13 @@ static void sym_Digit (RDE_PARAM p) { /* * [0123456789] */ - if (rde_param_i_symbol_start (p, 5)) return ; - rde_param_i_next_class (p, "0123456789", 3); - rde_param_i_symbol_done_leaf (p, 5, 4); + if (rde_param_i_symbol_start (p, 19)) return ; + rde_param_i_next_class (p, "0123456789", 17); + rde_param_i_symbol_done_leaf (p, 19, 18); return; } /* * value Symbol 'Expression' @@ -1789,13 +1834,13 @@ * x * (MulOp) * (Factor) */ - if (rde_param_i_symbol_start_d (p, 9)) return ; + if (rde_param_i_symbol_start_d (p, 23)) return ; choice_20 (p); - rde_param_i_symbol_done_d_reduce (p, 9, 8); + rde_param_i_symbol_done_d_reduce (p, 23, 22); return; } static void choice_20 (RDE_PARAM p) { /* @@ -1827,15 +1872,15 @@ * (Expression) * '\)' */ rde_param_i_state_push_void (p); - rde_param_i_next_char (p, "\50", 6); + rde_param_i_next_char (p, "(", 20); if (rde_param_i_seq_void2value(p)) return; sym_Expression (p); if (rde_param_i_seq_value2value(p)) return; - rde_param_i_next_char (p, "\51", 7); + rde_param_i_next_char (p, ")", 21); rde_param_i_state_merge_value (p); return; } static void sequence_18 (RDE_PARAM p) { @@ -1899,13 +1944,13 @@ * x * (AddOp) * (Term) */ - if (rde_param_i_symbol_start_d (p, 11)) return ; + if (rde_param_i_symbol_start_d (p, 25)) return ; sequence_30 (p); - rde_param_i_symbol_done_d_reduce (p, 11, 10); + rde_param_i_symbol_done_d_reduce (p, 25, 24); return; } static void sequence_30 (RDE_PARAM p) { /* @@ -1963,13 +2008,13 @@ static void sym_MulOp (RDE_PARAM p) { /* * [\u002a\u002f] */ - if (rde_param_i_symbol_start (p, 14)) return ; - rde_param_i_next_class (p, "*/", 12); - rde_param_i_symbol_done_leaf (p, 14, 13); + if (rde_param_i_symbol_start (p, 28)) return ; + rde_param_i_next_class (p, "*/", 26); + rde_param_i_symbol_done_leaf (p, 28, 27); return; } /* * value Symbol 'Number' @@ -1982,13 +2027,13 @@ * (Sign) * + * (Digit) */ - if (rde_param_i_symbol_start_d (p, 16)) return ; + if (rde_param_i_symbol_start_d (p, 30)) return ; sequence_41 (p); - rde_param_i_symbol_done_d_reduce (p, 16, 15); + rde_param_i_symbol_done_d_reduce (p, 30, 29); return; } static void sequence_41 (RDE_PARAM p) { /* @@ -2043,13 +2088,13 @@ static void sym_Sign (RDE_PARAM p) { /* * [-+] */ - if (rde_param_i_symbol_start (p, 18)) return ; - rde_param_i_next_class (p, "-+", 0); - rde_param_i_symbol_done_leaf (p, 18, 17); + if (rde_param_i_symbol_start (p, 32)) return ; + rde_param_i_next_class (p, "-+", 14); + rde_param_i_symbol_done_leaf (p, 32, 31); return; } /* * value Symbol 'Term' @@ -2058,13 +2103,13 @@ static void sym_Term (RDE_PARAM p) { /* * (Number) */ - if (rde_param_i_symbol_start_d (p, 20)) return ; + if (rde_param_i_symbol_start_d (p, 34)) return ; sym_Number (p); - rde_param_i_symbol_done_d_reduce (p, 20, 19); + rde_param_i_symbol_done_d_reduce (p, 34, 33); return; } } @@ -2104,11 +2149,11 @@ Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; - sprintf (parserg->buf, "PARSER%d", parserg->counter); + sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void @@ -2167,45 +2212,52 @@ rde_param_data (p, buf, len); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } + /* See also rde_critcl/m.c, param_COMPLETE() */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) { if (rde_param_query_st (p)) { long int ac; Tcl_Obj** av; rde_param_query_ast (p, &ac, &av); if (ac > 1) { - long int lsc; - long int* lsv; Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); - rde_param_query_ls (p, &lsc, &lsv); - memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); lv [0] = Tcl_NewObj (); - lv [1] = Tcl_NewIntObj (1 + lsv [lsc-1]); + lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); ckfree ((char*) lv); + + } else if (ac == 0) { + /* + * Match, but no AST. This is possible if the grammar + * consists of only the start expression. + */ + Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); } else { Tcl_SetObjResult (interp, av [0]); } return TCL_OK; } else { Tcl_Obj* xv [1]; const ERROR_STATE* er = rde_param_query_er (p); Tcl_Obj* res = rde_param_query_er_tcl (p, er); + /* res = list (location, list(msg)) */ + /* Stick the exception type-tag before the existing elements */ xv [0] = Tcl_NewStringObj ("pt::rde",-1); - Tcl_ListObjReplace(interp, res, 0, 1, 1, xv); + Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); + Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); Tcl_SetObjResult (interp, res); return TCL_ERROR; } } } Index: modules/pt/tests/data/ok/peg_cparam-critcl/10_notahead ================================================================== --- modules/pt/tests/data/ok/peg_cparam-critcl/10_notahead +++ modules/pt/tests/data/ok/peg_cparam-critcl/10_notahead @@ -28,11 +28,11 @@ namespace eval ::PARSER { # # ## ### ##### ######## ############# ##################### ## Supporting code for the main command. catch { - #critcl::cheaders -g + #critcl::cflags -g #critcl::debug memory symbols } # # ## ### ###### ######## ############# ## RDE runtime, inlined, and made static. @@ -384,10 +384,14 @@ int clen; Tcl_UniChar uni; if (len < 0) { len = strlen (string); } + + if (!len) { + return tc->str + base; + } if ((tc->num + len) >= tc->max) { int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); char* str = ckrealloc (tc->str, new * sizeof(char)); ASSERT (str,"Memory allocation failure for token character array"); @@ -413,18 +417,18 @@ } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; - long int* ov; - rde_stack_get (tc->off, &oc, (void***) &ov); + void** ov; + rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); - off = ov [at]; + off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { - end = ov [at+1]; + end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; @@ -432,19 +436,19 @@ } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; - long int* ov; - rde_stack_get (tc->off, &oc, (void***) &ov); + void** ov; + rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); - off = ov [at]; + off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { - end = ov [last+1]; + end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; @@ -479,10 +483,11 @@ typedef int (*UniCharClass) (int); typedef enum test_class_id { tc_alnum, tc_alpha, tc_ascii, + tc_control, tc_ddigit, tc_digit, tc_graph, tc_lower, tc_printable, @@ -492,11 +497,11 @@ tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); - static void error_set (RDE_PARAM p, int s); + static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); @@ -645,13 +650,13 @@ rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void - rde_param_query_amark (RDE_PARAM p, long int* mc, long int** mv) + rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { - rde_stack_get (p->mark, mc, (void***) mv); + rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); @@ -688,25 +693,25 @@ res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; - long int* mv; + void** mv; int lastid; const char* msg; - rde_stack_get (er->msg, &mc, (void***) &mv); + rde_stack_get (er->msg, &mc, &mv); - qsort (mv, mc, sizeof (long int), er_int_compare); + qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); - if (mv [i] == lastid) continue; - lastid = mv [i]; - ASSERT_BOUNDS(mv[i],p->numstr); - msg = p->string [mv[i]]; + if (((long int) mv [i]) == lastid) continue; + lastid = (long int) mv [i]; + ASSERT_BOUNDS((long int) mv[i],p->numstr); + msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } @@ -721,13 +726,18 @@ rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) { rde_stack_get (p->ES, ec, (void***) ev); } SCOPE void - rde_param_query_ls (RDE_PARAM p, long int* lc, long int** lv) + rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) { - rde_stack_get (p->LS, lc, (void***) lv); + rde_stack_get (p->LS, lc, lv); + } + SCOPE long int + rde_param_query_lstop (RDE_PARAM p) + { + (long int) rde_stack_top (p->LS); } SCOPE Tcl_HashTable* rde_param_query_nc (RDE_PARAM p) { return &p->NC; @@ -770,11 +780,11 @@ { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; @@ -783,11 +793,11 @@ rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; @@ -818,12 +828,14 @@ rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void - rde_param_i_error_nonterminal (RDE_PARAM p, int s) + rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { + + return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; error_set (p, s); @@ -872,11 +884,11 @@ { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void - error_set (RDE_PARAM p, int s) + error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; @@ -914,20 +926,21 @@ rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void - rde_param_i_input_next (RDE_PARAM p, int m) + rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); - ASSERT_BOUNDS (p->CC_len, TCL_UTF_MAX); + + ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || @@ -960,11 +973,11 @@ rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int - rde_param_i_symbol_restore (RDE_PARAM p, int s) + rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; @@ -983,11 +996,11 @@ TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void - rde_param_i_symbol_save (RDE_PARAM p, int s) + rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; @@ -1049,11 +1062,16 @@ rde_param_i_test_ascii (RDE_PARAM p) { test_class (p, UniCharIsAscii, tc_ascii); } SCOPE void - rde_param_i_test_char (RDE_PARAM p, char* c, int msg) + rde_param_i_test_control (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsControl, tc_control); + } + SCOPE void + rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); @@ -1091,11 +1109,11 @@ rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void - rde_param_i_test_range (RDE_PARAM p, char* s, char* e, int msg) + rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); @@ -1160,11 +1178,11 @@ rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void - rde_param_i_value_leaf (RDE_PARAM p, int s) + rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); @@ -1174,11 +1192,11 @@ newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void - rde_param_i_value_reduce (RDE_PARAM p, int s) + rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; @@ -1206,18 +1224,21 @@ ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { - long int ai = *((long int*) a); - long int bi = *((long int*) b); - if (ai < bi) { return -1; } - if (ai > bi) { return 1; } + + const void** ael = (const void**) a; + const void** bel = (const void**) b; + long int avalue = (long int) *ael; + long int bvalue = (long int) *bel; + if (avalue < bvalue) { return -1; } + if (avalue > bvalue) { return 1; } return 0; } SCOPE int - rde_param_i_symbol_start (RDE_PARAM p, int s) + rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); @@ -1226,11 +1247,11 @@ } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int - rde_param_i_symbol_start_d (RDE_PARAM p, int s) + rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); @@ -1240,26 +1261,26 @@ rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int - rde_param_i_symbol_void_start (RDE_PARAM p, int s) + rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int - rde_param_i_symbol_void_start_d (RDE_PARAM p, int s) + rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void - rde_param_i_symbol_done_d_reduce (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); @@ -1272,11 +1293,11 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_leaf (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); @@ -1288,11 +1309,11 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_d_leaf (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); @@ -1305,126 +1326,133 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_void (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void - rde_param_i_symbol_done_d_void (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void - rde_param_i_next_char (RDE_PARAM p, char* c, int m) + rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void - rde_param_i_next_range (RDE_PARAM p, char* s, char* e, int m) + rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void - rde_param_i_next_alnum (RDE_PARAM p, int m) + rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void - rde_param_i_next_alpha (RDE_PARAM p, int m) + rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void - rde_param_i_next_ascii (RDE_PARAM p, int m) + rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void - rde_param_i_next_ddigit (RDE_PARAM p, int m) + rde_param_i_next_control (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_control (p); + } + SCOPE void + rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void - rde_param_i_next_digit (RDE_PARAM p, int m) + rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void - rde_param_i_next_graph (RDE_PARAM p, int m) + rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void - rde_param_i_next_lower (RDE_PARAM p, int m) + rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void - rde_param_i_next_print (RDE_PARAM p, int m) + rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void - rde_param_i_next_punct (RDE_PARAM p, int m) + rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void - rde_param_i_next_space (RDE_PARAM p, int m) + rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void - rde_param_i_next_upper (RDE_PARAM p, int m) + rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void - rde_param_i_next_wordchar (RDE_PARAM p, int m) + rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void - rde_param_i_next_xdigit (RDE_PARAM p, int m) + rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } @@ -1501,11 +1529,11 @@ rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } @@ -1569,11 +1597,11 @@ if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } @@ -1612,11 +1640,11 @@ rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; @@ -1628,37 +1656,40 @@ if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void - rde_param_i_next_str (RDE_PARAM p, char* str, int m) + rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; + while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { + p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { + p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void - rde_param_i_next_class (RDE_PARAM p, char* class, int m) + rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; @@ -1691,14 +1722,28 @@ /* * Precomputed table of strings (symbols, error messages, etc.). */ - static char const* p_string [3] = { - /* 0 = */ "t a", - /* 1 = */ "n TEST", - /* 2 = */ "TEST" + static char const* p_string [17] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "t a", + /* 15 = */ "n TEST", + /* 16 = */ "TEST" }; /* * Grammar Start Expression */ @@ -1718,13 +1763,13 @@ * ! * 'a' * (IDENTIFIER) */ - if (rde_param_i_symbol_start (p, 2)) return ; + if (rde_param_i_symbol_start (p, 16)) return ; sequence_6 (p); - rde_param_i_symbol_done_leaf (p, 2, 1); + rde_param_i_symbol_done_leaf (p, 16, 15); return; } static void sequence_6 (RDE_PARAM p) { /* @@ -1748,11 +1793,11 @@ * ! * 'a' */ rde_param_i_loc_push (p); - rde_param_i_next_char (p, "a", 0); + rde_param_i_next_char (p, "a", 14); rde_param_i_notahead_exit (p); return; } } @@ -1793,11 +1838,11 @@ Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; - sprintf (parserg->buf, "PARSER%d", parserg->counter); + sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void @@ -1856,45 +1901,52 @@ rde_param_data (p, buf, len); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } + /* See also rde_critcl/m.c, param_COMPLETE() */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) { if (rde_param_query_st (p)) { long int ac; Tcl_Obj** av; rde_param_query_ast (p, &ac, &av); if (ac > 1) { - long int lsc; - long int* lsv; Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); - rde_param_query_ls (p, &lsc, &lsv); - memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); lv [0] = Tcl_NewObj (); - lv [1] = Tcl_NewIntObj (1 + lsv [lsc-1]); + lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); ckfree ((char*) lv); + + } else if (ac == 0) { + /* + * Match, but no AST. This is possible if the grammar + * consists of only the start expression. + */ + Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); } else { Tcl_SetObjResult (interp, av [0]); } return TCL_OK; } else { Tcl_Obj* xv [1]; const ERROR_STATE* er = rde_param_query_er (p); Tcl_Obj* res = rde_param_query_er_tcl (p, er); + /* res = list (location, list(msg)) */ + /* Stick the exception type-tag before the existing elements */ xv [0] = Tcl_NewStringObj ("pt::rde",-1); - Tcl_ListObjReplace(interp, res, 0, 1, 1, xv); + Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); + Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); Tcl_SetObjResult (interp, res); return TCL_ERROR; } } } Index: modules/pt/tests/data/ok/peg_cparam-critcl/11_epsilon ================================================================== --- modules/pt/tests/data/ok/peg_cparam-critcl/11_epsilon +++ modules/pt/tests/data/ok/peg_cparam-critcl/11_epsilon @@ -28,11 +28,11 @@ namespace eval ::PARSER { # # ## ### ##### ######## ############# ##################### ## Supporting code for the main command. catch { - #critcl::cheaders -g + #critcl::cflags -g #critcl::debug memory symbols } # # ## ### ###### ######## ############# ## RDE runtime, inlined, and made static. @@ -384,10 +384,14 @@ int clen; Tcl_UniChar uni; if (len < 0) { len = strlen (string); } + + if (!len) { + return tc->str + base; + } if ((tc->num + len) >= tc->max) { int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); char* str = ckrealloc (tc->str, new * sizeof(char)); ASSERT (str,"Memory allocation failure for token character array"); @@ -413,18 +417,18 @@ } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; - long int* ov; - rde_stack_get (tc->off, &oc, (void***) &ov); + void** ov; + rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); - off = ov [at]; + off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { - end = ov [at+1]; + end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; @@ -432,19 +436,19 @@ } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; - long int* ov; - rde_stack_get (tc->off, &oc, (void***) &ov); + void** ov; + rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); - off = ov [at]; + off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { - end = ov [last+1]; + end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; @@ -479,10 +483,11 @@ typedef int (*UniCharClass) (int); typedef enum test_class_id { tc_alnum, tc_alpha, tc_ascii, + tc_control, tc_ddigit, tc_digit, tc_graph, tc_lower, tc_printable, @@ -492,11 +497,11 @@ tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); - static void error_set (RDE_PARAM p, int s); + static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); @@ -645,13 +650,13 @@ rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void - rde_param_query_amark (RDE_PARAM p, long int* mc, long int** mv) + rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { - rde_stack_get (p->mark, mc, (void***) mv); + rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); @@ -688,25 +693,25 @@ res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; - long int* mv; + void** mv; int lastid; const char* msg; - rde_stack_get (er->msg, &mc, (void***) &mv); + rde_stack_get (er->msg, &mc, &mv); - qsort (mv, mc, sizeof (long int), er_int_compare); + qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); - if (mv [i] == lastid) continue; - lastid = mv [i]; - ASSERT_BOUNDS(mv[i],p->numstr); - msg = p->string [mv[i]]; + if (((long int) mv [i]) == lastid) continue; + lastid = (long int) mv [i]; + ASSERT_BOUNDS((long int) mv[i],p->numstr); + msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } @@ -721,13 +726,18 @@ rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) { rde_stack_get (p->ES, ec, (void***) ev); } SCOPE void - rde_param_query_ls (RDE_PARAM p, long int* lc, long int** lv) + rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) { - rde_stack_get (p->LS, lc, (void***) lv); + rde_stack_get (p->LS, lc, lv); + } + SCOPE long int + rde_param_query_lstop (RDE_PARAM p) + { + (long int) rde_stack_top (p->LS); } SCOPE Tcl_HashTable* rde_param_query_nc (RDE_PARAM p) { return &p->NC; @@ -770,11 +780,11 @@ { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; @@ -783,11 +793,11 @@ rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; @@ -818,12 +828,14 @@ rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void - rde_param_i_error_nonterminal (RDE_PARAM p, int s) + rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { + + return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; error_set (p, s); @@ -872,11 +884,11 @@ { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void - error_set (RDE_PARAM p, int s) + error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; @@ -914,20 +926,21 @@ rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void - rde_param_i_input_next (RDE_PARAM p, int m) + rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); - ASSERT_BOUNDS (p->CC_len, TCL_UTF_MAX); + + ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || @@ -960,11 +973,11 @@ rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int - rde_param_i_symbol_restore (RDE_PARAM p, int s) + rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; @@ -983,11 +996,11 @@ TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void - rde_param_i_symbol_save (RDE_PARAM p, int s) + rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; @@ -1049,11 +1062,16 @@ rde_param_i_test_ascii (RDE_PARAM p) { test_class (p, UniCharIsAscii, tc_ascii); } SCOPE void - rde_param_i_test_char (RDE_PARAM p, char* c, int msg) + rde_param_i_test_control (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsControl, tc_control); + } + SCOPE void + rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); @@ -1091,11 +1109,11 @@ rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void - rde_param_i_test_range (RDE_PARAM p, char* s, char* e, int msg) + rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); @@ -1160,11 +1178,11 @@ rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void - rde_param_i_value_leaf (RDE_PARAM p, int s) + rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); @@ -1174,11 +1192,11 @@ newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void - rde_param_i_value_reduce (RDE_PARAM p, int s) + rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; @@ -1206,18 +1224,21 @@ ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { - long int ai = *((long int*) a); - long int bi = *((long int*) b); - if (ai < bi) { return -1; } - if (ai > bi) { return 1; } + + const void** ael = (const void**) a; + const void** bel = (const void**) b; + long int avalue = (long int) *ael; + long int bvalue = (long int) *bel; + if (avalue < bvalue) { return -1; } + if (avalue > bvalue) { return 1; } return 0; } SCOPE int - rde_param_i_symbol_start (RDE_PARAM p, int s) + rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); @@ -1226,11 +1247,11 @@ } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int - rde_param_i_symbol_start_d (RDE_PARAM p, int s) + rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); @@ -1240,26 +1261,26 @@ rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int - rde_param_i_symbol_void_start (RDE_PARAM p, int s) + rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int - rde_param_i_symbol_void_start_d (RDE_PARAM p, int s) + rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void - rde_param_i_symbol_done_d_reduce (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); @@ -1272,11 +1293,11 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_leaf (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); @@ -1288,11 +1309,11 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_d_leaf (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); @@ -1305,126 +1326,133 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_void (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void - rde_param_i_symbol_done_d_void (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void - rde_param_i_next_char (RDE_PARAM p, char* c, int m) + rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void - rde_param_i_next_range (RDE_PARAM p, char* s, char* e, int m) + rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void - rde_param_i_next_alnum (RDE_PARAM p, int m) + rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void - rde_param_i_next_alpha (RDE_PARAM p, int m) + rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void - rde_param_i_next_ascii (RDE_PARAM p, int m) + rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void - rde_param_i_next_ddigit (RDE_PARAM p, int m) + rde_param_i_next_control (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_control (p); + } + SCOPE void + rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void - rde_param_i_next_digit (RDE_PARAM p, int m) + rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void - rde_param_i_next_graph (RDE_PARAM p, int m) + rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void - rde_param_i_next_lower (RDE_PARAM p, int m) + rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void - rde_param_i_next_print (RDE_PARAM p, int m) + rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void - rde_param_i_next_punct (RDE_PARAM p, int m) + rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void - rde_param_i_next_space (RDE_PARAM p, int m) + rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void - rde_param_i_next_upper (RDE_PARAM p, int m) + rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void - rde_param_i_next_wordchar (RDE_PARAM p, int m) + rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void - rde_param_i_next_xdigit (RDE_PARAM p, int m) + rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } @@ -1501,11 +1529,11 @@ rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } @@ -1569,11 +1597,11 @@ if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } @@ -1612,11 +1640,11 @@ rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; @@ -1628,37 +1656,40 @@ if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void - rde_param_i_next_str (RDE_PARAM p, char* str, int m) + rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; + while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { + p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { + p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void - rde_param_i_next_class (RDE_PARAM p, char* class, int m) + rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; @@ -1689,12 +1720,26 @@ /* * Precomputed table of strings (symbols, error messages, etc.). */ - static char const* p_string [1] = { - /* 0 = */ "t a" + static char const* p_string [15] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "t a" }; /* * Grammar Start Expression */ @@ -1710,11 +1755,11 @@ * 'a' * */ rde_param_i_state_push_void (p); - rde_param_i_next_char (p, "a", 0); + rde_param_i_next_char (p, "a", 14); if (rde_param_i_bra_void2void(p)) return; rde_param_i_status_ok (p); rde_param_i_state_merge_void (p); return; } @@ -1757,11 +1802,11 @@ Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; - sprintf (parserg->buf, "PARSER%d", parserg->counter); + sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void @@ -1820,45 +1865,52 @@ rde_param_data (p, buf, len); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } + /* See also rde_critcl/m.c, param_COMPLETE() */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) { if (rde_param_query_st (p)) { long int ac; Tcl_Obj** av; rde_param_query_ast (p, &ac, &av); if (ac > 1) { - long int lsc; - long int* lsv; Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); - rde_param_query_ls (p, &lsc, &lsv); - memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); lv [0] = Tcl_NewObj (); - lv [1] = Tcl_NewIntObj (1 + lsv [lsc-1]); + lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); ckfree ((char*) lv); + + } else if (ac == 0) { + /* + * Match, but no AST. This is possible if the grammar + * consists of only the start expression. + */ + Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); } else { Tcl_SetObjResult (interp, av [0]); } return TCL_OK; } else { Tcl_Obj* xv [1]; const ERROR_STATE* er = rde_param_query_er (p); Tcl_Obj* res = rde_param_query_er_tcl (p, er); + /* res = list (location, list(msg)) */ + /* Stick the exception type-tag before the existing elements */ xv [0] = Tcl_NewStringObj ("pt::rde",-1); - Tcl_ListObjReplace(interp, res, 0, 1, 1, xv); + Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); + Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); Tcl_SetObjResult (interp, res); return TCL_ERROR; } } } Index: modules/pt/tests/data/ok/peg_cparam-critcl/1_functions ================================================================== --- modules/pt/tests/data/ok/peg_cparam-critcl/1_functions +++ modules/pt/tests/data/ok/peg_cparam-critcl/1_functions @@ -28,11 +28,11 @@ namespace eval ::PARSER { # # ## ### ##### ######## ############# ##################### ## Supporting code for the main command. catch { - #critcl::cheaders -g + #critcl::cflags -g #critcl::debug memory symbols } # # ## ### ###### ######## ############# ## RDE runtime, inlined, and made static. @@ -384,10 +384,14 @@ int clen; Tcl_UniChar uni; if (len < 0) { len = strlen (string); } + + if (!len) { + return tc->str + base; + } if ((tc->num + len) >= tc->max) { int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); char* str = ckrealloc (tc->str, new * sizeof(char)); ASSERT (str,"Memory allocation failure for token character array"); @@ -413,18 +417,18 @@ } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; - long int* ov; - rde_stack_get (tc->off, &oc, (void***) &ov); + void** ov; + rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); - off = ov [at]; + off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { - end = ov [at+1]; + end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; @@ -432,19 +436,19 @@ } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; - long int* ov; - rde_stack_get (tc->off, &oc, (void***) &ov); + void** ov; + rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); - off = ov [at]; + off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { - end = ov [last+1]; + end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; @@ -479,10 +483,11 @@ typedef int (*UniCharClass) (int); typedef enum test_class_id { tc_alnum, tc_alpha, tc_ascii, + tc_control, tc_ddigit, tc_digit, tc_graph, tc_lower, tc_printable, @@ -492,11 +497,11 @@ tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); - static void error_set (RDE_PARAM p, int s); + static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); @@ -645,13 +650,13 @@ rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void - rde_param_query_amark (RDE_PARAM p, long int* mc, long int** mv) + rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { - rde_stack_get (p->mark, mc, (void***) mv); + rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); @@ -688,25 +693,25 @@ res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; - long int* mv; + void** mv; int lastid; const char* msg; - rde_stack_get (er->msg, &mc, (void***) &mv); + rde_stack_get (er->msg, &mc, &mv); - qsort (mv, mc, sizeof (long int), er_int_compare); + qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); - if (mv [i] == lastid) continue; - lastid = mv [i]; - ASSERT_BOUNDS(mv[i],p->numstr); - msg = p->string [mv[i]]; + if (((long int) mv [i]) == lastid) continue; + lastid = (long int) mv [i]; + ASSERT_BOUNDS((long int) mv[i],p->numstr); + msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } @@ -721,13 +726,18 @@ rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) { rde_stack_get (p->ES, ec, (void***) ev); } SCOPE void - rde_param_query_ls (RDE_PARAM p, long int* lc, long int** lv) + rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) { - rde_stack_get (p->LS, lc, (void***) lv); + rde_stack_get (p->LS, lc, lv); + } + SCOPE long int + rde_param_query_lstop (RDE_PARAM p) + { + (long int) rde_stack_top (p->LS); } SCOPE Tcl_HashTable* rde_param_query_nc (RDE_PARAM p) { return &p->NC; @@ -770,11 +780,11 @@ { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; @@ -783,11 +793,11 @@ rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; @@ -818,12 +828,14 @@ rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void - rde_param_i_error_nonterminal (RDE_PARAM p, int s) + rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { + + return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; error_set (p, s); @@ -872,11 +884,11 @@ { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void - error_set (RDE_PARAM p, int s) + error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; @@ -914,20 +926,21 @@ rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void - rde_param_i_input_next (RDE_PARAM p, int m) + rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); - ASSERT_BOUNDS (p->CC_len, TCL_UTF_MAX); + + ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || @@ -960,11 +973,11 @@ rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int - rde_param_i_symbol_restore (RDE_PARAM p, int s) + rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; @@ -983,11 +996,11 @@ TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void - rde_param_i_symbol_save (RDE_PARAM p, int s) + rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; @@ -1049,11 +1062,16 @@ rde_param_i_test_ascii (RDE_PARAM p) { test_class (p, UniCharIsAscii, tc_ascii); } SCOPE void - rde_param_i_test_char (RDE_PARAM p, char* c, int msg) + rde_param_i_test_control (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsControl, tc_control); + } + SCOPE void + rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); @@ -1091,11 +1109,11 @@ rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void - rde_param_i_test_range (RDE_PARAM p, char* s, char* e, int msg) + rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); @@ -1160,11 +1178,11 @@ rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void - rde_param_i_value_leaf (RDE_PARAM p, int s) + rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); @@ -1174,11 +1192,11 @@ newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void - rde_param_i_value_reduce (RDE_PARAM p, int s) + rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; @@ -1206,18 +1224,21 @@ ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { - long int ai = *((long int*) a); - long int bi = *((long int*) b); - if (ai < bi) { return -1; } - if (ai > bi) { return 1; } + + const void** ael = (const void**) a; + const void** bel = (const void**) b; + long int avalue = (long int) *ael; + long int bvalue = (long int) *bel; + if (avalue < bvalue) { return -1; } + if (avalue > bvalue) { return 1; } return 0; } SCOPE int - rde_param_i_symbol_start (RDE_PARAM p, int s) + rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); @@ -1226,11 +1247,11 @@ } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int - rde_param_i_symbol_start_d (RDE_PARAM p, int s) + rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); @@ -1240,26 +1261,26 @@ rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int - rde_param_i_symbol_void_start (RDE_PARAM p, int s) + rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int - rde_param_i_symbol_void_start_d (RDE_PARAM p, int s) + rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void - rde_param_i_symbol_done_d_reduce (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); @@ -1272,11 +1293,11 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_leaf (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); @@ -1288,11 +1309,11 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_d_leaf (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); @@ -1305,126 +1326,133 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_void (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void - rde_param_i_symbol_done_d_void (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void - rde_param_i_next_char (RDE_PARAM p, char* c, int m) + rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void - rde_param_i_next_range (RDE_PARAM p, char* s, char* e, int m) + rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void - rde_param_i_next_alnum (RDE_PARAM p, int m) + rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void - rde_param_i_next_alpha (RDE_PARAM p, int m) + rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void - rde_param_i_next_ascii (RDE_PARAM p, int m) + rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void - rde_param_i_next_ddigit (RDE_PARAM p, int m) + rde_param_i_next_control (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_control (p); + } + SCOPE void + rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void - rde_param_i_next_digit (RDE_PARAM p, int m) + rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void - rde_param_i_next_graph (RDE_PARAM p, int m) + rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void - rde_param_i_next_lower (RDE_PARAM p, int m) + rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void - rde_param_i_next_print (RDE_PARAM p, int m) + rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void - rde_param_i_next_punct (RDE_PARAM p, int m) + rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void - rde_param_i_next_space (RDE_PARAM p, int m) + rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void - rde_param_i_next_upper (RDE_PARAM p, int m) + rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void - rde_param_i_next_wordchar (RDE_PARAM p, int m) + rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void - rde_param_i_next_xdigit (RDE_PARAM p, int m) + rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } @@ -1501,11 +1529,11 @@ rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } @@ -1569,11 +1597,11 @@ if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } @@ -1612,11 +1640,11 @@ rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; @@ -1628,37 +1656,40 @@ if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void - rde_param_i_next_str (RDE_PARAM p, char* str, int m) + rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; + while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { + p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { + p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void - rde_param_i_next_class (RDE_PARAM p, char* class, int m) + rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; @@ -1692,19 +1723,33 @@ /* * Precomputed table of strings (symbols, error messages, etc.). */ - static char const* p_string [8] = { - /* 0 = */ "n Expression", - /* 1 = */ "Expression", - /* 2 = */ "n Function", - /* 3 = */ "Function", - /* 4 = */ "str 'sin\50'", - /* 5 = */ "t \51", - /* 6 = */ "n Sinus", - /* 7 = */ "Sinus" + static char const* p_string [22] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "n Expression", + /* 15 = */ "Expression", + /* 16 = */ "n Function", + /* 17 = */ "Function", + /* 18 = */ "str sin(", + /* 19 = */ "t )", + /* 20 = */ "n Sinus", + /* 21 = */ "Sinus" }; /* * Grammar Start Expression */ @@ -1721,13 +1766,13 @@ static void sym_Expression (RDE_PARAM p) { /* * (Function) */ - if (rde_param_i_symbol_start_d (p, 1)) return ; + if (rde_param_i_symbol_start_d (p, 15)) return ; sym_Function (p); - rde_param_i_symbol_done_d_reduce (p, 1, 0); + rde_param_i_symbol_done_d_reduce (p, 15, 14); return; } /* * value Symbol 'Function' @@ -1736,13 +1781,13 @@ static void sym_Function (RDE_PARAM p) { /* * (Sinus) */ - if (rde_param_i_symbol_start_d (p, 3)) return ; + if (rde_param_i_symbol_start_d (p, 17)) return ; sym_Sinus (p); - rde_param_i_symbol_done_d_reduce (p, 3, 2); + rde_param_i_symbol_done_d_reduce (p, 17, 16); return; } /* * value Symbol 'Sinus' @@ -1754,13 +1799,13 @@ * "sin\(" * (Expression) * '\)' */ - if (rde_param_i_symbol_start_d (p, 7)) return ; + if (rde_param_i_symbol_start_d (p, 21)) return ; sequence_9 (p); - rde_param_i_symbol_done_d_reduce (p, 7, 6); + rde_param_i_symbol_done_d_reduce (p, 21, 20); return; } static void sequence_9 (RDE_PARAM p) { /* @@ -1769,15 +1814,15 @@ * (Expression) * '\)' */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "sin\50", 4); + rde_param_i_next_str (p, "sin(", 18); if (rde_param_i_seq_void2value(p)) return; sym_Expression (p); if (rde_param_i_seq_value2value(p)) return; - rde_param_i_next_char (p, "\51", 5); + rde_param_i_next_char (p, ")", 19); rde_param_i_state_merge_value (p); return; } } @@ -1818,11 +1863,11 @@ Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; - sprintf (parserg->buf, "PARSER%d", parserg->counter); + sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void @@ -1881,45 +1926,52 @@ rde_param_data (p, buf, len); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } + /* See also rde_critcl/m.c, param_COMPLETE() */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) { if (rde_param_query_st (p)) { long int ac; Tcl_Obj** av; rde_param_query_ast (p, &ac, &av); if (ac > 1) { - long int lsc; - long int* lsv; Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); - rde_param_query_ls (p, &lsc, &lsv); - memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); lv [0] = Tcl_NewObj (); - lv [1] = Tcl_NewIntObj (1 + lsv [lsc-1]); + lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); ckfree ((char*) lv); + + } else if (ac == 0) { + /* + * Match, but no AST. This is possible if the grammar + * consists of only the start expression. + */ + Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); } else { Tcl_SetObjResult (interp, av [0]); } return TCL_OK; } else { Tcl_Obj* xv [1]; const ERROR_STATE* er = rde_param_query_er (p); Tcl_Obj* res = rde_param_query_er_tcl (p, er); + /* res = list (location, list(msg)) */ + /* Stick the exception type-tag before the existing elements */ xv [0] = Tcl_NewStringObj ("pt::rde",-1); - Tcl_ListObjReplace(interp, res, 0, 1, 1, xv); + Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); + Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); Tcl_SetObjResult (interp, res); return TCL_ERROR; } } } Index: modules/pt/tests/data/ok/peg_cparam-critcl/2_fun_arithmetic ================================================================== --- modules/pt/tests/data/ok/peg_cparam-critcl/2_fun_arithmetic +++ modules/pt/tests/data/ok/peg_cparam-critcl/2_fun_arithmetic @@ -28,11 +28,11 @@ namespace eval ::PARSER { # # ## ### ##### ######## ############# ##################### ## Supporting code for the main command. catch { - #critcl::cheaders -g + #critcl::cflags -g #critcl::debug memory symbols } # # ## ### ###### ######## ############# ## RDE runtime, inlined, and made static. @@ -384,10 +384,14 @@ int clen; Tcl_UniChar uni; if (len < 0) { len = strlen (string); } + + if (!len) { + return tc->str + base; + } if ((tc->num + len) >= tc->max) { int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); char* str = ckrealloc (tc->str, new * sizeof(char)); ASSERT (str,"Memory allocation failure for token character array"); @@ -413,18 +417,18 @@ } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; - long int* ov; - rde_stack_get (tc->off, &oc, (void***) &ov); + void** ov; + rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); - off = ov [at]; + off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { - end = ov [at+1]; + end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; @@ -432,19 +436,19 @@ } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; - long int* ov; - rde_stack_get (tc->off, &oc, (void***) &ov); + void** ov; + rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); - off = ov [at]; + off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { - end = ov [last+1]; + end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; @@ -479,10 +483,11 @@ typedef int (*UniCharClass) (int); typedef enum test_class_id { tc_alnum, tc_alpha, tc_ascii, + tc_control, tc_ddigit, tc_digit, tc_graph, tc_lower, tc_printable, @@ -492,11 +497,11 @@ tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); - static void error_set (RDE_PARAM p, int s); + static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); @@ -645,13 +650,13 @@ rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void - rde_param_query_amark (RDE_PARAM p, long int* mc, long int** mv) + rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { - rde_stack_get (p->mark, mc, (void***) mv); + rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); @@ -688,25 +693,25 @@ res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; - long int* mv; + void** mv; int lastid; const char* msg; - rde_stack_get (er->msg, &mc, (void***) &mv); + rde_stack_get (er->msg, &mc, &mv); - qsort (mv, mc, sizeof (long int), er_int_compare); + qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); - if (mv [i] == lastid) continue; - lastid = mv [i]; - ASSERT_BOUNDS(mv[i],p->numstr); - msg = p->string [mv[i]]; + if (((long int) mv [i]) == lastid) continue; + lastid = (long int) mv [i]; + ASSERT_BOUNDS((long int) mv[i],p->numstr); + msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } @@ -721,13 +726,18 @@ rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) { rde_stack_get (p->ES, ec, (void***) ev); } SCOPE void - rde_param_query_ls (RDE_PARAM p, long int* lc, long int** lv) + rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) { - rde_stack_get (p->LS, lc, (void***) lv); + rde_stack_get (p->LS, lc, lv); + } + SCOPE long int + rde_param_query_lstop (RDE_PARAM p) + { + (long int) rde_stack_top (p->LS); } SCOPE Tcl_HashTable* rde_param_query_nc (RDE_PARAM p) { return &p->NC; @@ -770,11 +780,11 @@ { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; @@ -783,11 +793,11 @@ rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; @@ -818,12 +828,14 @@ rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void - rde_param_i_error_nonterminal (RDE_PARAM p, int s) + rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { + + return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; error_set (p, s); @@ -872,11 +884,11 @@ { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void - error_set (RDE_PARAM p, int s) + error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; @@ -914,20 +926,21 @@ rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void - rde_param_i_input_next (RDE_PARAM p, int m) + rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); - ASSERT_BOUNDS (p->CC_len, TCL_UTF_MAX); + + ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || @@ -960,11 +973,11 @@ rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int - rde_param_i_symbol_restore (RDE_PARAM p, int s) + rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; @@ -983,11 +996,11 @@ TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void - rde_param_i_symbol_save (RDE_PARAM p, int s) + rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; @@ -1049,11 +1062,16 @@ rde_param_i_test_ascii (RDE_PARAM p) { test_class (p, UniCharIsAscii, tc_ascii); } SCOPE void - rde_param_i_test_char (RDE_PARAM p, char* c, int msg) + rde_param_i_test_control (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsControl, tc_control); + } + SCOPE void + rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); @@ -1091,11 +1109,11 @@ rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void - rde_param_i_test_range (RDE_PARAM p, char* s, char* e, int msg) + rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); @@ -1160,11 +1178,11 @@ rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void - rde_param_i_value_leaf (RDE_PARAM p, int s) + rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); @@ -1174,11 +1192,11 @@ newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void - rde_param_i_value_reduce (RDE_PARAM p, int s) + rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; @@ -1206,18 +1224,21 @@ ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { - long int ai = *((long int*) a); - long int bi = *((long int*) b); - if (ai < bi) { return -1; } - if (ai > bi) { return 1; } + + const void** ael = (const void**) a; + const void** bel = (const void**) b; + long int avalue = (long int) *ael; + long int bvalue = (long int) *bel; + if (avalue < bvalue) { return -1; } + if (avalue > bvalue) { return 1; } return 0; } SCOPE int - rde_param_i_symbol_start (RDE_PARAM p, int s) + rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); @@ -1226,11 +1247,11 @@ } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int - rde_param_i_symbol_start_d (RDE_PARAM p, int s) + rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); @@ -1240,26 +1261,26 @@ rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int - rde_param_i_symbol_void_start (RDE_PARAM p, int s) + rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int - rde_param_i_symbol_void_start_d (RDE_PARAM p, int s) + rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void - rde_param_i_symbol_done_d_reduce (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); @@ -1272,11 +1293,11 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_leaf (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); @@ -1288,11 +1309,11 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_d_leaf (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); @@ -1305,126 +1326,133 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_void (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void - rde_param_i_symbol_done_d_void (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void - rde_param_i_next_char (RDE_PARAM p, char* c, int m) + rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void - rde_param_i_next_range (RDE_PARAM p, char* s, char* e, int m) + rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void - rde_param_i_next_alnum (RDE_PARAM p, int m) + rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void - rde_param_i_next_alpha (RDE_PARAM p, int m) + rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void - rde_param_i_next_ascii (RDE_PARAM p, int m) + rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void - rde_param_i_next_ddigit (RDE_PARAM p, int m) + rde_param_i_next_control (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_control (p); + } + SCOPE void + rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void - rde_param_i_next_digit (RDE_PARAM p, int m) + rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void - rde_param_i_next_graph (RDE_PARAM p, int m) + rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void - rde_param_i_next_lower (RDE_PARAM p, int m) + rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void - rde_param_i_next_print (RDE_PARAM p, int m) + rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void - rde_param_i_next_punct (RDE_PARAM p, int m) + rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void - rde_param_i_next_space (RDE_PARAM p, int m) + rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void - rde_param_i_next_upper (RDE_PARAM p, int m) + rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void - rde_param_i_next_wordchar (RDE_PARAM p, int m) + rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void - rde_param_i_next_xdigit (RDE_PARAM p, int m) + rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } @@ -1501,11 +1529,11 @@ rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } @@ -1569,11 +1597,11 @@ if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } @@ -1612,11 +1640,11 @@ rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; @@ -1628,37 +1656,40 @@ if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void - rde_param_i_next_str (RDE_PARAM p, char* str, int m) + rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; + while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { + p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { + p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void - rde_param_i_next_class (RDE_PARAM p, char* class, int m) + rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; @@ -1710,37 +1741,51 @@ /* * Precomputed table of strings (symbols, error messages, etc.). */ - static char const* p_string [26] = { - /* 0 = */ "cl '-+'", - /* 1 = */ "n AddOp", - /* 2 = */ "AddOp", - /* 3 = */ "cl '0123456789'", - /* 4 = */ "n Digit", - /* 5 = */ "Digit", - /* 6 = */ "t \50", - /* 7 = */ "t \51", - /* 8 = */ "n Expression", - /* 9 = */ "Expression", - /* 10 = */ "n Factor", - /* 11 = */ "Factor", - /* 12 = */ "n Function", - /* 13 = */ "Function", - /* 14 = */ "cl '*/'", - /* 15 = */ "n MulOp", - /* 16 = */ "MulOp", - /* 17 = */ "n Number", - /* 18 = */ "Number", - /* 19 = */ "n Sign", - /* 20 = */ "Sign", - /* 21 = */ "str 'sin\50'", - /* 22 = */ "n Sinus", - /* 23 = */ "Sinus", - /* 24 = */ "n Term", - /* 25 = */ "Term" + static char const* p_string [40] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "cl -+", + /* 15 = */ "n AddOp", + /* 16 = */ "AddOp", + /* 17 = */ "cl 0123456789", + /* 18 = */ "n Digit", + /* 19 = */ "Digit", + /* 20 = */ "t (", + /* 21 = */ "t )", + /* 22 = */ "n Expression", + /* 23 = */ "Expression", + /* 24 = */ "n Factor", + /* 25 = */ "Factor", + /* 26 = */ "n Function", + /* 27 = */ "Function", + /* 28 = */ "cl */", + /* 29 = */ "n MulOp", + /* 30 = */ "MulOp", + /* 31 = */ "n Number", + /* 32 = */ "Number", + /* 33 = */ "n Sign", + /* 34 = */ "Sign", + /* 35 = */ "str sin(", + /* 36 = */ "n Sinus", + /* 37 = */ "Sinus", + /* 38 = */ "n Term", + /* 39 = */ "Term" }; /* * Grammar Start Expression */ @@ -1757,13 +1802,13 @@ static void sym_AddOp (RDE_PARAM p) { /* * [-+] */ - if (rde_param_i_symbol_start (p, 2)) return ; - rde_param_i_next_class (p, "-+", 0); - rde_param_i_symbol_done_leaf (p, 2, 1); + if (rde_param_i_symbol_start (p, 16)) return ; + rde_param_i_next_class (p, "-+", 14); + rde_param_i_symbol_done_leaf (p, 16, 15); return; } /* * value Symbol 'Digit' @@ -1772,13 +1817,13 @@ static void sym_Digit (RDE_PARAM p) { /* * [0123456789] */ - if (rde_param_i_symbol_start (p, 5)) return ; - rde_param_i_next_class (p, "0123456789", 3); - rde_param_i_symbol_done_leaf (p, 5, 4); + if (rde_param_i_symbol_start (p, 19)) return ; + rde_param_i_next_class (p, "0123456789", 17); + rde_param_i_symbol_done_leaf (p, 19, 18); return; } /* * value Symbol 'Expression' @@ -1798,13 +1843,13 @@ * x * (MulOp) * (Factor) */ - if (rde_param_i_symbol_start_d (p, 9)) return ; + if (rde_param_i_symbol_start_d (p, 23)) return ; choice_21 (p); - rde_param_i_symbol_done_d_reduce (p, 9, 8); + rde_param_i_symbol_done_d_reduce (p, 23, 22); return; } static void choice_21 (RDE_PARAM p) { /* @@ -1839,15 +1884,15 @@ * (Expression) * '\)' */ rde_param_i_state_push_void (p); - rde_param_i_next_char (p, "\50", 6); + rde_param_i_next_char (p, "(", 20); if (rde_param_i_seq_void2value(p)) return; sym_Expression (p); if (rde_param_i_seq_value2value(p)) return; - rde_param_i_next_char (p, "\51", 7); + rde_param_i_next_char (p, ")", 21); rde_param_i_state_merge_value (p); return; } static void sequence_19 (RDE_PARAM p) { @@ -1911,13 +1956,13 @@ * x * (AddOp) * (Term) */ - if (rde_param_i_symbol_start_d (p, 11)) return ; + if (rde_param_i_symbol_start_d (p, 25)) return ; sequence_31 (p); - rde_param_i_symbol_done_d_reduce (p, 11, 10); + rde_param_i_symbol_done_d_reduce (p, 25, 24); return; } static void sequence_31 (RDE_PARAM p) { /* @@ -1975,13 +2020,13 @@ static void sym_Function (RDE_PARAM p) { /* * (Sinus) */ - if (rde_param_i_symbol_start_d (p, 13)) return ; + if (rde_param_i_symbol_start_d (p, 27)) return ; sym_Sinus (p); - rde_param_i_symbol_done_d_reduce (p, 13, 12); + rde_param_i_symbol_done_d_reduce (p, 27, 26); return; } /* * value Symbol 'MulOp' @@ -1990,13 +2035,13 @@ static void sym_MulOp (RDE_PARAM p) { /* * [\u002a\u002f] */ - if (rde_param_i_symbol_start (p, 16)) return ; - rde_param_i_next_class (p, "*/", 14); - rde_param_i_symbol_done_leaf (p, 16, 15); + if (rde_param_i_symbol_start (p, 30)) return ; + rde_param_i_next_class (p, "*/", 28); + rde_param_i_symbol_done_leaf (p, 30, 29); return; } /* * value Symbol 'Number' @@ -2009,13 +2054,13 @@ * (Sign) * + * (Digit) */ - if (rde_param_i_symbol_start_d (p, 18)) return ; + if (rde_param_i_symbol_start_d (p, 32)) return ; sequence_44 (p); - rde_param_i_symbol_done_d_reduce (p, 18, 17); + rde_param_i_symbol_done_d_reduce (p, 32, 31); return; } static void sequence_44 (RDE_PARAM p) { /* @@ -2070,13 +2115,13 @@ static void sym_Sign (RDE_PARAM p) { /* * [-+] */ - if (rde_param_i_symbol_start (p, 20)) return ; - rde_param_i_next_class (p, "-+", 0); - rde_param_i_symbol_done_leaf (p, 20, 19); + if (rde_param_i_symbol_start (p, 34)) return ; + rde_param_i_next_class (p, "-+", 14); + rde_param_i_symbol_done_leaf (p, 34, 33); return; } /* * value Symbol 'Sinus' @@ -2088,13 +2133,13 @@ * "sin\(" * (Expression) * '\)' */ - if (rde_param_i_symbol_start_d (p, 23)) return ; + if (rde_param_i_symbol_start_d (p, 37)) return ; sequence_52 (p); - rde_param_i_symbol_done_d_reduce (p, 23, 22); + rde_param_i_symbol_done_d_reduce (p, 37, 36); return; } static void sequence_52 (RDE_PARAM p) { /* @@ -2103,15 +2148,15 @@ * (Expression) * '\)' */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "sin\50", 21); + rde_param_i_next_str (p, "sin(", 35); if (rde_param_i_seq_void2value(p)) return; sym_Expression (p); if (rde_param_i_seq_value2value(p)) return; - rde_param_i_next_char (p, "\51", 7); + rde_param_i_next_char (p, ")", 21); rde_param_i_state_merge_value (p); return; } /* @@ -2121,13 +2166,13 @@ static void sym_Term (RDE_PARAM p) { /* * (Number) */ - if (rde_param_i_symbol_start_d (p, 25)) return ; + if (rde_param_i_symbol_start_d (p, 39)) return ; sym_Number (p); - rde_param_i_symbol_done_d_reduce (p, 25, 24); + rde_param_i_symbol_done_d_reduce (p, 39, 38); return; } } @@ -2167,11 +2212,11 @@ Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; - sprintf (parserg->buf, "PARSER%d", parserg->counter); + sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void @@ -2230,45 +2275,52 @@ rde_param_data (p, buf, len); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } + /* See also rde_critcl/m.c, param_COMPLETE() */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) { if (rde_param_query_st (p)) { long int ac; Tcl_Obj** av; rde_param_query_ast (p, &ac, &av); if (ac > 1) { - long int lsc; - long int* lsv; Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); - rde_param_query_ls (p, &lsc, &lsv); - memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); lv [0] = Tcl_NewObj (); - lv [1] = Tcl_NewIntObj (1 + lsv [lsc-1]); + lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); ckfree ((char*) lv); + + } else if (ac == 0) { + /* + * Match, but no AST. This is possible if the grammar + * consists of only the start expression. + */ + Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); } else { Tcl_SetObjResult (interp, av [0]); } return TCL_OK; } else { Tcl_Obj* xv [1]; const ERROR_STATE* er = rde_param_query_er (p); Tcl_Obj* res = rde_param_query_er_tcl (p, er); + /* res = list (location, list(msg)) */ + /* Stick the exception type-tag before the existing elements */ xv [0] = Tcl_NewStringObj ("pt::rde",-1); - Tcl_ListObjReplace(interp, res, 0, 1, 1, xv); + Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); + Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); Tcl_SetObjResult (interp, res); return TCL_ERROR; } } } Index: modules/pt/tests/data/ok/peg_cparam-critcl/3_peg_itself ================================================================== --- modules/pt/tests/data/ok/peg_cparam-critcl/3_peg_itself +++ modules/pt/tests/data/ok/peg_cparam-critcl/3_peg_itself @@ -28,11 +28,11 @@ namespace eval ::PARSER { # # ## ### ##### ######## ############# ##################### ## Supporting code for the main command. catch { - #critcl::cheaders -g + #critcl::cflags -g #critcl::debug memory symbols } # # ## ### ###### ######## ############# ## RDE runtime, inlined, and made static. @@ -384,10 +384,14 @@ int clen; Tcl_UniChar uni; if (len < 0) { len = strlen (string); } + + if (!len) { + return tc->str + base; + } if ((tc->num + len) >= tc->max) { int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); char* str = ckrealloc (tc->str, new * sizeof(char)); ASSERT (str,"Memory allocation failure for token character array"); @@ -413,18 +417,18 @@ } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; - long int* ov; - rde_stack_get (tc->off, &oc, (void***) &ov); + void** ov; + rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); - off = ov [at]; + off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { - end = ov [at+1]; + end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; @@ -432,19 +436,19 @@ } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; - long int* ov; - rde_stack_get (tc->off, &oc, (void***) &ov); + void** ov; + rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); - off = ov [at]; + off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { - end = ov [last+1]; + end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; @@ -479,10 +483,11 @@ typedef int (*UniCharClass) (int); typedef enum test_class_id { tc_alnum, tc_alpha, tc_ascii, + tc_control, tc_ddigit, tc_digit, tc_graph, tc_lower, tc_printable, @@ -492,11 +497,11 @@ tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); - static void error_set (RDE_PARAM p, int s); + static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); @@ -645,13 +650,13 @@ rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void - rde_param_query_amark (RDE_PARAM p, long int* mc, long int** mv) + rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { - rde_stack_get (p->mark, mc, (void***) mv); + rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); @@ -688,25 +693,25 @@ res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; - long int* mv; + void** mv; int lastid; const char* msg; - rde_stack_get (er->msg, &mc, (void***) &mv); + rde_stack_get (er->msg, &mc, &mv); - qsort (mv, mc, sizeof (long int), er_int_compare); + qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); - if (mv [i] == lastid) continue; - lastid = mv [i]; - ASSERT_BOUNDS(mv[i],p->numstr); - msg = p->string [mv[i]]; + if (((long int) mv [i]) == lastid) continue; + lastid = (long int) mv [i]; + ASSERT_BOUNDS((long int) mv[i],p->numstr); + msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } @@ -721,13 +726,18 @@ rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) { rde_stack_get (p->ES, ec, (void***) ev); } SCOPE void - rde_param_query_ls (RDE_PARAM p, long int* lc, long int** lv) + rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) { - rde_stack_get (p->LS, lc, (void***) lv); + rde_stack_get (p->LS, lc, lv); + } + SCOPE long int + rde_param_query_lstop (RDE_PARAM p) + { + (long int) rde_stack_top (p->LS); } SCOPE Tcl_HashTable* rde_param_query_nc (RDE_PARAM p) { return &p->NC; @@ -770,11 +780,11 @@ { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; @@ -783,11 +793,11 @@ rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; @@ -818,12 +828,14 @@ rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void - rde_param_i_error_nonterminal (RDE_PARAM p, int s) + rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { + + return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; error_set (p, s); @@ -872,11 +884,11 @@ { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void - error_set (RDE_PARAM p, int s) + error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; @@ -914,20 +926,21 @@ rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void - rde_param_i_input_next (RDE_PARAM p, int m) + rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); - ASSERT_BOUNDS (p->CC_len, TCL_UTF_MAX); + + ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || @@ -960,11 +973,11 @@ rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int - rde_param_i_symbol_restore (RDE_PARAM p, int s) + rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; @@ -983,11 +996,11 @@ TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void - rde_param_i_symbol_save (RDE_PARAM p, int s) + rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; @@ -1049,11 +1062,16 @@ rde_param_i_test_ascii (RDE_PARAM p) { test_class (p, UniCharIsAscii, tc_ascii); } SCOPE void - rde_param_i_test_char (RDE_PARAM p, char* c, int msg) + rde_param_i_test_control (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsControl, tc_control); + } + SCOPE void + rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); @@ -1091,11 +1109,11 @@ rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void - rde_param_i_test_range (RDE_PARAM p, char* s, char* e, int msg) + rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); @@ -1160,11 +1178,11 @@ rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void - rde_param_i_value_leaf (RDE_PARAM p, int s) + rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); @@ -1174,11 +1192,11 @@ newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void - rde_param_i_value_reduce (RDE_PARAM p, int s) + rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; @@ -1206,18 +1224,21 @@ ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { - long int ai = *((long int*) a); - long int bi = *((long int*) b); - if (ai < bi) { return -1; } - if (ai > bi) { return 1; } + + const void** ael = (const void**) a; + const void** bel = (const void**) b; + long int avalue = (long int) *ael; + long int bvalue = (long int) *bel; + if (avalue < bvalue) { return -1; } + if (avalue > bvalue) { return 1; } return 0; } SCOPE int - rde_param_i_symbol_start (RDE_PARAM p, int s) + rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); @@ -1226,11 +1247,11 @@ } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int - rde_param_i_symbol_start_d (RDE_PARAM p, int s) + rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); @@ -1240,26 +1261,26 @@ rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int - rde_param_i_symbol_void_start (RDE_PARAM p, int s) + rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int - rde_param_i_symbol_void_start_d (RDE_PARAM p, int s) + rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void - rde_param_i_symbol_done_d_reduce (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); @@ -1272,11 +1293,11 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_leaf (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); @@ -1288,11 +1309,11 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_d_leaf (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); @@ -1305,126 +1326,133 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_void (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void - rde_param_i_symbol_done_d_void (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void - rde_param_i_next_char (RDE_PARAM p, char* c, int m) + rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void - rde_param_i_next_range (RDE_PARAM p, char* s, char* e, int m) + rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void - rde_param_i_next_alnum (RDE_PARAM p, int m) + rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void - rde_param_i_next_alpha (RDE_PARAM p, int m) + rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void - rde_param_i_next_ascii (RDE_PARAM p, int m) + rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void - rde_param_i_next_ddigit (RDE_PARAM p, int m) + rde_param_i_next_control (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_control (p); + } + SCOPE void + rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void - rde_param_i_next_digit (RDE_PARAM p, int m) + rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void - rde_param_i_next_graph (RDE_PARAM p, int m) + rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void - rde_param_i_next_lower (RDE_PARAM p, int m) + rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void - rde_param_i_next_print (RDE_PARAM p, int m) + rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void - rde_param_i_next_punct (RDE_PARAM p, int m) + rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void - rde_param_i_next_space (RDE_PARAM p, int m) + rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void - rde_param_i_next_upper (RDE_PARAM p, int m) + rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void - rde_param_i_next_wordchar (RDE_PARAM p, int m) + rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void - rde_param_i_next_xdigit (RDE_PARAM p, int m) + rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } @@ -1501,11 +1529,11 @@ rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } @@ -1569,11 +1597,11 @@ if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } @@ -1612,11 +1640,11 @@ rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; @@ -1628,37 +1656,40 @@ if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void - rde_param_i_next_str (RDE_PARAM p, char* str, int m) + rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; + while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { + p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { + p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void - rde_param_i_next_class (RDE_PARAM p, char* class, int m) + rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; @@ -1741,279 +1772,286 @@ static void sym_Definition (RDE_PARAM p); static void sequence_148 (RDE_PARAM p); static void sym_DIGIT (RDE_PARAM p); static void sequence_153 (RDE_PARAM p); static void sym_DOT (RDE_PARAM p); - static void sequence_158 (RDE_PARAM p); - static void sym_END (RDE_PARAM p); - static void notahead_162 (RDE_PARAM p); + static void notahead_157 (RDE_PARAM p); static void sym_EOF (RDE_PARAM p); static void sym_EOL (RDE_PARAM p); - static void sequence_170 (RDE_PARAM p); - static void kleene_172 (RDE_PARAM p); - static void sequence_174 (RDE_PARAM p); + static void sequence_165 (RDE_PARAM p); + static void kleene_167 (RDE_PARAM p); + static void sequence_169 (RDE_PARAM p); static void sym_Expression (RDE_PARAM p); - static void sequence_180 (RDE_PARAM p); + static void sequence_176 (RDE_PARAM p); static void sym_Final (RDE_PARAM p); - static void kleene_186 (RDE_PARAM p); - static void sequence_190 (RDE_PARAM p); + static void kleene_182 (RDE_PARAM p); + static void sequence_186 (RDE_PARAM p); static void sym_Grammar (RDE_PARAM p); - static void sequence_195 (RDE_PARAM p); + static void sequence_191 (RDE_PARAM p); static void sym_GRAPH (RDE_PARAM p); - static void sequence_201 (RDE_PARAM p); + static void sequence_197 (RDE_PARAM p); static void sym_Header (RDE_PARAM p); + static void choice_202 (RDE_PARAM p); static void choice_206 (RDE_PARAM p); - static void choice_210 (RDE_PARAM p); - static void kleene_212 (RDE_PARAM p); - static void sequence_214 (RDE_PARAM p); + static void kleene_208 (RDE_PARAM p); + static void sequence_210 (RDE_PARAM p); static void sym_Ident (RDE_PARAM p); - static void sequence_219 (RDE_PARAM p); + static void sequence_215 (RDE_PARAM p); static void sym_Identifier (RDE_PARAM p); - static void sequence_224 (RDE_PARAM p); + static void sequence_220 (RDE_PARAM p); static void sym_IS (RDE_PARAM p); - static void sequence_229 (RDE_PARAM p); + static void sequence_225 (RDE_PARAM p); static void sym_LEAF (RDE_PARAM p); - static void notahead_234 (RDE_PARAM p); - static void sequence_237 (RDE_PARAM p); - static void kleene_239 (RDE_PARAM p); - static void sequence_243 (RDE_PARAM p); - static void notahead_247 (RDE_PARAM p); - static void sequence_250 (RDE_PARAM p); - static void kleene_252 (RDE_PARAM p); - static void sequence_256 (RDE_PARAM p); - static void choice_258 (RDE_PARAM p); + static void notahead_230 (RDE_PARAM p); + static void sequence_233 (RDE_PARAM p); + static void kleene_235 (RDE_PARAM p); + static void sequence_239 (RDE_PARAM p); + static void notahead_243 (RDE_PARAM p); + static void sequence_246 (RDE_PARAM p); + static void kleene_248 (RDE_PARAM p); + static void sequence_252 (RDE_PARAM p); + static void choice_254 (RDE_PARAM p); static void sym_Literal (RDE_PARAM p); - static void sequence_263 (RDE_PARAM p); + static void sequence_259 (RDE_PARAM p); static void sym_LOWER (RDE_PARAM p); - static void sequence_268 (RDE_PARAM p); + static void sequence_264 (RDE_PARAM p); static void sym_NOT (RDE_PARAM p); - static void sequence_273 (RDE_PARAM p); + static void sequence_269 (RDE_PARAM p); static void sym_OPEN (RDE_PARAM p); static void sym_OPENB (RDE_PARAM p); - static void sequence_280 (RDE_PARAM p); + static void notahead_278 (RDE_PARAM p); + static void sequence_281 (RDE_PARAM p); static void sym_PEG (RDE_PARAM p); - static void sequence_285 (RDE_PARAM p); + static void sequence_286 (RDE_PARAM p); static void sym_PLUS (RDE_PARAM p); - static void choice_290 (RDE_PARAM p); - static void optional_292 (RDE_PARAM p); - static void sequence_295 (RDE_PARAM p); + static void choice_291 (RDE_PARAM p); + static void optional_293 (RDE_PARAM p); + static void sequence_296 (RDE_PARAM p); static void sym_Prefix (RDE_PARAM p); - static void sequence_316 (RDE_PARAM p); - static void choice_321 (RDE_PARAM p); + static void sequence_317 (RDE_PARAM p); + static void choice_322 (RDE_PARAM p); static void sym_Primary (RDE_PARAM p); - static void sequence_326 (RDE_PARAM p); + static void sequence_327 (RDE_PARAM p); static void sym_PRINTABLE (RDE_PARAM p); - static void sequence_331 (RDE_PARAM p); + static void sequence_332 (RDE_PARAM p); static void sym_PUNCT (RDE_PARAM p); - static void sequence_336 (RDE_PARAM p); + static void sequence_337 (RDE_PARAM p); static void sym_QUESTION (RDE_PARAM p); - static void sequence_342 (RDE_PARAM p); - static void choice_345 (RDE_PARAM p); + static void sequence_343 (RDE_PARAM p); + static void choice_346 (RDE_PARAM p); static void sym_Range (RDE_PARAM p); - static void sequence_350 (RDE_PARAM p); + static void sequence_351 (RDE_PARAM p); static void sym_SEMICOLON (RDE_PARAM p); - static void poskleene_354 (RDE_PARAM p); + static void poskleene_355 (RDE_PARAM p); static void sym_Sequence (RDE_PARAM p); - static void sequence_359 (RDE_PARAM p); + static void sequence_360 (RDE_PARAM p); static void sym_SLASH (RDE_PARAM p); - static void sequence_364 (RDE_PARAM p); + static void sequence_365 (RDE_PARAM p); static void sym_SPACE (RDE_PARAM p); - static void sequence_369 (RDE_PARAM p); + static void sequence_370 (RDE_PARAM p); static void sym_STAR (RDE_PARAM p); static void sym_StartExpr (RDE_PARAM p); - static void choice_381 (RDE_PARAM p); - static void optional_383 (RDE_PARAM p); - static void sequence_385 (RDE_PARAM p); + static void choice_382 (RDE_PARAM p); + static void optional_384 (RDE_PARAM p); + static void sequence_386 (RDE_PARAM p); static void sym_Suffix (RDE_PARAM p); static void sym_TO (RDE_PARAM p); - static void sequence_392 (RDE_PARAM p); + static void sequence_393 (RDE_PARAM p); static void sym_UPPER (RDE_PARAM p); - static void sequence_397 (RDE_PARAM p); + static void sequence_398 (RDE_PARAM p); static void sym_VOID (RDE_PARAM p); - static void choice_402 (RDE_PARAM p); - static void kleene_404 (RDE_PARAM p); + static void choice_403 (RDE_PARAM p); + static void kleene_405 (RDE_PARAM p); static void sym_WHITESPACE (RDE_PARAM p); - static void sequence_409 (RDE_PARAM p); + static void sequence_410 (RDE_PARAM p); static void sym_WORDCHAR (RDE_PARAM p); - static void sequence_414 (RDE_PARAM p); + static void sequence_415 (RDE_PARAM p); static void sym_XDIGIT (RDE_PARAM p); /* * Precomputed table of strings (symbols, error messages, etc.). */ - static char const* p_string [170] = { - /* 0 = */ "str ''", - /* 1 = */ "n ALNUM", - /* 2 = */ "ALNUM", - /* 3 = */ "str ''", - /* 4 = */ "n ALPHA", - /* 5 = */ "ALPHA", - /* 6 = */ "t &", - /* 7 = */ "n AND", - /* 8 = */ "AND", - /* 9 = */ "t '", - /* 10 = */ "n APOSTROPH", - /* 11 = */ "APOSTROPH", - /* 12 = */ "str ''", - /* 13 = */ "n ASCII", - /* 14 = */ "ASCII", - /* 15 = */ "n Attribute", - /* 16 = */ "Attribute", - /* 17 = */ "n Char", - /* 18 = */ "Char", - /* 19 = */ "t \134", - /* 20 = */ ".. 0 2", - /* 21 = */ ".. 0 7", - /* 22 = */ "n CharOctalFull", - /* 23 = */ "CharOctalFull", - /* 24 = */ "n CharOctalPart", - /* 25 = */ "CharOctalPart", - /* 26 = */ "cl 'nrt'\42\133\135\134'", - /* 27 = */ "n CharSpecial", - /* 28 = */ "CharSpecial", - /* 29 = */ "dot", - /* 30 = */ "n CharUnescaped", - /* 31 = */ "CharUnescaped", - /* 32 = */ "str '\134u'", - /* 33 = */ "xdigit", - /* 34 = */ "n CharUnicode", - /* 35 = */ "CharUnicode", - /* 36 = */ "n Class", - /* 37 = */ "Class", - /* 38 = */ "t \51", - /* 39 = */ "n CLOSE", - /* 40 = */ "CLOSE", - /* 41 = */ "t \135", - /* 42 = */ "n CLOSEB", - /* 43 = */ "CLOSEB", - /* 44 = */ "t :", - /* 45 = */ "n COLON", - /* 46 = */ "COLON", - /* 47 = */ "t #", - /* 48 = */ "n COMMENT", - /* 49 = */ "COMMENT", - /* 50 = */ "str ''", - /* 51 = */ "n CONTROL", - /* 52 = */ "CONTROL", - /* 53 = */ "t \42", - /* 54 = */ "n DAPOSTROPH", - /* 55 = */ "DAPOSTROPH", - /* 56 = */ "str ''", - /* 57 = */ "n DDIGIT", - /* 58 = */ "DDIGIT", - /* 59 = */ "n Definition", - /* 60 = */ "Definition", - /* 61 = */ "str ''", - /* 62 = */ "n DIGIT", - /* 63 = */ "DIGIT", - /* 64 = */ "t .", - /* 65 = */ "n DOT", - /* 66 = */ "DOT", - /* 67 = */ "str 'END'", - /* 68 = */ "n END", - /* 69 = */ "END", - /* 70 = */ "n EOF", - /* 71 = */ "EOF", - /* 72 = */ "cl '\n\r'", - /* 73 = */ "n EOL", - /* 74 = */ "EOL", - /* 75 = */ "n Expression", - /* 76 = */ "Expression", - /* 77 = */ "n Final", - /* 78 = */ "Final", - /* 79 = */ "n Grammar", - /* 80 = */ "Grammar", - /* 81 = */ "str ''", - /* 82 = */ "n GRAPH", - /* 83 = */ "GRAPH", - /* 84 = */ "n Header", - /* 85 = */ "Header", - /* 86 = */ "cl '_:'", - /* 87 = */ "alpha", - /* 88 = */ "alnum", - /* 89 = */ "n Ident", - /* 90 = */ "Ident", - /* 91 = */ "n Identifier", - /* 92 = */ "Identifier", - /* 93 = */ "str '<-'", - /* 94 = */ "n IS", - /* 95 = */ "IS", - /* 96 = */ "str 'leaf'", - /* 97 = */ "n LEAF", - /* 98 = */ "LEAF", - /* 99 = */ "n Literal", - /* 100 = */ "Literal", - /* 101 = */ "str ''", - /* 102 = */ "n LOWER", - /* 103 = */ "LOWER", - /* 104 = */ "t !", - /* 105 = */ "n NOT", - /* 106 = */ "NOT", - /* 107 = */ "t \50", - /* 108 = */ "n OPEN", - /* 109 = */ "OPEN", - /* 110 = */ "t \133", - /* 111 = */ "n OPENB", - /* 112 = */ "OPENB", - /* 113 = */ "str 'PEG'", - /* 114 = */ "n PEG", - /* 115 = */ "PEG", - /* 116 = */ "t +", - /* 117 = */ "n PLUS", - /* 118 = */ "PLUS", - /* 119 = */ "n Prefix", - /* 120 = */ "Prefix", - /* 121 = */ "n Primary", - /* 122 = */ "Primary", - /* 123 = */ "str ''", - /* 124 = */ "n PRINTABLE", - /* 125 = */ "PRINTABLE", - /* 126 = */ "str ''", - /* 127 = */ "n PUNCT", - /* 128 = */ "PUNCT", - /* 129 = */ "t ?", - /* 130 = */ "n QUESTION", - /* 131 = */ "QUESTION", - /* 132 = */ "n Range", - /* 133 = */ "Range", - /* 134 = */ "t \73", - /* 135 = */ "n SEMICOLON", - /* 136 = */ "SEMICOLON", - /* 137 = */ "n Sequence", - /* 138 = */ "Sequence", - /* 139 = */ "t /", - /* 140 = */ "n SLASH", - /* 141 = */ "SLASH", - /* 142 = */ "str ''", - /* 143 = */ "n SPACE", - /* 144 = */ "SPACE", - /* 145 = */ "t *", - /* 146 = */ "n STAR", - /* 147 = */ "STAR", - /* 148 = */ "n StartExpr", - /* 149 = */ "StartExpr", - /* 150 = */ "n Suffix", - /* 151 = */ "Suffix", - /* 152 = */ "t -", - /* 153 = */ "n TO", - /* 154 = */ "TO", - /* 155 = */ "str ''", - /* 156 = */ "n UPPER", - /* 157 = */ "UPPER", - /* 158 = */ "str 'void'", - /* 159 = */ "n VOID", - /* 160 = */ "VOID", - /* 161 = */ "space", - /* 162 = */ "n WHITESPACE", - /* 163 = */ "WHITESPACE", - /* 164 = */ "str ''", - /* 165 = */ "n WORDCHAR", - /* 166 = */ "WORDCHAR", - /* 167 = */ "str ''", - /* 168 = */ "n XDIGIT", - /* 169 = */ "XDIGIT" + static char const* p_string [178] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "str ", + /* 15 = */ "n ALNUM", + /* 16 = */ "ALNUM", + /* 17 = */ "str ", + /* 18 = */ "n ALPHA", + /* 19 = */ "ALPHA", + /* 20 = */ "t &", + /* 21 = */ "n AND", + /* 22 = */ "AND", + /* 23 = */ "t '", + /* 24 = */ "n APOSTROPH", + /* 25 = */ "APOSTROPH", + /* 26 = */ "str ", + /* 27 = */ "n ASCII", + /* 28 = */ "ASCII", + /* 29 = */ "n Attribute", + /* 30 = */ "Attribute", + /* 31 = */ "n Char", + /* 32 = */ "Char", + /* 33 = */ "t \\\\", + /* 34 = */ ".. 0 2", + /* 35 = */ ".. 0 7", + /* 36 = */ "n CharOctalFull", + /* 37 = */ "CharOctalFull", + /* 38 = */ "n CharOctalPart", + /* 39 = */ "CharOctalPart", + /* 40 = */ "cl nrt'\\\"\\[\\]\\\\", + /* 41 = */ "n CharSpecial", + /* 42 = */ "CharSpecial", + /* 43 = */ "dot", + /* 44 = */ "n CharUnescaped", + /* 45 = */ "CharUnescaped", + /* 46 = */ "str \173\\u\175", + /* 47 = */ "n CharUnicode", + /* 48 = */ "CharUnicode", + /* 49 = */ "n Class", + /* 50 = */ "Class", + /* 51 = */ "t )", + /* 52 = */ "n CLOSE", + /* 53 = */ "CLOSE", + /* 54 = */ "t \\]", + /* 55 = */ "n CLOSEB", + /* 56 = */ "CLOSEB", + /* 57 = */ "t :", + /* 58 = */ "n COLON", + /* 59 = */ "COLON", + /* 60 = */ "t #", + /* 61 = */ "n COMMENT", + /* 62 = */ "COMMENT", + /* 63 = */ "str ", + /* 64 = */ "n CONTROL", + /* 65 = */ "CONTROL", + /* 66 = */ "t \173\"\175", + /* 67 = */ "n DAPOSTROPH", + /* 68 = */ "DAPOSTROPH", + /* 69 = */ "str ", + /* 70 = */ "n DDIGIT", + /* 71 = */ "DDIGIT", + /* 72 = */ "n Definition", + /* 73 = */ "Definition", + /* 74 = */ "str ", + /* 75 = */ "n DIGIT", + /* 76 = */ "DIGIT", + /* 77 = */ "t .", + /* 78 = */ "n DOT", + /* 79 = */ "DOT", + /* 80 = */ "n EOF", + /* 81 = */ "EOF", + /* 82 = */ "cl \173\n\r\175", + /* 83 = */ "n EOL", + /* 84 = */ "EOL", + /* 85 = */ "n Expression", + /* 86 = */ "Expression", + /* 87 = */ "str END", + /* 88 = */ "n Final", + /* 89 = */ "Final", + /* 90 = */ "n Grammar", + /* 91 = */ "Grammar", + /* 92 = */ "str ", + /* 93 = */ "n GRAPH", + /* 94 = */ "GRAPH", + /* 95 = */ "n Header", + /* 96 = */ "Header", + /* 97 = */ "cl _:", + /* 98 = */ "n Ident", + /* 99 = */ "Ident", + /* 100 = */ "n Identifier", + /* 101 = */ "Identifier", + /* 102 = */ "str <-", + /* 103 = */ "n IS", + /* 104 = */ "IS", + /* 105 = */ "str leaf", + /* 106 = */ "n LEAF", + /* 107 = */ "LEAF", + /* 108 = */ "n Literal", + /* 109 = */ "Literal", + /* 110 = */ "str ", + /* 111 = */ "n LOWER", + /* 112 = */ "LOWER", + /* 113 = */ "t !", + /* 114 = */ "n NOT", + /* 115 = */ "NOT", + /* 116 = */ "t (", + /* 117 = */ "n OPEN", + /* 118 = */ "OPEN", + /* 119 = */ "t \173[\175", + /* 120 = */ "n OPENB", + /* 121 = */ "OPENB", + /* 122 = */ "str PEG", + /* 123 = */ "n PEG", + /* 124 = */ "PEG", + /* 125 = */ "t +", + /* 126 = */ "n PLUS", + /* 127 = */ "PLUS", + /* 128 = */ "n Prefix", + /* 129 = */ "Prefix", + /* 130 = */ "n Primary", + /* 131 = */ "Primary", + /* 132 = */ "str ", + /* 133 = */ "n PRINTABLE", + /* 134 = */ "PRINTABLE", + /* 135 = */ "str ", + /* 136 = */ "n PUNCT", + /* 137 = */ "PUNCT", + /* 138 = */ "t ?", + /* 139 = */ "n QUESTION", + /* 140 = */ "QUESTION", + /* 141 = */ "n Range", + /* 142 = */ "Range", + /* 143 = */ "t \173;\175", + /* 144 = */ "n SEMICOLON", + /* 145 = */ "SEMICOLON", + /* 146 = */ "n Sequence", + /* 147 = */ "Sequence", + /* 148 = */ "t /", + /* 149 = */ "n SLASH", + /* 150 = */ "SLASH", + /* 151 = */ "str ", + /* 152 = */ "n SPACE", + /* 153 = */ "SPACE", + /* 154 = */ "t *", + /* 155 = */ "n STAR", + /* 156 = */ "STAR", + /* 157 = */ "n StartExpr", + /* 158 = */ "StartExpr", + /* 159 = */ "n Suffix", + /* 160 = */ "Suffix", + /* 161 = */ "t -", + /* 162 = */ "n TO", + /* 163 = */ "TO", + /* 164 = */ "str ", + /* 165 = */ "n UPPER", + /* 166 = */ "UPPER", + /* 167 = */ "str void", + /* 168 = */ "n VOID", + /* 169 = */ "VOID", + /* 170 = */ "n WHITESPACE", + /* 171 = */ "WHITESPACE", + /* 172 = */ "str ", + /* 173 = */ "n WORDCHAR", + /* 174 = */ "WORDCHAR", + /* 175 = */ "str ", + /* 176 = */ "n XDIGIT", + /* 177 = */ "XDIGIT" }; /* * Grammar Start Expression */ @@ -2032,13 +2070,13 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 2)) return ; + if (rde_param_i_symbol_start (p, 16)) return ; sequence_4 (p); - rde_param_i_symbol_done_leaf (p, 2, 1); + rde_param_i_symbol_done_leaf (p, 16, 15); return; } static void sequence_4 (RDE_PARAM p) { /* @@ -2046,11 +2084,11 @@ * "" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "", 0); + rde_param_i_next_str (p, "", 14); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -2064,13 +2102,13 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 5)) return ; + if (rde_param_i_symbol_start (p, 19)) return ; sequence_9 (p); - rde_param_i_symbol_done_leaf (p, 5, 4); + rde_param_i_symbol_done_leaf (p, 19, 18); return; } static void sequence_9 (RDE_PARAM p) { /* @@ -2078,11 +2116,11 @@ * "" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "", 3); + rde_param_i_next_str (p, "", 17); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -2096,13 +2134,13 @@ * x * '&' * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 8)) return ; + if (rde_param_i_symbol_start (p, 22)) return ; sequence_14 (p); - rde_param_i_symbol_done_leaf (p, 8, 7); + rde_param_i_symbol_done_leaf (p, 22, 21); return; } static void sequence_14 (RDE_PARAM p) { /* @@ -2110,11 +2148,11 @@ * '&' * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_char (p, "&", 6); + rde_param_i_next_char (p, "&", 20); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -2126,13 +2164,13 @@ static void sym_APOSTROPH (RDE_PARAM p) { /* * ''' */ - if (rde_param_i_symbol_void_start (p, 11)) return ; - rde_param_i_next_char (p, "'", 9); - rde_param_i_symbol_done_void (p, 11, 10); + if (rde_param_i_symbol_void_start (p, 25)) return ; + rde_param_i_next_char (p, "'", 23); + rde_param_i_symbol_done_void (p, 25, 24); return; } /* * leaf Symbol 'ASCII' @@ -2143,13 +2181,13 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 14)) return ; + if (rde_param_i_symbol_start (p, 28)) return ; sequence_21 (p); - rde_param_i_symbol_done_leaf (p, 14, 13); + rde_param_i_symbol_done_leaf (p, 28, 27); return; } static void sequence_21 (RDE_PARAM p) { /* @@ -2157,11 +2195,11 @@ * "" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "", 12); + rde_param_i_next_str (p, "", 26); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -2177,13 +2215,13 @@ * (VOID) * (LEAF) * (COLON) */ - if (rde_param_i_symbol_start_d (p, 16)) return ; + if (rde_param_i_symbol_start_d (p, 30)) return ; sequence_29 (p); - rde_param_i_symbol_done_d_reduce (p, 16, 15); + rde_param_i_symbol_done_d_reduce (p, 30, 29); return; } static void sequence_29 (RDE_PARAM p) { /* @@ -2229,13 +2267,13 @@ * (CharOctalPart) * (CharUnicode) * (CharUnescaped) */ - if (rde_param_i_symbol_start_d (p, 18)) return ; + if (rde_param_i_symbol_start_d (p, 32)) return ; choice_37 (p); - rde_param_i_symbol_done_d_reduce (p, 18, 17); + rde_param_i_symbol_done_d_reduce (p, 32, 31); return; } static void choice_37 (RDE_PARAM p) { /* @@ -2272,13 +2310,13 @@ * range (0 .. 2) * range (0 .. 7) * range (0 .. 7) */ - if (rde_param_i_symbol_start (p, 23)) return ; + if (rde_param_i_symbol_start (p, 37)) return ; sequence_44 (p); - rde_param_i_symbol_done_leaf (p, 23, 22); + rde_param_i_symbol_done_leaf (p, 37, 36); return; } static void sequence_44 (RDE_PARAM p) { /* @@ -2288,17 +2326,17 @@ * range (0 .. 7) * range (0 .. 7) */ rde_param_i_state_push_void (p); - rde_param_i_next_char (p, "\134", 19); + rde_param_i_next_char (p, "\\", 33); + if (rde_param_i_seq_void2void(p)) return; + rde_param_i_next_range (p, "0", "2", 34); if (rde_param_i_seq_void2void(p)) return; - rde_param_i_next_range (p, "0", "2", 20); + rde_param_i_next_range (p, "0", "7", 35); if (rde_param_i_seq_void2void(p)) return; - rde_param_i_next_range (p, "0", "7", 21); - if (rde_param_i_seq_void2void(p)) return; - rde_param_i_next_range (p, "0", "7", 21); + rde_param_i_next_range (p, "0", "7", 35); rde_param_i_state_merge_void (p); return; } /* @@ -2312,13 +2350,13 @@ * range (0 .. 7) * ? * range (0 .. 7) */ - if (rde_param_i_symbol_start (p, 25)) return ; + if (rde_param_i_symbol_start (p, 39)) return ; sequence_52 (p); - rde_param_i_symbol_done_leaf (p, 25, 24); + rde_param_i_symbol_done_leaf (p, 39, 38); return; } static void sequence_52 (RDE_PARAM p) { /* @@ -2328,13 +2366,13 @@ * ? * range (0 .. 7) */ rde_param_i_state_push_void (p); - rde_param_i_next_char (p, "\134", 19); + rde_param_i_next_char (p, "\\", 33); if (rde_param_i_seq_void2void(p)) return; - rde_param_i_next_range (p, "0", "7", 21); + rde_param_i_next_range (p, "0", "7", 35); if (rde_param_i_seq_void2void(p)) return; optional_50 (p); rde_param_i_state_merge_void (p); return; } @@ -2344,11 +2382,11 @@ * ? * range (0 .. 7) */ rde_param_i_state_push_2 (p); - rde_param_i_next_range (p, "0", "7", 21); + rde_param_i_next_range (p, "0", "7", 35); rde_param_i_state_merge_ok (p); return; } /* @@ -2360,13 +2398,13 @@ * x * '\' * [nrt'\"[]\] */ - if (rde_param_i_symbol_start (p, 28)) return ; + if (rde_param_i_symbol_start (p, 42)) return ; sequence_57 (p); - rde_param_i_symbol_done_leaf (p, 28, 27); + rde_param_i_symbol_done_leaf (p, 42, 41); return; } static void sequence_57 (RDE_PARAM p) { /* @@ -2374,13 +2412,13 @@ * '\' * [nrt'\"[]\] */ rde_param_i_state_push_void (p); - rde_param_i_next_char (p, "\134", 19); + rde_param_i_next_char (p, "\\", 33); if (rde_param_i_seq_void2void(p)) return; - rde_param_i_next_class (p, "nrt'\42\133\135\134", 26); + rde_param_i_next_class (p, "nrt'\"[]\\", 40); rde_param_i_state_merge_void (p); return; } /* @@ -2393,13 +2431,13 @@ * ! * '\' * */ - if (rde_param_i_symbol_start (p, 31)) return ; + if (rde_param_i_symbol_start (p, 45)) return ; sequence_64 (p); - rde_param_i_symbol_done_leaf (p, 31, 30); + rde_param_i_symbol_done_leaf (p, 45, 44); return; } static void sequence_64 (RDE_PARAM p) { /* @@ -2410,11 +2448,11 @@ */ rde_param_i_state_push_void (p); notahead_61 (p); if (rde_param_i_seq_void2void(p)) return; - rde_param_i_input_next (p, 29); + rde_param_i_input_next (p, 43); rde_param_i_state_merge_void (p); return; } static void notahead_61 (RDE_PARAM p) { @@ -2422,11 +2460,11 @@ * ! * '\' */ rde_param_i_loc_push (p); - rde_param_i_next_char (p, "\134", 19); + rde_param_i_next_char (p, "\\", 33); rde_param_i_notahead_exit (p); return; } /* @@ -2446,13 +2484,13 @@ * * ? * */ - if (rde_param_i_symbol_start (p, 35)) return ; + if (rde_param_i_symbol_start (p, 48)) return ; sequence_82 (p); - rde_param_i_symbol_done_leaf (p, 35, 34); + rde_param_i_symbol_done_leaf (p, 48, 47); return; } static void sequence_82 (RDE_PARAM p) { /* @@ -2468,13 +2506,13 @@ * ? * */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "\134u", 32); + rde_param_i_next_str (p, "\\u", 46); if (rde_param_i_seq_void2void(p)) return; - rde_param_i_next_xdigit (p, 33); + rde_param_i_next_xdigit (p, 13); if (rde_param_i_seq_void2void(p)) return; optional_80 (p); rde_param_i_state_merge_void (p); return; } @@ -2507,11 +2545,11 @@ * ? * */ rde_param_i_state_push_void (p); - rde_param_i_next_xdigit (p, 33); + rde_param_i_next_xdigit (p, 13); if (rde_param_i_seq_void2void(p)) return; optional_76 (p); rde_param_i_state_merge_void (p); return; } @@ -2538,11 +2576,11 @@ * ? * */ rde_param_i_state_push_void (p); - rde_param_i_next_xdigit (p, 33); + rde_param_i_next_xdigit (p, 13); if (rde_param_i_seq_void2void(p)) return; optional_72 (p); rde_param_i_state_merge_void (p); return; } @@ -2552,11 +2590,11 @@ * ? * */ rde_param_i_state_push_2 (p); - rde_param_i_next_xdigit (p, 33); + rde_param_i_next_xdigit (p, 13); rde_param_i_state_merge_ok (p); return; } /* @@ -2574,13 +2612,13 @@ * (Range) * (CLOSEB) * (WHITESPACE) */ - if (rde_param_i_symbol_start_d (p, 37)) return ; + if (rde_param_i_symbol_start_d (p, 50)) return ; sequence_96 (p); - rde_param_i_symbol_done_d_reduce (p, 37, 36); + rde_param_i_symbol_done_d_reduce (p, 50, 49); return; } static void sequence_96 (RDE_PARAM p) { /* @@ -2661,13 +2699,13 @@ * x * '\)' * (WHITESPACE) */ - if (rde_param_i_symbol_void_start (p, 40)) return ; + if (rde_param_i_symbol_void_start (p, 53)) return ; sequence_101 (p); - rde_param_i_symbol_done_void (p, 40, 39); + rde_param_i_symbol_done_void (p, 53, 52); return; } static void sequence_101 (RDE_PARAM p) { /* @@ -2675,11 +2713,11 @@ * '\)' * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_char (p, "\51", 38); + rde_param_i_next_char (p, ")", 51); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -2691,13 +2729,13 @@ static void sym_CLOSEB (RDE_PARAM p) { /* * ']' */ - if (rde_param_i_symbol_void_start (p, 43)) return ; - rde_param_i_next_char (p, "\135", 41); - rde_param_i_symbol_done_void (p, 43, 42); + if (rde_param_i_symbol_void_start (p, 56)) return ; + rde_param_i_next_char (p, "]", 54); + rde_param_i_symbol_done_void (p, 56, 55); return; } /* * void Symbol 'COLON' @@ -2708,13 +2746,13 @@ * x * ':' * (WHITESPACE) */ - if (rde_param_i_symbol_void_start (p, 46)) return ; + if (rde_param_i_symbol_void_start (p, 59)) return ; sequence_108 (p); - rde_param_i_symbol_done_void (p, 46, 45); + rde_param_i_symbol_done_void (p, 59, 58); return; } static void sequence_108 (RDE_PARAM p) { /* @@ -2722,11 +2760,11 @@ * ':' * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_char (p, ":", 44); + rde_param_i_next_char (p, ":", 57); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -2745,13 +2783,13 @@ * (EOL) * * (EOL) */ - if (rde_param_i_symbol_void_start (p, 49)) return ; + if (rde_param_i_symbol_void_start (p, 62)) return ; sequence_121 (p); - rde_param_i_symbol_done_void (p, 49, 48); + rde_param_i_symbol_done_void (p, 62, 61); return; } static void sequence_121 (RDE_PARAM p) { /* @@ -2764,11 +2802,11 @@ * * (EOL) */ rde_param_i_state_push_void (p); - rde_param_i_next_char (p, "#", 47); + rde_param_i_next_char (p, "#", 60); if (rde_param_i_seq_void2void(p)) return; kleene_118 (p); if (rde_param_i_seq_void2void(p)) return; sym_EOL (p); rde_param_i_state_merge_void (p); @@ -2801,11 +2839,11 @@ */ rde_param_i_state_push_void (p); notahead_113 (p); if (rde_param_i_seq_void2void(p)) return; - rde_param_i_input_next (p, 29); + rde_param_i_input_next (p, 43); rde_param_i_state_merge_void (p); return; } static void notahead_113 (RDE_PARAM p) { @@ -2829,13 +2867,13 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 52)) return ; + if (rde_param_i_symbol_start (p, 65)) return ; sequence_126 (p); - rde_param_i_symbol_done_leaf (p, 52, 51); + rde_param_i_symbol_done_leaf (p, 65, 64); return; } static void sequence_126 (RDE_PARAM p) { /* @@ -2843,11 +2881,11 @@ * "" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "", 50); + rde_param_i_next_str (p, "", 63); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -2859,13 +2897,13 @@ static void sym_DAPOSTROPH (RDE_PARAM p) { /* * '\"' */ - if (rde_param_i_symbol_void_start (p, 55)) return ; - rde_param_i_next_char (p, "\42", 53); - rde_param_i_symbol_done_void (p, 55, 54); + if (rde_param_i_symbol_void_start (p, 68)) return ; + rde_param_i_next_char (p, "\"", 66); + rde_param_i_symbol_done_void (p, 68, 67); return; } /* * leaf Symbol 'DDIGIT' @@ -2876,13 +2914,13 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 58)) return ; + if (rde_param_i_symbol_start (p, 71)) return ; sequence_133 (p); - rde_param_i_symbol_done_leaf (p, 58, 57); + rde_param_i_symbol_done_leaf (p, 71, 70); return; } static void sequence_133 (RDE_PARAM p) { /* @@ -2890,11 +2928,11 @@ * "" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "", 56); + rde_param_i_next_str (p, "", 69); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -2912,13 +2950,13 @@ * (IS) * (Expression) * (SEMICOLON) */ - if (rde_param_i_symbol_start_d (p, 60)) return ; + if (rde_param_i_symbol_start_d (p, 73)) return ; sequence_143 (p); - rde_param_i_symbol_done_d_reduce (p, 60, 59); + rde_param_i_symbol_done_d_reduce (p, 73, 72); return; } static void sequence_143 (RDE_PARAM p) { /* @@ -2966,13 +3004,13 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 63)) return ; + if (rde_param_i_symbol_start (p, 76)) return ; sequence_148 (p); - rde_param_i_symbol_done_leaf (p, 63, 62); + rde_param_i_symbol_done_leaf (p, 76, 75); return; } static void sequence_148 (RDE_PARAM p) { /* @@ -2980,11 +3018,11 @@ * "" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "", 61); + rde_param_i_next_str (p, "", 74); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -2998,13 +3036,13 @@ * x * '.' * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 66)) return ; + if (rde_param_i_symbol_start (p, 79)) return ; sequence_153 (p); - rde_param_i_symbol_done_leaf (p, 66, 65); + rde_param_i_symbol_done_leaf (p, 79, 78); return; } static void sequence_153 (RDE_PARAM p) { /* @@ -3012,43 +3050,11 @@ * '.' * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_char (p, ".", 64); - if (rde_param_i_seq_void2void(p)) return; - sym_WHITESPACE (p); - rde_param_i_state_merge_void (p); - return; - } - - /* - * void Symbol 'END' - */ - - static void sym_END (RDE_PARAM p) { - /* - * x - * "END" - * (WHITESPACE) - */ - - if (rde_param_i_symbol_void_start (p, 69)) return ; - sequence_158 (p); - rde_param_i_symbol_done_void (p, 69, 68); - return; - } - - static void sequence_158 (RDE_PARAM p) { - /* - * x - * "END" - * (WHITESPACE) - */ - - rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "END", 67); + rde_param_i_next_char (p, ".", 77); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -3061,24 +3067,24 @@ /* * ! * */ - if (rde_param_i_symbol_void_start (p, 71)) return ; - notahead_162 (p); - rde_param_i_symbol_done_void (p, 71, 70); + if (rde_param_i_symbol_void_start (p, 81)) return ; + notahead_157 (p); + rde_param_i_symbol_done_void (p, 81, 80); return; } - static void notahead_162 (RDE_PARAM p) { + static void notahead_157 (RDE_PARAM p) { /* * ! * */ rde_param_i_loc_push (p); - rde_param_i_input_next (p, 29); + rde_param_i_input_next (p, 43); rde_param_i_notahead_exit (p); return; } /* @@ -3088,13 +3094,13 @@ static void sym_EOL (RDE_PARAM p) { /* * [\n\r] */ - if (rde_param_i_symbol_void_start (p, 74)) return ; - rde_param_i_next_class (p, "\n\r", 72); - rde_param_i_symbol_done_void (p, 74, 73); + if (rde_param_i_symbol_void_start (p, 84)) return ; + rde_param_i_next_class (p, "\n\r", 82); + rde_param_i_symbol_done_void (p, 84, 83); return; } /* * value Symbol 'Expression' @@ -3108,17 +3114,17 @@ * x * (SLASH) * (Sequence) */ - if (rde_param_i_symbol_start_d (p, 76)) return ; - sequence_174 (p); - rde_param_i_symbol_done_d_reduce (p, 76, 75); + if (rde_param_i_symbol_start_d (p, 86)) return ; + sequence_169 (p); + rde_param_i_symbol_done_d_reduce (p, 86, 85); return; } - static void sequence_174 (RDE_PARAM p) { + static void sequence_169 (RDE_PARAM p) { /* * x * (Sequence) * * * x @@ -3127,32 +3133,32 @@ */ rde_param_i_state_push_value (p); sym_Sequence (p); if (rde_param_i_seq_value2value(p)) return; - kleene_172 (p); + kleene_167 (p); rde_param_i_state_merge_value (p); return; } - static void kleene_172 (RDE_PARAM p) { + static void kleene_167 (RDE_PARAM p) { /* * * * x * (SLASH) * (Sequence) */ while (1) { rde_param_i_state_push_2 (p); - sequence_170 (p); + sequence_165 (p); if (rde_param_i_kleene_close(p)) return; } return; } - static void sequence_170 (RDE_PARAM p) { + static void sequence_165 (RDE_PARAM p) { /* * x * (SLASH) * (Sequence) */ @@ -3170,31 +3176,35 @@ */ static void sym_Final (RDE_PARAM p) { /* * x - * (END) + * "END" + * (WHITESPACE) * (SEMICOLON) * (WHITESPACE) */ - if (rde_param_i_symbol_void_start (p, 78)) return ; - sequence_180 (p); - rde_param_i_symbol_done_void (p, 78, 77); + if (rde_param_i_symbol_void_start (p, 89)) return ; + sequence_176 (p); + rde_param_i_symbol_done_void (p, 89, 88); return; } - static void sequence_180 (RDE_PARAM p) { + static void sequence_176 (RDE_PARAM p) { /* * x - * (END) + * "END" + * (WHITESPACE) * (SEMICOLON) * (WHITESPACE) */ rde_param_i_state_push_void (p); - sym_END (p); + rde_param_i_next_str (p, "END", 87); + if (rde_param_i_seq_void2void(p)) return; + sym_WHITESPACE (p); if (rde_param_i_seq_void2void(p)) return; sym_SEMICOLON (p); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); @@ -3214,17 +3224,17 @@ * (Definition) * (Final) * (EOF) */ - if (rde_param_i_symbol_start_d (p, 80)) return ; - sequence_190 (p); - rde_param_i_symbol_done_d_reduce (p, 80, 79); + if (rde_param_i_symbol_start_d (p, 91)) return ; + sequence_186 (p); + rde_param_i_symbol_done_d_reduce (p, 91, 90); return; } - static void sequence_190 (RDE_PARAM p) { + static void sequence_186 (RDE_PARAM p) { /* * x * (WHITESPACE) * (Header) * * @@ -3236,20 +3246,20 @@ rde_param_i_state_push_void (p); sym_WHITESPACE (p); if (rde_param_i_seq_void2value(p)) return; sym_Header (p); if (rde_param_i_seq_value2value(p)) return; - kleene_186 (p); + kleene_182 (p); if (rde_param_i_seq_value2value(p)) return; sym_Final (p); if (rde_param_i_seq_value2value(p)) return; sym_EOF (p); rde_param_i_state_merge_value (p); return; } - static void kleene_186 (RDE_PARAM p) { + static void kleene_182 (RDE_PARAM p) { /* * * * (Definition) */ @@ -3270,25 +3280,25 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 83)) return ; - sequence_195 (p); - rde_param_i_symbol_done_leaf (p, 83, 82); + if (rde_param_i_symbol_start (p, 94)) return ; + sequence_191 (p); + rde_param_i_symbol_done_leaf (p, 94, 93); return; } - static void sequence_195 (RDE_PARAM p) { + static void sequence_191 (RDE_PARAM p) { /* * x * "" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "", 81); + rde_param_i_next_str (p, "", 92); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -3303,17 +3313,17 @@ * (PEG) * (Identifier) * (StartExpr) */ - if (rde_param_i_symbol_start_d (p, 85)) return ; - sequence_201 (p); - rde_param_i_symbol_done_d_reduce (p, 85, 84); + if (rde_param_i_symbol_start_d (p, 96)) return ; + sequence_197 (p); + rde_param_i_symbol_done_d_reduce (p, 96, 95); return; } - static void sequence_201 (RDE_PARAM p) { + static void sequence_197 (RDE_PARAM p) { /* * x * (PEG) * (Identifier) * (StartExpr) @@ -3343,17 +3353,17 @@ * / * [_:] * */ - if (rde_param_i_symbol_start (p, 90)) return ; - sequence_214 (p); - rde_param_i_symbol_done_leaf (p, 90, 89); + if (rde_param_i_symbol_start (p, 99)) return ; + sequence_210 (p); + rde_param_i_symbol_done_leaf (p, 99, 98); return; } - static void sequence_214 (RDE_PARAM p) { + static void sequence_210 (RDE_PARAM p) { /* * x * / * [_:] * @@ -3362,59 +3372,59 @@ * [_:] * */ rde_param_i_state_push_void (p); - choice_206 (p); + choice_202 (p); if (rde_param_i_seq_void2void(p)) return; - kleene_212 (p); + kleene_208 (p); rde_param_i_state_merge_void (p); return; } - static void choice_206 (RDE_PARAM p) { + static void choice_202 (RDE_PARAM p) { /* * / * [_:] * */ rde_param_i_state_push_void (p); - rde_param_i_next_class (p, "_:", 86); + rde_param_i_next_class (p, "_:", 97); if (rde_param_i_bra_void2void(p)) return; - rde_param_i_next_alpha (p, 87); + rde_param_i_next_alpha (p, 1); rde_param_i_state_merge_void (p); return; } - static void kleene_212 (RDE_PARAM p) { + static void kleene_208 (RDE_PARAM p) { /* * * * / * [_:] * */ while (1) { rde_param_i_state_push_2 (p); - choice_210 (p); + choice_206 (p); if (rde_param_i_kleene_close(p)) return; } return; } - static void choice_210 (RDE_PARAM p) { + static void choice_206 (RDE_PARAM p) { /* * / * [_:] * */ rde_param_i_state_push_void (p); - rde_param_i_next_class (p, "_:", 86); + rde_param_i_next_class (p, "_:", 97); if (rde_param_i_bra_void2void(p)) return; - rde_param_i_next_alnum (p, 88); + rde_param_i_next_alnum (p, 0); rde_param_i_state_merge_void (p); return; } /* @@ -3426,17 +3436,17 @@ * x * (Ident) * (WHITESPACE) */ - if (rde_param_i_symbol_start_d (p, 92)) return ; - sequence_219 (p); - rde_param_i_symbol_done_d_reduce (p, 92, 91); + if (rde_param_i_symbol_start_d (p, 101)) return ; + sequence_215 (p); + rde_param_i_symbol_done_d_reduce (p, 101, 100); return; } - static void sequence_219 (RDE_PARAM p) { + static void sequence_215 (RDE_PARAM p) { /* * x * (Ident) * (WHITESPACE) */ @@ -3458,25 +3468,25 @@ * x * "<-" * (WHITESPACE) */ - if (rde_param_i_symbol_void_start (p, 95)) return ; - sequence_224 (p); - rde_param_i_symbol_done_void (p, 95, 94); + if (rde_param_i_symbol_void_start (p, 104)) return ; + sequence_220 (p); + rde_param_i_symbol_done_void (p, 104, 103); return; } - static void sequence_224 (RDE_PARAM p) { + static void sequence_220 (RDE_PARAM p) { /* * x * "<-" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "<-", 93); + rde_param_i_next_str (p, "<-", 102); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -3490,25 +3500,25 @@ * x * "leaf" * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 98)) return ; - sequence_229 (p); - rde_param_i_symbol_done_leaf (p, 98, 97); + if (rde_param_i_symbol_start (p, 107)) return ; + sequence_225 (p); + rde_param_i_symbol_done_leaf (p, 107, 106); return; } - static void sequence_229 (RDE_PARAM p) { + static void sequence_225 (RDE_PARAM p) { /* * x * "leaf" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "leaf", 96); + rde_param_i_next_str (p, "leaf", 105); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -3538,17 +3548,17 @@ * (Char) * (DAPOSTROPH) * (WHITESPACE) */ - if (rde_param_i_symbol_start_d (p, 100)) return ; - choice_258 (p); - rde_param_i_symbol_done_d_reduce (p, 100, 99); + if (rde_param_i_symbol_start_d (p, 109)) return ; + choice_254 (p); + rde_param_i_symbol_done_d_reduce (p, 109, 108); return; } - static void choice_258 (RDE_PARAM p) { + static void choice_254 (RDE_PARAM p) { /* * / * x * (APOSTROPH) * * @@ -3568,18 +3578,18 @@ * (DAPOSTROPH) * (WHITESPACE) */ rde_param_i_state_push_value (p); - sequence_243 (p); + sequence_239 (p); if (rde_param_i_bra_value2value(p)) return; - sequence_256 (p); + sequence_252 (p); rde_param_i_state_merge_value (p); return; } - static void sequence_243 (RDE_PARAM p) { + static void sequence_239 (RDE_PARAM p) { /* * x * (APOSTROPH) * * * x @@ -3591,20 +3601,20 @@ */ rde_param_i_state_push_void (p); sym_APOSTROPH (p); if (rde_param_i_seq_void2value(p)) return; - kleene_239 (p); + kleene_235 (p); if (rde_param_i_seq_value2value(p)) return; sym_APOSTROPH (p); if (rde_param_i_seq_value2value(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_value (p); return; } - static void kleene_239 (RDE_PARAM p) { + static void kleene_235 (RDE_PARAM p) { /* * * * x * ! * (APOSTROPH) @@ -3611,33 +3621,33 @@ * (Char) */ while (1) { rde_param_i_state_push_2 (p); - sequence_237 (p); + sequence_233 (p); if (rde_param_i_kleene_close(p)) return; } return; } - static void sequence_237 (RDE_PARAM p) { + static void sequence_233 (RDE_PARAM p) { /* * x * ! * (APOSTROPH) * (Char) */ rde_param_i_state_push_void (p); - notahead_234 (p); + notahead_230 (p); if (rde_param_i_seq_void2value(p)) return; sym_Char (p); rde_param_i_state_merge_value (p); return; } - static void notahead_234 (RDE_PARAM p) { + static void notahead_230 (RDE_PARAM p) { /* * ! * (APOSTROPH) */ @@ -3645,11 +3655,11 @@ sym_APOSTROPH (p); rde_param_i_notahead_exit (p); return; } - static void sequence_256 (RDE_PARAM p) { + static void sequence_252 (RDE_PARAM p) { /* * x * (DAPOSTROPH) * * * x @@ -3661,20 +3671,20 @@ */ rde_param_i_state_push_void (p); sym_DAPOSTROPH (p); if (rde_param_i_seq_void2value(p)) return; - kleene_252 (p); + kleene_248 (p); if (rde_param_i_seq_value2value(p)) return; sym_DAPOSTROPH (p); if (rde_param_i_seq_value2value(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_value (p); return; } - static void kleene_252 (RDE_PARAM p) { + static void kleene_248 (RDE_PARAM p) { /* * * * x * ! * (DAPOSTROPH) @@ -3681,33 +3691,33 @@ * (Char) */ while (1) { rde_param_i_state_push_2 (p); - sequence_250 (p); + sequence_246 (p); if (rde_param_i_kleene_close(p)) return; } return; } - static void sequence_250 (RDE_PARAM p) { + static void sequence_246 (RDE_PARAM p) { /* * x * ! * (DAPOSTROPH) * (Char) */ rde_param_i_state_push_void (p); - notahead_247 (p); + notahead_243 (p); if (rde_param_i_seq_void2value(p)) return; sym_Char (p); rde_param_i_state_merge_value (p); return; } - static void notahead_247 (RDE_PARAM p) { + static void notahead_243 (RDE_PARAM p) { /* * ! * (DAPOSTROPH) */ @@ -3726,25 +3736,25 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 103)) return ; - sequence_263 (p); - rde_param_i_symbol_done_leaf (p, 103, 102); + if (rde_param_i_symbol_start (p, 112)) return ; + sequence_259 (p); + rde_param_i_symbol_done_leaf (p, 112, 111); return; } - static void sequence_263 (RDE_PARAM p) { + static void sequence_259 (RDE_PARAM p) { /* * x * "" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "", 101); + rde_param_i_next_str (p, "", 110); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -3758,25 +3768,25 @@ * x * '!' * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 106)) return ; - sequence_268 (p); - rde_param_i_symbol_done_leaf (p, 106, 105); + if (rde_param_i_symbol_start (p, 115)) return ; + sequence_264 (p); + rde_param_i_symbol_done_leaf (p, 115, 114); return; } - static void sequence_268 (RDE_PARAM p) { + static void sequence_264 (RDE_PARAM p) { /* * x * '!' * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_char (p, "!", 104); + rde_param_i_next_char (p, "!", 113); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -3790,25 +3800,25 @@ * x * '\(' * (WHITESPACE) */ - if (rde_param_i_symbol_void_start (p, 109)) return ; - sequence_273 (p); - rde_param_i_symbol_done_void (p, 109, 108); + if (rde_param_i_symbol_void_start (p, 118)) return ; + sequence_269 (p); + rde_param_i_symbol_done_void (p, 118, 117); return; } - static void sequence_273 (RDE_PARAM p) { + static void sequence_269 (RDE_PARAM p) { /* * x * '\(' * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_char (p, "\50", 107); + rde_param_i_next_char (p, "(", 116); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -3820,13 +3830,13 @@ static void sym_OPENB (RDE_PARAM p) { /* * '[' */ - if (rde_param_i_symbol_void_start (p, 112)) return ; - rde_param_i_next_char (p, "\133", 110); - rde_param_i_symbol_done_void (p, 112, 111); + if (rde_param_i_symbol_void_start (p, 121)) return ; + rde_param_i_next_char (p, "[", 119); + rde_param_i_symbol_done_void (p, 121, 120); return; } /* * void Symbol 'PEG' @@ -3834,33 +3844,57 @@ static void sym_PEG (RDE_PARAM p) { /* * x * "PEG" + * ! + * / + * [_:] + * * (WHITESPACE) */ - if (rde_param_i_symbol_void_start (p, 115)) return ; - sequence_280 (p); - rde_param_i_symbol_done_void (p, 115, 114); + if (rde_param_i_symbol_void_start (p, 124)) return ; + sequence_281 (p); + rde_param_i_symbol_done_void (p, 124, 123); return; } - static void sequence_280 (RDE_PARAM p) { + static void sequence_281 (RDE_PARAM p) { /* * x * "PEG" + * ! + * / + * [_:] + * * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "PEG", 113); + rde_param_i_next_str (p, "PEG", 122); + if (rde_param_i_seq_void2void(p)) return; + notahead_278 (p); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } + + static void notahead_278 (RDE_PARAM p) { + /* + * ! + * / + * [_:] + * + */ + + rde_param_i_loc_push (p); + choice_206 (p); + rde_param_i_notahead_exit (p); + return; + } /* * leaf Symbol 'PLUS' */ @@ -3869,25 +3903,25 @@ * x * '+' * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 118)) return ; - sequence_285 (p); - rde_param_i_symbol_done_leaf (p, 118, 117); + if (rde_param_i_symbol_start (p, 127)) return ; + sequence_286 (p); + rde_param_i_symbol_done_leaf (p, 127, 126); return; } - static void sequence_285 (RDE_PARAM p) { + static void sequence_286 (RDE_PARAM p) { /* * x * '+' * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_char (p, "+", 116); + rde_param_i_next_char (p, "+", 125); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -3904,17 +3938,17 @@ * (AND) * (NOT) * (Suffix) */ - if (rde_param_i_symbol_start_d (p, 120)) return ; - sequence_295 (p); - rde_param_i_symbol_done_d_reduce (p, 120, 119); + if (rde_param_i_symbol_start_d (p, 129)) return ; + sequence_296 (p); + rde_param_i_symbol_done_d_reduce (p, 129, 128); return; } - static void sequence_295 (RDE_PARAM p) { + static void sequence_296 (RDE_PARAM p) { /* * x * ? * / * (AND) @@ -3921,32 +3955,32 @@ * (NOT) * (Suffix) */ rde_param_i_state_push_value (p); - optional_292 (p); + optional_293 (p); if (rde_param_i_seq_value2value(p)) return; sym_Suffix (p); rde_param_i_state_merge_value (p); return; } - static void optional_292 (RDE_PARAM p) { + static void optional_293 (RDE_PARAM p) { /* * ? * / * (AND) * (NOT) */ rde_param_i_state_push_2 (p); - choice_290 (p); + choice_291 (p); rde_param_i_state_merge_ok (p); return; } - static void choice_290 (RDE_PARAM p) { + static void choice_291 (RDE_PARAM p) { /* * / * (AND) * (NOT) */ @@ -3988,17 +4022,17 @@ * (Literal) * (Class) * (DOT) */ - if (rde_param_i_symbol_start_d (p, 122)) return ; - choice_321 (p); - rde_param_i_symbol_done_d_reduce (p, 122, 121); + if (rde_param_i_symbol_start_d (p, 131)) return ; + choice_322 (p); + rde_param_i_symbol_done_d_reduce (p, 131, 130); return; } - static void choice_321 (RDE_PARAM p) { + static void choice_322 (RDE_PARAM p) { /* * / * (ALNUM) * (ALPHA) * (ASCII) @@ -4052,11 +4086,11 @@ if (rde_param_i_bra_value2value(p)) return; sym_XDIGIT (p); if (rde_param_i_bra_value2value(p)) return; sym_Identifier (p); if (rde_param_i_bra_value2value(p)) return; - sequence_316 (p); + sequence_317 (p); if (rde_param_i_bra_value2value(p)) return; sym_Literal (p); if (rde_param_i_bra_value2value(p)) return; sym_Class (p); if (rde_param_i_bra_value2value(p)) return; @@ -4063,11 +4097,11 @@ sym_DOT (p); rde_param_i_state_merge_value (p); return; } - static void sequence_316 (RDE_PARAM p) { + static void sequence_317 (RDE_PARAM p) { /* * x * (OPEN) * (Expression) * (CLOSE) @@ -4092,25 +4126,25 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 125)) return ; - sequence_326 (p); - rde_param_i_symbol_done_leaf (p, 125, 124); + if (rde_param_i_symbol_start (p, 134)) return ; + sequence_327 (p); + rde_param_i_symbol_done_leaf (p, 134, 133); return; } - static void sequence_326 (RDE_PARAM p) { + static void sequence_327 (RDE_PARAM p) { /* * x * "" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "", 123); + rde_param_i_next_str (p, "", 132); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -4124,25 +4158,25 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 128)) return ; - sequence_331 (p); - rde_param_i_symbol_done_leaf (p, 128, 127); + if (rde_param_i_symbol_start (p, 137)) return ; + sequence_332 (p); + rde_param_i_symbol_done_leaf (p, 137, 136); return; } - static void sequence_331 (RDE_PARAM p) { + static void sequence_332 (RDE_PARAM p) { /* * x * "" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "", 126); + rde_param_i_next_str (p, "", 135); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -4156,25 +4190,25 @@ * x * '?' * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 131)) return ; - sequence_336 (p); - rde_param_i_symbol_done_leaf (p, 131, 130); + if (rde_param_i_symbol_start (p, 140)) return ; + sequence_337 (p); + rde_param_i_symbol_done_leaf (p, 140, 139); return; } - static void sequence_336 (RDE_PARAM p) { + static void sequence_337 (RDE_PARAM p) { /* * x * '?' * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_char (p, "?", 129); + rde_param_i_next_char (p, "?", 138); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -4191,17 +4225,17 @@ * (TO) * (Char) * (Char) */ - if (rde_param_i_symbol_start_d (p, 133)) return ; - choice_345 (p); - rde_param_i_symbol_done_d_reduce (p, 133, 132); + if (rde_param_i_symbol_start_d (p, 142)) return ; + choice_346 (p); + rde_param_i_symbol_done_d_reduce (p, 142, 141); return; } - static void choice_345 (RDE_PARAM p) { + static void choice_346 (RDE_PARAM p) { /* * / * x * (Char) * (TO) @@ -4208,18 +4242,18 @@ * (Char) * (Char) */ rde_param_i_state_push_value (p); - sequence_342 (p); + sequence_343 (p); if (rde_param_i_bra_value2value(p)) return; sym_Char (p); rde_param_i_state_merge_value (p); return; } - static void sequence_342 (RDE_PARAM p) { + static void sequence_343 (RDE_PARAM p) { /* * x * (Char) * (TO) * (Char) @@ -4244,25 +4278,25 @@ * x * ';' * (WHITESPACE) */ - if (rde_param_i_symbol_void_start (p, 136)) return ; - sequence_350 (p); - rde_param_i_symbol_done_void (p, 136, 135); + if (rde_param_i_symbol_void_start (p, 145)) return ; + sequence_351 (p); + rde_param_i_symbol_done_void (p, 145, 144); return; } - static void sequence_350 (RDE_PARAM p) { + static void sequence_351 (RDE_PARAM p) { /* * x * ';' * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_char (p, "\73", 134); + rde_param_i_next_char (p, ";", 143); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -4275,17 +4309,17 @@ /* * + * (Prefix) */ - if (rde_param_i_symbol_start_d (p, 138)) return ; - poskleene_354 (p); - rde_param_i_symbol_done_d_reduce (p, 138, 137); + if (rde_param_i_symbol_start_d (p, 147)) return ; + poskleene_355 (p); + rde_param_i_symbol_done_d_reduce (p, 147, 146); return; } - static void poskleene_354 (RDE_PARAM p) { + static void poskleene_355 (RDE_PARAM p) { /* * + * (Prefix) */ @@ -4309,25 +4343,25 @@ * x * '/' * (WHITESPACE) */ - if (rde_param_i_symbol_void_start (p, 141)) return ; - sequence_359 (p); - rde_param_i_symbol_done_void (p, 141, 140); + if (rde_param_i_symbol_void_start (p, 150)) return ; + sequence_360 (p); + rde_param_i_symbol_done_void (p, 150, 149); return; } - static void sequence_359 (RDE_PARAM p) { + static void sequence_360 (RDE_PARAM p) { /* * x * '/' * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_char (p, "/", 139); + rde_param_i_next_char (p, "/", 148); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -4341,25 +4375,25 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 144)) return ; - sequence_364 (p); - rde_param_i_symbol_done_leaf (p, 144, 143); + if (rde_param_i_symbol_start (p, 153)) return ; + sequence_365 (p); + rde_param_i_symbol_done_leaf (p, 153, 152); return; } - static void sequence_364 (RDE_PARAM p) { + static void sequence_365 (RDE_PARAM p) { /* * x * "" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "", 142); + rde_param_i_next_str (p, "", 151); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -4373,25 +4407,25 @@ * x * '*' * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 147)) return ; - sequence_369 (p); - rde_param_i_symbol_done_leaf (p, 147, 146); + if (rde_param_i_symbol_start (p, 156)) return ; + sequence_370 (p); + rde_param_i_symbol_done_leaf (p, 156, 155); return; } - static void sequence_369 (RDE_PARAM p) { + static void sequence_370 (RDE_PARAM p) { /* * x * '*' * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_char (p, "*", 145); + rde_param_i_next_char (p, "*", 154); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -4406,13 +4440,13 @@ * (OPEN) * (Expression) * (CLOSE) */ - if (rde_param_i_symbol_start_d (p, 149)) return ; - sequence_316 (p); - rde_param_i_symbol_done_d_reduce (p, 149, 148); + if (rde_param_i_symbol_start_d (p, 158)) return ; + sequence_317 (p); + rde_param_i_symbol_done_d_reduce (p, 158, 157); return; } /* * value Symbol 'Suffix' @@ -4427,17 +4461,17 @@ * (QUESTION) * (STAR) * (PLUS) */ - if (rde_param_i_symbol_start_d (p, 151)) return ; - sequence_385 (p); - rde_param_i_symbol_done_d_reduce (p, 151, 150); + if (rde_param_i_symbol_start_d (p, 160)) return ; + sequence_386 (p); + rde_param_i_symbol_done_d_reduce (p, 160, 159); return; } - static void sequence_385 (RDE_PARAM p) { + static void sequence_386 (RDE_PARAM p) { /* * x * (Primary) * ? * / @@ -4447,31 +4481,31 @@ */ rde_param_i_state_push_value (p); sym_Primary (p); if (rde_param_i_seq_value2value(p)) return; - optional_383 (p); + optional_384 (p); rde_param_i_state_merge_value (p); return; } - static void optional_383 (RDE_PARAM p) { + static void optional_384 (RDE_PARAM p) { /* * ? * / * (QUESTION) * (STAR) * (PLUS) */ rde_param_i_state_push_2 (p); - choice_381 (p); + choice_382 (p); rde_param_i_state_merge_ok (p); return; } - static void choice_381 (RDE_PARAM p) { + static void choice_382 (RDE_PARAM p) { /* * / * (QUESTION) * (STAR) * (PLUS) @@ -4494,13 +4528,13 @@ static void sym_TO (RDE_PARAM p) { /* * '-' */ - if (rde_param_i_symbol_void_start (p, 154)) return ; - rde_param_i_next_char (p, "-", 152); - rde_param_i_symbol_done_void (p, 154, 153); + if (rde_param_i_symbol_void_start (p, 163)) return ; + rde_param_i_next_char (p, "-", 161); + rde_param_i_symbol_done_void (p, 163, 162); return; } /* * leaf Symbol 'UPPER' @@ -4511,25 +4545,25 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 157)) return ; - sequence_392 (p); - rde_param_i_symbol_done_leaf (p, 157, 156); + if (rde_param_i_symbol_start (p, 166)) return ; + sequence_393 (p); + rde_param_i_symbol_done_leaf (p, 166, 165); return; } - static void sequence_392 (RDE_PARAM p) { + static void sequence_393 (RDE_PARAM p) { /* * x * "" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "", 155); + rde_param_i_next_str (p, "", 164); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -4543,25 +4577,25 @@ * x * "void" * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 160)) return ; - sequence_397 (p); - rde_param_i_symbol_done_leaf (p, 160, 159); + if (rde_param_i_symbol_start (p, 169)) return ; + sequence_398 (p); + rde_param_i_symbol_done_leaf (p, 169, 168); return; } - static void sequence_397 (RDE_PARAM p) { + static void sequence_398 (RDE_PARAM p) { /* * x * "void" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "void", 158); + rde_param_i_next_str (p, "void", 167); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -4576,41 +4610,41 @@ * / * * (COMMENT) */ - if (rde_param_i_symbol_void_start (p, 163)) return ; - kleene_404 (p); - rde_param_i_symbol_done_void (p, 163, 162); + if (rde_param_i_symbol_void_start (p, 171)) return ; + kleene_405 (p); + rde_param_i_symbol_done_void (p, 171, 170); return; } - static void kleene_404 (RDE_PARAM p) { + static void kleene_405 (RDE_PARAM p) { /* * * * / * * (COMMENT) */ while (1) { rde_param_i_state_push_2 (p); - choice_402 (p); + choice_403 (p); if (rde_param_i_kleene_close(p)) return; } return; } - static void choice_402 (RDE_PARAM p) { + static void choice_403 (RDE_PARAM p) { /* * / * * (COMMENT) */ rde_param_i_state_push_void (p); - rde_param_i_next_space (p, 161); + rde_param_i_next_space (p, 10); if (rde_param_i_bra_void2void(p)) return; sym_COMMENT (p); rde_param_i_state_merge_void (p); return; } @@ -4624,25 +4658,25 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 166)) return ; - sequence_409 (p); - rde_param_i_symbol_done_leaf (p, 166, 165); + if (rde_param_i_symbol_start (p, 174)) return ; + sequence_410 (p); + rde_param_i_symbol_done_leaf (p, 174, 173); return; } - static void sequence_409 (RDE_PARAM p) { + static void sequence_410 (RDE_PARAM p) { /* * x * "" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "", 164); + rde_param_i_next_str (p, "", 172); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -4656,25 +4690,25 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (p, 169)) return ; - sequence_414 (p); - rde_param_i_symbol_done_leaf (p, 169, 168); + if (rde_param_i_symbol_start (p, 177)) return ; + sequence_415 (p); + rde_param_i_symbol_done_leaf (p, 177, 176); return; } - static void sequence_414 (RDE_PARAM p) { + static void sequence_415 (RDE_PARAM p) { /* * x * "" * (WHITESPACE) */ rde_param_i_state_push_void (p); - rde_param_i_next_str (p, "", 167); + rde_param_i_next_str (p, "", 175); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } @@ -4717,11 +4751,11 @@ Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; - sprintf (parserg->buf, "PARSER%d", parserg->counter); + sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void @@ -4780,45 +4814,52 @@ rde_param_data (p, buf, len); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } + /* See also rde_critcl/m.c, param_COMPLETE() */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) { if (rde_param_query_st (p)) { long int ac; Tcl_Obj** av; rde_param_query_ast (p, &ac, &av); if (ac > 1) { - long int lsc; - long int* lsv; Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); - rde_param_query_ls (p, &lsc, &lsv); - memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); lv [0] = Tcl_NewObj (); - lv [1] = Tcl_NewIntObj (1 + lsv [lsc-1]); + lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); ckfree ((char*) lv); + + } else if (ac == 0) { + /* + * Match, but no AST. This is possible if the grammar + * consists of only the start expression. + */ + Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); } else { Tcl_SetObjResult (interp, av [0]); } return TCL_OK; } else { Tcl_Obj* xv [1]; const ERROR_STATE* er = rde_param_query_er (p); Tcl_Obj* res = rde_param_query_er_tcl (p, er); + /* res = list (location, list(msg)) */ + /* Stick the exception type-tag before the existing elements */ xv [0] = Tcl_NewStringObj ("pt::rde",-1); - Tcl_ListObjReplace(interp, res, 0, 1, 1, xv); + Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); + Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); Tcl_SetObjResult (interp, res); return TCL_ERROR; } } } Index: modules/pt/tests/data/ok/peg_cparam-critcl/4_choice ================================================================== --- modules/pt/tests/data/ok/peg_cparam-critcl/4_choice +++ modules/pt/tests/data/ok/peg_cparam-critcl/4_choice @@ -28,11 +28,11 @@ namespace eval ::PARSER { # # ## ### ##### ######## ############# ##################### ## Supporting code for the main command. catch { - #critcl::cheaders -g + #critcl::cflags -g #critcl::debug memory symbols } # # ## ### ###### ######## ############# ## RDE runtime, inlined, and made static. @@ -384,10 +384,14 @@ int clen; Tcl_UniChar uni; if (len < 0) { len = strlen (string); } + + if (!len) { + return tc->str + base; + } if ((tc->num + len) >= tc->max) { int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); char* str = ckrealloc (tc->str, new * sizeof(char)); ASSERT (str,"Memory allocation failure for token character array"); @@ -413,18 +417,18 @@ } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; - long int* ov; - rde_stack_get (tc->off, &oc, (void***) &ov); + void** ov; + rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); - off = ov [at]; + off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { - end = ov [at+1]; + end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; @@ -432,19 +436,19 @@ } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; - long int* ov; - rde_stack_get (tc->off, &oc, (void***) &ov); + void** ov; + rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); - off = ov [at]; + off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { - end = ov [last+1]; + end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; @@ -479,10 +483,11 @@ typedef int (*UniCharClass) (int); typedef enum test_class_id { tc_alnum, tc_alpha, tc_ascii, + tc_control, tc_ddigit, tc_digit, tc_graph, tc_lower, tc_printable, @@ -492,11 +497,11 @@ tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); - static void error_set (RDE_PARAM p, int s); + static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); @@ -645,13 +650,13 @@ rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void - rde_param_query_amark (RDE_PARAM p, long int* mc, long int** mv) + rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { - rde_stack_get (p->mark, mc, (void***) mv); + rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); @@ -688,25 +693,25 @@ res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; - long int* mv; + void** mv; int lastid; const char* msg; - rde_stack_get (er->msg, &mc, (void***) &mv); + rde_stack_get (er->msg, &mc, &mv); - qsort (mv, mc, sizeof (long int), er_int_compare); + qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); - if (mv [i] == lastid) continue; - lastid = mv [i]; - ASSERT_BOUNDS(mv[i],p->numstr); - msg = p->string [mv[i]]; + if (((long int) mv [i]) == lastid) continue; + lastid = (long int) mv [i]; + ASSERT_BOUNDS((long int) mv[i],p->numstr); + msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } @@ -721,13 +726,18 @@ rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) { rde_stack_get (p->ES, ec, (void***) ev); } SCOPE void - rde_param_query_ls (RDE_PARAM p, long int* lc, long int** lv) + rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) { - rde_stack_get (p->LS, lc, (void***) lv); + rde_stack_get (p->LS, lc, lv); + } + SCOPE long int + rde_param_query_lstop (RDE_PARAM p) + { + (long int) rde_stack_top (p->LS); } SCOPE Tcl_HashTable* rde_param_query_nc (RDE_PARAM p) { return &p->NC; @@ -770,11 +780,11 @@ { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; @@ -783,11 +793,11 @@ rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; @@ -818,12 +828,14 @@ rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void - rde_param_i_error_nonterminal (RDE_PARAM p, int s) + rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { + + return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; error_set (p, s); @@ -872,11 +884,11 @@ { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void - error_set (RDE_PARAM p, int s) + error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; @@ -914,20 +926,21 @@ rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void - rde_param_i_input_next (RDE_PARAM p, int m) + rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); - ASSERT_BOUNDS (p->CC_len, TCL_UTF_MAX); + + ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || @@ -960,11 +973,11 @@ rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int - rde_param_i_symbol_restore (RDE_PARAM p, int s) + rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; @@ -983,11 +996,11 @@ TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void - rde_param_i_symbol_save (RDE_PARAM p, int s) + rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; @@ -1049,11 +1062,16 @@ rde_param_i_test_ascii (RDE_PARAM p) { test_class (p, UniCharIsAscii, tc_ascii); } SCOPE void - rde_param_i_test_char (RDE_PARAM p, char* c, int msg) + rde_param_i_test_control (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsControl, tc_control); + } + SCOPE void + rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); @@ -1091,11 +1109,11 @@ rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void - rde_param_i_test_range (RDE_PARAM p, char* s, char* e, int msg) + rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); @@ -1160,11 +1178,11 @@ rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void - rde_param_i_value_leaf (RDE_PARAM p, int s) + rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); @@ -1174,11 +1192,11 @@ newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void - rde_param_i_value_reduce (RDE_PARAM p, int s) + rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; @@ -1206,18 +1224,21 @@ ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { - long int ai = *((long int*) a); - long int bi = *((long int*) b); - if (ai < bi) { return -1; } - if (ai > bi) { return 1; } + + const void** ael = (const void**) a; + const void** bel = (const void**) b; + long int avalue = (long int) *ael; + long int bvalue = (long int) *bel; + if (avalue < bvalue) { return -1; } + if (avalue > bvalue) { return 1; } return 0; } SCOPE int - rde_param_i_symbol_start (RDE_PARAM p, int s) + rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); @@ -1226,11 +1247,11 @@ } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int - rde_param_i_symbol_start_d (RDE_PARAM p, int s) + rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); @@ -1240,26 +1261,26 @@ rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int - rde_param_i_symbol_void_start (RDE_PARAM p, int s) + rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int - rde_param_i_symbol_void_start_d (RDE_PARAM p, int s) + rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void - rde_param_i_symbol_done_d_reduce (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); @@ -1272,11 +1293,11 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_leaf (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); @@ -1288,11 +1309,11 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_d_leaf (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); @@ -1305,126 +1326,133 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_void (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void - rde_param_i_symbol_done_d_void (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void - rde_param_i_next_char (RDE_PARAM p, char* c, int m) + rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void - rde_param_i_next_range (RDE_PARAM p, char* s, char* e, int m) + rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void - rde_param_i_next_alnum (RDE_PARAM p, int m) + rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void - rde_param_i_next_alpha (RDE_PARAM p, int m) + rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void - rde_param_i_next_ascii (RDE_PARAM p, int m) + rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void - rde_param_i_next_ddigit (RDE_PARAM p, int m) + rde_param_i_next_control (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_control (p); + } + SCOPE void + rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void - rde_param_i_next_digit (RDE_PARAM p, int m) + rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void - rde_param_i_next_graph (RDE_PARAM p, int m) + rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void - rde_param_i_next_lower (RDE_PARAM p, int m) + rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void - rde_param_i_next_print (RDE_PARAM p, int m) + rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void - rde_param_i_next_punct (RDE_PARAM p, int m) + rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void - rde_param_i_next_space (RDE_PARAM p, int m) + rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void - rde_param_i_next_upper (RDE_PARAM p, int m) + rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void - rde_param_i_next_wordchar (RDE_PARAM p, int m) + rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void - rde_param_i_next_xdigit (RDE_PARAM p, int m) + rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } @@ -1501,11 +1529,11 @@ rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } @@ -1569,11 +1597,11 @@ if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } @@ -1612,11 +1640,11 @@ rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; @@ -1628,37 +1656,40 @@ if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void - rde_param_i_next_str (RDE_PARAM p, char* str, int m) + rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; + while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { + p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { + p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void - rde_param_i_next_class (RDE_PARAM p, char* class, int m) + rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; @@ -1688,20 +1719,34 @@ /* * Precomputed table of strings (symbols, error messages, etc.). */ - static char const* p_string [1] = { - /* 0 = */ "cl 'abc'" + static char const* p_string [15] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "cl abc" }; /* * Grammar Start Expression */ static void MAIN (RDE_PARAM p) { - rde_param_i_next_class (p, "abc", 0); + rde_param_i_next_class (p, "abc", 14); return; } } @@ -1741,11 +1786,11 @@ Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; - sprintf (parserg->buf, "PARSER%d", parserg->counter); + sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void @@ -1804,45 +1849,52 @@ rde_param_data (p, buf, len); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } + /* See also rde_critcl/m.c, param_COMPLETE() */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) { if (rde_param_query_st (p)) { long int ac; Tcl_Obj** av; rde_param_query_ast (p, &ac, &av); if (ac > 1) { - long int lsc; - long int* lsv; Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); - rde_param_query_ls (p, &lsc, &lsv); - memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); lv [0] = Tcl_NewObj (); - lv [1] = Tcl_NewIntObj (1 + lsv [lsc-1]); + lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); ckfree ((char*) lv); + + } else if (ac == 0) { + /* + * Match, but no AST. This is possible if the grammar + * consists of only the start expression. + */ + Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); } else { Tcl_SetObjResult (interp, av [0]); } return TCL_OK; } else { Tcl_Obj* xv [1]; const ERROR_STATE* er = rde_param_query_er (p); Tcl_Obj* res = rde_param_query_er_tcl (p, er); + /* res = list (location, list(msg)) */ + /* Stick the exception type-tag before the existing elements */ xv [0] = Tcl_NewStringObj ("pt::rde",-1); - Tcl_ListObjReplace(interp, res, 0, 1, 1, xv); + Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); + Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); Tcl_SetObjResult (interp, res); return TCL_ERROR; } } } Index: modules/pt/tests/data/ok/peg_cparam-critcl/5_sequence ================================================================== --- modules/pt/tests/data/ok/peg_cparam-critcl/5_sequence +++ modules/pt/tests/data/ok/peg_cparam-critcl/5_sequence @@ -28,11 +28,11 @@ namespace eval ::PARSER { # # ## ### ##### ######## ############# ##################### ## Supporting code for the main command. catch { - #critcl::cheaders -g + #critcl::cflags -g #critcl::debug memory symbols } # # ## ### ###### ######## ############# ## RDE runtime, inlined, and made static. @@ -384,10 +384,14 @@ int clen; Tcl_UniChar uni; if (len < 0) { len = strlen (string); } + + if (!len) { + return tc->str + base; + } if ((tc->num + len) >= tc->max) { int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); char* str = ckrealloc (tc->str, new * sizeof(char)); ASSERT (str,"Memory allocation failure for token character array"); @@ -413,18 +417,18 @@ } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; - long int* ov; - rde_stack_get (tc->off, &oc, (void***) &ov); + void** ov; + rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); - off = ov [at]; + off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { - end = ov [at+1]; + end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; @@ -432,19 +436,19 @@ } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; - long int* ov; - rde_stack_get (tc->off, &oc, (void***) &ov); + void** ov; + rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); - off = ov [at]; + off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { - end = ov [last+1]; + end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; @@ -479,10 +483,11 @@ typedef int (*UniCharClass) (int); typedef enum test_class_id { tc_alnum, tc_alpha, tc_ascii, + tc_control, tc_ddigit, tc_digit, tc_graph, tc_lower, tc_printable, @@ -492,11 +497,11 @@ tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); - static void error_set (RDE_PARAM p, int s); + static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); @@ -645,13 +650,13 @@ rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void - rde_param_query_amark (RDE_PARAM p, long int* mc, long int** mv) + rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { - rde_stack_get (p->mark, mc, (void***) mv); + rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); @@ -688,25 +693,25 @@ res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; - long int* mv; + void** mv; int lastid; const char* msg; - rde_stack_get (er->msg, &mc, (void***) &mv); + rde_stack_get (er->msg, &mc, &mv); - qsort (mv, mc, sizeof (long int), er_int_compare); + qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); - if (mv [i] == lastid) continue; - lastid = mv [i]; - ASSERT_BOUNDS(mv[i],p->numstr); - msg = p->string [mv[i]]; + if (((long int) mv [i]) == lastid) continue; + lastid = (long int) mv [i]; + ASSERT_BOUNDS((long int) mv[i],p->numstr); + msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } @@ -721,13 +726,18 @@ rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) { rde_stack_get (p->ES, ec, (void***) ev); } SCOPE void - rde_param_query_ls (RDE_PARAM p, long int* lc, long int** lv) + rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) { - rde_stack_get (p->LS, lc, (void***) lv); + rde_stack_get (p->LS, lc, lv); + } + SCOPE long int + rde_param_query_lstop (RDE_PARAM p) + { + (long int) rde_stack_top (p->LS); } SCOPE Tcl_HashTable* rde_param_query_nc (RDE_PARAM p) { return &p->NC; @@ -770,11 +780,11 @@ { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; @@ -783,11 +793,11 @@ rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; @@ -818,12 +828,14 @@ rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void - rde_param_i_error_nonterminal (RDE_PARAM p, int s) + rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { + + return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; error_set (p, s); @@ -872,11 +884,11 @@ { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void - error_set (RDE_PARAM p, int s) + error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; @@ -914,20 +926,21 @@ rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void - rde_param_i_input_next (RDE_PARAM p, int m) + rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); - ASSERT_BOUNDS (p->CC_len, TCL_UTF_MAX); + + ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || @@ -960,11 +973,11 @@ rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int - rde_param_i_symbol_restore (RDE_PARAM p, int s) + rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; @@ -983,11 +996,11 @@ TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void - rde_param_i_symbol_save (RDE_PARAM p, int s) + rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; @@ -1049,11 +1062,16 @@ rde_param_i_test_ascii (RDE_PARAM p) { test_class (p, UniCharIsAscii, tc_ascii); } SCOPE void - rde_param_i_test_char (RDE_PARAM p, char* c, int msg) + rde_param_i_test_control (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsControl, tc_control); + } + SCOPE void + rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); @@ -1091,11 +1109,11 @@ rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void - rde_param_i_test_range (RDE_PARAM p, char* s, char* e, int msg) + rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); @@ -1160,11 +1178,11 @@ rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void - rde_param_i_value_leaf (RDE_PARAM p, int s) + rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); @@ -1174,11 +1192,11 @@ newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void - rde_param_i_value_reduce (RDE_PARAM p, int s) + rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; @@ -1206,18 +1224,21 @@ ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { - long int ai = *((long int*) a); - long int bi = *((long int*) b); - if (ai < bi) { return -1; } - if (ai > bi) { return 1; } + + const void** ael = (const void**) a; + const void** bel = (const void**) b; + long int avalue = (long int) *ael; + long int bvalue = (long int) *bel; + if (avalue < bvalue) { return -1; } + if (avalue > bvalue) { return 1; } return 0; } SCOPE int - rde_param_i_symbol_start (RDE_PARAM p, int s) + rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); @@ -1226,11 +1247,11 @@ } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int - rde_param_i_symbol_start_d (RDE_PARAM p, int s) + rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); @@ -1240,26 +1261,26 @@ rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int - rde_param_i_symbol_void_start (RDE_PARAM p, int s) + rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int - rde_param_i_symbol_void_start_d (RDE_PARAM p, int s) + rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void - rde_param_i_symbol_done_d_reduce (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); @@ -1272,11 +1293,11 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_leaf (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); @@ -1288,11 +1309,11 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_d_leaf (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); @@ -1305,126 +1326,133 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_void (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void - rde_param_i_symbol_done_d_void (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void - rde_param_i_next_char (RDE_PARAM p, char* c, int m) + rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void - rde_param_i_next_range (RDE_PARAM p, char* s, char* e, int m) + rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void - rde_param_i_next_alnum (RDE_PARAM p, int m) + rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void - rde_param_i_next_alpha (RDE_PARAM p, int m) + rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void - rde_param_i_next_ascii (RDE_PARAM p, int m) + rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void - rde_param_i_next_ddigit (RDE_PARAM p, int m) + rde_param_i_next_control (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_control (p); + } + SCOPE void + rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void - rde_param_i_next_digit (RDE_PARAM p, int m) + rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void - rde_param_i_next_graph (RDE_PARAM p, int m) + rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void - rde_param_i_next_lower (RDE_PARAM p, int m) + rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void - rde_param_i_next_print (RDE_PARAM p, int m) + rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void - rde_param_i_next_punct (RDE_PARAM p, int m) + rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void - rde_param_i_next_space (RDE_PARAM p, int m) + rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void - rde_param_i_next_upper (RDE_PARAM p, int m) + rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void - rde_param_i_next_wordchar (RDE_PARAM p, int m) + rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void - rde_param_i_next_xdigit (RDE_PARAM p, int m) + rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } @@ -1501,11 +1529,11 @@ rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } @@ -1569,11 +1597,11 @@ if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } @@ -1612,11 +1640,11 @@ rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; @@ -1628,37 +1656,40 @@ if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void - rde_param_i_next_str (RDE_PARAM p, char* str, int m) + rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; + while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { + p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { + p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void - rde_param_i_next_class (RDE_PARAM p, char* class, int m) + rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; @@ -1688,20 +1719,34 @@ /* * Precomputed table of strings (symbols, error messages, etc.). */ - static char const* p_string [1] = { - /* 0 = */ "str 'abc'" + static char const* p_string [15] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "str abc" }; /* * Grammar Start Expression */ static void MAIN (RDE_PARAM p) { - rde_param_i_next_str (p, "abc", 0); + rde_param_i_next_str (p, "abc", 14); return; } } @@ -1741,11 +1786,11 @@ Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; - sprintf (parserg->buf, "PARSER%d", parserg->counter); + sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void @@ -1804,45 +1849,52 @@ rde_param_data (p, buf, len); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } + /* See also rde_critcl/m.c, param_COMPLETE() */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) { if (rde_param_query_st (p)) { long int ac; Tcl_Obj** av; rde_param_query_ast (p, &ac, &av); if (ac > 1) { - long int lsc; - long int* lsv; Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); - rde_param_query_ls (p, &lsc, &lsv); - memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); lv [0] = Tcl_NewObj (); - lv [1] = Tcl_NewIntObj (1 + lsv [lsc-1]); + lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); ckfree ((char*) lv); + + } else if (ac == 0) { + /* + * Match, but no AST. This is possible if the grammar + * consists of only the start expression. + */ + Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); } else { Tcl_SetObjResult (interp, av [0]); } return TCL_OK; } else { Tcl_Obj* xv [1]; const ERROR_STATE* er = rde_param_query_er (p); Tcl_Obj* res = rde_param_query_er_tcl (p, er); + /* res = list (location, list(msg)) */ + /* Stick the exception type-tag before the existing elements */ xv [0] = Tcl_NewStringObj ("pt::rde",-1); - Tcl_ListObjReplace(interp, res, 0, 1, 1, xv); + Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); + Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); Tcl_SetObjResult (interp, res); return TCL_ERROR; } } } Index: modules/pt/tests/data/ok/peg_cparam-critcl/6_optional ================================================================== --- modules/pt/tests/data/ok/peg_cparam-critcl/6_optional +++ modules/pt/tests/data/ok/peg_cparam-critcl/6_optional @@ -28,11 +28,11 @@ namespace eval ::PARSER { # # ## ### ##### ######## ############# ##################### ## Supporting code for the main command. catch { - #critcl::cheaders -g + #critcl::cflags -g #critcl::debug memory symbols } # # ## ### ###### ######## ############# ## RDE runtime, inlined, and made static. @@ -384,10 +384,14 @@ int clen; Tcl_UniChar uni; if (len < 0) { len = strlen (string); } + + if (!len) { + return tc->str + base; + } if ((tc->num + len) >= tc->max) { int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); char* str = ckrealloc (tc->str, new * sizeof(char)); ASSERT (str,"Memory allocation failure for token character array"); @@ -413,18 +417,18 @@ } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; - long int* ov; - rde_stack_get (tc->off, &oc, (void***) &ov); + void** ov; + rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); - off = ov [at]; + off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { - end = ov [at+1]; + end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; @@ -432,19 +436,19 @@ } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; - long int* ov; - rde_stack_get (tc->off, &oc, (void***) &ov); + void** ov; + rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); - off = ov [at]; + off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { - end = ov [last+1]; + end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; @@ -479,10 +483,11 @@ typedef int (*UniCharClass) (int); typedef enum test_class_id { tc_alnum, tc_alpha, tc_ascii, + tc_control, tc_ddigit, tc_digit, tc_graph, tc_lower, tc_printable, @@ -492,11 +497,11 @@ tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); - static void error_set (RDE_PARAM p, int s); + static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); @@ -645,13 +650,13 @@ rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void - rde_param_query_amark (RDE_PARAM p, long int* mc, long int** mv) + rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { - rde_stack_get (p->mark, mc, (void***) mv); + rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); @@ -688,25 +693,25 @@ res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; - long int* mv; + void** mv; int lastid; const char* msg; - rde_stack_get (er->msg, &mc, (void***) &mv); + rde_stack_get (er->msg, &mc, &mv); - qsort (mv, mc, sizeof (long int), er_int_compare); + qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); - if (mv [i] == lastid) continue; - lastid = mv [i]; - ASSERT_BOUNDS(mv[i],p->numstr); - msg = p->string [mv[i]]; + if (((long int) mv [i]) == lastid) continue; + lastid = (long int) mv [i]; + ASSERT_BOUNDS((long int) mv[i],p->numstr); + msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } @@ -721,13 +726,18 @@ rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) { rde_stack_get (p->ES, ec, (void***) ev); } SCOPE void - rde_param_query_ls (RDE_PARAM p, long int* lc, long int** lv) + rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) { - rde_stack_get (p->LS, lc, (void***) lv); + rde_stack_get (p->LS, lc, lv); + } + SCOPE long int + rde_param_query_lstop (RDE_PARAM p) + { + (long int) rde_stack_top (p->LS); } SCOPE Tcl_HashTable* rde_param_query_nc (RDE_PARAM p) { return &p->NC; @@ -770,11 +780,11 @@ { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; @@ -783,11 +793,11 @@ rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; @@ -818,12 +828,14 @@ rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void - rde_param_i_error_nonterminal (RDE_PARAM p, int s) + rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { + + return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; error_set (p, s); @@ -872,11 +884,11 @@ { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void - error_set (RDE_PARAM p, int s) + error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; @@ -914,20 +926,21 @@ rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void - rde_param_i_input_next (RDE_PARAM p, int m) + rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); - ASSERT_BOUNDS (p->CC_len, TCL_UTF_MAX); + + ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || @@ -960,11 +973,11 @@ rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int - rde_param_i_symbol_restore (RDE_PARAM p, int s) + rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; @@ -983,11 +996,11 @@ TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void - rde_param_i_symbol_save (RDE_PARAM p, int s) + rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; @@ -1049,11 +1062,16 @@ rde_param_i_test_ascii (RDE_PARAM p) { test_class (p, UniCharIsAscii, tc_ascii); } SCOPE void - rde_param_i_test_char (RDE_PARAM p, char* c, int msg) + rde_param_i_test_control (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsControl, tc_control); + } + SCOPE void + rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); @@ -1091,11 +1109,11 @@ rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void - rde_param_i_test_range (RDE_PARAM p, char* s, char* e, int msg) + rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); @@ -1160,11 +1178,11 @@ rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void - rde_param_i_value_leaf (RDE_PARAM p, int s) + rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); @@ -1174,11 +1192,11 @@ newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void - rde_param_i_value_reduce (RDE_PARAM p, int s) + rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; @@ -1206,18 +1224,21 @@ ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { - long int ai = *((long int*) a); - long int bi = *((long int*) b); - if (ai < bi) { return -1; } - if (ai > bi) { return 1; } + + const void** ael = (const void**) a; + const void** bel = (const void**) b; + long int avalue = (long int) *ael; + long int bvalue = (long int) *bel; + if (avalue < bvalue) { return -1; } + if (avalue > bvalue) { return 1; } return 0; } SCOPE int - rde_param_i_symbol_start (RDE_PARAM p, int s) + rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); @@ -1226,11 +1247,11 @@ } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int - rde_param_i_symbol_start_d (RDE_PARAM p, int s) + rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); @@ -1240,26 +1261,26 @@ rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int - rde_param_i_symbol_void_start (RDE_PARAM p, int s) + rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int - rde_param_i_symbol_void_start_d (RDE_PARAM p, int s) + rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void - rde_param_i_symbol_done_d_reduce (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); @@ -1272,11 +1293,11 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_leaf (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); @@ -1288,11 +1309,11 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_d_leaf (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); @@ -1305,126 +1326,133 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_void (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void - rde_param_i_symbol_done_d_void (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void - rde_param_i_next_char (RDE_PARAM p, char* c, int m) + rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void - rde_param_i_next_range (RDE_PARAM p, char* s, char* e, int m) + rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void - rde_param_i_next_alnum (RDE_PARAM p, int m) + rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void - rde_param_i_next_alpha (RDE_PARAM p, int m) + rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void - rde_param_i_next_ascii (RDE_PARAM p, int m) + rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void - rde_param_i_next_ddigit (RDE_PARAM p, int m) + rde_param_i_next_control (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_control (p); + } + SCOPE void + rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void - rde_param_i_next_digit (RDE_PARAM p, int m) + rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void - rde_param_i_next_graph (RDE_PARAM p, int m) + rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void - rde_param_i_next_lower (RDE_PARAM p, int m) + rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void - rde_param_i_next_print (RDE_PARAM p, int m) + rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void - rde_param_i_next_punct (RDE_PARAM p, int m) + rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void - rde_param_i_next_space (RDE_PARAM p, int m) + rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void - rde_param_i_next_upper (RDE_PARAM p, int m) + rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void - rde_param_i_next_wordchar (RDE_PARAM p, int m) + rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void - rde_param_i_next_xdigit (RDE_PARAM p, int m) + rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } @@ -1501,11 +1529,11 @@ rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } @@ -1569,11 +1597,11 @@ if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } @@ -1612,11 +1640,11 @@ rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; @@ -1628,37 +1656,40 @@ if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void - rde_param_i_next_str (RDE_PARAM p, char* str, int m) + rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; + while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { + p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { + p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void - rde_param_i_next_class (RDE_PARAM p, char* class, int m) + rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; @@ -1689,12 +1720,26 @@ /* * Precomputed table of strings (symbols, error messages, etc.). */ - static char const* p_string [1] = { - /* 0 = */ "t a" + static char const* p_string [15] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "t a" }; /* * Grammar Start Expression */ @@ -1709,11 +1754,11 @@ * ? * 'a' */ rde_param_i_state_push_2 (p); - rde_param_i_next_char (p, "a", 0); + rde_param_i_next_char (p, "a", 14); rde_param_i_state_merge_ok (p); return; } } @@ -1754,11 +1799,11 @@ Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; - sprintf (parserg->buf, "PARSER%d", parserg->counter); + sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void @@ -1817,45 +1862,52 @@ rde_param_data (p, buf, len); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } + /* See also rde_critcl/m.c, param_COMPLETE() */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) { if (rde_param_query_st (p)) { long int ac; Tcl_Obj** av; rde_param_query_ast (p, &ac, &av); if (ac > 1) { - long int lsc; - long int* lsv; Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); - rde_param_query_ls (p, &lsc, &lsv); - memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); lv [0] = Tcl_NewObj (); - lv [1] = Tcl_NewIntObj (1 + lsv [lsc-1]); + lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); ckfree ((char*) lv); + + } else if (ac == 0) { + /* + * Match, but no AST. This is possible if the grammar + * consists of only the start expression. + */ + Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); } else { Tcl_SetObjResult (interp, av [0]); } return TCL_OK; } else { Tcl_Obj* xv [1]; const ERROR_STATE* er = rde_param_query_er (p); Tcl_Obj* res = rde_param_query_er_tcl (p, er); + /* res = list (location, list(msg)) */ + /* Stick the exception type-tag before the existing elements */ xv [0] = Tcl_NewStringObj ("pt::rde",-1); - Tcl_ListObjReplace(interp, res, 0, 1, 1, xv); + Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); + Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); Tcl_SetObjResult (interp, res); return TCL_ERROR; } } } Index: modules/pt/tests/data/ok/peg_cparam-critcl/7_kleene ================================================================== --- modules/pt/tests/data/ok/peg_cparam-critcl/7_kleene +++ modules/pt/tests/data/ok/peg_cparam-critcl/7_kleene @@ -28,11 +28,11 @@ namespace eval ::PARSER { # # ## ### ##### ######## ############# ##################### ## Supporting code for the main command. catch { - #critcl::cheaders -g + #critcl::cflags -g #critcl::debug memory symbols } # # ## ### ###### ######## ############# ## RDE runtime, inlined, and made static. @@ -384,10 +384,14 @@ int clen; Tcl_UniChar uni; if (len < 0) { len = strlen (string); } + + if (!len) { + return tc->str + base; + } if ((tc->num + len) >= tc->max) { int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); char* str = ckrealloc (tc->str, new * sizeof(char)); ASSERT (str,"Memory allocation failure for token character array"); @@ -413,18 +417,18 @@ } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; - long int* ov; - rde_stack_get (tc->off, &oc, (void***) &ov); + void** ov; + rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); - off = ov [at]; + off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { - end = ov [at+1]; + end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; @@ -432,19 +436,19 @@ } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; - long int* ov; - rde_stack_get (tc->off, &oc, (void***) &ov); + void** ov; + rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); - off = ov [at]; + off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { - end = ov [last+1]; + end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; @@ -479,10 +483,11 @@ typedef int (*UniCharClass) (int); typedef enum test_class_id { tc_alnum, tc_alpha, tc_ascii, + tc_control, tc_ddigit, tc_digit, tc_graph, tc_lower, tc_printable, @@ -492,11 +497,11 @@ tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); - static void error_set (RDE_PARAM p, int s); + static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); @@ -645,13 +650,13 @@ rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void - rde_param_query_amark (RDE_PARAM p, long int* mc, long int** mv) + rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { - rde_stack_get (p->mark, mc, (void***) mv); + rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); @@ -688,25 +693,25 @@ res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; - long int* mv; + void** mv; int lastid; const char* msg; - rde_stack_get (er->msg, &mc, (void***) &mv); + rde_stack_get (er->msg, &mc, &mv); - qsort (mv, mc, sizeof (long int), er_int_compare); + qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); - if (mv [i] == lastid) continue; - lastid = mv [i]; - ASSERT_BOUNDS(mv[i],p->numstr); - msg = p->string [mv[i]]; + if (((long int) mv [i]) == lastid) continue; + lastid = (long int) mv [i]; + ASSERT_BOUNDS((long int) mv[i],p->numstr); + msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } @@ -721,13 +726,18 @@ rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) { rde_stack_get (p->ES, ec, (void***) ev); } SCOPE void - rde_param_query_ls (RDE_PARAM p, long int* lc, long int** lv) + rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) { - rde_stack_get (p->LS, lc, (void***) lv); + rde_stack_get (p->LS, lc, lv); + } + SCOPE long int + rde_param_query_lstop (RDE_PARAM p) + { + (long int) rde_stack_top (p->LS); } SCOPE Tcl_HashTable* rde_param_query_nc (RDE_PARAM p) { return &p->NC; @@ -770,11 +780,11 @@ { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; @@ -783,11 +793,11 @@ rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; @@ -818,12 +828,14 @@ rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void - rde_param_i_error_nonterminal (RDE_PARAM p, int s) + rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { + + return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; error_set (p, s); @@ -872,11 +884,11 @@ { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void - error_set (RDE_PARAM p, int s) + error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; @@ -914,20 +926,21 @@ rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void - rde_param_i_input_next (RDE_PARAM p, int m) + rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); - ASSERT_BOUNDS (p->CC_len, TCL_UTF_MAX); + + ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || @@ -960,11 +973,11 @@ rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int - rde_param_i_symbol_restore (RDE_PARAM p, int s) + rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; @@ -983,11 +996,11 @@ TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void - rde_param_i_symbol_save (RDE_PARAM p, int s) + rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; @@ -1049,11 +1062,16 @@ rde_param_i_test_ascii (RDE_PARAM p) { test_class (p, UniCharIsAscii, tc_ascii); } SCOPE void - rde_param_i_test_char (RDE_PARAM p, char* c, int msg) + rde_param_i_test_control (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsControl, tc_control); + } + SCOPE void + rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); @@ -1091,11 +1109,11 @@ rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void - rde_param_i_test_range (RDE_PARAM p, char* s, char* e, int msg) + rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); @@ -1160,11 +1178,11 @@ rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void - rde_param_i_value_leaf (RDE_PARAM p, int s) + rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); @@ -1174,11 +1192,11 @@ newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void - rde_param_i_value_reduce (RDE_PARAM p, int s) + rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; @@ -1206,18 +1224,21 @@ ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { - long int ai = *((long int*) a); - long int bi = *((long int*) b); - if (ai < bi) { return -1; } - if (ai > bi) { return 1; } + + const void** ael = (const void**) a; + const void** bel = (const void**) b; + long int avalue = (long int) *ael; + long int bvalue = (long int) *bel; + if (avalue < bvalue) { return -1; } + if (avalue > bvalue) { return 1; } return 0; } SCOPE int - rde_param_i_symbol_start (RDE_PARAM p, int s) + rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); @@ -1226,11 +1247,11 @@ } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int - rde_param_i_symbol_start_d (RDE_PARAM p, int s) + rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); @@ -1240,26 +1261,26 @@ rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int - rde_param_i_symbol_void_start (RDE_PARAM p, int s) + rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int - rde_param_i_symbol_void_start_d (RDE_PARAM p, int s) + rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void - rde_param_i_symbol_done_d_reduce (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); @@ -1272,11 +1293,11 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_leaf (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); @@ -1288,11 +1309,11 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_d_leaf (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); @@ -1305,126 +1326,133 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_void (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void - rde_param_i_symbol_done_d_void (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void - rde_param_i_next_char (RDE_PARAM p, char* c, int m) + rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void - rde_param_i_next_range (RDE_PARAM p, char* s, char* e, int m) + rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void - rde_param_i_next_alnum (RDE_PARAM p, int m) + rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void - rde_param_i_next_alpha (RDE_PARAM p, int m) + rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void - rde_param_i_next_ascii (RDE_PARAM p, int m) + rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void - rde_param_i_next_ddigit (RDE_PARAM p, int m) + rde_param_i_next_control (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_control (p); + } + SCOPE void + rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void - rde_param_i_next_digit (RDE_PARAM p, int m) + rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void - rde_param_i_next_graph (RDE_PARAM p, int m) + rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void - rde_param_i_next_lower (RDE_PARAM p, int m) + rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void - rde_param_i_next_print (RDE_PARAM p, int m) + rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void - rde_param_i_next_punct (RDE_PARAM p, int m) + rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void - rde_param_i_next_space (RDE_PARAM p, int m) + rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void - rde_param_i_next_upper (RDE_PARAM p, int m) + rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void - rde_param_i_next_wordchar (RDE_PARAM p, int m) + rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void - rde_param_i_next_xdigit (RDE_PARAM p, int m) + rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } @@ -1501,11 +1529,11 @@ rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } @@ -1569,11 +1597,11 @@ if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } @@ -1612,11 +1640,11 @@ rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; @@ -1628,37 +1656,40 @@ if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void - rde_param_i_next_str (RDE_PARAM p, char* str, int m) + rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; + while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { + p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { + p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void - rde_param_i_next_class (RDE_PARAM p, char* class, int m) + rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; @@ -1689,12 +1720,26 @@ /* * Precomputed table of strings (symbols, error messages, etc.). */ - static char const* p_string [1] = { - /* 0 = */ "t a" + static char const* p_string [15] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "t a" }; /* * Grammar Start Expression */ @@ -1710,11 +1755,11 @@ * 'a' */ while (1) { rde_param_i_state_push_2 (p); - rde_param_i_next_char (p, "a", 0); + rde_param_i_next_char (p, "a", 14); if (rde_param_i_kleene_close(p)) return; } return; } @@ -1756,11 +1801,11 @@ Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; - sprintf (parserg->buf, "PARSER%d", parserg->counter); + sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void @@ -1819,45 +1864,52 @@ rde_param_data (p, buf, len); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } + /* See also rde_critcl/m.c, param_COMPLETE() */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) { if (rde_param_query_st (p)) { long int ac; Tcl_Obj** av; rde_param_query_ast (p, &ac, &av); if (ac > 1) { - long int lsc; - long int* lsv; Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); - rde_param_query_ls (p, &lsc, &lsv); - memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); lv [0] = Tcl_NewObj (); - lv [1] = Tcl_NewIntObj (1 + lsv [lsc-1]); + lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); ckfree ((char*) lv); + + } else if (ac == 0) { + /* + * Match, but no AST. This is possible if the grammar + * consists of only the start expression. + */ + Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); } else { Tcl_SetObjResult (interp, av [0]); } return TCL_OK; } else { Tcl_Obj* xv [1]; const ERROR_STATE* er = rde_param_query_er (p); Tcl_Obj* res = rde_param_query_er_tcl (p, er); + /* res = list (location, list(msg)) */ + /* Stick the exception type-tag before the existing elements */ xv [0] = Tcl_NewStringObj ("pt::rde",-1); - Tcl_ListObjReplace(interp, res, 0, 1, 1, xv); + Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); + Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); Tcl_SetObjResult (interp, res); return TCL_ERROR; } } } Index: modules/pt/tests/data/ok/peg_cparam-critcl/8_pkleene ================================================================== --- modules/pt/tests/data/ok/peg_cparam-critcl/8_pkleene +++ modules/pt/tests/data/ok/peg_cparam-critcl/8_pkleene @@ -28,11 +28,11 @@ namespace eval ::PARSER { # # ## ### ##### ######## ############# ##################### ## Supporting code for the main command. catch { - #critcl::cheaders -g + #critcl::cflags -g #critcl::debug memory symbols } # # ## ### ###### ######## ############# ## RDE runtime, inlined, and made static. @@ -384,10 +384,14 @@ int clen; Tcl_UniChar uni; if (len < 0) { len = strlen (string); } + + if (!len) { + return tc->str + base; + } if ((tc->num + len) >= tc->max) { int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); char* str = ckrealloc (tc->str, new * sizeof(char)); ASSERT (str,"Memory allocation failure for token character array"); @@ -413,18 +417,18 @@ } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; - long int* ov; - rde_stack_get (tc->off, &oc, (void***) &ov); + void** ov; + rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); - off = ov [at]; + off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { - end = ov [at+1]; + end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; @@ -432,19 +436,19 @@ } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; - long int* ov; - rde_stack_get (tc->off, &oc, (void***) &ov); + void** ov; + rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); - off = ov [at]; + off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { - end = ov [last+1]; + end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; @@ -479,10 +483,11 @@ typedef int (*UniCharClass) (int); typedef enum test_class_id { tc_alnum, tc_alpha, tc_ascii, + tc_control, tc_ddigit, tc_digit, tc_graph, tc_lower, tc_printable, @@ -492,11 +497,11 @@ tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); - static void error_set (RDE_PARAM p, int s); + static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); @@ -645,13 +650,13 @@ rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void - rde_param_query_amark (RDE_PARAM p, long int* mc, long int** mv) + rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { - rde_stack_get (p->mark, mc, (void***) mv); + rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); @@ -688,25 +693,25 @@ res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; - long int* mv; + void** mv; int lastid; const char* msg; - rde_stack_get (er->msg, &mc, (void***) &mv); + rde_stack_get (er->msg, &mc, &mv); - qsort (mv, mc, sizeof (long int), er_int_compare); + qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); - if (mv [i] == lastid) continue; - lastid = mv [i]; - ASSERT_BOUNDS(mv[i],p->numstr); - msg = p->string [mv[i]]; + if (((long int) mv [i]) == lastid) continue; + lastid = (long int) mv [i]; + ASSERT_BOUNDS((long int) mv[i],p->numstr); + msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } @@ -721,13 +726,18 @@ rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) { rde_stack_get (p->ES, ec, (void***) ev); } SCOPE void - rde_param_query_ls (RDE_PARAM p, long int* lc, long int** lv) + rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) { - rde_stack_get (p->LS, lc, (void***) lv); + rde_stack_get (p->LS, lc, lv); + } + SCOPE long int + rde_param_query_lstop (RDE_PARAM p) + { + (long int) rde_stack_top (p->LS); } SCOPE Tcl_HashTable* rde_param_query_nc (RDE_PARAM p) { return &p->NC; @@ -770,11 +780,11 @@ { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; @@ -783,11 +793,11 @@ rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; @@ -818,12 +828,14 @@ rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void - rde_param_i_error_nonterminal (RDE_PARAM p, int s) + rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { + + return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; error_set (p, s); @@ -872,11 +884,11 @@ { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void - error_set (RDE_PARAM p, int s) + error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; @@ -914,20 +926,21 @@ rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void - rde_param_i_input_next (RDE_PARAM p, int m) + rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); - ASSERT_BOUNDS (p->CC_len, TCL_UTF_MAX); + + ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || @@ -960,11 +973,11 @@ rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int - rde_param_i_symbol_restore (RDE_PARAM p, int s) + rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; @@ -983,11 +996,11 @@ TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void - rde_param_i_symbol_save (RDE_PARAM p, int s) + rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; @@ -1049,11 +1062,16 @@ rde_param_i_test_ascii (RDE_PARAM p) { test_class (p, UniCharIsAscii, tc_ascii); } SCOPE void - rde_param_i_test_char (RDE_PARAM p, char* c, int msg) + rde_param_i_test_control (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsControl, tc_control); + } + SCOPE void + rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); @@ -1091,11 +1109,11 @@ rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void - rde_param_i_test_range (RDE_PARAM p, char* s, char* e, int msg) + rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); @@ -1160,11 +1178,11 @@ rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void - rde_param_i_value_leaf (RDE_PARAM p, int s) + rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); @@ -1174,11 +1192,11 @@ newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void - rde_param_i_value_reduce (RDE_PARAM p, int s) + rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; @@ -1206,18 +1224,21 @@ ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { - long int ai = *((long int*) a); - long int bi = *((long int*) b); - if (ai < bi) { return -1; } - if (ai > bi) { return 1; } + + const void** ael = (const void**) a; + const void** bel = (const void**) b; + long int avalue = (long int) *ael; + long int bvalue = (long int) *bel; + if (avalue < bvalue) { return -1; } + if (avalue > bvalue) { return 1; } return 0; } SCOPE int - rde_param_i_symbol_start (RDE_PARAM p, int s) + rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); @@ -1226,11 +1247,11 @@ } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int - rde_param_i_symbol_start_d (RDE_PARAM p, int s) + rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); @@ -1240,26 +1261,26 @@ rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int - rde_param_i_symbol_void_start (RDE_PARAM p, int s) + rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int - rde_param_i_symbol_void_start_d (RDE_PARAM p, int s) + rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void - rde_param_i_symbol_done_d_reduce (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); @@ -1272,11 +1293,11 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_leaf (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); @@ -1288,11 +1309,11 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_d_leaf (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); @@ -1305,126 +1326,133 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_void (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void - rde_param_i_symbol_done_d_void (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void - rde_param_i_next_char (RDE_PARAM p, char* c, int m) + rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void - rde_param_i_next_range (RDE_PARAM p, char* s, char* e, int m) + rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void - rde_param_i_next_alnum (RDE_PARAM p, int m) + rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void - rde_param_i_next_alpha (RDE_PARAM p, int m) + rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void - rde_param_i_next_ascii (RDE_PARAM p, int m) + rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void - rde_param_i_next_ddigit (RDE_PARAM p, int m) + rde_param_i_next_control (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_control (p); + } + SCOPE void + rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void - rde_param_i_next_digit (RDE_PARAM p, int m) + rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void - rde_param_i_next_graph (RDE_PARAM p, int m) + rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void - rde_param_i_next_lower (RDE_PARAM p, int m) + rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void - rde_param_i_next_print (RDE_PARAM p, int m) + rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void - rde_param_i_next_punct (RDE_PARAM p, int m) + rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void - rde_param_i_next_space (RDE_PARAM p, int m) + rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void - rde_param_i_next_upper (RDE_PARAM p, int m) + rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void - rde_param_i_next_wordchar (RDE_PARAM p, int m) + rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void - rde_param_i_next_xdigit (RDE_PARAM p, int m) + rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } @@ -1501,11 +1529,11 @@ rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } @@ -1569,11 +1597,11 @@ if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } @@ -1612,11 +1640,11 @@ rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; @@ -1628,37 +1656,40 @@ if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void - rde_param_i_next_str (RDE_PARAM p, char* str, int m) + rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; + while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { + p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { + p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void - rde_param_i_next_class (RDE_PARAM p, char* class, int m) + rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; @@ -1689,12 +1720,26 @@ /* * Precomputed table of strings (symbols, error messages, etc.). */ - static char const* p_string [1] = { - /* 0 = */ "t a" + static char const* p_string [15] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "t a" }; /* * Grammar Start Expression */ @@ -1709,15 +1754,15 @@ * + * 'a' */ rde_param_i_loc_push (p); - rde_param_i_next_char (p, "a", 0); + rde_param_i_next_char (p, "a", 14); if (rde_param_i_kleene_abort(p)) return; while (1) { rde_param_i_state_push_2 (p); - rde_param_i_next_char (p, "a", 0); + rde_param_i_next_char (p, "a", 14); if (rde_param_i_kleene_close(p)) return; } return; } @@ -1759,11 +1804,11 @@ Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; - sprintf (parserg->buf, "PARSER%d", parserg->counter); + sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void @@ -1822,45 +1867,52 @@ rde_param_data (p, buf, len); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } + /* See also rde_critcl/m.c, param_COMPLETE() */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) { if (rde_param_query_st (p)) { long int ac; Tcl_Obj** av; rde_param_query_ast (p, &ac, &av); if (ac > 1) { - long int lsc; - long int* lsv; Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); - rde_param_query_ls (p, &lsc, &lsv); - memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); lv [0] = Tcl_NewObj (); - lv [1] = Tcl_NewIntObj (1 + lsv [lsc-1]); + lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); ckfree ((char*) lv); + + } else if (ac == 0) { + /* + * Match, but no AST. This is possible if the grammar + * consists of only the start expression. + */ + Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); } else { Tcl_SetObjResult (interp, av [0]); } return TCL_OK; } else { Tcl_Obj* xv [1]; const ERROR_STATE* er = rde_param_query_er (p); Tcl_Obj* res = rde_param_query_er_tcl (p, er); + /* res = list (location, list(msg)) */ + /* Stick the exception type-tag before the existing elements */ xv [0] = Tcl_NewStringObj ("pt::rde",-1); - Tcl_ListObjReplace(interp, res, 0, 1, 1, xv); + Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); + Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); Tcl_SetObjResult (interp, res); return TCL_ERROR; } } } Index: modules/pt/tests/data/ok/peg_cparam-critcl/9_ahead ================================================================== --- modules/pt/tests/data/ok/peg_cparam-critcl/9_ahead +++ modules/pt/tests/data/ok/peg_cparam-critcl/9_ahead @@ -28,11 +28,11 @@ namespace eval ::PARSER { # # ## ### ##### ######## ############# ##################### ## Supporting code for the main command. catch { - #critcl::cheaders -g + #critcl::cflags -g #critcl::debug memory symbols } # # ## ### ###### ######## ############# ## RDE runtime, inlined, and made static. @@ -384,10 +384,14 @@ int clen; Tcl_UniChar uni; if (len < 0) { len = strlen (string); } + + if (!len) { + return tc->str + base; + } if ((tc->num + len) >= tc->max) { int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); char* str = ckrealloc (tc->str, new * sizeof(char)); ASSERT (str,"Memory allocation failure for token character array"); @@ -413,18 +417,18 @@ } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; - long int* ov; - rde_stack_get (tc->off, &oc, (void***) &ov); + void** ov; + rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); - off = ov [at]; + off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { - end = ov [at+1]; + end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; @@ -432,19 +436,19 @@ } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; - long int* ov; - rde_stack_get (tc->off, &oc, (void***) &ov); + void** ov; + rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); - off = ov [at]; + off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { - end = ov [last+1]; + end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; @@ -479,10 +483,11 @@ typedef int (*UniCharClass) (int); typedef enum test_class_id { tc_alnum, tc_alpha, tc_ascii, + tc_control, tc_ddigit, tc_digit, tc_graph, tc_lower, tc_printable, @@ -492,11 +497,11 @@ tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); - static void error_set (RDE_PARAM p, int s); + static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); @@ -645,13 +650,13 @@ rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void - rde_param_query_amark (RDE_PARAM p, long int* mc, long int** mv) + rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { - rde_stack_get (p->mark, mc, (void***) mv); + rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); @@ -688,25 +693,25 @@ res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; - long int* mv; + void** mv; int lastid; const char* msg; - rde_stack_get (er->msg, &mc, (void***) &mv); + rde_stack_get (er->msg, &mc, &mv); - qsort (mv, mc, sizeof (long int), er_int_compare); + qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); - if (mv [i] == lastid) continue; - lastid = mv [i]; - ASSERT_BOUNDS(mv[i],p->numstr); - msg = p->string [mv[i]]; + if (((long int) mv [i]) == lastid) continue; + lastid = (long int) mv [i]; + ASSERT_BOUNDS((long int) mv[i],p->numstr); + msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } @@ -721,13 +726,18 @@ rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) { rde_stack_get (p->ES, ec, (void***) ev); } SCOPE void - rde_param_query_ls (RDE_PARAM p, long int* lc, long int** lv) + rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) { - rde_stack_get (p->LS, lc, (void***) lv); + rde_stack_get (p->LS, lc, lv); + } + SCOPE long int + rde_param_query_lstop (RDE_PARAM p) + { + (long int) rde_stack_top (p->LS); } SCOPE Tcl_HashTable* rde_param_query_nc (RDE_PARAM p) { return &p->NC; @@ -770,11 +780,11 @@ { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; @@ -783,11 +793,11 @@ rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; @@ -818,12 +828,14 @@ rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void - rde_param_i_error_nonterminal (RDE_PARAM p, int s) + rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { + + return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; error_set (p, s); @@ -872,11 +884,11 @@ { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void - error_set (RDE_PARAM p, int s) + error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; @@ -914,20 +926,21 @@ rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void - rde_param_i_input_next (RDE_PARAM p, int m) + rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); - ASSERT_BOUNDS (p->CC_len, TCL_UTF_MAX); + + ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || @@ -960,11 +973,11 @@ rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int - rde_param_i_symbol_restore (RDE_PARAM p, int s) + rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; @@ -983,11 +996,11 @@ TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void - rde_param_i_symbol_save (RDE_PARAM p, int s) + rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; @@ -1049,11 +1062,16 @@ rde_param_i_test_ascii (RDE_PARAM p) { test_class (p, UniCharIsAscii, tc_ascii); } SCOPE void - rde_param_i_test_char (RDE_PARAM p, char* c, int msg) + rde_param_i_test_control (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsControl, tc_control); + } + SCOPE void + rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); @@ -1091,11 +1109,11 @@ rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void - rde_param_i_test_range (RDE_PARAM p, char* s, char* e, int msg) + rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); @@ -1160,11 +1178,11 @@ rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void - rde_param_i_value_leaf (RDE_PARAM p, int s) + rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); @@ -1174,11 +1192,11 @@ newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void - rde_param_i_value_reduce (RDE_PARAM p, int s) + rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; @@ -1206,18 +1224,21 @@ ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { - long int ai = *((long int*) a); - long int bi = *((long int*) b); - if (ai < bi) { return -1; } - if (ai > bi) { return 1; } + + const void** ael = (const void**) a; + const void** bel = (const void**) b; + long int avalue = (long int) *ael; + long int bvalue = (long int) *bel; + if (avalue < bvalue) { return -1; } + if (avalue > bvalue) { return 1; } return 0; } SCOPE int - rde_param_i_symbol_start (RDE_PARAM p, int s) + rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); @@ -1226,11 +1247,11 @@ } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int - rde_param_i_symbol_start_d (RDE_PARAM p, int s) + rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); @@ -1240,26 +1261,26 @@ rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int - rde_param_i_symbol_void_start (RDE_PARAM p, int s) + rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int - rde_param_i_symbol_void_start_d (RDE_PARAM p, int s) + rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void - rde_param_i_symbol_done_d_reduce (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); @@ -1272,11 +1293,11 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_leaf (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); @@ -1288,11 +1309,11 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_d_leaf (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); @@ -1305,126 +1326,133 @@ rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void - rde_param_i_symbol_done_void (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void - rde_param_i_symbol_done_d_void (RDE_PARAM p, int s, int m) + rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void - rde_param_i_next_char (RDE_PARAM p, char* c, int m) + rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void - rde_param_i_next_range (RDE_PARAM p, char* s, char* e, int m) + rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void - rde_param_i_next_alnum (RDE_PARAM p, int m) + rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void - rde_param_i_next_alpha (RDE_PARAM p, int m) + rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void - rde_param_i_next_ascii (RDE_PARAM p, int m) + rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void - rde_param_i_next_ddigit (RDE_PARAM p, int m) + rde_param_i_next_control (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_control (p); + } + SCOPE void + rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void - rde_param_i_next_digit (RDE_PARAM p, int m) + rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void - rde_param_i_next_graph (RDE_PARAM p, int m) + rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void - rde_param_i_next_lower (RDE_PARAM p, int m) + rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void - rde_param_i_next_print (RDE_PARAM p, int m) + rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void - rde_param_i_next_punct (RDE_PARAM p, int m) + rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void - rde_param_i_next_space (RDE_PARAM p, int m) + rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void - rde_param_i_next_upper (RDE_PARAM p, int m) + rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void - rde_param_i_next_wordchar (RDE_PARAM p, int m) + rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void - rde_param_i_next_xdigit (RDE_PARAM p, int m) + rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } @@ -1501,11 +1529,11 @@ rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } @@ -1569,11 +1597,11 @@ if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } @@ -1612,11 +1640,11 @@ rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; @@ -1628,37 +1656,40 @@ if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); - rde_stack_trim (p->ast, (int) trim); + rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void - rde_param_i_next_str (RDE_PARAM p, char* str, int m) + rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; + while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { + p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { + p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void - rde_param_i_next_class (RDE_PARAM p, char* class, int m) + rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; @@ -1691,14 +1722,28 @@ /* * Precomputed table of strings (symbols, error messages, etc.). */ - static char const* p_string [3] = { - /* 0 = */ "t a", - /* 1 = */ "n TEST", - /* 2 = */ "TEST" + static char const* p_string [17] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "t a", + /* 15 = */ "n TEST", + /* 16 = */ "TEST" }; /* * Grammar Start Expression */ @@ -1718,13 +1763,13 @@ * & * 'a' * (IDENTIFIER) */ - if (rde_param_i_symbol_start (p, 2)) return ; + if (rde_param_i_symbol_start (p, 16)) return ; sequence_6 (p); - rde_param_i_symbol_done_leaf (p, 2, 1); + rde_param_i_symbol_done_leaf (p, 16, 15); return; } static void sequence_6 (RDE_PARAM p) { /* @@ -1748,11 +1793,11 @@ * & * 'a' */ rde_param_i_loc_push (p); - rde_param_i_next_char (p, "a", 0); + rde_param_i_next_char (p, "a", 14); rde_param_i_loc_pop_rewind (p); return; } } @@ -1793,11 +1838,11 @@ Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; - sprintf (parserg->buf, "PARSER%d", parserg->counter); + sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void @@ -1856,45 +1901,52 @@ rde_param_data (p, buf, len); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } + /* See also rde_critcl/m.c, param_COMPLETE() */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) { if (rde_param_query_st (p)) { long int ac; Tcl_Obj** av; rde_param_query_ast (p, &ac, &av); if (ac > 1) { - long int lsc; - long int* lsv; Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); - rde_param_query_ls (p, &lsc, &lsv); - memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); lv [0] = Tcl_NewObj (); - lv [1] = Tcl_NewIntObj (1 + lsv [lsc-1]); + lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); ckfree ((char*) lv); + + } else if (ac == 0) { + /* + * Match, but no AST. This is possible if the grammar + * consists of only the start expression. + */ + Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); } else { Tcl_SetObjResult (interp, av [0]); } return TCL_OK; } else { Tcl_Obj* xv [1]; const ERROR_STATE* er = rde_param_query_er (p); Tcl_Obj* res = rde_param_query_er_tcl (p, er); + /* res = list (location, list(msg)) */ + /* Stick the exception type-tag before the existing elements */ xv [0] = Tcl_NewStringObj ("pt::rde",-1); - Tcl_ListObjReplace(interp, res, 0, 1, 1, xv); + Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); + Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); Tcl_SetObjResult (interp, res); return TCL_ERROR; } } } ADDED modules/pt/tests/data/ok/peg_cparam-tea/0_basic_arithmetic Index: modules/pt/tests/data/ok/peg_cparam-tea/0_basic_arithmetic ================================================================== --- /dev/null +++ modules/pt/tests/data/ok/peg_cparam-tea/0_basic_arithmetic @@ -0,0 +1,2349 @@ +/************************************************************ +** +** TEA-based C/PARAM implementation of the parsing +** expression grammar +** +** TEMPLATE +** +** Generated from file TEST +** for user unknown +** +* * ** *** ***** ******** ************* *********************/ + #include + #include + #include + #include + #define SCOPE static + +#line 1 "rde_critcl/util.h" + + #ifndef _RDE_UTIL_H + #define _RDE_UTIL_H 1 + #ifndef SCOPE + #define SCOPE + #endif + #define ALLOC(type) (type *) ckalloc (sizeof (type)) + #define NALLOC(n,type) (type *) ckalloc ((n) * sizeof (type)) + #undef RDE_DEBUG + #define RDE_DEBUG 1 + #undef RDE_TRACE + #ifdef RDE_DEBUG + #define STOPAFTER(x) { static int count = (x); count --; if (!count) { Tcl_Panic ("stop"); } } + #define XSTR(x) #x + #define STR(x) XSTR(x) + #define RANGEOK(i,n) ((0 <= (i)) && (i < (n))) + #define ASSERT(x,msg) if (!(x)) { Tcl_Panic (msg " (" #x "), in file " __FILE__ " @line " STR(__LINE__));} + #define ASSERT_BOUNDS(i,n) ASSERT (RANGEOK(i,n),"array index out of bounds: " STR(i) " >= " STR(n)) + #else + #define STOPAFTER(x) + #define ASSERT(x,msg) + #define ASSERT_BOUNDS(i,n) + #endif + #ifdef RDE_TRACE + SCOPE void trace_enter (const char* fun); + SCOPE void trace_return (const char *pat, ...); + SCOPE void trace_printf (const char *pat, ...); + #define ENTER(fun) trace_enter (fun) + #define RETURN(format,x) trace_return (format,x) ; return x + #define RETURNVOID trace_return ("%s","(void)") ; return + #define TRACE0(x) trace_printf0 x + #define TRACE(x) trace_printf x + #else + #define ENTER(fun) + #define RETURN(f,x) return x + #define RETURNVOID return + #define TRACE0(x) + #define TRACE(x) + #endif + #endif + + +#line 1 "rde_critcl/stack.h" + + #ifndef _RDE_DS_STACK_H + #define _RDE_DS_STACK_H 1 + typedef void (*RDE_STACK_CELL_FREE) (void* cell); + typedef struct RDE_STACK_* RDE_STACK; + static const int RDE_STACK_INITIAL_SIZE = 256; + #endif + + +#line 1 "rde_critcl/tc.h" + + #ifndef _RDE_DS_TC_H + #define _RDE_DS_TC_H 1 + typedef struct RDE_TC_* RDE_TC; + #endif + + +#line 1 "rde_critcl/param.h" + + #ifndef _RDE_DS_PARAM_H + #define _RDE_DS_PARAM_H 1 + typedef struct RDE_PARAM_* RDE_PARAM; + typedef struct ERROR_STATE { + int refCount; + long int loc; + RDE_STACK msg; + } ERROR_STATE; + typedef struct NC_STATE { + long int CL; + long int ST; + Tcl_Obj* SV; + ERROR_STATE* ER; + } NC_STATE; + #endif + + +#line 1 "rde_critcl/util.c" + + #ifdef RDE_TRACE + typedef struct F_STACK { + const char* str; + struct F_STACK* down; + } F_STACK; + static F_STACK* top = 0; + static int level = 0; + static void + push (const char* str) + { + F_STACK* new = ALLOC (F_STACK); + new->str = str; + new->down = top; + top = new; + level += 4; + } + static void + pop (void) + { + F_STACK* next = top->down; + level -= 4; + ckfree ((char*)top); + top = next; + } + static void + indent (void) + { + int i; + for (i = 0; i < level; i++) { + fwrite(" ", 1, 1, stdout); + fflush (stdout); + } + if (top) { + fwrite(top->str, 1, strlen(top->str), stdout); + fflush (stdout); + } + fwrite(" ", 1, 1, stdout); + fflush (stdout); + } + SCOPE void + trace_enter (const char* fun) + { + push (fun); + indent(); + fwrite("ENTER\n", 1, 6, stdout); + fflush (stdout); + } + static char msg [1024*1024]; + SCOPE void + trace_return (const char *pat, ...) + { + int len; + va_list args; + indent(); + fwrite("RETURN = ", 1, 9, stdout); + fflush (stdout); + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + pop(); + } + SCOPE void + trace_printf (const char *pat, ...) + { + int len; + va_list args; + indent(); + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + } + SCOPE void + trace_printf0 (const char *pat, ...) + { + int len; + va_list args; + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + } + #endif + + +#line 1 "rde_critcl/stack.c" + + typedef struct RDE_STACK_ { + long int max; + long int top; + RDE_STACK_CELL_FREE freeCellProc; + void** cell; + } RDE_STACK_; + + SCOPE RDE_STACK + rde_stack_new (RDE_STACK_CELL_FREE freeCellProc) + { + RDE_STACK s = ALLOC (RDE_STACK_); + s->cell = NALLOC (RDE_STACK_INITIAL_SIZE, void*); + s->max = RDE_STACK_INITIAL_SIZE; + s->top = 0; + s->freeCellProc = freeCellProc; + return s; + } + SCOPE void + rde_stack_del (RDE_STACK s) + { + if (s->freeCellProc && s->top) { + long int i; + for (i=0; i < s->top; i++) { + ASSERT_BOUNDS(i,s->max); + s->freeCellProc ( s->cell [i] ); + } + } + ckfree ((char*) s->cell); + ckfree ((char*) s); + } + SCOPE void + rde_stack_push (RDE_STACK s, void* item) + { + if (s->top >= s->max) { + long int new = s->max ? (2 * s->max) : RDE_STACK_INITIAL_SIZE; + void** cell = (void**) ckrealloc ((char*) s->cell, new * sizeof(void*)); + ASSERT (cell,"Memory allocation failure for RDE stack"); + s->max = new; + s->cell = cell; + } + ASSERT_BOUNDS(s->top,s->max); + s->cell [s->top] = item; + s->top ++; + } + SCOPE void* + rde_stack_top (RDE_STACK s) + { + ASSERT_BOUNDS(s->top-1,s->max); + return s->cell [s->top - 1]; + } + SCOPE void + rde_stack_pop (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad pop count"); + if (n == 0) return; + if (s->freeCellProc) { + while (n) { + s->top --; + ASSERT_BOUNDS(s->top,s->max); + s->freeCellProc ( s->cell [s->top] ); + n --; + } + } else { + s->top -= n; + } + } + SCOPE void + rde_stack_trim (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad trimsize"); + if (s->freeCellProc) { + while (s->top > n) { + s->top --; + ASSERT_BOUNDS(s->top,s->max); + s->freeCellProc ( s->cell [s->top] ); + } + } else { + s->top = n; + } + } + SCOPE void + rde_stack_drop (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad pop count"); + if (n == 0) return; + s->top -= n; + } + SCOPE void + rde_stack_move (RDE_STACK dst, RDE_STACK src) + { + ASSERT (dst->freeCellProc == src->freeCellProc, "Ownership mismatch"); + + while (src->top > 0) { + src->top --; + ASSERT_BOUNDS(src->top,src->max); + rde_stack_push (dst, src->cell [src->top] ); + } + } + SCOPE void + rde_stack_get (RDE_STACK s, long int* cn, void*** cc) + { + *cn = s->top; + *cc = s->cell; + } + SCOPE long int + rde_stack_size (RDE_STACK s) + { + return s->top; + } + + +#line 1 "rde_critcl/tc.c" + + typedef struct RDE_TC_ { + int max; + int num; + char* str; + RDE_STACK off; + } RDE_TC_; + + SCOPE RDE_TC + rde_tc_new (void) + { + RDE_TC tc = ALLOC (RDE_TC_); + tc->max = RDE_STACK_INITIAL_SIZE; + tc->num = 0; + tc->str = NALLOC (RDE_STACK_INITIAL_SIZE, char); + tc->off = rde_stack_new (NULL); + return tc; + } + SCOPE void + rde_tc_del (RDE_TC tc) + { + rde_stack_del (tc->off); + ckfree (tc->str); + ckfree ((char*) tc); + } + SCOPE long int + rde_tc_size (RDE_TC tc) + { + return rde_stack_size (tc->off); + } + SCOPE void + rde_tc_clear (RDE_TC tc) + { + tc->num = 0; + rde_stack_trim (tc->off, 0); + } + SCOPE char* + rde_tc_append (RDE_TC tc, char* string, long int len) + { + long int base = tc->num; + long int off = tc->num; + char* ch; + int clen; + Tcl_UniChar uni; + if (len < 0) { + len = strlen (string); + } + + if (!len) { + return tc->str + base; + } + + if ((tc->num + len) >= tc->max) { + int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); + char* str = ckrealloc (tc->str, new * sizeof(char)); + ASSERT (str,"Memory allocation failure for token character array"); + tc->max = new; + tc->str = str; + } + tc->num += len; + ASSERT_BOUNDS(tc->num,tc->max); + ASSERT_BOUNDS(off,tc->max); + ASSERT_BOUNDS(off+len-1,tc->max); + ASSERT_BOUNDS(off+len-1,tc->num); + memcpy (tc->str + off, string, len); + + ch = string; + while (ch < (string + len)) { + ASSERT_BOUNDS(off,tc->num); + rde_stack_push (tc->off, (void*) off); + clen = Tcl_UtfToUniChar (ch, &uni); + off += clen; + ch += clen; + } + return tc->str + base; + } + SCOPE void + rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) + { + long int oc, off, top, end; + void** ov; + rde_stack_get (tc->off, &oc, &ov); + ASSERT_BOUNDS(at,oc); + off = (long int) ov [at]; + if ((at+1) == oc) { + end = tc->num; + } else { + end = (long int) ov [at+1]; + } + TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); + ASSERT_BOUNDS(off,tc->num); + ASSERT_BOUNDS(end-1,tc->num); + *ch = tc->str + off; + *len = end - off; + } + SCOPE void + rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) + { + long int oc, off, top, end; + void** ov; + rde_stack_get (tc->off, &oc, &ov); + ASSERT_BOUNDS(at,oc); + ASSERT_BOUNDS(last,oc); + off = (long int) ov [at]; + if ((last+1) == oc) { + end = tc->num; + } else { + end = (long int) ov [last+1]; + } + TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); + ASSERT_BOUNDS(off,tc->num); + ASSERT_BOUNDS(end-1,tc->num); + *ch = tc->str + off; + *len = end - off; + } + + +#line 1 "rde_critcl/param.c" + + typedef struct RDE_PARAM_ { + Tcl_Channel IN; + Tcl_Obj* readbuf; + char* CC; + long int CC_len; + RDE_TC TC; + long int CL; + RDE_STACK LS; + ERROR_STATE* ER; + RDE_STACK ES; + long int ST; + Tcl_Obj* SV; + Tcl_HashTable NC; + + RDE_STACK ast ; + RDE_STACK mark ; + + long int numstr; + char** string; + + ClientData clientData; + } RDE_PARAM_; + typedef int (*UniCharClass) (int); + typedef enum test_class_id { + tc_alnum, + tc_alpha, + tc_ascii, + tc_control, + tc_ddigit, + tc_digit, + tc_graph, + tc_lower, + tc_printable, + tc_punct, + tc_space, + tc_upper, + tc_wordchar, + tc_xdigit + } test_class_id; + static void ast_node_free (void* n); + static void error_state_free (void* es); + static void error_set (RDE_PARAM p, long int s); + static void nc_clear (RDE_PARAM p); + static int UniCharIsAscii (int character); + static int UniCharIsHexDigit (int character); + static int UniCharIsDecDigit (int character); + static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); + static int er_int_compare (const void* a, const void* b); + #define SV_INIT(p) \ + p->SV = NULL; \ + TRACE (("SV_INIT (%p => %p)", (p), (p)->SV)) + #define SV_SET(p,newsv) \ + if (((p)->SV) != (newsv)) { \ + TRACE (("SV_CLEAR/set (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_DecrRefCount ((p)->SV); \ + } \ + (p)->SV = (newsv); \ + TRACE (("SV_SET (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_IncrRefCount ((p)->SV); \ + } \ + } + #define SV_CLEAR(p) \ + TRACE (("SV_CLEAR (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_DecrRefCount ((p)->SV); \ + } \ + (p)->SV = NULL + #define ER_INIT(p) \ + p->ER = NULL; \ + TRACE (("ER_INIT (%p => %p)", (p), (p)->ER)) + #define ER_CLEAR(p) \ + error_state_free ((p)->ER); \ + (p)->ER = NULL + SCOPE RDE_PARAM + rde_param_new (long int nstr, char** strings) + { + RDE_PARAM p; + ENTER ("rde_param_new"); + TRACE (("\tINT %d strings @ %p", nstr, strings)); + p = ALLOC (RDE_PARAM_); + p->numstr = nstr; + p->string = strings; + p->readbuf = Tcl_NewObj (); + Tcl_IncrRefCount (p->readbuf); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + Tcl_InitHashTable (&p->NC, TCL_ONE_WORD_KEYS); + p->IN = NULL; + p->CL = -1; + p->ST = 0; + ER_INIT (p); + SV_INIT (p); + p->CC = NULL; + p->CC_len = 0; + p->TC = rde_tc_new (); + p->ES = rde_stack_new (error_state_free); + p->LS = rde_stack_new (NULL); + p->ast = rde_stack_new (ast_node_free); + p->mark = rde_stack_new (NULL); + RETURN ("%p", p); + } + SCOPE void + rde_param_del (RDE_PARAM p) + { + ENTER ("rde_param_del"); + TRACE (("RDE_PARAM %p",p)); + ER_CLEAR (p); TRACE (("\ter_clear")); + SV_CLEAR (p); TRACE (("\tsv_clear")); + nc_clear (p); TRACE (("\tnc_clear")); + Tcl_DeleteHashTable (&p->NC); TRACE (("\tnc hashtable delete")); + rde_tc_del (p->TC); TRACE (("\ttc clear")); + rde_stack_del (p->ES); TRACE (("\tes clear")); + rde_stack_del (p->LS); TRACE (("\tls clear")); + rde_stack_del (p->ast); TRACE (("\tast clear")); + rde_stack_del (p->mark); TRACE (("\tmark clear")); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + Tcl_DecrRefCount (p->readbuf); + ckfree ((char*) p); + RETURNVOID; + } + SCOPE void + rde_param_reset (RDE_PARAM p, Tcl_Channel chan) + { + ENTER ("rde_param_reset"); + TRACE (("RDE_PARAM %p",p)); + TRACE (("Tcl_Channel %p",chan)); + p->IN = chan; + p->CL = -1; + p->ST = 0; + p->CC = NULL; + p->CC_len = 0; + ER_CLEAR (p); + SV_CLEAR (p); + nc_clear (p); + rde_tc_clear (p->TC); + rde_stack_trim (p->ES, 0); + rde_stack_trim (p->LS, 0); + rde_stack_trim (p->ast, 0); + rde_stack_trim (p->mark, 0); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + RETURNVOID; + } + SCOPE void + rde_param_update_strings (RDE_PARAM p, long int nstr, char** strings) + { + ENTER ("rde_param_update_strings"); + TRACE (("RDE_PARAM %p", p)); + TRACE (("INT %d strings", nstr)); + p->numstr = nstr; + p->string = strings; + RETURNVOID; + } + SCOPE void + rde_param_data (RDE_PARAM p, char* buf, long int len) + { + (void) rde_tc_append (p->TC, buf, len); + } + SCOPE void + rde_param_clientdata (RDE_PARAM p, ClientData clientData) + { + p->clientData = clientData; + } + static void + nc_clear (RDE_PARAM p) + { + Tcl_HashSearch hs; + Tcl_HashEntry* he; + Tcl_HashTable* tablePtr; + for(he = Tcl_FirstHashEntry(&p->NC, &hs); + he != NULL; + he = Tcl_FirstHashEntry(&p->NC, &hs)) { + Tcl_HashSearch hsc; + Tcl_HashEntry* hec; + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (he); + for(hec = Tcl_FirstHashEntry(tablePtr, &hsc); + hec != NULL; + hec = Tcl_NextHashEntry(&hsc)) { + NC_STATE* scs = Tcl_GetHashValue (hec); + error_state_free (scs->ER); + if (scs->SV) { Tcl_DecrRefCount (scs->SV); } + ckfree ((char*) scs); + } + Tcl_DeleteHashTable (tablePtr); + ckfree ((char*) tablePtr); + Tcl_DeleteHashEntry (he); + } + } + SCOPE ClientData + rde_param_query_clientdata (RDE_PARAM p) + { + return p->clientData; + } + SCOPE void + rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) + { + rde_stack_get (p->mark, mc, mv); + } + SCOPE void + rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) + { + rde_stack_get (p->ast, ac, (void***) av); + } + SCOPE const char* + rde_param_query_in (RDE_PARAM p) + { + return p->IN + ? Tcl_GetChannelName (p->IN) + : ""; + } + SCOPE const char* + rde_param_query_cc (RDE_PARAM p, long int* len) + { + *len = p->CC_len; + return p->CC; + } + SCOPE int + rde_param_query_cl (RDE_PARAM p) + { + return p->CL; + } + SCOPE const ERROR_STATE* + rde_param_query_er (RDE_PARAM p) + { + return p->ER; + } + SCOPE Tcl_Obj* + rde_param_query_er_tcl (RDE_PARAM p, const ERROR_STATE* er) + { + Tcl_Obj* res; + if (!er) { + + res = Tcl_NewStringObj ("", 0); + } else { + Tcl_Obj* ov [2]; + Tcl_Obj** mov; + long int mc, i, j; + void** mv; + int lastid; + const char* msg; + rde_stack_get (er->msg, &mc, &mv); + + qsort (mv, mc, sizeof (void*), er_int_compare); + + mov = NALLOC (mc, Tcl_Obj*); + lastid = -1; + for (i=0, j=0; i < mc; i++) { + ASSERT_BOUNDS (i,mc); + if (((long int) mv [i]) == lastid) continue; + lastid = (long int) mv [i]; + ASSERT_BOUNDS((long int) mv[i],p->numstr); + msg = p->string [(long int) mv[i]]; + ASSERT_BOUNDS (j,mc); + mov [j] = Tcl_NewStringObj (msg, -1); + j++; + } + + ov [0] = Tcl_NewIntObj (er->loc); + ov [1] = Tcl_NewListObj (j, mov); + res = Tcl_NewListObj (2, ov); + ckfree ((char*) mov); + } + return res; + } + SCOPE void + rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) + { + rde_stack_get (p->ES, ec, (void***) ev); + } + SCOPE void + rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) + { + rde_stack_get (p->LS, lc, lv); + } + SCOPE long int + rde_param_query_lstop (RDE_PARAM p) + { + (long int) rde_stack_top (p->LS); + } + SCOPE Tcl_HashTable* + rde_param_query_nc (RDE_PARAM p) + { + return &p->NC; + } + SCOPE int + rde_param_query_st (RDE_PARAM p) + { + return p->ST; + } + SCOPE Tcl_Obj* + rde_param_query_sv (RDE_PARAM p) + { + TRACE (("SV_QUERY %p => (%p)", (p), (p)->SV)); \ + return p->SV; + } + SCOPE long int + rde_param_query_tc_size (RDE_PARAM p) + { + return rde_tc_size (p->TC); + } + SCOPE void + rde_param_query_tc_get_s (RDE_PARAM p, long int at, long int last, char** ch, long int* len) + { + rde_tc_get_s (p->TC, at, last, ch, len); + } + SCOPE const char* + rde_param_query_string (RDE_PARAM p, long int id) + { + TRACE (("rde_param_query_string (RDE_PARAM %p, %d/%d)", p, id, p->numstr)); + ASSERT_BOUNDS(id,p->numstr); + return p->string [id]; + } + SCOPE void + rde_param_i_ast_pop_discard (RDE_PARAM p) + { + rde_stack_pop (p->mark, 1); + } + SCOPE void + rde_param_i_ast_pop_rewind (RDE_PARAM p) + { + long int trim = (long int) rde_stack_top (p->mark); + ENTER ("rde_param_i_ast_pop_rewind"); + TRACE (("RDE_PARAM %p",p)); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_ast_rewind (RDE_PARAM p) + { + long int trim = (long int) rde_stack_top (p->mark); + ENTER ("rde_param_i_ast_rewind"); + TRACE (("RDE_PARAM %p",p)); + rde_stack_trim (p->ast, trim); + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_ast_push (RDE_PARAM p) + { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + } + SCOPE void + rde_param_i_ast_value_push (RDE_PARAM p) + { + ENTER ("rde_param_i_ast_value_push"); + TRACE (("RDE_PARAM %p",p)); + ASSERT(p->SV,"Unable to push undefined semantic value"); + TRACE (("rde_param_i_ast_value_push %p => (%p)", p, p->SV)); + TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV->refCount, Tcl_GetString (p->SV))); + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + RETURNVOID; + } + static void + ast_node_free (void* n) + { + Tcl_DecrRefCount ((Tcl_Obj*) n); + } + SCOPE void + rde_param_i_error_clear (RDE_PARAM p) + { + ER_CLEAR (p); + } + SCOPE void + rde_param_i_error_nonterminal (RDE_PARAM p, long int s) + { + + return; + long int pos; + if (!p->ER) return; + pos = 1 + (long int) rde_stack_top (p->LS); + if (p->ER->loc != pos) return; + error_set (p, s); + p->ER->loc = pos; + } + SCOPE void + rde_param_i_error_pop_merge (RDE_PARAM p) + { + ERROR_STATE* top = (ERROR_STATE*) rde_stack_top (p->ES); + + if (top == p->ER) { + rde_stack_pop (p->ES, 1); + return; + } + + if (!top) { + rde_stack_pop (p->ES, 1); + return; + } + + if (!p->ER) { + rde_stack_drop (p->ES, 1); + p->ER = top; + + return; + } + + if (top->loc < p->ER->loc) { + rde_stack_pop (p->ES, 1); + return; + } + + if (top->loc > p->ER->loc) { + rde_stack_drop (p->ES, 1); + error_state_free (p->ER); + p->ER = top; + + return; + } + + rde_stack_move (p->ER->msg, top->msg); + rde_stack_pop (p->ES, 1); + } + SCOPE void + rde_param_i_error_push (RDE_PARAM p) + { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + static void + error_set (RDE_PARAM p, long int s) + { + error_state_free (p->ER); + p->ER = ALLOC (ERROR_STATE); + p->ER->refCount = 1; + p->ER->loc = p->CL; + p->ER->msg = rde_stack_new (NULL); + ASSERT_BOUNDS(s,p->numstr); + rde_stack_push (p->ER->msg, (void*) s); + } + static void + error_state_free (void* esx) + { + ERROR_STATE* es = esx; + if (!es) return; + es->refCount --; + if (es->refCount > 0) return; + rde_stack_del (es->msg); + ckfree ((char*) es); + } + SCOPE void + rde_param_i_loc_pop_discard (RDE_PARAM p) + { + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_loc_pop_rewind (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_loc_push (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + } + SCOPE void + rde_param_i_loc_rewind (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + } + SCOPE void + rde_param_i_input_next (RDE_PARAM p, long int m) + { + int leni; + char* ch; + ASSERT_BOUNDS(m,p->numstr); + p->CL ++; + if (p->CL < rde_tc_size (p->TC)) { + + rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); + + ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); + p->ST = 1; + ER_CLEAR (p); + return; + } + if (!p->IN || + Tcl_Eof (p->IN) || + (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { + + p->ST = 0; + error_set (p, m); + return; + } + + ch = Tcl_GetStringFromObj (p->readbuf, &leni); + ASSERT_BOUNDS (leni, TCL_UTF_MAX); + p->CC = rde_tc_append (p->TC, ch, leni); + p->CC_len = leni; + p->ST = 1; + ER_CLEAR (p); + } + SCOPE void + rde_param_i_status_fail (RDE_PARAM p) + { + p->ST = 0; + } + SCOPE void + rde_param_i_status_ok (RDE_PARAM p) + { + p->ST = 1; + } + SCOPE void + rde_param_i_status_negate (RDE_PARAM p) + { + p->ST = !p->ST; + } + SCOPE int + rde_param_i_symbol_restore (RDE_PARAM p, long int s) + { + NC_STATE* scs; + Tcl_HashEntry* hPtr; + Tcl_HashTable* tablePtr; + + hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); + if (!hPtr) { return 0; } + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); + hPtr = Tcl_FindHashEntry (tablePtr, (char*) s); + if (!hPtr) { return 0; } + + scs = Tcl_GetHashValue (hPtr); + p->CL = scs->CL; + p->ST = scs->ST; + error_state_free (p->ER); + p->ER = scs->ER; + if (p->ER) { p->ER->refCount ++; } + TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); + SV_SET (p, scs->SV); + return 1; + } + SCOPE void + rde_param_i_symbol_save (RDE_PARAM p, long int s) + { + long int at = (long int) rde_stack_top (p->LS); + NC_STATE* scs; + Tcl_HashEntry* hPtr; + Tcl_HashTable* tablePtr; + int isnew; + ENTER ("rde_param_i_symbol_save"); + TRACE (("RDE_PARAM %p",p)); + TRACE (("INT %d",s)); + + hPtr = Tcl_CreateHashEntry (&p->NC, (char*) at, &isnew); + if (isnew) { + tablePtr = ALLOC (Tcl_HashTable); + Tcl_InitHashTable (tablePtr, TCL_ONE_WORD_KEYS); + Tcl_SetHashValue (hPtr, tablePtr); + } else { + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); + } + hPtr = Tcl_CreateHashEntry (tablePtr, (char*) s, &isnew); + if (isnew) { + + scs = ALLOC (NC_STATE); + scs->CL = p->CL; + scs->ST = p->ST; + TRACE (("SV_CACHE (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "")); + scs->SV = p->SV; + if (scs->SV) { Tcl_IncrRefCount (scs->SV); } + scs->ER = p->ER; + if (scs->ER) { scs->ER->refCount ++; } + Tcl_SetHashValue (hPtr, scs); + } else { + + scs = (NC_STATE*) Tcl_GetHashValue (hPtr); + scs->CL = p->CL; + scs->ST = p->ST; + TRACE (("SV_CACHE/over (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "" )); + if (scs->SV) { Tcl_DecrRefCount (scs->SV); } + scs->SV = p->SV; + if (scs->SV) { Tcl_IncrRefCount (scs->SV); } + error_state_free (scs->ER); + scs->ER = p->ER; + if (scs->ER) { scs->ER->refCount ++; } + } + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_test_alnum (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsAlnum, tc_alnum); + } + SCOPE void + rde_param_i_test_alpha (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsAlpha, tc_alpha); + } + SCOPE void + rde_param_i_test_ascii (RDE_PARAM p) + { + test_class (p, UniCharIsAscii, tc_ascii); + } + SCOPE void + rde_param_i_test_control (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsControl, tc_control); + } + SCOPE void + rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) + { + ASSERT_BOUNDS(msg,p->numstr); + p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, msg); + p->CL --; + } + } + SCOPE void + rde_param_i_test_ddigit (RDE_PARAM p) + { + test_class (p, UniCharIsDecDigit, tc_ddigit); + } + SCOPE void + rde_param_i_test_digit (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsDigit, tc_digit); + } + SCOPE void + rde_param_i_test_graph (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsGraph, tc_graph); + } + SCOPE void + rde_param_i_test_lower (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsLower, tc_lower); + } + SCOPE void + rde_param_i_test_print (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsPrint, tc_printable); + } + SCOPE void + rde_param_i_test_punct (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsPunct, tc_punct); + } + SCOPE void + rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) + { + ASSERT_BOUNDS(msg,p->numstr); + p->ST = + (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && + (Tcl_UtfNcmp (p->CC, e, 1) <= 0); + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, msg); + p->CL --; + } + } + SCOPE void + rde_param_i_test_space (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsSpace, tc_space); + } + SCOPE void + rde_param_i_test_upper (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsUpper, tc_upper); + } + SCOPE void + rde_param_i_test_wordchar (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsWordChar, tc_wordchar); + } + SCOPE void + rde_param_i_test_xdigit (RDE_PARAM p) + { + test_class (p, UniCharIsHexDigit, tc_xdigit); + } + static void + test_class (RDE_PARAM p, UniCharClass class, test_class_id id) + { + Tcl_UniChar ch; + Tcl_UtfToUniChar(p->CC, &ch); + ASSERT_BOUNDS(id,p->numstr); + p->ST = !!class (ch); + + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, id); + p->CL --; + } + } + static int + UniCharIsAscii (int character) + { + return (character >= 0) && (character < 0x80); + } + static int + UniCharIsHexDigit (int character) + { + return (character >= 0) && (character < 0x80) && isxdigit(character); + } + static int + UniCharIsDecDigit (int character) + { + return (character >= 0) && (character < 0x80) && isdigit(character); + } + SCOPE void + rde_param_i_value_clear (RDE_PARAM p) + { + SV_CLEAR (p); + } + SCOPE void + rde_param_i_value_leaf (RDE_PARAM p, long int s) + { + Tcl_Obj* newsv; + Tcl_Obj* ov [3]; + long int pos = 1 + (long int) rde_stack_top (p->LS); + ASSERT_BOUNDS(s,p->numstr); + ov [0] = Tcl_NewStringObj (p->string[s], -1); + ov [1] = Tcl_NewIntObj (pos); + ov [2] = Tcl_NewIntObj (p->CL); + newsv = Tcl_NewListObj (3, ov); + TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); + SV_SET (p, newsv); + } + SCOPE void + rde_param_i_value_reduce (RDE_PARAM p, long int s) + { + Tcl_Obj* newsv; + int oc, i, j; + Tcl_Obj** ov; + long int ac; + Tcl_Obj** av; + long int pos = 1 + (long int) rde_stack_top (p->LS); + long int mark = (long int) rde_stack_top (p->mark); + long int asize = rde_stack_size (p->ast); + long int new = asize - mark; + ASSERT (new >= 0, "Bad number of elements to reduce"); + ov = NALLOC (3+new, Tcl_Obj*); + ASSERT_BOUNDS(s,p->numstr); + ov [0] = Tcl_NewStringObj (p->string[s], -1); + ov [1] = Tcl_NewIntObj (pos); + ov [2] = Tcl_NewIntObj (p->CL); + rde_stack_get (p->ast, &ac, (void***) &av); + for (i = 3, j = mark; j < asize; i++, j++) { + ASSERT_BOUNDS (i, 3+new); + ASSERT_BOUNDS (j, ac); + ov [i] = av [j]; + } + ASSERT (i == 3+new, "Reduction result incomplete"); + newsv = Tcl_NewListObj (3+new, ov); + TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); + SV_SET (p, newsv); + ckfree ((char*) ov); + } + static int + er_int_compare (const void* a, const void* b) + { + + const void** ael = (const void**) a; + const void** bel = (const void**) b; + long int avalue = (long int) *ael; + long int bvalue = (long int) *bel; + if (avalue < bvalue) { return -1; } + if (avalue > bvalue) { return 1; } + return 0; + } + SCOPE int + rde_param_i_symbol_start (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) { + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + return 1; + } + rde_stack_push (p->LS, (void*) p->CL); + return 0; + } + SCOPE int + rde_param_i_symbol_start_d (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) { + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + return 1; + } + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + return 0; + } + SCOPE int + rde_param_i_symbol_void_start (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) return 1; + rde_stack_push (p->LS, (void*) p->CL); + return 0; + } + SCOPE int + rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) return 1; + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + return 0; + } + SCOPE void + rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_reduce (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_leaf (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_leaf (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) + { + SV_CLEAR (p); + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) + { + SV_CLEAR (p); + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_char (p, c, m); + } + SCOPE void + rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_range (p, s, e, m); + } + SCOPE void + rde_param_i_next_alnum (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_alnum (p); + } + SCOPE void + rde_param_i_next_alpha (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_alpha (p); + } + SCOPE void + rde_param_i_next_ascii (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_ascii (p); + } + SCOPE void + rde_param_i_next_control (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_control (p); + } + SCOPE void + rde_param_i_next_ddigit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_ddigit (p); + } + SCOPE void + rde_param_i_next_digit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_digit (p); + } + SCOPE void + rde_param_i_next_graph (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_graph (p); + } + SCOPE void + rde_param_i_next_lower (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_lower (p); + } + SCOPE void + rde_param_i_next_print (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_print (p); + } + SCOPE void + rde_param_i_next_punct (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_punct (p); + } + SCOPE void + rde_param_i_next_space (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_space (p); + } + SCOPE void + rde_param_i_next_upper (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_upper (p); + } + SCOPE void + rde_param_i_next_wordchar (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_wordchar (p); + } + SCOPE void + rde_param_i_next_xdigit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_xdigit (p); + } + SCOPE void + rde_param_i_notahead_start_d (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + } + SCOPE void + rde_param_i_notahead_exit_d (RDE_PARAM p) + { + if (p->ST) { + rde_param_i_ast_pop_rewind (p); + } else { + rde_stack_pop (p->mark, 1); + } + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + p->ST = !p->ST; + } + SCOPE void + rde_param_i_notahead_exit (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + p->ST = !p->ST; + } + SCOPE void + rde_param_i_state_push_2 (RDE_PARAM p) + { + + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + SCOPE void + rde_param_i_state_push_void (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + ER_CLEAR (p); + rde_stack_push (p->ES, p->ER); + + } + SCOPE void + rde_param_i_state_push_value (RDE_PARAM p) + { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + rde_stack_push (p->LS, (void*) p->CL); + ER_CLEAR (p); + rde_stack_push (p->ES, p->ER); + + } + SCOPE void + rde_param_i_state_merge_ok (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + p->ST = 1; + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_state_merge_void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_state_merge_value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } + SCOPE int + rde_param_i_kleene_close (RDE_PARAM p) + { + int stop = !p->ST; + rde_param_i_error_pop_merge (p); + if (stop) { + p->ST = 1; + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + return stop; + } + SCOPE int + rde_param_i_kleene_abort (RDE_PARAM p) + { + int stop = !p->ST; + if (stop) { + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + return stop; + } + SCOPE int + rde_param_i_seq_void2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_seq_void2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_seq_value2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_bra_void2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->LS, 1); + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_void2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->LS, 1); + } else { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_value2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_value2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE void + rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) + { + int at = p->CL; + + while (*str) { + rde_param_i_input_next (p, m); + if (!p->ST) { + p->ER->loc = at+1; + p->CL = at; + return; + } + rde_param_i_test_char (p, str, m); + if (!p->ST) { + p->ER->loc = at+1; + p->CL = at; + return; + } + str = Tcl_UtfNext (str); + } + } + SCOPE void + rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + while (*class) { + p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; + if (p->ST) { + ER_CLEAR (p); + return; + } + class = Tcl_UtfNext (class); + } + error_set (p, m); + p->CL --; + } + + + /* + * Declaring the parse functions + */ + + static void sym_AddOp (RDE_PARAM p); + static void sym_Digit (RDE_PARAM p); + static void sequence_9 (RDE_PARAM p); + static void sequence_14 (RDE_PARAM p); + static void kleene_16 (RDE_PARAM p); + static void sequence_18 (RDE_PARAM p); + static void choice_20 (RDE_PARAM p); + static void sym_Expression (RDE_PARAM p); + static void sequence_26 (RDE_PARAM p); + static void kleene_28 (RDE_PARAM p); + static void sequence_30 (RDE_PARAM p); + static void sym_Factor (RDE_PARAM p); + static void sym_MulOp (RDE_PARAM p); + static void optional_36 (RDE_PARAM p); + static void poskleene_39 (RDE_PARAM p); + static void sequence_41 (RDE_PARAM p); + static void sym_Number (RDE_PARAM p); + static void sym_Sign (RDE_PARAM p); + static void sym_Term (RDE_PARAM p); + + /* + * Precomputed table of strings (symbols, error messages, etc.). + */ + + static char const* p_string [35] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "cl -+", + /* 15 = */ "n AddOp", + /* 16 = */ "AddOp", + /* 17 = */ "cl 0123456789", + /* 18 = */ "n Digit", + /* 19 = */ "Digit", + /* 20 = */ "t (", + /* 21 = */ "t )", + /* 22 = */ "n Expression", + /* 23 = */ "Expression", + /* 24 = */ "n Factor", + /* 25 = */ "Factor", + /* 26 = */ "cl */", + /* 27 = */ "n MulOp", + /* 28 = */ "MulOp", + /* 29 = */ "n Number", + /* 30 = */ "Number", + /* 31 = */ "n Sign", + /* 32 = */ "Sign", + /* 33 = */ "n Term", + /* 34 = */ "Term" + }; + + /* + * Grammar Start Expression + */ + + static void MAIN (RDE_PARAM p) { + sym_Expression (p); + return; + } + + /* + * value Symbol 'AddOp' + */ + + static void sym_AddOp (RDE_PARAM p) { + /* + * [-+] + */ + + if (rde_param_i_symbol_start (p, 16)) return ; + rde_param_i_next_class (p, "-+", 14); + rde_param_i_symbol_done_leaf (p, 16, 15); + return; + } + + /* + * value Symbol 'Digit' + */ + + static void sym_Digit (RDE_PARAM p) { + /* + * [0123456789] + */ + + if (rde_param_i_symbol_start (p, 19)) return ; + rde_param_i_next_class (p, "0123456789", 17); + rde_param_i_symbol_done_leaf (p, 19, 18); + return; + } + + /* + * value Symbol 'Expression' + */ + + static void sym_Expression (RDE_PARAM p) { + /* + * / + * x + * '\(' + * (Expression) + * '\)' + * x + * (Factor) + * * + * x + * (MulOp) + * (Factor) + */ + + if (rde_param_i_symbol_start_d (p, 23)) return ; + choice_20 (p); + rde_param_i_symbol_done_d_reduce (p, 23, 22); + return; + } + + static void choice_20 (RDE_PARAM p) { + /* + * / + * x + * '\(' + * (Expression) + * '\)' + * x + * (Factor) + * * + * x + * (MulOp) + * (Factor) + */ + + rde_param_i_state_push_value (p); + sequence_9 (p); + if (rde_param_i_bra_value2value(p)) return; + sequence_18 (p); + rde_param_i_state_merge_value (p); + return; + } + + static void sequence_9 (RDE_PARAM p) { + /* + * x + * '\(' + * (Expression) + * '\)' + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_char (p, "(", 20); + if (rde_param_i_seq_void2value(p)) return; + sym_Expression (p); + if (rde_param_i_seq_value2value(p)) return; + rde_param_i_next_char (p, ")", 21); + rde_param_i_state_merge_value (p); + return; + } + + static void sequence_18 (RDE_PARAM p) { + /* + * x + * (Factor) + * * + * x + * (MulOp) + * (Factor) + */ + + rde_param_i_state_push_value (p); + sym_Factor (p); + if (rde_param_i_seq_value2value(p)) return; + kleene_16 (p); + rde_param_i_state_merge_value (p); + return; + } + + static void kleene_16 (RDE_PARAM p) { + /* + * * + * x + * (MulOp) + * (Factor) + */ + + while (1) { + rde_param_i_state_push_2 (p); + sequence_14 (p); + if (rde_param_i_kleene_close(p)) return; + } + return; + } + + static void sequence_14 (RDE_PARAM p) { + /* + * x + * (MulOp) + * (Factor) + */ + + rde_param_i_state_push_value (p); + sym_MulOp (p); + if (rde_param_i_seq_value2value(p)) return; + sym_Factor (p); + rde_param_i_state_merge_value (p); + return; + } + + /* + * value Symbol 'Factor' + */ + + static void sym_Factor (RDE_PARAM p) { + /* + * x + * (Term) + * * + * x + * (AddOp) + * (Term) + */ + + if (rde_param_i_symbol_start_d (p, 25)) return ; + sequence_30 (p); + rde_param_i_symbol_done_d_reduce (p, 25, 24); + return; + } + + static void sequence_30 (RDE_PARAM p) { + /* + * x + * (Term) + * * + * x + * (AddOp) + * (Term) + */ + + rde_param_i_state_push_value (p); + sym_Term (p); + if (rde_param_i_seq_value2value(p)) return; + kleene_28 (p); + rde_param_i_state_merge_value (p); + return; + } + + static void kleene_28 (RDE_PARAM p) { + /* + * * + * x + * (AddOp) + * (Term) + */ + + while (1) { + rde_param_i_state_push_2 (p); + sequence_26 (p); + if (rde_param_i_kleene_close(p)) return; + } + return; + } + + static void sequence_26 (RDE_PARAM p) { + /* + * x + * (AddOp) + * (Term) + */ + + rde_param_i_state_push_value (p); + sym_AddOp (p); + if (rde_param_i_seq_value2value(p)) return; + sym_Term (p); + rde_param_i_state_merge_value (p); + return; + } + + /* + * value Symbol 'MulOp' + */ + + static void sym_MulOp (RDE_PARAM p) { + /* + * [\u002a\u002f] + */ + + if (rde_param_i_symbol_start (p, 28)) return ; + rde_param_i_next_class (p, "*/", 26); + rde_param_i_symbol_done_leaf (p, 28, 27); + return; + } + + /* + * value Symbol 'Number' + */ + + static void sym_Number (RDE_PARAM p) { + /* + * x + * ? + * (Sign) + * + + * (Digit) + */ + + if (rde_param_i_symbol_start_d (p, 30)) return ; + sequence_41 (p); + rde_param_i_symbol_done_d_reduce (p, 30, 29); + return; + } + + static void sequence_41 (RDE_PARAM p) { + /* + * x + * ? + * (Sign) + * + + * (Digit) + */ + + rde_param_i_state_push_value (p); + optional_36 (p); + if (rde_param_i_seq_value2value(p)) return; + poskleene_39 (p); + rde_param_i_state_merge_value (p); + return; + } + + static void optional_36 (RDE_PARAM p) { + /* + * ? + * (Sign) + */ + + rde_param_i_state_push_2 (p); + sym_Sign (p); + rde_param_i_state_merge_ok (p); + return; + } + + static void poskleene_39 (RDE_PARAM p) { + /* + * + + * (Digit) + */ + + rde_param_i_loc_push (p); + sym_Digit (p); + if (rde_param_i_kleene_abort(p)) return; + while (1) { + rde_param_i_state_push_2 (p); + sym_Digit (p); + if (rde_param_i_kleene_close(p)) return; + } + return; + } + + /* + * value Symbol 'Sign' + */ + + static void sym_Sign (RDE_PARAM p) { + /* + * [-+] + */ + + if (rde_param_i_symbol_start (p, 32)) return ; + rde_param_i_next_class (p, "-+", 14); + rde_param_i_symbol_done_leaf (p, 32, 31); + return; + } + + /* + * value Symbol 'Term' + */ + + static void sym_Term (RDE_PARAM p) { + /* + * (Number) + */ + + if (rde_param_i_symbol_start_d (p, 34)) return ; + sym_Number (p); + rde_param_i_symbol_done_d_reduce (p, 34, 33); + return; + } + + /* -*- c -*- */ + + typedef struct PARSERg { + long int counter; + char buf [50]; + } PARSERg; + + static void + PARSERgRelease (ClientData cd, Tcl_Interp* interp) + { + ckfree((char*) cd); + } + + static const char* + PARSERnewName (Tcl_Interp* interp) + { +#define KEY "tcllib/parser/PACKAGE/TEA" + + Tcl_InterpDeleteProc* proc = PARSERgRelease; + PARSERg* parserg; + + parserg = Tcl_GetAssocData (interp, KEY, &proc); + if (parserg == NULL) { + parserg = (PARSERg*) ckalloc (sizeof (PARSERg)); + parserg->counter = 0; + + Tcl_SetAssocData (interp, KEY, proc, + (ClientData) parserg); + } + + parserg->counter ++; + sprintf (parserg->buf, "PARSER%ld", parserg->counter); + return parserg->buf; +#undef KEY + } + + static void + PARSERdeleteCmd (ClientData clientData) + { + /* + * Release the whole PARSER + * (Low-level engine only actually). + */ + rde_param_del ((RDE_PARAM) clientData); + } + + + /* * ** *** ***** ******** ************* + ** Functions implementing the object methods, and helper. + */ + + static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp); + + static int parser_PARSE (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + int mode; + Tcl_Channel chan; + + if (objc != 3) { + Tcl_WrongNumArgs (interp, 2, objv, "chan"); + return TCL_ERROR; + } + + chan = Tcl_GetChannel(interp, + Tcl_GetString (objv[2]), + &mode); + + if (!chan) { + return TCL_ERROR; + } + + rde_param_reset (p, chan); + MAIN (p) ; /* Entrypoint for the generated code. */ + return COMPLETE (p, interp); + } + + static int parser_PARSET (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + char* buf; + int len; + + if (objc != 3) { + Tcl_WrongNumArgs (interp, 2, objv, "text"); + return TCL_ERROR; + } + + buf = Tcl_GetStringFromObj (objv[2], &len); + + rde_param_reset (p, NULL); + rde_param_data (p, buf, len); + MAIN (p) ; /* Entrypoint for the generated code. */ + return COMPLETE (p, interp); + } + + /* See also rde_critcl/m.c, param_COMPLETE() */ + static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) + { + if (rde_param_query_st (p)) { + long int ac; + Tcl_Obj** av; + + rde_param_query_ast (p, &ac, &av); + + if (ac > 1) { + Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); + + memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); + lv [0] = Tcl_NewObj (); + lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); + lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); + + Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); + ckfree ((char*) lv); + + } else if (ac == 0) { + /* + * Match, but no AST. This is possible if the grammar + * consists of only the start expression. + */ + Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); + } else { + Tcl_SetObjResult (interp, av [0]); + } + + return TCL_OK; + } else { + Tcl_Obj* xv [1]; + const ERROR_STATE* er = rde_param_query_er (p); + Tcl_Obj* res = rde_param_query_er_tcl (p, er); + /* res = list (location, list(msg)) */ + + /* Stick the exception type-tag before the existing elements */ + xv [0] = Tcl_NewStringObj ("pt::rde",-1); + Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); + + Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); + Tcl_SetObjResult (interp, res); + return TCL_ERROR; + } + } + + + /* * ** *** ***** ******** ************* + ** Object command, method dispatch. + */ + static int parser_objcmd (ClientData cd, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + RDE_PARAM p = (RDE_PARAM) cd; + int m, res; + + static CONST char* methods [] = { + "destroy", "parse", "parset", NULL + }; + enum methods { + M_DESTROY, M_PARSE, M_PARSET + }; + + if (objc < 2) { + Tcl_WrongNumArgs (interp, objc, objv, "option ?arg arg ...?"); + return TCL_ERROR; + } else if (Tcl_GetIndexFromObj (interp, objv [1], methods, "option", + 0, &m) != TCL_OK) { + return TCL_ERROR; + } + + /* Dispatch to methods. They check the #args in + * detail before performing the requested + * functionality + */ + + switch (m) { + case M_DESTROY: + if (objc != 2) { + Tcl_WrongNumArgs (interp, 2, objv, NULL); + return TCL_ERROR; + } + + Tcl_DeleteCommandFromToken(interp, (Tcl_Command) rde_param_query_clientdata (p)); + return TCL_OK; + + case M_PARSE: res = parser_PARSE (p, interp, objc, objv); break; + case M_PARSET: res = parser_PARSET (p, interp, objc, objv); break; + default: + /* Not coming to this place */ + ASSERT (0,"Reached unreachable location"); + } + + return res; + } + + /** * ** *** ***** ******** ************* + * Class command, i.e. object construction. + */ + static int ParserClassCmd (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const*objv) { + /* + * Syntax: No arguments beyond the name + */ + + RDE_PARAM parser; + CONST char* name; + Tcl_Obj* fqn; + Tcl_CmdInfo ci; + Tcl_Command c; + +#define USAGE "?name?" + + if ((objc != 2) && (objc != 1)) { + Tcl_WrongNumArgs (interp, 1, objv, USAGE); + return TCL_ERROR; + } + + if (objc < 2) { + name = PARSERnewName (interp); + } else { + name = Tcl_GetString (objv [1]); + } + + if (!Tcl_StringMatch (name, "::*")) { + /* Relative name. Prefix with current namespace */ + + Tcl_Eval (interp, "namespace current"); + fqn = Tcl_GetObjResult (interp); + fqn = Tcl_DuplicateObj (fqn); + Tcl_IncrRefCount (fqn); + + if (!Tcl_StringMatch (Tcl_GetString (fqn), "::")) { + Tcl_AppendToObj (fqn, "::", -1); + } + Tcl_AppendToObj (fqn, name, -1); + } else { + fqn = Tcl_NewStringObj (name, -1); + Tcl_IncrRefCount (fqn); + } + Tcl_ResetResult (interp); + + if (Tcl_GetCommandInfo (interp, + Tcl_GetString (fqn), + &ci)) { + Tcl_Obj* err; + + err = Tcl_NewObj (); + Tcl_AppendToObj (err, "command \"", -1); + Tcl_AppendObjToObj (err, fqn); + Tcl_AppendToObj (err, "\" already exists", -1); + + Tcl_DecrRefCount (fqn); + Tcl_SetObjResult (interp, err); + return TCL_ERROR; + } + + parser = rde_param_new (sizeof(p_string)/sizeof(char*), (char**) p_string); + c = Tcl_CreateObjCommand (interp, Tcl_GetString (fqn), + parser_objcmd, (ClientData) parser, + PARSERdeleteCmd); + rde_param_clientdata (parser, (ClientData) c); + Tcl_SetObjResult (interp, fqn); + Tcl_DecrRefCount (fqn); + return TCL_OK; + } + +int Package_Init(Tcl_Interp* interp) { + if (interp == 0) return TCL_ERROR; + + if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { + return TCL_ERROR; + } + + if (Tcl_CreateObjCommand(interp, "PARSER", ParserClassCmd , NULL, NULL) == NULL) { + Tcl_SetResult(interp, "Can't create constructor", NULL); + return TCL_ERROR; + } + + + Tcl_PkgProvide(interp, "PACKAGE", "0.1"); + + return TCL_OK; +} ADDED modules/pt/tests/data/ok/peg_cparam-tea/10_notahead Index: modules/pt/tests/data/ok/peg_cparam-tea/10_notahead ================================================================== --- /dev/null +++ modules/pt/tests/data/ok/peg_cparam-tea/10_notahead @@ -0,0 +1,2038 @@ +/************************************************************ +** +** TEA-based C/PARAM implementation of the parsing +** expression grammar +** +** TEMPLATE +** +** Generated from file TEST +** for user unknown +** +* * ** *** ***** ******** ************* *********************/ + #include + #include + #include + #include + #define SCOPE static + +#line 1 "rde_critcl/util.h" + + #ifndef _RDE_UTIL_H + #define _RDE_UTIL_H 1 + #ifndef SCOPE + #define SCOPE + #endif + #define ALLOC(type) (type *) ckalloc (sizeof (type)) + #define NALLOC(n,type) (type *) ckalloc ((n) * sizeof (type)) + #undef RDE_DEBUG + #define RDE_DEBUG 1 + #undef RDE_TRACE + #ifdef RDE_DEBUG + #define STOPAFTER(x) { static int count = (x); count --; if (!count) { Tcl_Panic ("stop"); } } + #define XSTR(x) #x + #define STR(x) XSTR(x) + #define RANGEOK(i,n) ((0 <= (i)) && (i < (n))) + #define ASSERT(x,msg) if (!(x)) { Tcl_Panic (msg " (" #x "), in file " __FILE__ " @line " STR(__LINE__));} + #define ASSERT_BOUNDS(i,n) ASSERT (RANGEOK(i,n),"array index out of bounds: " STR(i) " >= " STR(n)) + #else + #define STOPAFTER(x) + #define ASSERT(x,msg) + #define ASSERT_BOUNDS(i,n) + #endif + #ifdef RDE_TRACE + SCOPE void trace_enter (const char* fun); + SCOPE void trace_return (const char *pat, ...); + SCOPE void trace_printf (const char *pat, ...); + #define ENTER(fun) trace_enter (fun) + #define RETURN(format,x) trace_return (format,x) ; return x + #define RETURNVOID trace_return ("%s","(void)") ; return + #define TRACE0(x) trace_printf0 x + #define TRACE(x) trace_printf x + #else + #define ENTER(fun) + #define RETURN(f,x) return x + #define RETURNVOID return + #define TRACE0(x) + #define TRACE(x) + #endif + #endif + + +#line 1 "rde_critcl/stack.h" + + #ifndef _RDE_DS_STACK_H + #define _RDE_DS_STACK_H 1 + typedef void (*RDE_STACK_CELL_FREE) (void* cell); + typedef struct RDE_STACK_* RDE_STACK; + static const int RDE_STACK_INITIAL_SIZE = 256; + #endif + + +#line 1 "rde_critcl/tc.h" + + #ifndef _RDE_DS_TC_H + #define _RDE_DS_TC_H 1 + typedef struct RDE_TC_* RDE_TC; + #endif + + +#line 1 "rde_critcl/param.h" + + #ifndef _RDE_DS_PARAM_H + #define _RDE_DS_PARAM_H 1 + typedef struct RDE_PARAM_* RDE_PARAM; + typedef struct ERROR_STATE { + int refCount; + long int loc; + RDE_STACK msg; + } ERROR_STATE; + typedef struct NC_STATE { + long int CL; + long int ST; + Tcl_Obj* SV; + ERROR_STATE* ER; + } NC_STATE; + #endif + + +#line 1 "rde_critcl/util.c" + + #ifdef RDE_TRACE + typedef struct F_STACK { + const char* str; + struct F_STACK* down; + } F_STACK; + static F_STACK* top = 0; + static int level = 0; + static void + push (const char* str) + { + F_STACK* new = ALLOC (F_STACK); + new->str = str; + new->down = top; + top = new; + level += 4; + } + static void + pop (void) + { + F_STACK* next = top->down; + level -= 4; + ckfree ((char*)top); + top = next; + } + static void + indent (void) + { + int i; + for (i = 0; i < level; i++) { + fwrite(" ", 1, 1, stdout); + fflush (stdout); + } + if (top) { + fwrite(top->str, 1, strlen(top->str), stdout); + fflush (stdout); + } + fwrite(" ", 1, 1, stdout); + fflush (stdout); + } + SCOPE void + trace_enter (const char* fun) + { + push (fun); + indent(); + fwrite("ENTER\n", 1, 6, stdout); + fflush (stdout); + } + static char msg [1024*1024]; + SCOPE void + trace_return (const char *pat, ...) + { + int len; + va_list args; + indent(); + fwrite("RETURN = ", 1, 9, stdout); + fflush (stdout); + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + pop(); + } + SCOPE void + trace_printf (const char *pat, ...) + { + int len; + va_list args; + indent(); + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + } + SCOPE void + trace_printf0 (const char *pat, ...) + { + int len; + va_list args; + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + } + #endif + + +#line 1 "rde_critcl/stack.c" + + typedef struct RDE_STACK_ { + long int max; + long int top; + RDE_STACK_CELL_FREE freeCellProc; + void** cell; + } RDE_STACK_; + + SCOPE RDE_STACK + rde_stack_new (RDE_STACK_CELL_FREE freeCellProc) + { + RDE_STACK s = ALLOC (RDE_STACK_); + s->cell = NALLOC (RDE_STACK_INITIAL_SIZE, void*); + s->max = RDE_STACK_INITIAL_SIZE; + s->top = 0; + s->freeCellProc = freeCellProc; + return s; + } + SCOPE void + rde_stack_del (RDE_STACK s) + { + if (s->freeCellProc && s->top) { + long int i; + for (i=0; i < s->top; i++) { + ASSERT_BOUNDS(i,s->max); + s->freeCellProc ( s->cell [i] ); + } + } + ckfree ((char*) s->cell); + ckfree ((char*) s); + } + SCOPE void + rde_stack_push (RDE_STACK s, void* item) + { + if (s->top >= s->max) { + long int new = s->max ? (2 * s->max) : RDE_STACK_INITIAL_SIZE; + void** cell = (void**) ckrealloc ((char*) s->cell, new * sizeof(void*)); + ASSERT (cell,"Memory allocation failure for RDE stack"); + s->max = new; + s->cell = cell; + } + ASSERT_BOUNDS(s->top,s->max); + s->cell [s->top] = item; + s->top ++; + } + SCOPE void* + rde_stack_top (RDE_STACK s) + { + ASSERT_BOUNDS(s->top-1,s->max); + return s->cell [s->top - 1]; + } + SCOPE void + rde_stack_pop (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad pop count"); + if (n == 0) return; + if (s->freeCellProc) { + while (n) { + s->top --; + ASSERT_BOUNDS(s->top,s->max); + s->freeCellProc ( s->cell [s->top] ); + n --; + } + } else { + s->top -= n; + } + } + SCOPE void + rde_stack_trim (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad trimsize"); + if (s->freeCellProc) { + while (s->top > n) { + s->top --; + ASSERT_BOUNDS(s->top,s->max); + s->freeCellProc ( s->cell [s->top] ); + } + } else { + s->top = n; + } + } + SCOPE void + rde_stack_drop (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad pop count"); + if (n == 0) return; + s->top -= n; + } + SCOPE void + rde_stack_move (RDE_STACK dst, RDE_STACK src) + { + ASSERT (dst->freeCellProc == src->freeCellProc, "Ownership mismatch"); + + while (src->top > 0) { + src->top --; + ASSERT_BOUNDS(src->top,src->max); + rde_stack_push (dst, src->cell [src->top] ); + } + } + SCOPE void + rde_stack_get (RDE_STACK s, long int* cn, void*** cc) + { + *cn = s->top; + *cc = s->cell; + } + SCOPE long int + rde_stack_size (RDE_STACK s) + { + return s->top; + } + + +#line 1 "rde_critcl/tc.c" + + typedef struct RDE_TC_ { + int max; + int num; + char* str; + RDE_STACK off; + } RDE_TC_; + + SCOPE RDE_TC + rde_tc_new (void) + { + RDE_TC tc = ALLOC (RDE_TC_); + tc->max = RDE_STACK_INITIAL_SIZE; + tc->num = 0; + tc->str = NALLOC (RDE_STACK_INITIAL_SIZE, char); + tc->off = rde_stack_new (NULL); + return tc; + } + SCOPE void + rde_tc_del (RDE_TC tc) + { + rde_stack_del (tc->off); + ckfree (tc->str); + ckfree ((char*) tc); + } + SCOPE long int + rde_tc_size (RDE_TC tc) + { + return rde_stack_size (tc->off); + } + SCOPE void + rde_tc_clear (RDE_TC tc) + { + tc->num = 0; + rde_stack_trim (tc->off, 0); + } + SCOPE char* + rde_tc_append (RDE_TC tc, char* string, long int len) + { + long int base = tc->num; + long int off = tc->num; + char* ch; + int clen; + Tcl_UniChar uni; + if (len < 0) { + len = strlen (string); + } + + if (!len) { + return tc->str + base; + } + + if ((tc->num + len) >= tc->max) { + int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); + char* str = ckrealloc (tc->str, new * sizeof(char)); + ASSERT (str,"Memory allocation failure for token character array"); + tc->max = new; + tc->str = str; + } + tc->num += len; + ASSERT_BOUNDS(tc->num,tc->max); + ASSERT_BOUNDS(off,tc->max); + ASSERT_BOUNDS(off+len-1,tc->max); + ASSERT_BOUNDS(off+len-1,tc->num); + memcpy (tc->str + off, string, len); + + ch = string; + while (ch < (string + len)) { + ASSERT_BOUNDS(off,tc->num); + rde_stack_push (tc->off, (void*) off); + clen = Tcl_UtfToUniChar (ch, &uni); + off += clen; + ch += clen; + } + return tc->str + base; + } + SCOPE void + rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) + { + long int oc, off, top, end; + void** ov; + rde_stack_get (tc->off, &oc, &ov); + ASSERT_BOUNDS(at,oc); + off = (long int) ov [at]; + if ((at+1) == oc) { + end = tc->num; + } else { + end = (long int) ov [at+1]; + } + TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); + ASSERT_BOUNDS(off,tc->num); + ASSERT_BOUNDS(end-1,tc->num); + *ch = tc->str + off; + *len = end - off; + } + SCOPE void + rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) + { + long int oc, off, top, end; + void** ov; + rde_stack_get (tc->off, &oc, &ov); + ASSERT_BOUNDS(at,oc); + ASSERT_BOUNDS(last,oc); + off = (long int) ov [at]; + if ((last+1) == oc) { + end = tc->num; + } else { + end = (long int) ov [last+1]; + } + TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); + ASSERT_BOUNDS(off,tc->num); + ASSERT_BOUNDS(end-1,tc->num); + *ch = tc->str + off; + *len = end - off; + } + + +#line 1 "rde_critcl/param.c" + + typedef struct RDE_PARAM_ { + Tcl_Channel IN; + Tcl_Obj* readbuf; + char* CC; + long int CC_len; + RDE_TC TC; + long int CL; + RDE_STACK LS; + ERROR_STATE* ER; + RDE_STACK ES; + long int ST; + Tcl_Obj* SV; + Tcl_HashTable NC; + + RDE_STACK ast ; + RDE_STACK mark ; + + long int numstr; + char** string; + + ClientData clientData; + } RDE_PARAM_; + typedef int (*UniCharClass) (int); + typedef enum test_class_id { + tc_alnum, + tc_alpha, + tc_ascii, + tc_control, + tc_ddigit, + tc_digit, + tc_graph, + tc_lower, + tc_printable, + tc_punct, + tc_space, + tc_upper, + tc_wordchar, + tc_xdigit + } test_class_id; + static void ast_node_free (void* n); + static void error_state_free (void* es); + static void error_set (RDE_PARAM p, long int s); + static void nc_clear (RDE_PARAM p); + static int UniCharIsAscii (int character); + static int UniCharIsHexDigit (int character); + static int UniCharIsDecDigit (int character); + static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); + static int er_int_compare (const void* a, const void* b); + #define SV_INIT(p) \ + p->SV = NULL; \ + TRACE (("SV_INIT (%p => %p)", (p), (p)->SV)) + #define SV_SET(p,newsv) \ + if (((p)->SV) != (newsv)) { \ + TRACE (("SV_CLEAR/set (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_DecrRefCount ((p)->SV); \ + } \ + (p)->SV = (newsv); \ + TRACE (("SV_SET (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_IncrRefCount ((p)->SV); \ + } \ + } + #define SV_CLEAR(p) \ + TRACE (("SV_CLEAR (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_DecrRefCount ((p)->SV); \ + } \ + (p)->SV = NULL + #define ER_INIT(p) \ + p->ER = NULL; \ + TRACE (("ER_INIT (%p => %p)", (p), (p)->ER)) + #define ER_CLEAR(p) \ + error_state_free ((p)->ER); \ + (p)->ER = NULL + SCOPE RDE_PARAM + rde_param_new (long int nstr, char** strings) + { + RDE_PARAM p; + ENTER ("rde_param_new"); + TRACE (("\tINT %d strings @ %p", nstr, strings)); + p = ALLOC (RDE_PARAM_); + p->numstr = nstr; + p->string = strings; + p->readbuf = Tcl_NewObj (); + Tcl_IncrRefCount (p->readbuf); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + Tcl_InitHashTable (&p->NC, TCL_ONE_WORD_KEYS); + p->IN = NULL; + p->CL = -1; + p->ST = 0; + ER_INIT (p); + SV_INIT (p); + p->CC = NULL; + p->CC_len = 0; + p->TC = rde_tc_new (); + p->ES = rde_stack_new (error_state_free); + p->LS = rde_stack_new (NULL); + p->ast = rde_stack_new (ast_node_free); + p->mark = rde_stack_new (NULL); + RETURN ("%p", p); + } + SCOPE void + rde_param_del (RDE_PARAM p) + { + ENTER ("rde_param_del"); + TRACE (("RDE_PARAM %p",p)); + ER_CLEAR (p); TRACE (("\ter_clear")); + SV_CLEAR (p); TRACE (("\tsv_clear")); + nc_clear (p); TRACE (("\tnc_clear")); + Tcl_DeleteHashTable (&p->NC); TRACE (("\tnc hashtable delete")); + rde_tc_del (p->TC); TRACE (("\ttc clear")); + rde_stack_del (p->ES); TRACE (("\tes clear")); + rde_stack_del (p->LS); TRACE (("\tls clear")); + rde_stack_del (p->ast); TRACE (("\tast clear")); + rde_stack_del (p->mark); TRACE (("\tmark clear")); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + Tcl_DecrRefCount (p->readbuf); + ckfree ((char*) p); + RETURNVOID; + } + SCOPE void + rde_param_reset (RDE_PARAM p, Tcl_Channel chan) + { + ENTER ("rde_param_reset"); + TRACE (("RDE_PARAM %p",p)); + TRACE (("Tcl_Channel %p",chan)); + p->IN = chan; + p->CL = -1; + p->ST = 0; + p->CC = NULL; + p->CC_len = 0; + ER_CLEAR (p); + SV_CLEAR (p); + nc_clear (p); + rde_tc_clear (p->TC); + rde_stack_trim (p->ES, 0); + rde_stack_trim (p->LS, 0); + rde_stack_trim (p->ast, 0); + rde_stack_trim (p->mark, 0); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + RETURNVOID; + } + SCOPE void + rde_param_update_strings (RDE_PARAM p, long int nstr, char** strings) + { + ENTER ("rde_param_update_strings"); + TRACE (("RDE_PARAM %p", p)); + TRACE (("INT %d strings", nstr)); + p->numstr = nstr; + p->string = strings; + RETURNVOID; + } + SCOPE void + rde_param_data (RDE_PARAM p, char* buf, long int len) + { + (void) rde_tc_append (p->TC, buf, len); + } + SCOPE void + rde_param_clientdata (RDE_PARAM p, ClientData clientData) + { + p->clientData = clientData; + } + static void + nc_clear (RDE_PARAM p) + { + Tcl_HashSearch hs; + Tcl_HashEntry* he; + Tcl_HashTable* tablePtr; + for(he = Tcl_FirstHashEntry(&p->NC, &hs); + he != NULL; + he = Tcl_FirstHashEntry(&p->NC, &hs)) { + Tcl_HashSearch hsc; + Tcl_HashEntry* hec; + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (he); + for(hec = Tcl_FirstHashEntry(tablePtr, &hsc); + hec != NULL; + hec = Tcl_NextHashEntry(&hsc)) { + NC_STATE* scs = Tcl_GetHashValue (hec); + error_state_free (scs->ER); + if (scs->SV) { Tcl_DecrRefCount (scs->SV); } + ckfree ((char*) scs); + } + Tcl_DeleteHashTable (tablePtr); + ckfree ((char*) tablePtr); + Tcl_DeleteHashEntry (he); + } + } + SCOPE ClientData + rde_param_query_clientdata (RDE_PARAM p) + { + return p->clientData; + } + SCOPE void + rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) + { + rde_stack_get (p->mark, mc, mv); + } + SCOPE void + rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) + { + rde_stack_get (p->ast, ac, (void***) av); + } + SCOPE const char* + rde_param_query_in (RDE_PARAM p) + { + return p->IN + ? Tcl_GetChannelName (p->IN) + : ""; + } + SCOPE const char* + rde_param_query_cc (RDE_PARAM p, long int* len) + { + *len = p->CC_len; + return p->CC; + } + SCOPE int + rde_param_query_cl (RDE_PARAM p) + { + return p->CL; + } + SCOPE const ERROR_STATE* + rde_param_query_er (RDE_PARAM p) + { + return p->ER; + } + SCOPE Tcl_Obj* + rde_param_query_er_tcl (RDE_PARAM p, const ERROR_STATE* er) + { + Tcl_Obj* res; + if (!er) { + + res = Tcl_NewStringObj ("", 0); + } else { + Tcl_Obj* ov [2]; + Tcl_Obj** mov; + long int mc, i, j; + void** mv; + int lastid; + const char* msg; + rde_stack_get (er->msg, &mc, &mv); + + qsort (mv, mc, sizeof (void*), er_int_compare); + + mov = NALLOC (mc, Tcl_Obj*); + lastid = -1; + for (i=0, j=0; i < mc; i++) { + ASSERT_BOUNDS (i,mc); + if (((long int) mv [i]) == lastid) continue; + lastid = (long int) mv [i]; + ASSERT_BOUNDS((long int) mv[i],p->numstr); + msg = p->string [(long int) mv[i]]; + ASSERT_BOUNDS (j,mc); + mov [j] = Tcl_NewStringObj (msg, -1); + j++; + } + + ov [0] = Tcl_NewIntObj (er->loc); + ov [1] = Tcl_NewListObj (j, mov); + res = Tcl_NewListObj (2, ov); + ckfree ((char*) mov); + } + return res; + } + SCOPE void + rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) + { + rde_stack_get (p->ES, ec, (void***) ev); + } + SCOPE void + rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) + { + rde_stack_get (p->LS, lc, lv); + } + SCOPE long int + rde_param_query_lstop (RDE_PARAM p) + { + (long int) rde_stack_top (p->LS); + } + SCOPE Tcl_HashTable* + rde_param_query_nc (RDE_PARAM p) + { + return &p->NC; + } + SCOPE int + rde_param_query_st (RDE_PARAM p) + { + return p->ST; + } + SCOPE Tcl_Obj* + rde_param_query_sv (RDE_PARAM p) + { + TRACE (("SV_QUERY %p => (%p)", (p), (p)->SV)); \ + return p->SV; + } + SCOPE long int + rde_param_query_tc_size (RDE_PARAM p) + { + return rde_tc_size (p->TC); + } + SCOPE void + rde_param_query_tc_get_s (RDE_PARAM p, long int at, long int last, char** ch, long int* len) + { + rde_tc_get_s (p->TC, at, last, ch, len); + } + SCOPE const char* + rde_param_query_string (RDE_PARAM p, long int id) + { + TRACE (("rde_param_query_string (RDE_PARAM %p, %d/%d)", p, id, p->numstr)); + ASSERT_BOUNDS(id,p->numstr); + return p->string [id]; + } + SCOPE void + rde_param_i_ast_pop_discard (RDE_PARAM p) + { + rde_stack_pop (p->mark, 1); + } + SCOPE void + rde_param_i_ast_pop_rewind (RDE_PARAM p) + { + long int trim = (long int) rde_stack_top (p->mark); + ENTER ("rde_param_i_ast_pop_rewind"); + TRACE (("RDE_PARAM %p",p)); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_ast_rewind (RDE_PARAM p) + { + long int trim = (long int) rde_stack_top (p->mark); + ENTER ("rde_param_i_ast_rewind"); + TRACE (("RDE_PARAM %p",p)); + rde_stack_trim (p->ast, trim); + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_ast_push (RDE_PARAM p) + { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + } + SCOPE void + rde_param_i_ast_value_push (RDE_PARAM p) + { + ENTER ("rde_param_i_ast_value_push"); + TRACE (("RDE_PARAM %p",p)); + ASSERT(p->SV,"Unable to push undefined semantic value"); + TRACE (("rde_param_i_ast_value_push %p => (%p)", p, p->SV)); + TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV->refCount, Tcl_GetString (p->SV))); + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + RETURNVOID; + } + static void + ast_node_free (void* n) + { + Tcl_DecrRefCount ((Tcl_Obj*) n); + } + SCOPE void + rde_param_i_error_clear (RDE_PARAM p) + { + ER_CLEAR (p); + } + SCOPE void + rde_param_i_error_nonterminal (RDE_PARAM p, long int s) + { + + return; + long int pos; + if (!p->ER) return; + pos = 1 + (long int) rde_stack_top (p->LS); + if (p->ER->loc != pos) return; + error_set (p, s); + p->ER->loc = pos; + } + SCOPE void + rde_param_i_error_pop_merge (RDE_PARAM p) + { + ERROR_STATE* top = (ERROR_STATE*) rde_stack_top (p->ES); + + if (top == p->ER) { + rde_stack_pop (p->ES, 1); + return; + } + + if (!top) { + rde_stack_pop (p->ES, 1); + return; + } + + if (!p->ER) { + rde_stack_drop (p->ES, 1); + p->ER = top; + + return; + } + + if (top->loc < p->ER->loc) { + rde_stack_pop (p->ES, 1); + return; + } + + if (top->loc > p->ER->loc) { + rde_stack_drop (p->ES, 1); + error_state_free (p->ER); + p->ER = top; + + return; + } + + rde_stack_move (p->ER->msg, top->msg); + rde_stack_pop (p->ES, 1); + } + SCOPE void + rde_param_i_error_push (RDE_PARAM p) + { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + static void + error_set (RDE_PARAM p, long int s) + { + error_state_free (p->ER); + p->ER = ALLOC (ERROR_STATE); + p->ER->refCount = 1; + p->ER->loc = p->CL; + p->ER->msg = rde_stack_new (NULL); + ASSERT_BOUNDS(s,p->numstr); + rde_stack_push (p->ER->msg, (void*) s); + } + static void + error_state_free (void* esx) + { + ERROR_STATE* es = esx; + if (!es) return; + es->refCount --; + if (es->refCount > 0) return; + rde_stack_del (es->msg); + ckfree ((char*) es); + } + SCOPE void + rde_param_i_loc_pop_discard (RDE_PARAM p) + { + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_loc_pop_rewind (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_loc_push (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + } + SCOPE void + rde_param_i_loc_rewind (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + } + SCOPE void + rde_param_i_input_next (RDE_PARAM p, long int m) + { + int leni; + char* ch; + ASSERT_BOUNDS(m,p->numstr); + p->CL ++; + if (p->CL < rde_tc_size (p->TC)) { + + rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); + + ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); + p->ST = 1; + ER_CLEAR (p); + return; + } + if (!p->IN || + Tcl_Eof (p->IN) || + (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { + + p->ST = 0; + error_set (p, m); + return; + } + + ch = Tcl_GetStringFromObj (p->readbuf, &leni); + ASSERT_BOUNDS (leni, TCL_UTF_MAX); + p->CC = rde_tc_append (p->TC, ch, leni); + p->CC_len = leni; + p->ST = 1; + ER_CLEAR (p); + } + SCOPE void + rde_param_i_status_fail (RDE_PARAM p) + { + p->ST = 0; + } + SCOPE void + rde_param_i_status_ok (RDE_PARAM p) + { + p->ST = 1; + } + SCOPE void + rde_param_i_status_negate (RDE_PARAM p) + { + p->ST = !p->ST; + } + SCOPE int + rde_param_i_symbol_restore (RDE_PARAM p, long int s) + { + NC_STATE* scs; + Tcl_HashEntry* hPtr; + Tcl_HashTable* tablePtr; + + hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); + if (!hPtr) { return 0; } + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); + hPtr = Tcl_FindHashEntry (tablePtr, (char*) s); + if (!hPtr) { return 0; } + + scs = Tcl_GetHashValue (hPtr); + p->CL = scs->CL; + p->ST = scs->ST; + error_state_free (p->ER); + p->ER = scs->ER; + if (p->ER) { p->ER->refCount ++; } + TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); + SV_SET (p, scs->SV); + return 1; + } + SCOPE void + rde_param_i_symbol_save (RDE_PARAM p, long int s) + { + long int at = (long int) rde_stack_top (p->LS); + NC_STATE* scs; + Tcl_HashEntry* hPtr; + Tcl_HashTable* tablePtr; + int isnew; + ENTER ("rde_param_i_symbol_save"); + TRACE (("RDE_PARAM %p",p)); + TRACE (("INT %d",s)); + + hPtr = Tcl_CreateHashEntry (&p->NC, (char*) at, &isnew); + if (isnew) { + tablePtr = ALLOC (Tcl_HashTable); + Tcl_InitHashTable (tablePtr, TCL_ONE_WORD_KEYS); + Tcl_SetHashValue (hPtr, tablePtr); + } else { + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); + } + hPtr = Tcl_CreateHashEntry (tablePtr, (char*) s, &isnew); + if (isnew) { + + scs = ALLOC (NC_STATE); + scs->CL = p->CL; + scs->ST = p->ST; + TRACE (("SV_CACHE (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "")); + scs->SV = p->SV; + if (scs->SV) { Tcl_IncrRefCount (scs->SV); } + scs->ER = p->ER; + if (scs->ER) { scs->ER->refCount ++; } + Tcl_SetHashValue (hPtr, scs); + } else { + + scs = (NC_STATE*) Tcl_GetHashValue (hPtr); + scs->CL = p->CL; + scs->ST = p->ST; + TRACE (("SV_CACHE/over (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "" )); + if (scs->SV) { Tcl_DecrRefCount (scs->SV); } + scs->SV = p->SV; + if (scs->SV) { Tcl_IncrRefCount (scs->SV); } + error_state_free (scs->ER); + scs->ER = p->ER; + if (scs->ER) { scs->ER->refCount ++; } + } + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_test_alnum (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsAlnum, tc_alnum); + } + SCOPE void + rde_param_i_test_alpha (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsAlpha, tc_alpha); + } + SCOPE void + rde_param_i_test_ascii (RDE_PARAM p) + { + test_class (p, UniCharIsAscii, tc_ascii); + } + SCOPE void + rde_param_i_test_control (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsControl, tc_control); + } + SCOPE void + rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) + { + ASSERT_BOUNDS(msg,p->numstr); + p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, msg); + p->CL --; + } + } + SCOPE void + rde_param_i_test_ddigit (RDE_PARAM p) + { + test_class (p, UniCharIsDecDigit, tc_ddigit); + } + SCOPE void + rde_param_i_test_digit (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsDigit, tc_digit); + } + SCOPE void + rde_param_i_test_graph (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsGraph, tc_graph); + } + SCOPE void + rde_param_i_test_lower (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsLower, tc_lower); + } + SCOPE void + rde_param_i_test_print (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsPrint, tc_printable); + } + SCOPE void + rde_param_i_test_punct (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsPunct, tc_punct); + } + SCOPE void + rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) + { + ASSERT_BOUNDS(msg,p->numstr); + p->ST = + (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && + (Tcl_UtfNcmp (p->CC, e, 1) <= 0); + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, msg); + p->CL --; + } + } + SCOPE void + rde_param_i_test_space (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsSpace, tc_space); + } + SCOPE void + rde_param_i_test_upper (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsUpper, tc_upper); + } + SCOPE void + rde_param_i_test_wordchar (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsWordChar, tc_wordchar); + } + SCOPE void + rde_param_i_test_xdigit (RDE_PARAM p) + { + test_class (p, UniCharIsHexDigit, tc_xdigit); + } + static void + test_class (RDE_PARAM p, UniCharClass class, test_class_id id) + { + Tcl_UniChar ch; + Tcl_UtfToUniChar(p->CC, &ch); + ASSERT_BOUNDS(id,p->numstr); + p->ST = !!class (ch); + + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, id); + p->CL --; + } + } + static int + UniCharIsAscii (int character) + { + return (character >= 0) && (character < 0x80); + } + static int + UniCharIsHexDigit (int character) + { + return (character >= 0) && (character < 0x80) && isxdigit(character); + } + static int + UniCharIsDecDigit (int character) + { + return (character >= 0) && (character < 0x80) && isdigit(character); + } + SCOPE void + rde_param_i_value_clear (RDE_PARAM p) + { + SV_CLEAR (p); + } + SCOPE void + rde_param_i_value_leaf (RDE_PARAM p, long int s) + { + Tcl_Obj* newsv; + Tcl_Obj* ov [3]; + long int pos = 1 + (long int) rde_stack_top (p->LS); + ASSERT_BOUNDS(s,p->numstr); + ov [0] = Tcl_NewStringObj (p->string[s], -1); + ov [1] = Tcl_NewIntObj (pos); + ov [2] = Tcl_NewIntObj (p->CL); + newsv = Tcl_NewListObj (3, ov); + TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); + SV_SET (p, newsv); + } + SCOPE void + rde_param_i_value_reduce (RDE_PARAM p, long int s) + { + Tcl_Obj* newsv; + int oc, i, j; + Tcl_Obj** ov; + long int ac; + Tcl_Obj** av; + long int pos = 1 + (long int) rde_stack_top (p->LS); + long int mark = (long int) rde_stack_top (p->mark); + long int asize = rde_stack_size (p->ast); + long int new = asize - mark; + ASSERT (new >= 0, "Bad number of elements to reduce"); + ov = NALLOC (3+new, Tcl_Obj*); + ASSERT_BOUNDS(s,p->numstr); + ov [0] = Tcl_NewStringObj (p->string[s], -1); + ov [1] = Tcl_NewIntObj (pos); + ov [2] = Tcl_NewIntObj (p->CL); + rde_stack_get (p->ast, &ac, (void***) &av); + for (i = 3, j = mark; j < asize; i++, j++) { + ASSERT_BOUNDS (i, 3+new); + ASSERT_BOUNDS (j, ac); + ov [i] = av [j]; + } + ASSERT (i == 3+new, "Reduction result incomplete"); + newsv = Tcl_NewListObj (3+new, ov); + TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); + SV_SET (p, newsv); + ckfree ((char*) ov); + } + static int + er_int_compare (const void* a, const void* b) + { + + const void** ael = (const void**) a; + const void** bel = (const void**) b; + long int avalue = (long int) *ael; + long int bvalue = (long int) *bel; + if (avalue < bvalue) { return -1; } + if (avalue > bvalue) { return 1; } + return 0; + } + SCOPE int + rde_param_i_symbol_start (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) { + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + return 1; + } + rde_stack_push (p->LS, (void*) p->CL); + return 0; + } + SCOPE int + rde_param_i_symbol_start_d (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) { + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + return 1; + } + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + return 0; + } + SCOPE int + rde_param_i_symbol_void_start (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) return 1; + rde_stack_push (p->LS, (void*) p->CL); + return 0; + } + SCOPE int + rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) return 1; + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + return 0; + } + SCOPE void + rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_reduce (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_leaf (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_leaf (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) + { + SV_CLEAR (p); + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) + { + SV_CLEAR (p); + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_char (p, c, m); + } + SCOPE void + rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_range (p, s, e, m); + } + SCOPE void + rde_param_i_next_alnum (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_alnum (p); + } + SCOPE void + rde_param_i_next_alpha (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_alpha (p); + } + SCOPE void + rde_param_i_next_ascii (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_ascii (p); + } + SCOPE void + rde_param_i_next_control (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_control (p); + } + SCOPE void + rde_param_i_next_ddigit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_ddigit (p); + } + SCOPE void + rde_param_i_next_digit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_digit (p); + } + SCOPE void + rde_param_i_next_graph (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_graph (p); + } + SCOPE void + rde_param_i_next_lower (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_lower (p); + } + SCOPE void + rde_param_i_next_print (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_print (p); + } + SCOPE void + rde_param_i_next_punct (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_punct (p); + } + SCOPE void + rde_param_i_next_space (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_space (p); + } + SCOPE void + rde_param_i_next_upper (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_upper (p); + } + SCOPE void + rde_param_i_next_wordchar (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_wordchar (p); + } + SCOPE void + rde_param_i_next_xdigit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_xdigit (p); + } + SCOPE void + rde_param_i_notahead_start_d (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + } + SCOPE void + rde_param_i_notahead_exit_d (RDE_PARAM p) + { + if (p->ST) { + rde_param_i_ast_pop_rewind (p); + } else { + rde_stack_pop (p->mark, 1); + } + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + p->ST = !p->ST; + } + SCOPE void + rde_param_i_notahead_exit (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + p->ST = !p->ST; + } + SCOPE void + rde_param_i_state_push_2 (RDE_PARAM p) + { + + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + SCOPE void + rde_param_i_state_push_void (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + ER_CLEAR (p); + rde_stack_push (p->ES, p->ER); + + } + SCOPE void + rde_param_i_state_push_value (RDE_PARAM p) + { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + rde_stack_push (p->LS, (void*) p->CL); + ER_CLEAR (p); + rde_stack_push (p->ES, p->ER); + + } + SCOPE void + rde_param_i_state_merge_ok (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + p->ST = 1; + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_state_merge_void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_state_merge_value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } + SCOPE int + rde_param_i_kleene_close (RDE_PARAM p) + { + int stop = !p->ST; + rde_param_i_error_pop_merge (p); + if (stop) { + p->ST = 1; + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + return stop; + } + SCOPE int + rde_param_i_kleene_abort (RDE_PARAM p) + { + int stop = !p->ST; + if (stop) { + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + return stop; + } + SCOPE int + rde_param_i_seq_void2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_seq_void2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_seq_value2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_bra_void2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->LS, 1); + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_void2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->LS, 1); + } else { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_value2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_value2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE void + rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) + { + int at = p->CL; + + while (*str) { + rde_param_i_input_next (p, m); + if (!p->ST) { + p->ER->loc = at+1; + p->CL = at; + return; + } + rde_param_i_test_char (p, str, m); + if (!p->ST) { + p->ER->loc = at+1; + p->CL = at; + return; + } + str = Tcl_UtfNext (str); + } + } + SCOPE void + rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + while (*class) { + p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; + if (p->ST) { + ER_CLEAR (p); + return; + } + class = Tcl_UtfNext (class); + } + error_set (p, m); + p->CL --; + } + + + /* + * Declaring the parse functions + */ + + static void notahead_3 (RDE_PARAM p); + static void sequence_6 (RDE_PARAM p); + static void sym_TEST (RDE_PARAM p); + + /* + * Precomputed table of strings (symbols, error messages, etc.). + */ + + static char const* p_string [17] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "t a", + /* 15 = */ "n TEST", + /* 16 = */ "TEST" + }; + + /* + * Grammar Start Expression + */ + + static void MAIN (RDE_PARAM p) { + sym_TEST (p); + return; + } + + /* + * value Symbol 'TEST' + */ + + static void sym_TEST (RDE_PARAM p) { + /* + * x + * ! + * 'a' + * (IDENTIFIER) + */ + + if (rde_param_i_symbol_start (p, 16)) return ; + sequence_6 (p); + rde_param_i_symbol_done_leaf (p, 16, 15); + return; + } + + static void sequence_6 (RDE_PARAM p) { + /* + * x + * ! + * 'a' + * (IDENTIFIER) + */ + + rde_param_i_state_push_void (p); + notahead_3 (p); + if (rde_param_i_seq_void2void(p)) return; + /* Undefined symbol 'IDENTIFIER' */; + rde_param_i_status_fail (p); + rde_param_i_state_merge_void (p); + return; + } + + static void notahead_3 (RDE_PARAM p) { + /* + * ! + * 'a' + */ + + rde_param_i_loc_push (p); + rde_param_i_next_char (p, "a", 14); + rde_param_i_notahead_exit (p); + return; + } + + /* -*- c -*- */ + + typedef struct PARSERg { + long int counter; + char buf [50]; + } PARSERg; + + static void + PARSERgRelease (ClientData cd, Tcl_Interp* interp) + { + ckfree((char*) cd); + } + + static const char* + PARSERnewName (Tcl_Interp* interp) + { +#define KEY "tcllib/parser/PACKAGE/TEA" + + Tcl_InterpDeleteProc* proc = PARSERgRelease; + PARSERg* parserg; + + parserg = Tcl_GetAssocData (interp, KEY, &proc); + if (parserg == NULL) { + parserg = (PARSERg*) ckalloc (sizeof (PARSERg)); + parserg->counter = 0; + + Tcl_SetAssocData (interp, KEY, proc, + (ClientData) parserg); + } + + parserg->counter ++; + sprintf (parserg->buf, "PARSER%ld", parserg->counter); + return parserg->buf; +#undef KEY + } + + static void + PARSERdeleteCmd (ClientData clientData) + { + /* + * Release the whole PARSER + * (Low-level engine only actually). + */ + rde_param_del ((RDE_PARAM) clientData); + } + + + /* * ** *** ***** ******** ************* + ** Functions implementing the object methods, and helper. + */ + + static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp); + + static int parser_PARSE (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + int mode; + Tcl_Channel chan; + + if (objc != 3) { + Tcl_WrongNumArgs (interp, 2, objv, "chan"); + return TCL_ERROR; + } + + chan = Tcl_GetChannel(interp, + Tcl_GetString (objv[2]), + &mode); + + if (!chan) { + return TCL_ERROR; + } + + rde_param_reset (p, chan); + MAIN (p) ; /* Entrypoint for the generated code. */ + return COMPLETE (p, interp); + } + + static int parser_PARSET (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + char* buf; + int len; + + if (objc != 3) { + Tcl_WrongNumArgs (interp, 2, objv, "text"); + return TCL_ERROR; + } + + buf = Tcl_GetStringFromObj (objv[2], &len); + + rde_param_reset (p, NULL); + rde_param_data (p, buf, len); + MAIN (p) ; /* Entrypoint for the generated code. */ + return COMPLETE (p, interp); + } + + /* See also rde_critcl/m.c, param_COMPLETE() */ + static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) + { + if (rde_param_query_st (p)) { + long int ac; + Tcl_Obj** av; + + rde_param_query_ast (p, &ac, &av); + + if (ac > 1) { + Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); + + memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); + lv [0] = Tcl_NewObj (); + lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); + lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); + + Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); + ckfree ((char*) lv); + + } else if (ac == 0) { + /* + * Match, but no AST. This is possible if the grammar + * consists of only the start expression. + */ + Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); + } else { + Tcl_SetObjResult (interp, av [0]); + } + + return TCL_OK; + } else { + Tcl_Obj* xv [1]; + const ERROR_STATE* er = rde_param_query_er (p); + Tcl_Obj* res = rde_param_query_er_tcl (p, er); + /* res = list (location, list(msg)) */ + + /* Stick the exception type-tag before the existing elements */ + xv [0] = Tcl_NewStringObj ("pt::rde",-1); + Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); + + Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); + Tcl_SetObjResult (interp, res); + return TCL_ERROR; + } + } + + + /* * ** *** ***** ******** ************* + ** Object command, method dispatch. + */ + static int parser_objcmd (ClientData cd, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + RDE_PARAM p = (RDE_PARAM) cd; + int m, res; + + static CONST char* methods [] = { + "destroy", "parse", "parset", NULL + }; + enum methods { + M_DESTROY, M_PARSE, M_PARSET + }; + + if (objc < 2) { + Tcl_WrongNumArgs (interp, objc, objv, "option ?arg arg ...?"); + return TCL_ERROR; + } else if (Tcl_GetIndexFromObj (interp, objv [1], methods, "option", + 0, &m) != TCL_OK) { + return TCL_ERROR; + } + + /* Dispatch to methods. They check the #args in + * detail before performing the requested + * functionality + */ + + switch (m) { + case M_DESTROY: + if (objc != 2) { + Tcl_WrongNumArgs (interp, 2, objv, NULL); + return TCL_ERROR; + } + + Tcl_DeleteCommandFromToken(interp, (Tcl_Command) rde_param_query_clientdata (p)); + return TCL_OK; + + case M_PARSE: res = parser_PARSE (p, interp, objc, objv); break; + case M_PARSET: res = parser_PARSET (p, interp, objc, objv); break; + default: + /* Not coming to this place */ + ASSERT (0,"Reached unreachable location"); + } + + return res; + } + + /** * ** *** ***** ******** ************* + * Class command, i.e. object construction. + */ + static int ParserClassCmd (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const*objv) { + /* + * Syntax: No arguments beyond the name + */ + + RDE_PARAM parser; + CONST char* name; + Tcl_Obj* fqn; + Tcl_CmdInfo ci; + Tcl_Command c; + +#define USAGE "?name?" + + if ((objc != 2) && (objc != 1)) { + Tcl_WrongNumArgs (interp, 1, objv, USAGE); + return TCL_ERROR; + } + + if (objc < 2) { + name = PARSERnewName (interp); + } else { + name = Tcl_GetString (objv [1]); + } + + if (!Tcl_StringMatch (name, "::*")) { + /* Relative name. Prefix with current namespace */ + + Tcl_Eval (interp, "namespace current"); + fqn = Tcl_GetObjResult (interp); + fqn = Tcl_DuplicateObj (fqn); + Tcl_IncrRefCount (fqn); + + if (!Tcl_StringMatch (Tcl_GetString (fqn), "::")) { + Tcl_AppendToObj (fqn, "::", -1); + } + Tcl_AppendToObj (fqn, name, -1); + } else { + fqn = Tcl_NewStringObj (name, -1); + Tcl_IncrRefCount (fqn); + } + Tcl_ResetResult (interp); + + if (Tcl_GetCommandInfo (interp, + Tcl_GetString (fqn), + &ci)) { + Tcl_Obj* err; + + err = Tcl_NewObj (); + Tcl_AppendToObj (err, "command \"", -1); + Tcl_AppendObjToObj (err, fqn); + Tcl_AppendToObj (err, "\" already exists", -1); + + Tcl_DecrRefCount (fqn); + Tcl_SetObjResult (interp, err); + return TCL_ERROR; + } + + parser = rde_param_new (sizeof(p_string)/sizeof(char*), (char**) p_string); + c = Tcl_CreateObjCommand (interp, Tcl_GetString (fqn), + parser_objcmd, (ClientData) parser, + PARSERdeleteCmd); + rde_param_clientdata (parser, (ClientData) c); + Tcl_SetObjResult (interp, fqn); + Tcl_DecrRefCount (fqn); + return TCL_OK; + } + +int Package_Init(Tcl_Interp* interp) { + if (interp == 0) return TCL_ERROR; + + if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { + return TCL_ERROR; + } + + if (Tcl_CreateObjCommand(interp, "PARSER", ParserClassCmd , NULL, NULL) == NULL) { + Tcl_SetResult(interp, "Can't create constructor", NULL); + return TCL_ERROR; + } + + + Tcl_PkgProvide(interp, "PACKAGE", "0.1"); + + return TCL_OK; +} ADDED modules/pt/tests/data/ok/peg_cparam-tea/11_epsilon Index: modules/pt/tests/data/ok/peg_cparam-tea/11_epsilon ================================================================== --- /dev/null +++ modules/pt/tests/data/ok/peg_cparam-tea/11_epsilon @@ -0,0 +1,2002 @@ +/************************************************************ +** +** TEA-based C/PARAM implementation of the parsing +** expression grammar +** +** TEMPLATE +** +** Generated from file TEST +** for user unknown +** +* * ** *** ***** ******** ************* *********************/ + #include + #include + #include + #include + #define SCOPE static + +#line 1 "rde_critcl/util.h" + + #ifndef _RDE_UTIL_H + #define _RDE_UTIL_H 1 + #ifndef SCOPE + #define SCOPE + #endif + #define ALLOC(type) (type *) ckalloc (sizeof (type)) + #define NALLOC(n,type) (type *) ckalloc ((n) * sizeof (type)) + #undef RDE_DEBUG + #define RDE_DEBUG 1 + #undef RDE_TRACE + #ifdef RDE_DEBUG + #define STOPAFTER(x) { static int count = (x); count --; if (!count) { Tcl_Panic ("stop"); } } + #define XSTR(x) #x + #define STR(x) XSTR(x) + #define RANGEOK(i,n) ((0 <= (i)) && (i < (n))) + #define ASSERT(x,msg) if (!(x)) { Tcl_Panic (msg " (" #x "), in file " __FILE__ " @line " STR(__LINE__));} + #define ASSERT_BOUNDS(i,n) ASSERT (RANGEOK(i,n),"array index out of bounds: " STR(i) " >= " STR(n)) + #else + #define STOPAFTER(x) + #define ASSERT(x,msg) + #define ASSERT_BOUNDS(i,n) + #endif + #ifdef RDE_TRACE + SCOPE void trace_enter (const char* fun); + SCOPE void trace_return (const char *pat, ...); + SCOPE void trace_printf (const char *pat, ...); + #define ENTER(fun) trace_enter (fun) + #define RETURN(format,x) trace_return (format,x) ; return x + #define RETURNVOID trace_return ("%s","(void)") ; return + #define TRACE0(x) trace_printf0 x + #define TRACE(x) trace_printf x + #else + #define ENTER(fun) + #define RETURN(f,x) return x + #define RETURNVOID return + #define TRACE0(x) + #define TRACE(x) + #endif + #endif + + +#line 1 "rde_critcl/stack.h" + + #ifndef _RDE_DS_STACK_H + #define _RDE_DS_STACK_H 1 + typedef void (*RDE_STACK_CELL_FREE) (void* cell); + typedef struct RDE_STACK_* RDE_STACK; + static const int RDE_STACK_INITIAL_SIZE = 256; + #endif + + +#line 1 "rde_critcl/tc.h" + + #ifndef _RDE_DS_TC_H + #define _RDE_DS_TC_H 1 + typedef struct RDE_TC_* RDE_TC; + #endif + + +#line 1 "rde_critcl/param.h" + + #ifndef _RDE_DS_PARAM_H + #define _RDE_DS_PARAM_H 1 + typedef struct RDE_PARAM_* RDE_PARAM; + typedef struct ERROR_STATE { + int refCount; + long int loc; + RDE_STACK msg; + } ERROR_STATE; + typedef struct NC_STATE { + long int CL; + long int ST; + Tcl_Obj* SV; + ERROR_STATE* ER; + } NC_STATE; + #endif + + +#line 1 "rde_critcl/util.c" + + #ifdef RDE_TRACE + typedef struct F_STACK { + const char* str; + struct F_STACK* down; + } F_STACK; + static F_STACK* top = 0; + static int level = 0; + static void + push (const char* str) + { + F_STACK* new = ALLOC (F_STACK); + new->str = str; + new->down = top; + top = new; + level += 4; + } + static void + pop (void) + { + F_STACK* next = top->down; + level -= 4; + ckfree ((char*)top); + top = next; + } + static void + indent (void) + { + int i; + for (i = 0; i < level; i++) { + fwrite(" ", 1, 1, stdout); + fflush (stdout); + } + if (top) { + fwrite(top->str, 1, strlen(top->str), stdout); + fflush (stdout); + } + fwrite(" ", 1, 1, stdout); + fflush (stdout); + } + SCOPE void + trace_enter (const char* fun) + { + push (fun); + indent(); + fwrite("ENTER\n", 1, 6, stdout); + fflush (stdout); + } + static char msg [1024*1024]; + SCOPE void + trace_return (const char *pat, ...) + { + int len; + va_list args; + indent(); + fwrite("RETURN = ", 1, 9, stdout); + fflush (stdout); + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + pop(); + } + SCOPE void + trace_printf (const char *pat, ...) + { + int len; + va_list args; + indent(); + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + } + SCOPE void + trace_printf0 (const char *pat, ...) + { + int len; + va_list args; + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + } + #endif + + +#line 1 "rde_critcl/stack.c" + + typedef struct RDE_STACK_ { + long int max; + long int top; + RDE_STACK_CELL_FREE freeCellProc; + void** cell; + } RDE_STACK_; + + SCOPE RDE_STACK + rde_stack_new (RDE_STACK_CELL_FREE freeCellProc) + { + RDE_STACK s = ALLOC (RDE_STACK_); + s->cell = NALLOC (RDE_STACK_INITIAL_SIZE, void*); + s->max = RDE_STACK_INITIAL_SIZE; + s->top = 0; + s->freeCellProc = freeCellProc; + return s; + } + SCOPE void + rde_stack_del (RDE_STACK s) + { + if (s->freeCellProc && s->top) { + long int i; + for (i=0; i < s->top; i++) { + ASSERT_BOUNDS(i,s->max); + s->freeCellProc ( s->cell [i] ); + } + } + ckfree ((char*) s->cell); + ckfree ((char*) s); + } + SCOPE void + rde_stack_push (RDE_STACK s, void* item) + { + if (s->top >= s->max) { + long int new = s->max ? (2 * s->max) : RDE_STACK_INITIAL_SIZE; + void** cell = (void**) ckrealloc ((char*) s->cell, new * sizeof(void*)); + ASSERT (cell,"Memory allocation failure for RDE stack"); + s->max = new; + s->cell = cell; + } + ASSERT_BOUNDS(s->top,s->max); + s->cell [s->top] = item; + s->top ++; + } + SCOPE void* + rde_stack_top (RDE_STACK s) + { + ASSERT_BOUNDS(s->top-1,s->max); + return s->cell [s->top - 1]; + } + SCOPE void + rde_stack_pop (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad pop count"); + if (n == 0) return; + if (s->freeCellProc) { + while (n) { + s->top --; + ASSERT_BOUNDS(s->top,s->max); + s->freeCellProc ( s->cell [s->top] ); + n --; + } + } else { + s->top -= n; + } + } + SCOPE void + rde_stack_trim (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad trimsize"); + if (s->freeCellProc) { + while (s->top > n) { + s->top --; + ASSERT_BOUNDS(s->top,s->max); + s->freeCellProc ( s->cell [s->top] ); + } + } else { + s->top = n; + } + } + SCOPE void + rde_stack_drop (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad pop count"); + if (n == 0) return; + s->top -= n; + } + SCOPE void + rde_stack_move (RDE_STACK dst, RDE_STACK src) + { + ASSERT (dst->freeCellProc == src->freeCellProc, "Ownership mismatch"); + + while (src->top > 0) { + src->top --; + ASSERT_BOUNDS(src->top,src->max); + rde_stack_push (dst, src->cell [src->top] ); + } + } + SCOPE void + rde_stack_get (RDE_STACK s, long int* cn, void*** cc) + { + *cn = s->top; + *cc = s->cell; + } + SCOPE long int + rde_stack_size (RDE_STACK s) + { + return s->top; + } + + +#line 1 "rde_critcl/tc.c" + + typedef struct RDE_TC_ { + int max; + int num; + char* str; + RDE_STACK off; + } RDE_TC_; + + SCOPE RDE_TC + rde_tc_new (void) + { + RDE_TC tc = ALLOC (RDE_TC_); + tc->max = RDE_STACK_INITIAL_SIZE; + tc->num = 0; + tc->str = NALLOC (RDE_STACK_INITIAL_SIZE, char); + tc->off = rde_stack_new (NULL); + return tc; + } + SCOPE void + rde_tc_del (RDE_TC tc) + { + rde_stack_del (tc->off); + ckfree (tc->str); + ckfree ((char*) tc); + } + SCOPE long int + rde_tc_size (RDE_TC tc) + { + return rde_stack_size (tc->off); + } + SCOPE void + rde_tc_clear (RDE_TC tc) + { + tc->num = 0; + rde_stack_trim (tc->off, 0); + } + SCOPE char* + rde_tc_append (RDE_TC tc, char* string, long int len) + { + long int base = tc->num; + long int off = tc->num; + char* ch; + int clen; + Tcl_UniChar uni; + if (len < 0) { + len = strlen (string); + } + + if (!len) { + return tc->str + base; + } + + if ((tc->num + len) >= tc->max) { + int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); + char* str = ckrealloc (tc->str, new * sizeof(char)); + ASSERT (str,"Memory allocation failure for token character array"); + tc->max = new; + tc->str = str; + } + tc->num += len; + ASSERT_BOUNDS(tc->num,tc->max); + ASSERT_BOUNDS(off,tc->max); + ASSERT_BOUNDS(off+len-1,tc->max); + ASSERT_BOUNDS(off+len-1,tc->num); + memcpy (tc->str + off, string, len); + + ch = string; + while (ch < (string + len)) { + ASSERT_BOUNDS(off,tc->num); + rde_stack_push (tc->off, (void*) off); + clen = Tcl_UtfToUniChar (ch, &uni); + off += clen; + ch += clen; + } + return tc->str + base; + } + SCOPE void + rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) + { + long int oc, off, top, end; + void** ov; + rde_stack_get (tc->off, &oc, &ov); + ASSERT_BOUNDS(at,oc); + off = (long int) ov [at]; + if ((at+1) == oc) { + end = tc->num; + } else { + end = (long int) ov [at+1]; + } + TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); + ASSERT_BOUNDS(off,tc->num); + ASSERT_BOUNDS(end-1,tc->num); + *ch = tc->str + off; + *len = end - off; + } + SCOPE void + rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) + { + long int oc, off, top, end; + void** ov; + rde_stack_get (tc->off, &oc, &ov); + ASSERT_BOUNDS(at,oc); + ASSERT_BOUNDS(last,oc); + off = (long int) ov [at]; + if ((last+1) == oc) { + end = tc->num; + } else { + end = (long int) ov [last+1]; + } + TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); + ASSERT_BOUNDS(off,tc->num); + ASSERT_BOUNDS(end-1,tc->num); + *ch = tc->str + off; + *len = end - off; + } + + +#line 1 "rde_critcl/param.c" + + typedef struct RDE_PARAM_ { + Tcl_Channel IN; + Tcl_Obj* readbuf; + char* CC; + long int CC_len; + RDE_TC TC; + long int CL; + RDE_STACK LS; + ERROR_STATE* ER; + RDE_STACK ES; + long int ST; + Tcl_Obj* SV; + Tcl_HashTable NC; + + RDE_STACK ast ; + RDE_STACK mark ; + + long int numstr; + char** string; + + ClientData clientData; + } RDE_PARAM_; + typedef int (*UniCharClass) (int); + typedef enum test_class_id { + tc_alnum, + tc_alpha, + tc_ascii, + tc_control, + tc_ddigit, + tc_digit, + tc_graph, + tc_lower, + tc_printable, + tc_punct, + tc_space, + tc_upper, + tc_wordchar, + tc_xdigit + } test_class_id; + static void ast_node_free (void* n); + static void error_state_free (void* es); + static void error_set (RDE_PARAM p, long int s); + static void nc_clear (RDE_PARAM p); + static int UniCharIsAscii (int character); + static int UniCharIsHexDigit (int character); + static int UniCharIsDecDigit (int character); + static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); + static int er_int_compare (const void* a, const void* b); + #define SV_INIT(p) \ + p->SV = NULL; \ + TRACE (("SV_INIT (%p => %p)", (p), (p)->SV)) + #define SV_SET(p,newsv) \ + if (((p)->SV) != (newsv)) { \ + TRACE (("SV_CLEAR/set (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_DecrRefCount ((p)->SV); \ + } \ + (p)->SV = (newsv); \ + TRACE (("SV_SET (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_IncrRefCount ((p)->SV); \ + } \ + } + #define SV_CLEAR(p) \ + TRACE (("SV_CLEAR (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_DecrRefCount ((p)->SV); \ + } \ + (p)->SV = NULL + #define ER_INIT(p) \ + p->ER = NULL; \ + TRACE (("ER_INIT (%p => %p)", (p), (p)->ER)) + #define ER_CLEAR(p) \ + error_state_free ((p)->ER); \ + (p)->ER = NULL + SCOPE RDE_PARAM + rde_param_new (long int nstr, char** strings) + { + RDE_PARAM p; + ENTER ("rde_param_new"); + TRACE (("\tINT %d strings @ %p", nstr, strings)); + p = ALLOC (RDE_PARAM_); + p->numstr = nstr; + p->string = strings; + p->readbuf = Tcl_NewObj (); + Tcl_IncrRefCount (p->readbuf); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + Tcl_InitHashTable (&p->NC, TCL_ONE_WORD_KEYS); + p->IN = NULL; + p->CL = -1; + p->ST = 0; + ER_INIT (p); + SV_INIT (p); + p->CC = NULL; + p->CC_len = 0; + p->TC = rde_tc_new (); + p->ES = rde_stack_new (error_state_free); + p->LS = rde_stack_new (NULL); + p->ast = rde_stack_new (ast_node_free); + p->mark = rde_stack_new (NULL); + RETURN ("%p", p); + } + SCOPE void + rde_param_del (RDE_PARAM p) + { + ENTER ("rde_param_del"); + TRACE (("RDE_PARAM %p",p)); + ER_CLEAR (p); TRACE (("\ter_clear")); + SV_CLEAR (p); TRACE (("\tsv_clear")); + nc_clear (p); TRACE (("\tnc_clear")); + Tcl_DeleteHashTable (&p->NC); TRACE (("\tnc hashtable delete")); + rde_tc_del (p->TC); TRACE (("\ttc clear")); + rde_stack_del (p->ES); TRACE (("\tes clear")); + rde_stack_del (p->LS); TRACE (("\tls clear")); + rde_stack_del (p->ast); TRACE (("\tast clear")); + rde_stack_del (p->mark); TRACE (("\tmark clear")); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + Tcl_DecrRefCount (p->readbuf); + ckfree ((char*) p); + RETURNVOID; + } + SCOPE void + rde_param_reset (RDE_PARAM p, Tcl_Channel chan) + { + ENTER ("rde_param_reset"); + TRACE (("RDE_PARAM %p",p)); + TRACE (("Tcl_Channel %p",chan)); + p->IN = chan; + p->CL = -1; + p->ST = 0; + p->CC = NULL; + p->CC_len = 0; + ER_CLEAR (p); + SV_CLEAR (p); + nc_clear (p); + rde_tc_clear (p->TC); + rde_stack_trim (p->ES, 0); + rde_stack_trim (p->LS, 0); + rde_stack_trim (p->ast, 0); + rde_stack_trim (p->mark, 0); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + RETURNVOID; + } + SCOPE void + rde_param_update_strings (RDE_PARAM p, long int nstr, char** strings) + { + ENTER ("rde_param_update_strings"); + TRACE (("RDE_PARAM %p", p)); + TRACE (("INT %d strings", nstr)); + p->numstr = nstr; + p->string = strings; + RETURNVOID; + } + SCOPE void + rde_param_data (RDE_PARAM p, char* buf, long int len) + { + (void) rde_tc_append (p->TC, buf, len); + } + SCOPE void + rde_param_clientdata (RDE_PARAM p, ClientData clientData) + { + p->clientData = clientData; + } + static void + nc_clear (RDE_PARAM p) + { + Tcl_HashSearch hs; + Tcl_HashEntry* he; + Tcl_HashTable* tablePtr; + for(he = Tcl_FirstHashEntry(&p->NC, &hs); + he != NULL; + he = Tcl_FirstHashEntry(&p->NC, &hs)) { + Tcl_HashSearch hsc; + Tcl_HashEntry* hec; + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (he); + for(hec = Tcl_FirstHashEntry(tablePtr, &hsc); + hec != NULL; + hec = Tcl_NextHashEntry(&hsc)) { + NC_STATE* scs = Tcl_GetHashValue (hec); + error_state_free (scs->ER); + if (scs->SV) { Tcl_DecrRefCount (scs->SV); } + ckfree ((char*) scs); + } + Tcl_DeleteHashTable (tablePtr); + ckfree ((char*) tablePtr); + Tcl_DeleteHashEntry (he); + } + } + SCOPE ClientData + rde_param_query_clientdata (RDE_PARAM p) + { + return p->clientData; + } + SCOPE void + rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) + { + rde_stack_get (p->mark, mc, mv); + } + SCOPE void + rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) + { + rde_stack_get (p->ast, ac, (void***) av); + } + SCOPE const char* + rde_param_query_in (RDE_PARAM p) + { + return p->IN + ? Tcl_GetChannelName (p->IN) + : ""; + } + SCOPE const char* + rde_param_query_cc (RDE_PARAM p, long int* len) + { + *len = p->CC_len; + return p->CC; + } + SCOPE int + rde_param_query_cl (RDE_PARAM p) + { + return p->CL; + } + SCOPE const ERROR_STATE* + rde_param_query_er (RDE_PARAM p) + { + return p->ER; + } + SCOPE Tcl_Obj* + rde_param_query_er_tcl (RDE_PARAM p, const ERROR_STATE* er) + { + Tcl_Obj* res; + if (!er) { + + res = Tcl_NewStringObj ("", 0); + } else { + Tcl_Obj* ov [2]; + Tcl_Obj** mov; + long int mc, i, j; + void** mv; + int lastid; + const char* msg; + rde_stack_get (er->msg, &mc, &mv); + + qsort (mv, mc, sizeof (void*), er_int_compare); + + mov = NALLOC (mc, Tcl_Obj*); + lastid = -1; + for (i=0, j=0; i < mc; i++) { + ASSERT_BOUNDS (i,mc); + if (((long int) mv [i]) == lastid) continue; + lastid = (long int) mv [i]; + ASSERT_BOUNDS((long int) mv[i],p->numstr); + msg = p->string [(long int) mv[i]]; + ASSERT_BOUNDS (j,mc); + mov [j] = Tcl_NewStringObj (msg, -1); + j++; + } + + ov [0] = Tcl_NewIntObj (er->loc); + ov [1] = Tcl_NewListObj (j, mov); + res = Tcl_NewListObj (2, ov); + ckfree ((char*) mov); + } + return res; + } + SCOPE void + rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) + { + rde_stack_get (p->ES, ec, (void***) ev); + } + SCOPE void + rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) + { + rde_stack_get (p->LS, lc, lv); + } + SCOPE long int + rde_param_query_lstop (RDE_PARAM p) + { + (long int) rde_stack_top (p->LS); + } + SCOPE Tcl_HashTable* + rde_param_query_nc (RDE_PARAM p) + { + return &p->NC; + } + SCOPE int + rde_param_query_st (RDE_PARAM p) + { + return p->ST; + } + SCOPE Tcl_Obj* + rde_param_query_sv (RDE_PARAM p) + { + TRACE (("SV_QUERY %p => (%p)", (p), (p)->SV)); \ + return p->SV; + } + SCOPE long int + rde_param_query_tc_size (RDE_PARAM p) + { + return rde_tc_size (p->TC); + } + SCOPE void + rde_param_query_tc_get_s (RDE_PARAM p, long int at, long int last, char** ch, long int* len) + { + rde_tc_get_s (p->TC, at, last, ch, len); + } + SCOPE const char* + rde_param_query_string (RDE_PARAM p, long int id) + { + TRACE (("rde_param_query_string (RDE_PARAM %p, %d/%d)", p, id, p->numstr)); + ASSERT_BOUNDS(id,p->numstr); + return p->string [id]; + } + SCOPE void + rde_param_i_ast_pop_discard (RDE_PARAM p) + { + rde_stack_pop (p->mark, 1); + } + SCOPE void + rde_param_i_ast_pop_rewind (RDE_PARAM p) + { + long int trim = (long int) rde_stack_top (p->mark); + ENTER ("rde_param_i_ast_pop_rewind"); + TRACE (("RDE_PARAM %p",p)); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_ast_rewind (RDE_PARAM p) + { + long int trim = (long int) rde_stack_top (p->mark); + ENTER ("rde_param_i_ast_rewind"); + TRACE (("RDE_PARAM %p",p)); + rde_stack_trim (p->ast, trim); + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_ast_push (RDE_PARAM p) + { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + } + SCOPE void + rde_param_i_ast_value_push (RDE_PARAM p) + { + ENTER ("rde_param_i_ast_value_push"); + TRACE (("RDE_PARAM %p",p)); + ASSERT(p->SV,"Unable to push undefined semantic value"); + TRACE (("rde_param_i_ast_value_push %p => (%p)", p, p->SV)); + TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV->refCount, Tcl_GetString (p->SV))); + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + RETURNVOID; + } + static void + ast_node_free (void* n) + { + Tcl_DecrRefCount ((Tcl_Obj*) n); + } + SCOPE void + rde_param_i_error_clear (RDE_PARAM p) + { + ER_CLEAR (p); + } + SCOPE void + rde_param_i_error_nonterminal (RDE_PARAM p, long int s) + { + + return; + long int pos; + if (!p->ER) return; + pos = 1 + (long int) rde_stack_top (p->LS); + if (p->ER->loc != pos) return; + error_set (p, s); + p->ER->loc = pos; + } + SCOPE void + rde_param_i_error_pop_merge (RDE_PARAM p) + { + ERROR_STATE* top = (ERROR_STATE*) rde_stack_top (p->ES); + + if (top == p->ER) { + rde_stack_pop (p->ES, 1); + return; + } + + if (!top) { + rde_stack_pop (p->ES, 1); + return; + } + + if (!p->ER) { + rde_stack_drop (p->ES, 1); + p->ER = top; + + return; + } + + if (top->loc < p->ER->loc) { + rde_stack_pop (p->ES, 1); + return; + } + + if (top->loc > p->ER->loc) { + rde_stack_drop (p->ES, 1); + error_state_free (p->ER); + p->ER = top; + + return; + } + + rde_stack_move (p->ER->msg, top->msg); + rde_stack_pop (p->ES, 1); + } + SCOPE void + rde_param_i_error_push (RDE_PARAM p) + { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + static void + error_set (RDE_PARAM p, long int s) + { + error_state_free (p->ER); + p->ER = ALLOC (ERROR_STATE); + p->ER->refCount = 1; + p->ER->loc = p->CL; + p->ER->msg = rde_stack_new (NULL); + ASSERT_BOUNDS(s,p->numstr); + rde_stack_push (p->ER->msg, (void*) s); + } + static void + error_state_free (void* esx) + { + ERROR_STATE* es = esx; + if (!es) return; + es->refCount --; + if (es->refCount > 0) return; + rde_stack_del (es->msg); + ckfree ((char*) es); + } + SCOPE void + rde_param_i_loc_pop_discard (RDE_PARAM p) + { + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_loc_pop_rewind (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_loc_push (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + } + SCOPE void + rde_param_i_loc_rewind (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + } + SCOPE void + rde_param_i_input_next (RDE_PARAM p, long int m) + { + int leni; + char* ch; + ASSERT_BOUNDS(m,p->numstr); + p->CL ++; + if (p->CL < rde_tc_size (p->TC)) { + + rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); + + ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); + p->ST = 1; + ER_CLEAR (p); + return; + } + if (!p->IN || + Tcl_Eof (p->IN) || + (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { + + p->ST = 0; + error_set (p, m); + return; + } + + ch = Tcl_GetStringFromObj (p->readbuf, &leni); + ASSERT_BOUNDS (leni, TCL_UTF_MAX); + p->CC = rde_tc_append (p->TC, ch, leni); + p->CC_len = leni; + p->ST = 1; + ER_CLEAR (p); + } + SCOPE void + rde_param_i_status_fail (RDE_PARAM p) + { + p->ST = 0; + } + SCOPE void + rde_param_i_status_ok (RDE_PARAM p) + { + p->ST = 1; + } + SCOPE void + rde_param_i_status_negate (RDE_PARAM p) + { + p->ST = !p->ST; + } + SCOPE int + rde_param_i_symbol_restore (RDE_PARAM p, long int s) + { + NC_STATE* scs; + Tcl_HashEntry* hPtr; + Tcl_HashTable* tablePtr; + + hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); + if (!hPtr) { return 0; } + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); + hPtr = Tcl_FindHashEntry (tablePtr, (char*) s); + if (!hPtr) { return 0; } + + scs = Tcl_GetHashValue (hPtr); + p->CL = scs->CL; + p->ST = scs->ST; + error_state_free (p->ER); + p->ER = scs->ER; + if (p->ER) { p->ER->refCount ++; } + TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); + SV_SET (p, scs->SV); + return 1; + } + SCOPE void + rde_param_i_symbol_save (RDE_PARAM p, long int s) + { + long int at = (long int) rde_stack_top (p->LS); + NC_STATE* scs; + Tcl_HashEntry* hPtr; + Tcl_HashTable* tablePtr; + int isnew; + ENTER ("rde_param_i_symbol_save"); + TRACE (("RDE_PARAM %p",p)); + TRACE (("INT %d",s)); + + hPtr = Tcl_CreateHashEntry (&p->NC, (char*) at, &isnew); + if (isnew) { + tablePtr = ALLOC (Tcl_HashTable); + Tcl_InitHashTable (tablePtr, TCL_ONE_WORD_KEYS); + Tcl_SetHashValue (hPtr, tablePtr); + } else { + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); + } + hPtr = Tcl_CreateHashEntry (tablePtr, (char*) s, &isnew); + if (isnew) { + + scs = ALLOC (NC_STATE); + scs->CL = p->CL; + scs->ST = p->ST; + TRACE (("SV_CACHE (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "")); + scs->SV = p->SV; + if (scs->SV) { Tcl_IncrRefCount (scs->SV); } + scs->ER = p->ER; + if (scs->ER) { scs->ER->refCount ++; } + Tcl_SetHashValue (hPtr, scs); + } else { + + scs = (NC_STATE*) Tcl_GetHashValue (hPtr); + scs->CL = p->CL; + scs->ST = p->ST; + TRACE (("SV_CACHE/over (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "" )); + if (scs->SV) { Tcl_DecrRefCount (scs->SV); } + scs->SV = p->SV; + if (scs->SV) { Tcl_IncrRefCount (scs->SV); } + error_state_free (scs->ER); + scs->ER = p->ER; + if (scs->ER) { scs->ER->refCount ++; } + } + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_test_alnum (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsAlnum, tc_alnum); + } + SCOPE void + rde_param_i_test_alpha (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsAlpha, tc_alpha); + } + SCOPE void + rde_param_i_test_ascii (RDE_PARAM p) + { + test_class (p, UniCharIsAscii, tc_ascii); + } + SCOPE void + rde_param_i_test_control (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsControl, tc_control); + } + SCOPE void + rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) + { + ASSERT_BOUNDS(msg,p->numstr); + p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, msg); + p->CL --; + } + } + SCOPE void + rde_param_i_test_ddigit (RDE_PARAM p) + { + test_class (p, UniCharIsDecDigit, tc_ddigit); + } + SCOPE void + rde_param_i_test_digit (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsDigit, tc_digit); + } + SCOPE void + rde_param_i_test_graph (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsGraph, tc_graph); + } + SCOPE void + rde_param_i_test_lower (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsLower, tc_lower); + } + SCOPE void + rde_param_i_test_print (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsPrint, tc_printable); + } + SCOPE void + rde_param_i_test_punct (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsPunct, tc_punct); + } + SCOPE void + rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) + { + ASSERT_BOUNDS(msg,p->numstr); + p->ST = + (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && + (Tcl_UtfNcmp (p->CC, e, 1) <= 0); + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, msg); + p->CL --; + } + } + SCOPE void + rde_param_i_test_space (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsSpace, tc_space); + } + SCOPE void + rde_param_i_test_upper (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsUpper, tc_upper); + } + SCOPE void + rde_param_i_test_wordchar (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsWordChar, tc_wordchar); + } + SCOPE void + rde_param_i_test_xdigit (RDE_PARAM p) + { + test_class (p, UniCharIsHexDigit, tc_xdigit); + } + static void + test_class (RDE_PARAM p, UniCharClass class, test_class_id id) + { + Tcl_UniChar ch; + Tcl_UtfToUniChar(p->CC, &ch); + ASSERT_BOUNDS(id,p->numstr); + p->ST = !!class (ch); + + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, id); + p->CL --; + } + } + static int + UniCharIsAscii (int character) + { + return (character >= 0) && (character < 0x80); + } + static int + UniCharIsHexDigit (int character) + { + return (character >= 0) && (character < 0x80) && isxdigit(character); + } + static int + UniCharIsDecDigit (int character) + { + return (character >= 0) && (character < 0x80) && isdigit(character); + } + SCOPE void + rde_param_i_value_clear (RDE_PARAM p) + { + SV_CLEAR (p); + } + SCOPE void + rde_param_i_value_leaf (RDE_PARAM p, long int s) + { + Tcl_Obj* newsv; + Tcl_Obj* ov [3]; + long int pos = 1 + (long int) rde_stack_top (p->LS); + ASSERT_BOUNDS(s,p->numstr); + ov [0] = Tcl_NewStringObj (p->string[s], -1); + ov [1] = Tcl_NewIntObj (pos); + ov [2] = Tcl_NewIntObj (p->CL); + newsv = Tcl_NewListObj (3, ov); + TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); + SV_SET (p, newsv); + } + SCOPE void + rde_param_i_value_reduce (RDE_PARAM p, long int s) + { + Tcl_Obj* newsv; + int oc, i, j; + Tcl_Obj** ov; + long int ac; + Tcl_Obj** av; + long int pos = 1 + (long int) rde_stack_top (p->LS); + long int mark = (long int) rde_stack_top (p->mark); + long int asize = rde_stack_size (p->ast); + long int new = asize - mark; + ASSERT (new >= 0, "Bad number of elements to reduce"); + ov = NALLOC (3+new, Tcl_Obj*); + ASSERT_BOUNDS(s,p->numstr); + ov [0] = Tcl_NewStringObj (p->string[s], -1); + ov [1] = Tcl_NewIntObj (pos); + ov [2] = Tcl_NewIntObj (p->CL); + rde_stack_get (p->ast, &ac, (void***) &av); + for (i = 3, j = mark; j < asize; i++, j++) { + ASSERT_BOUNDS (i, 3+new); + ASSERT_BOUNDS (j, ac); + ov [i] = av [j]; + } + ASSERT (i == 3+new, "Reduction result incomplete"); + newsv = Tcl_NewListObj (3+new, ov); + TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); + SV_SET (p, newsv); + ckfree ((char*) ov); + } + static int + er_int_compare (const void* a, const void* b) + { + + const void** ael = (const void**) a; + const void** bel = (const void**) b; + long int avalue = (long int) *ael; + long int bvalue = (long int) *bel; + if (avalue < bvalue) { return -1; } + if (avalue > bvalue) { return 1; } + return 0; + } + SCOPE int + rde_param_i_symbol_start (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) { + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + return 1; + } + rde_stack_push (p->LS, (void*) p->CL); + return 0; + } + SCOPE int + rde_param_i_symbol_start_d (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) { + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + return 1; + } + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + return 0; + } + SCOPE int + rde_param_i_symbol_void_start (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) return 1; + rde_stack_push (p->LS, (void*) p->CL); + return 0; + } + SCOPE int + rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) return 1; + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + return 0; + } + SCOPE void + rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_reduce (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_leaf (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_leaf (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) + { + SV_CLEAR (p); + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) + { + SV_CLEAR (p); + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_char (p, c, m); + } + SCOPE void + rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_range (p, s, e, m); + } + SCOPE void + rde_param_i_next_alnum (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_alnum (p); + } + SCOPE void + rde_param_i_next_alpha (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_alpha (p); + } + SCOPE void + rde_param_i_next_ascii (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_ascii (p); + } + SCOPE void + rde_param_i_next_control (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_control (p); + } + SCOPE void + rde_param_i_next_ddigit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_ddigit (p); + } + SCOPE void + rde_param_i_next_digit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_digit (p); + } + SCOPE void + rde_param_i_next_graph (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_graph (p); + } + SCOPE void + rde_param_i_next_lower (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_lower (p); + } + SCOPE void + rde_param_i_next_print (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_print (p); + } + SCOPE void + rde_param_i_next_punct (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_punct (p); + } + SCOPE void + rde_param_i_next_space (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_space (p); + } + SCOPE void + rde_param_i_next_upper (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_upper (p); + } + SCOPE void + rde_param_i_next_wordchar (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_wordchar (p); + } + SCOPE void + rde_param_i_next_xdigit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_xdigit (p); + } + SCOPE void + rde_param_i_notahead_start_d (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + } + SCOPE void + rde_param_i_notahead_exit_d (RDE_PARAM p) + { + if (p->ST) { + rde_param_i_ast_pop_rewind (p); + } else { + rde_stack_pop (p->mark, 1); + } + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + p->ST = !p->ST; + } + SCOPE void + rde_param_i_notahead_exit (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + p->ST = !p->ST; + } + SCOPE void + rde_param_i_state_push_2 (RDE_PARAM p) + { + + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + SCOPE void + rde_param_i_state_push_void (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + ER_CLEAR (p); + rde_stack_push (p->ES, p->ER); + + } + SCOPE void + rde_param_i_state_push_value (RDE_PARAM p) + { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + rde_stack_push (p->LS, (void*) p->CL); + ER_CLEAR (p); + rde_stack_push (p->ES, p->ER); + + } + SCOPE void + rde_param_i_state_merge_ok (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + p->ST = 1; + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_state_merge_void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_state_merge_value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } + SCOPE int + rde_param_i_kleene_close (RDE_PARAM p) + { + int stop = !p->ST; + rde_param_i_error_pop_merge (p); + if (stop) { + p->ST = 1; + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + return stop; + } + SCOPE int + rde_param_i_kleene_abort (RDE_PARAM p) + { + int stop = !p->ST; + if (stop) { + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + return stop; + } + SCOPE int + rde_param_i_seq_void2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_seq_void2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_seq_value2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_bra_void2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->LS, 1); + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_void2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->LS, 1); + } else { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_value2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_value2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE void + rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) + { + int at = p->CL; + + while (*str) { + rde_param_i_input_next (p, m); + if (!p->ST) { + p->ER->loc = at+1; + p->CL = at; + return; + } + rde_param_i_test_char (p, str, m); + if (!p->ST) { + p->ER->loc = at+1; + p->CL = at; + return; + } + str = Tcl_UtfNext (str); + } + } + SCOPE void + rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + while (*class) { + p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; + if (p->ST) { + ER_CLEAR (p); + return; + } + class = Tcl_UtfNext (class); + } + error_set (p, m); + p->CL --; + } + + + /* + * Declaring the parse functions + */ + + static void choice_3 (RDE_PARAM p); + + /* + * Precomputed table of strings (symbols, error messages, etc.). + */ + + static char const* p_string [15] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "t a" + }; + + /* + * Grammar Start Expression + */ + + static void MAIN (RDE_PARAM p) { + choice_3 (p); + return; + } + + static void choice_3 (RDE_PARAM p) { + /* + * / + * 'a' + * + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_char (p, "a", 14); + if (rde_param_i_bra_void2void(p)) return; + rde_param_i_status_ok (p); + rde_param_i_state_merge_void (p); + return; + } + + /* -*- c -*- */ + + typedef struct PARSERg { + long int counter; + char buf [50]; + } PARSERg; + + static void + PARSERgRelease (ClientData cd, Tcl_Interp* interp) + { + ckfree((char*) cd); + } + + static const char* + PARSERnewName (Tcl_Interp* interp) + { +#define KEY "tcllib/parser/PACKAGE/TEA" + + Tcl_InterpDeleteProc* proc = PARSERgRelease; + PARSERg* parserg; + + parserg = Tcl_GetAssocData (interp, KEY, &proc); + if (parserg == NULL) { + parserg = (PARSERg*) ckalloc (sizeof (PARSERg)); + parserg->counter = 0; + + Tcl_SetAssocData (interp, KEY, proc, + (ClientData) parserg); + } + + parserg->counter ++; + sprintf (parserg->buf, "PARSER%ld", parserg->counter); + return parserg->buf; +#undef KEY + } + + static void + PARSERdeleteCmd (ClientData clientData) + { + /* + * Release the whole PARSER + * (Low-level engine only actually). + */ + rde_param_del ((RDE_PARAM) clientData); + } + + + /* * ** *** ***** ******** ************* + ** Functions implementing the object methods, and helper. + */ + + static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp); + + static int parser_PARSE (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + int mode; + Tcl_Channel chan; + + if (objc != 3) { + Tcl_WrongNumArgs (interp, 2, objv, "chan"); + return TCL_ERROR; + } + + chan = Tcl_GetChannel(interp, + Tcl_GetString (objv[2]), + &mode); + + if (!chan) { + return TCL_ERROR; + } + + rde_param_reset (p, chan); + MAIN (p) ; /* Entrypoint for the generated code. */ + return COMPLETE (p, interp); + } + + static int parser_PARSET (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + char* buf; + int len; + + if (objc != 3) { + Tcl_WrongNumArgs (interp, 2, objv, "text"); + return TCL_ERROR; + } + + buf = Tcl_GetStringFromObj (objv[2], &len); + + rde_param_reset (p, NULL); + rde_param_data (p, buf, len); + MAIN (p) ; /* Entrypoint for the generated code. */ + return COMPLETE (p, interp); + } + + /* See also rde_critcl/m.c, param_COMPLETE() */ + static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) + { + if (rde_param_query_st (p)) { + long int ac; + Tcl_Obj** av; + + rde_param_query_ast (p, &ac, &av); + + if (ac > 1) { + Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); + + memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); + lv [0] = Tcl_NewObj (); + lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); + lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); + + Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); + ckfree ((char*) lv); + + } else if (ac == 0) { + /* + * Match, but no AST. This is possible if the grammar + * consists of only the start expression. + */ + Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); + } else { + Tcl_SetObjResult (interp, av [0]); + } + + return TCL_OK; + } else { + Tcl_Obj* xv [1]; + const ERROR_STATE* er = rde_param_query_er (p); + Tcl_Obj* res = rde_param_query_er_tcl (p, er); + /* res = list (location, list(msg)) */ + + /* Stick the exception type-tag before the existing elements */ + xv [0] = Tcl_NewStringObj ("pt::rde",-1); + Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); + + Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); + Tcl_SetObjResult (interp, res); + return TCL_ERROR; + } + } + + + /* * ** *** ***** ******** ************* + ** Object command, method dispatch. + */ + static int parser_objcmd (ClientData cd, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + RDE_PARAM p = (RDE_PARAM) cd; + int m, res; + + static CONST char* methods [] = { + "destroy", "parse", "parset", NULL + }; + enum methods { + M_DESTROY, M_PARSE, M_PARSET + }; + + if (objc < 2) { + Tcl_WrongNumArgs (interp, objc, objv, "option ?arg arg ...?"); + return TCL_ERROR; + } else if (Tcl_GetIndexFromObj (interp, objv [1], methods, "option", + 0, &m) != TCL_OK) { + return TCL_ERROR; + } + + /* Dispatch to methods. They check the #args in + * detail before performing the requested + * functionality + */ + + switch (m) { + case M_DESTROY: + if (objc != 2) { + Tcl_WrongNumArgs (interp, 2, objv, NULL); + return TCL_ERROR; + } + + Tcl_DeleteCommandFromToken(interp, (Tcl_Command) rde_param_query_clientdata (p)); + return TCL_OK; + + case M_PARSE: res = parser_PARSE (p, interp, objc, objv); break; + case M_PARSET: res = parser_PARSET (p, interp, objc, objv); break; + default: + /* Not coming to this place */ + ASSERT (0,"Reached unreachable location"); + } + + return res; + } + + /** * ** *** ***** ******** ************* + * Class command, i.e. object construction. + */ + static int ParserClassCmd (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const*objv) { + /* + * Syntax: No arguments beyond the name + */ + + RDE_PARAM parser; + CONST char* name; + Tcl_Obj* fqn; + Tcl_CmdInfo ci; + Tcl_Command c; + +#define USAGE "?name?" + + if ((objc != 2) && (objc != 1)) { + Tcl_WrongNumArgs (interp, 1, objv, USAGE); + return TCL_ERROR; + } + + if (objc < 2) { + name = PARSERnewName (interp); + } else { + name = Tcl_GetString (objv [1]); + } + + if (!Tcl_StringMatch (name, "::*")) { + /* Relative name. Prefix with current namespace */ + + Tcl_Eval (interp, "namespace current"); + fqn = Tcl_GetObjResult (interp); + fqn = Tcl_DuplicateObj (fqn); + Tcl_IncrRefCount (fqn); + + if (!Tcl_StringMatch (Tcl_GetString (fqn), "::")) { + Tcl_AppendToObj (fqn, "::", -1); + } + Tcl_AppendToObj (fqn, name, -1); + } else { + fqn = Tcl_NewStringObj (name, -1); + Tcl_IncrRefCount (fqn); + } + Tcl_ResetResult (interp); + + if (Tcl_GetCommandInfo (interp, + Tcl_GetString (fqn), + &ci)) { + Tcl_Obj* err; + + err = Tcl_NewObj (); + Tcl_AppendToObj (err, "command \"", -1); + Tcl_AppendObjToObj (err, fqn); + Tcl_AppendToObj (err, "\" already exists", -1); + + Tcl_DecrRefCount (fqn); + Tcl_SetObjResult (interp, err); + return TCL_ERROR; + } + + parser = rde_param_new (sizeof(p_string)/sizeof(char*), (char**) p_string); + c = Tcl_CreateObjCommand (interp, Tcl_GetString (fqn), + parser_objcmd, (ClientData) parser, + PARSERdeleteCmd); + rde_param_clientdata (parser, (ClientData) c); + Tcl_SetObjResult (interp, fqn); + Tcl_DecrRefCount (fqn); + return TCL_OK; + } + +int Package_Init(Tcl_Interp* interp) { + if (interp == 0) return TCL_ERROR; + + if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { + return TCL_ERROR; + } + + if (Tcl_CreateObjCommand(interp, "PARSER", ParserClassCmd , NULL, NULL) == NULL) { + Tcl_SetResult(interp, "Can't create constructor", NULL); + return TCL_ERROR; + } + + + Tcl_PkgProvide(interp, "PACKAGE", "0.1"); + + return TCL_OK; +} ADDED modules/pt/tests/data/ok/peg_cparam-tea/1_functions Index: modules/pt/tests/data/ok/peg_cparam-tea/1_functions ================================================================== --- /dev/null +++ modules/pt/tests/data/ok/peg_cparam-tea/1_functions @@ -0,0 +1,2063 @@ +/************************************************************ +** +** TEA-based C/PARAM implementation of the parsing +** expression grammar +** +** TEMPLATE +** +** Generated from file TEST +** for user unknown +** +* * ** *** ***** ******** ************* *********************/ + #include + #include + #include + #include + #define SCOPE static + +#line 1 "rde_critcl/util.h" + + #ifndef _RDE_UTIL_H + #define _RDE_UTIL_H 1 + #ifndef SCOPE + #define SCOPE + #endif + #define ALLOC(type) (type *) ckalloc (sizeof (type)) + #define NALLOC(n,type) (type *) ckalloc ((n) * sizeof (type)) + #undef RDE_DEBUG + #define RDE_DEBUG 1 + #undef RDE_TRACE + #ifdef RDE_DEBUG + #define STOPAFTER(x) { static int count = (x); count --; if (!count) { Tcl_Panic ("stop"); } } + #define XSTR(x) #x + #define STR(x) XSTR(x) + #define RANGEOK(i,n) ((0 <= (i)) && (i < (n))) + #define ASSERT(x,msg) if (!(x)) { Tcl_Panic (msg " (" #x "), in file " __FILE__ " @line " STR(__LINE__));} + #define ASSERT_BOUNDS(i,n) ASSERT (RANGEOK(i,n),"array index out of bounds: " STR(i) " >= " STR(n)) + #else + #define STOPAFTER(x) + #define ASSERT(x,msg) + #define ASSERT_BOUNDS(i,n) + #endif + #ifdef RDE_TRACE + SCOPE void trace_enter (const char* fun); + SCOPE void trace_return (const char *pat, ...); + SCOPE void trace_printf (const char *pat, ...); + #define ENTER(fun) trace_enter (fun) + #define RETURN(format,x) trace_return (format,x) ; return x + #define RETURNVOID trace_return ("%s","(void)") ; return + #define TRACE0(x) trace_printf0 x + #define TRACE(x) trace_printf x + #else + #define ENTER(fun) + #define RETURN(f,x) return x + #define RETURNVOID return + #define TRACE0(x) + #define TRACE(x) + #endif + #endif + + +#line 1 "rde_critcl/stack.h" + + #ifndef _RDE_DS_STACK_H + #define _RDE_DS_STACK_H 1 + typedef void (*RDE_STACK_CELL_FREE) (void* cell); + typedef struct RDE_STACK_* RDE_STACK; + static const int RDE_STACK_INITIAL_SIZE = 256; + #endif + + +#line 1 "rde_critcl/tc.h" + + #ifndef _RDE_DS_TC_H + #define _RDE_DS_TC_H 1 + typedef struct RDE_TC_* RDE_TC; + #endif + + +#line 1 "rde_critcl/param.h" + + #ifndef _RDE_DS_PARAM_H + #define _RDE_DS_PARAM_H 1 + typedef struct RDE_PARAM_* RDE_PARAM; + typedef struct ERROR_STATE { + int refCount; + long int loc; + RDE_STACK msg; + } ERROR_STATE; + typedef struct NC_STATE { + long int CL; + long int ST; + Tcl_Obj* SV; + ERROR_STATE* ER; + } NC_STATE; + #endif + + +#line 1 "rde_critcl/util.c" + + #ifdef RDE_TRACE + typedef struct F_STACK { + const char* str; + struct F_STACK* down; + } F_STACK; + static F_STACK* top = 0; + static int level = 0; + static void + push (const char* str) + { + F_STACK* new = ALLOC (F_STACK); + new->str = str; + new->down = top; + top = new; + level += 4; + } + static void + pop (void) + { + F_STACK* next = top->down; + level -= 4; + ckfree ((char*)top); + top = next; + } + static void + indent (void) + { + int i; + for (i = 0; i < level; i++) { + fwrite(" ", 1, 1, stdout); + fflush (stdout); + } + if (top) { + fwrite(top->str, 1, strlen(top->str), stdout); + fflush (stdout); + } + fwrite(" ", 1, 1, stdout); + fflush (stdout); + } + SCOPE void + trace_enter (const char* fun) + { + push (fun); + indent(); + fwrite("ENTER\n", 1, 6, stdout); + fflush (stdout); + } + static char msg [1024*1024]; + SCOPE void + trace_return (const char *pat, ...) + { + int len; + va_list args; + indent(); + fwrite("RETURN = ", 1, 9, stdout); + fflush (stdout); + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + pop(); + } + SCOPE void + trace_printf (const char *pat, ...) + { + int len; + va_list args; + indent(); + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + } + SCOPE void + trace_printf0 (const char *pat, ...) + { + int len; + va_list args; + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + } + #endif + + +#line 1 "rde_critcl/stack.c" + + typedef struct RDE_STACK_ { + long int max; + long int top; + RDE_STACK_CELL_FREE freeCellProc; + void** cell; + } RDE_STACK_; + + SCOPE RDE_STACK + rde_stack_new (RDE_STACK_CELL_FREE freeCellProc) + { + RDE_STACK s = ALLOC (RDE_STACK_); + s->cell = NALLOC (RDE_STACK_INITIAL_SIZE, void*); + s->max = RDE_STACK_INITIAL_SIZE; + s->top = 0; + s->freeCellProc = freeCellProc; + return s; + } + SCOPE void + rde_stack_del (RDE_STACK s) + { + if (s->freeCellProc && s->top) { + long int i; + for (i=0; i < s->top; i++) { + ASSERT_BOUNDS(i,s->max); + s->freeCellProc ( s->cell [i] ); + } + } + ckfree ((char*) s->cell); + ckfree ((char*) s); + } + SCOPE void + rde_stack_push (RDE_STACK s, void* item) + { + if (s->top >= s->max) { + long int new = s->max ? (2 * s->max) : RDE_STACK_INITIAL_SIZE; + void** cell = (void**) ckrealloc ((char*) s->cell, new * sizeof(void*)); + ASSERT (cell,"Memory allocation failure for RDE stack"); + s->max = new; + s->cell = cell; + } + ASSERT_BOUNDS(s->top,s->max); + s->cell [s->top] = item; + s->top ++; + } + SCOPE void* + rde_stack_top (RDE_STACK s) + { + ASSERT_BOUNDS(s->top-1,s->max); + return s->cell [s->top - 1]; + } + SCOPE void + rde_stack_pop (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad pop count"); + if (n == 0) return; + if (s->freeCellProc) { + while (n) { + s->top --; + ASSERT_BOUNDS(s->top,s->max); + s->freeCellProc ( s->cell [s->top] ); + n --; + } + } else { + s->top -= n; + } + } + SCOPE void + rde_stack_trim (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad trimsize"); + if (s->freeCellProc) { + while (s->top > n) { + s->top --; + ASSERT_BOUNDS(s->top,s->max); + s->freeCellProc ( s->cell [s->top] ); + } + } else { + s->top = n; + } + } + SCOPE void + rde_stack_drop (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad pop count"); + if (n == 0) return; + s->top -= n; + } + SCOPE void + rde_stack_move (RDE_STACK dst, RDE_STACK src) + { + ASSERT (dst->freeCellProc == src->freeCellProc, "Ownership mismatch"); + + while (src->top > 0) { + src->top --; + ASSERT_BOUNDS(src->top,src->max); + rde_stack_push (dst, src->cell [src->top] ); + } + } + SCOPE void + rde_stack_get (RDE_STACK s, long int* cn, void*** cc) + { + *cn = s->top; + *cc = s->cell; + } + SCOPE long int + rde_stack_size (RDE_STACK s) + { + return s->top; + } + + +#line 1 "rde_critcl/tc.c" + + typedef struct RDE_TC_ { + int max; + int num; + char* str; + RDE_STACK off; + } RDE_TC_; + + SCOPE RDE_TC + rde_tc_new (void) + { + RDE_TC tc = ALLOC (RDE_TC_); + tc->max = RDE_STACK_INITIAL_SIZE; + tc->num = 0; + tc->str = NALLOC (RDE_STACK_INITIAL_SIZE, char); + tc->off = rde_stack_new (NULL); + return tc; + } + SCOPE void + rde_tc_del (RDE_TC tc) + { + rde_stack_del (tc->off); + ckfree (tc->str); + ckfree ((char*) tc); + } + SCOPE long int + rde_tc_size (RDE_TC tc) + { + return rde_stack_size (tc->off); + } + SCOPE void + rde_tc_clear (RDE_TC tc) + { + tc->num = 0; + rde_stack_trim (tc->off, 0); + } + SCOPE char* + rde_tc_append (RDE_TC tc, char* string, long int len) + { + long int base = tc->num; + long int off = tc->num; + char* ch; + int clen; + Tcl_UniChar uni; + if (len < 0) { + len = strlen (string); + } + + if (!len) { + return tc->str + base; + } + + if ((tc->num + len) >= tc->max) { + int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); + char* str = ckrealloc (tc->str, new * sizeof(char)); + ASSERT (str,"Memory allocation failure for token character array"); + tc->max = new; + tc->str = str; + } + tc->num += len; + ASSERT_BOUNDS(tc->num,tc->max); + ASSERT_BOUNDS(off,tc->max); + ASSERT_BOUNDS(off+len-1,tc->max); + ASSERT_BOUNDS(off+len-1,tc->num); + memcpy (tc->str + off, string, len); + + ch = string; + while (ch < (string + len)) { + ASSERT_BOUNDS(off,tc->num); + rde_stack_push (tc->off, (void*) off); + clen = Tcl_UtfToUniChar (ch, &uni); + off += clen; + ch += clen; + } + return tc->str + base; + } + SCOPE void + rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) + { + long int oc, off, top, end; + void** ov; + rde_stack_get (tc->off, &oc, &ov); + ASSERT_BOUNDS(at,oc); + off = (long int) ov [at]; + if ((at+1) == oc) { + end = tc->num; + } else { + end = (long int) ov [at+1]; + } + TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); + ASSERT_BOUNDS(off,tc->num); + ASSERT_BOUNDS(end-1,tc->num); + *ch = tc->str + off; + *len = end - off; + } + SCOPE void + rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) + { + long int oc, off, top, end; + void** ov; + rde_stack_get (tc->off, &oc, &ov); + ASSERT_BOUNDS(at,oc); + ASSERT_BOUNDS(last,oc); + off = (long int) ov [at]; + if ((last+1) == oc) { + end = tc->num; + } else { + end = (long int) ov [last+1]; + } + TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); + ASSERT_BOUNDS(off,tc->num); + ASSERT_BOUNDS(end-1,tc->num); + *ch = tc->str + off; + *len = end - off; + } + + +#line 1 "rde_critcl/param.c" + + typedef struct RDE_PARAM_ { + Tcl_Channel IN; + Tcl_Obj* readbuf; + char* CC; + long int CC_len; + RDE_TC TC; + long int CL; + RDE_STACK LS; + ERROR_STATE* ER; + RDE_STACK ES; + long int ST; + Tcl_Obj* SV; + Tcl_HashTable NC; + + RDE_STACK ast ; + RDE_STACK mark ; + + long int numstr; + char** string; + + ClientData clientData; + } RDE_PARAM_; + typedef int (*UniCharClass) (int); + typedef enum test_class_id { + tc_alnum, + tc_alpha, + tc_ascii, + tc_control, + tc_ddigit, + tc_digit, + tc_graph, + tc_lower, + tc_printable, + tc_punct, + tc_space, + tc_upper, + tc_wordchar, + tc_xdigit + } test_class_id; + static void ast_node_free (void* n); + static void error_state_free (void* es); + static void error_set (RDE_PARAM p, long int s); + static void nc_clear (RDE_PARAM p); + static int UniCharIsAscii (int character); + static int UniCharIsHexDigit (int character); + static int UniCharIsDecDigit (int character); + static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); + static int er_int_compare (const void* a, const void* b); + #define SV_INIT(p) \ + p->SV = NULL; \ + TRACE (("SV_INIT (%p => %p)", (p), (p)->SV)) + #define SV_SET(p,newsv) \ + if (((p)->SV) != (newsv)) { \ + TRACE (("SV_CLEAR/set (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_DecrRefCount ((p)->SV); \ + } \ + (p)->SV = (newsv); \ + TRACE (("SV_SET (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_IncrRefCount ((p)->SV); \ + } \ + } + #define SV_CLEAR(p) \ + TRACE (("SV_CLEAR (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_DecrRefCount ((p)->SV); \ + } \ + (p)->SV = NULL + #define ER_INIT(p) \ + p->ER = NULL; \ + TRACE (("ER_INIT (%p => %p)", (p), (p)->ER)) + #define ER_CLEAR(p) \ + error_state_free ((p)->ER); \ + (p)->ER = NULL + SCOPE RDE_PARAM + rde_param_new (long int nstr, char** strings) + { + RDE_PARAM p; + ENTER ("rde_param_new"); + TRACE (("\tINT %d strings @ %p", nstr, strings)); + p = ALLOC (RDE_PARAM_); + p->numstr = nstr; + p->string = strings; + p->readbuf = Tcl_NewObj (); + Tcl_IncrRefCount (p->readbuf); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + Tcl_InitHashTable (&p->NC, TCL_ONE_WORD_KEYS); + p->IN = NULL; + p->CL = -1; + p->ST = 0; + ER_INIT (p); + SV_INIT (p); + p->CC = NULL; + p->CC_len = 0; + p->TC = rde_tc_new (); + p->ES = rde_stack_new (error_state_free); + p->LS = rde_stack_new (NULL); + p->ast = rde_stack_new (ast_node_free); + p->mark = rde_stack_new (NULL); + RETURN ("%p", p); + } + SCOPE void + rde_param_del (RDE_PARAM p) + { + ENTER ("rde_param_del"); + TRACE (("RDE_PARAM %p",p)); + ER_CLEAR (p); TRACE (("\ter_clear")); + SV_CLEAR (p); TRACE (("\tsv_clear")); + nc_clear (p); TRACE (("\tnc_clear")); + Tcl_DeleteHashTable (&p->NC); TRACE (("\tnc hashtable delete")); + rde_tc_del (p->TC); TRACE (("\ttc clear")); + rde_stack_del (p->ES); TRACE (("\tes clear")); + rde_stack_del (p->LS); TRACE (("\tls clear")); + rde_stack_del (p->ast); TRACE (("\tast clear")); + rde_stack_del (p->mark); TRACE (("\tmark clear")); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + Tcl_DecrRefCount (p->readbuf); + ckfree ((char*) p); + RETURNVOID; + } + SCOPE void + rde_param_reset (RDE_PARAM p, Tcl_Channel chan) + { + ENTER ("rde_param_reset"); + TRACE (("RDE_PARAM %p",p)); + TRACE (("Tcl_Channel %p",chan)); + p->IN = chan; + p->CL = -1; + p->ST = 0; + p->CC = NULL; + p->CC_len = 0; + ER_CLEAR (p); + SV_CLEAR (p); + nc_clear (p); + rde_tc_clear (p->TC); + rde_stack_trim (p->ES, 0); + rde_stack_trim (p->LS, 0); + rde_stack_trim (p->ast, 0); + rde_stack_trim (p->mark, 0); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + RETURNVOID; + } + SCOPE void + rde_param_update_strings (RDE_PARAM p, long int nstr, char** strings) + { + ENTER ("rde_param_update_strings"); + TRACE (("RDE_PARAM %p", p)); + TRACE (("INT %d strings", nstr)); + p->numstr = nstr; + p->string = strings; + RETURNVOID; + } + SCOPE void + rde_param_data (RDE_PARAM p, char* buf, long int len) + { + (void) rde_tc_append (p->TC, buf, len); + } + SCOPE void + rde_param_clientdata (RDE_PARAM p, ClientData clientData) + { + p->clientData = clientData; + } + static void + nc_clear (RDE_PARAM p) + { + Tcl_HashSearch hs; + Tcl_HashEntry* he; + Tcl_HashTable* tablePtr; + for(he = Tcl_FirstHashEntry(&p->NC, &hs); + he != NULL; + he = Tcl_FirstHashEntry(&p->NC, &hs)) { + Tcl_HashSearch hsc; + Tcl_HashEntry* hec; + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (he); + for(hec = Tcl_FirstHashEntry(tablePtr, &hsc); + hec != NULL; + hec = Tcl_NextHashEntry(&hsc)) { + NC_STATE* scs = Tcl_GetHashValue (hec); + error_state_free (scs->ER); + if (scs->SV) { Tcl_DecrRefCount (scs->SV); } + ckfree ((char*) scs); + } + Tcl_DeleteHashTable (tablePtr); + ckfree ((char*) tablePtr); + Tcl_DeleteHashEntry (he); + } + } + SCOPE ClientData + rde_param_query_clientdata (RDE_PARAM p) + { + return p->clientData; + } + SCOPE void + rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) + { + rde_stack_get (p->mark, mc, mv); + } + SCOPE void + rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) + { + rde_stack_get (p->ast, ac, (void***) av); + } + SCOPE const char* + rde_param_query_in (RDE_PARAM p) + { + return p->IN + ? Tcl_GetChannelName (p->IN) + : ""; + } + SCOPE const char* + rde_param_query_cc (RDE_PARAM p, long int* len) + { + *len = p->CC_len; + return p->CC; + } + SCOPE int + rde_param_query_cl (RDE_PARAM p) + { + return p->CL; + } + SCOPE const ERROR_STATE* + rde_param_query_er (RDE_PARAM p) + { + return p->ER; + } + SCOPE Tcl_Obj* + rde_param_query_er_tcl (RDE_PARAM p, const ERROR_STATE* er) + { + Tcl_Obj* res; + if (!er) { + + res = Tcl_NewStringObj ("", 0); + } else { + Tcl_Obj* ov [2]; + Tcl_Obj** mov; + long int mc, i, j; + void** mv; + int lastid; + const char* msg; + rde_stack_get (er->msg, &mc, &mv); + + qsort (mv, mc, sizeof (void*), er_int_compare); + + mov = NALLOC (mc, Tcl_Obj*); + lastid = -1; + for (i=0, j=0; i < mc; i++) { + ASSERT_BOUNDS (i,mc); + if (((long int) mv [i]) == lastid) continue; + lastid = (long int) mv [i]; + ASSERT_BOUNDS((long int) mv[i],p->numstr); + msg = p->string [(long int) mv[i]]; + ASSERT_BOUNDS (j,mc); + mov [j] = Tcl_NewStringObj (msg, -1); + j++; + } + + ov [0] = Tcl_NewIntObj (er->loc); + ov [1] = Tcl_NewListObj (j, mov); + res = Tcl_NewListObj (2, ov); + ckfree ((char*) mov); + } + return res; + } + SCOPE void + rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) + { + rde_stack_get (p->ES, ec, (void***) ev); + } + SCOPE void + rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) + { + rde_stack_get (p->LS, lc, lv); + } + SCOPE long int + rde_param_query_lstop (RDE_PARAM p) + { + (long int) rde_stack_top (p->LS); + } + SCOPE Tcl_HashTable* + rde_param_query_nc (RDE_PARAM p) + { + return &p->NC; + } + SCOPE int + rde_param_query_st (RDE_PARAM p) + { + return p->ST; + } + SCOPE Tcl_Obj* + rde_param_query_sv (RDE_PARAM p) + { + TRACE (("SV_QUERY %p => (%p)", (p), (p)->SV)); \ + return p->SV; + } + SCOPE long int + rde_param_query_tc_size (RDE_PARAM p) + { + return rde_tc_size (p->TC); + } + SCOPE void + rde_param_query_tc_get_s (RDE_PARAM p, long int at, long int last, char** ch, long int* len) + { + rde_tc_get_s (p->TC, at, last, ch, len); + } + SCOPE const char* + rde_param_query_string (RDE_PARAM p, long int id) + { + TRACE (("rde_param_query_string (RDE_PARAM %p, %d/%d)", p, id, p->numstr)); + ASSERT_BOUNDS(id,p->numstr); + return p->string [id]; + } + SCOPE void + rde_param_i_ast_pop_discard (RDE_PARAM p) + { + rde_stack_pop (p->mark, 1); + } + SCOPE void + rde_param_i_ast_pop_rewind (RDE_PARAM p) + { + long int trim = (long int) rde_stack_top (p->mark); + ENTER ("rde_param_i_ast_pop_rewind"); + TRACE (("RDE_PARAM %p",p)); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_ast_rewind (RDE_PARAM p) + { + long int trim = (long int) rde_stack_top (p->mark); + ENTER ("rde_param_i_ast_rewind"); + TRACE (("RDE_PARAM %p",p)); + rde_stack_trim (p->ast, trim); + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_ast_push (RDE_PARAM p) + { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + } + SCOPE void + rde_param_i_ast_value_push (RDE_PARAM p) + { + ENTER ("rde_param_i_ast_value_push"); + TRACE (("RDE_PARAM %p",p)); + ASSERT(p->SV,"Unable to push undefined semantic value"); + TRACE (("rde_param_i_ast_value_push %p => (%p)", p, p->SV)); + TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV->refCount, Tcl_GetString (p->SV))); + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + RETURNVOID; + } + static void + ast_node_free (void* n) + { + Tcl_DecrRefCount ((Tcl_Obj*) n); + } + SCOPE void + rde_param_i_error_clear (RDE_PARAM p) + { + ER_CLEAR (p); + } + SCOPE void + rde_param_i_error_nonterminal (RDE_PARAM p, long int s) + { + + return; + long int pos; + if (!p->ER) return; + pos = 1 + (long int) rde_stack_top (p->LS); + if (p->ER->loc != pos) return; + error_set (p, s); + p->ER->loc = pos; + } + SCOPE void + rde_param_i_error_pop_merge (RDE_PARAM p) + { + ERROR_STATE* top = (ERROR_STATE*) rde_stack_top (p->ES); + + if (top == p->ER) { + rde_stack_pop (p->ES, 1); + return; + } + + if (!top) { + rde_stack_pop (p->ES, 1); + return; + } + + if (!p->ER) { + rde_stack_drop (p->ES, 1); + p->ER = top; + + return; + } + + if (top->loc < p->ER->loc) { + rde_stack_pop (p->ES, 1); + return; + } + + if (top->loc > p->ER->loc) { + rde_stack_drop (p->ES, 1); + error_state_free (p->ER); + p->ER = top; + + return; + } + + rde_stack_move (p->ER->msg, top->msg); + rde_stack_pop (p->ES, 1); + } + SCOPE void + rde_param_i_error_push (RDE_PARAM p) + { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + static void + error_set (RDE_PARAM p, long int s) + { + error_state_free (p->ER); + p->ER = ALLOC (ERROR_STATE); + p->ER->refCount = 1; + p->ER->loc = p->CL; + p->ER->msg = rde_stack_new (NULL); + ASSERT_BOUNDS(s,p->numstr); + rde_stack_push (p->ER->msg, (void*) s); + } + static void + error_state_free (void* esx) + { + ERROR_STATE* es = esx; + if (!es) return; + es->refCount --; + if (es->refCount > 0) return; + rde_stack_del (es->msg); + ckfree ((char*) es); + } + SCOPE void + rde_param_i_loc_pop_discard (RDE_PARAM p) + { + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_loc_pop_rewind (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_loc_push (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + } + SCOPE void + rde_param_i_loc_rewind (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + } + SCOPE void + rde_param_i_input_next (RDE_PARAM p, long int m) + { + int leni; + char* ch; + ASSERT_BOUNDS(m,p->numstr); + p->CL ++; + if (p->CL < rde_tc_size (p->TC)) { + + rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); + + ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); + p->ST = 1; + ER_CLEAR (p); + return; + } + if (!p->IN || + Tcl_Eof (p->IN) || + (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { + + p->ST = 0; + error_set (p, m); + return; + } + + ch = Tcl_GetStringFromObj (p->readbuf, &leni); + ASSERT_BOUNDS (leni, TCL_UTF_MAX); + p->CC = rde_tc_append (p->TC, ch, leni); + p->CC_len = leni; + p->ST = 1; + ER_CLEAR (p); + } + SCOPE void + rde_param_i_status_fail (RDE_PARAM p) + { + p->ST = 0; + } + SCOPE void + rde_param_i_status_ok (RDE_PARAM p) + { + p->ST = 1; + } + SCOPE void + rde_param_i_status_negate (RDE_PARAM p) + { + p->ST = !p->ST; + } + SCOPE int + rde_param_i_symbol_restore (RDE_PARAM p, long int s) + { + NC_STATE* scs; + Tcl_HashEntry* hPtr; + Tcl_HashTable* tablePtr; + + hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); + if (!hPtr) { return 0; } + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); + hPtr = Tcl_FindHashEntry (tablePtr, (char*) s); + if (!hPtr) { return 0; } + + scs = Tcl_GetHashValue (hPtr); + p->CL = scs->CL; + p->ST = scs->ST; + error_state_free (p->ER); + p->ER = scs->ER; + if (p->ER) { p->ER->refCount ++; } + TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); + SV_SET (p, scs->SV); + return 1; + } + SCOPE void + rde_param_i_symbol_save (RDE_PARAM p, long int s) + { + long int at = (long int) rde_stack_top (p->LS); + NC_STATE* scs; + Tcl_HashEntry* hPtr; + Tcl_HashTable* tablePtr; + int isnew; + ENTER ("rde_param_i_symbol_save"); + TRACE (("RDE_PARAM %p",p)); + TRACE (("INT %d",s)); + + hPtr = Tcl_CreateHashEntry (&p->NC, (char*) at, &isnew); + if (isnew) { + tablePtr = ALLOC (Tcl_HashTable); + Tcl_InitHashTable (tablePtr, TCL_ONE_WORD_KEYS); + Tcl_SetHashValue (hPtr, tablePtr); + } else { + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); + } + hPtr = Tcl_CreateHashEntry (tablePtr, (char*) s, &isnew); + if (isnew) { + + scs = ALLOC (NC_STATE); + scs->CL = p->CL; + scs->ST = p->ST; + TRACE (("SV_CACHE (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "")); + scs->SV = p->SV; + if (scs->SV) { Tcl_IncrRefCount (scs->SV); } + scs->ER = p->ER; + if (scs->ER) { scs->ER->refCount ++; } + Tcl_SetHashValue (hPtr, scs); + } else { + + scs = (NC_STATE*) Tcl_GetHashValue (hPtr); + scs->CL = p->CL; + scs->ST = p->ST; + TRACE (("SV_CACHE/over (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "" )); + if (scs->SV) { Tcl_DecrRefCount (scs->SV); } + scs->SV = p->SV; + if (scs->SV) { Tcl_IncrRefCount (scs->SV); } + error_state_free (scs->ER); + scs->ER = p->ER; + if (scs->ER) { scs->ER->refCount ++; } + } + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_test_alnum (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsAlnum, tc_alnum); + } + SCOPE void + rde_param_i_test_alpha (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsAlpha, tc_alpha); + } + SCOPE void + rde_param_i_test_ascii (RDE_PARAM p) + { + test_class (p, UniCharIsAscii, tc_ascii); + } + SCOPE void + rde_param_i_test_control (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsControl, tc_control); + } + SCOPE void + rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) + { + ASSERT_BOUNDS(msg,p->numstr); + p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, msg); + p->CL --; + } + } + SCOPE void + rde_param_i_test_ddigit (RDE_PARAM p) + { + test_class (p, UniCharIsDecDigit, tc_ddigit); + } + SCOPE void + rde_param_i_test_digit (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsDigit, tc_digit); + } + SCOPE void + rde_param_i_test_graph (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsGraph, tc_graph); + } + SCOPE void + rde_param_i_test_lower (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsLower, tc_lower); + } + SCOPE void + rde_param_i_test_print (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsPrint, tc_printable); + } + SCOPE void + rde_param_i_test_punct (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsPunct, tc_punct); + } + SCOPE void + rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) + { + ASSERT_BOUNDS(msg,p->numstr); + p->ST = + (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && + (Tcl_UtfNcmp (p->CC, e, 1) <= 0); + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, msg); + p->CL --; + } + } + SCOPE void + rde_param_i_test_space (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsSpace, tc_space); + } + SCOPE void + rde_param_i_test_upper (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsUpper, tc_upper); + } + SCOPE void + rde_param_i_test_wordchar (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsWordChar, tc_wordchar); + } + SCOPE void + rde_param_i_test_xdigit (RDE_PARAM p) + { + test_class (p, UniCharIsHexDigit, tc_xdigit); + } + static void + test_class (RDE_PARAM p, UniCharClass class, test_class_id id) + { + Tcl_UniChar ch; + Tcl_UtfToUniChar(p->CC, &ch); + ASSERT_BOUNDS(id,p->numstr); + p->ST = !!class (ch); + + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, id); + p->CL --; + } + } + static int + UniCharIsAscii (int character) + { + return (character >= 0) && (character < 0x80); + } + static int + UniCharIsHexDigit (int character) + { + return (character >= 0) && (character < 0x80) && isxdigit(character); + } + static int + UniCharIsDecDigit (int character) + { + return (character >= 0) && (character < 0x80) && isdigit(character); + } + SCOPE void + rde_param_i_value_clear (RDE_PARAM p) + { + SV_CLEAR (p); + } + SCOPE void + rde_param_i_value_leaf (RDE_PARAM p, long int s) + { + Tcl_Obj* newsv; + Tcl_Obj* ov [3]; + long int pos = 1 + (long int) rde_stack_top (p->LS); + ASSERT_BOUNDS(s,p->numstr); + ov [0] = Tcl_NewStringObj (p->string[s], -1); + ov [1] = Tcl_NewIntObj (pos); + ov [2] = Tcl_NewIntObj (p->CL); + newsv = Tcl_NewListObj (3, ov); + TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); + SV_SET (p, newsv); + } + SCOPE void + rde_param_i_value_reduce (RDE_PARAM p, long int s) + { + Tcl_Obj* newsv; + int oc, i, j; + Tcl_Obj** ov; + long int ac; + Tcl_Obj** av; + long int pos = 1 + (long int) rde_stack_top (p->LS); + long int mark = (long int) rde_stack_top (p->mark); + long int asize = rde_stack_size (p->ast); + long int new = asize - mark; + ASSERT (new >= 0, "Bad number of elements to reduce"); + ov = NALLOC (3+new, Tcl_Obj*); + ASSERT_BOUNDS(s,p->numstr); + ov [0] = Tcl_NewStringObj (p->string[s], -1); + ov [1] = Tcl_NewIntObj (pos); + ov [2] = Tcl_NewIntObj (p->CL); + rde_stack_get (p->ast, &ac, (void***) &av); + for (i = 3, j = mark; j < asize; i++, j++) { + ASSERT_BOUNDS (i, 3+new); + ASSERT_BOUNDS (j, ac); + ov [i] = av [j]; + } + ASSERT (i == 3+new, "Reduction result incomplete"); + newsv = Tcl_NewListObj (3+new, ov); + TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); + SV_SET (p, newsv); + ckfree ((char*) ov); + } + static int + er_int_compare (const void* a, const void* b) + { + + const void** ael = (const void**) a; + const void** bel = (const void**) b; + long int avalue = (long int) *ael; + long int bvalue = (long int) *bel; + if (avalue < bvalue) { return -1; } + if (avalue > bvalue) { return 1; } + return 0; + } + SCOPE int + rde_param_i_symbol_start (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) { + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + return 1; + } + rde_stack_push (p->LS, (void*) p->CL); + return 0; + } + SCOPE int + rde_param_i_symbol_start_d (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) { + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + return 1; + } + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + return 0; + } + SCOPE int + rde_param_i_symbol_void_start (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) return 1; + rde_stack_push (p->LS, (void*) p->CL); + return 0; + } + SCOPE int + rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) return 1; + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + return 0; + } + SCOPE void + rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_reduce (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_leaf (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_leaf (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) + { + SV_CLEAR (p); + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) + { + SV_CLEAR (p); + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_char (p, c, m); + } + SCOPE void + rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_range (p, s, e, m); + } + SCOPE void + rde_param_i_next_alnum (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_alnum (p); + } + SCOPE void + rde_param_i_next_alpha (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_alpha (p); + } + SCOPE void + rde_param_i_next_ascii (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_ascii (p); + } + SCOPE void + rde_param_i_next_control (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_control (p); + } + SCOPE void + rde_param_i_next_ddigit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_ddigit (p); + } + SCOPE void + rde_param_i_next_digit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_digit (p); + } + SCOPE void + rde_param_i_next_graph (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_graph (p); + } + SCOPE void + rde_param_i_next_lower (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_lower (p); + } + SCOPE void + rde_param_i_next_print (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_print (p); + } + SCOPE void + rde_param_i_next_punct (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_punct (p); + } + SCOPE void + rde_param_i_next_space (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_space (p); + } + SCOPE void + rde_param_i_next_upper (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_upper (p); + } + SCOPE void + rde_param_i_next_wordchar (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_wordchar (p); + } + SCOPE void + rde_param_i_next_xdigit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_xdigit (p); + } + SCOPE void + rde_param_i_notahead_start_d (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + } + SCOPE void + rde_param_i_notahead_exit_d (RDE_PARAM p) + { + if (p->ST) { + rde_param_i_ast_pop_rewind (p); + } else { + rde_stack_pop (p->mark, 1); + } + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + p->ST = !p->ST; + } + SCOPE void + rde_param_i_notahead_exit (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + p->ST = !p->ST; + } + SCOPE void + rde_param_i_state_push_2 (RDE_PARAM p) + { + + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + SCOPE void + rde_param_i_state_push_void (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + ER_CLEAR (p); + rde_stack_push (p->ES, p->ER); + + } + SCOPE void + rde_param_i_state_push_value (RDE_PARAM p) + { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + rde_stack_push (p->LS, (void*) p->CL); + ER_CLEAR (p); + rde_stack_push (p->ES, p->ER); + + } + SCOPE void + rde_param_i_state_merge_ok (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + p->ST = 1; + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_state_merge_void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_state_merge_value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } + SCOPE int + rde_param_i_kleene_close (RDE_PARAM p) + { + int stop = !p->ST; + rde_param_i_error_pop_merge (p); + if (stop) { + p->ST = 1; + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + return stop; + } + SCOPE int + rde_param_i_kleene_abort (RDE_PARAM p) + { + int stop = !p->ST; + if (stop) { + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + return stop; + } + SCOPE int + rde_param_i_seq_void2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_seq_void2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_seq_value2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_bra_void2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->LS, 1); + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_void2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->LS, 1); + } else { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_value2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_value2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE void + rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) + { + int at = p->CL; + + while (*str) { + rde_param_i_input_next (p, m); + if (!p->ST) { + p->ER->loc = at+1; + p->CL = at; + return; + } + rde_param_i_test_char (p, str, m); + if (!p->ST) { + p->ER->loc = at+1; + p->CL = at; + return; + } + str = Tcl_UtfNext (str); + } + } + SCOPE void + rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + while (*class) { + p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; + if (p->ST) { + ER_CLEAR (p); + return; + } + class = Tcl_UtfNext (class); + } + error_set (p, m); + p->CL --; + } + + + /* + * Declaring the parse functions + */ + + static void sym_Expression (RDE_PARAM p); + static void sym_Function (RDE_PARAM p); + static void sequence_9 (RDE_PARAM p); + static void sym_Sinus (RDE_PARAM p); + + /* + * Precomputed table of strings (symbols, error messages, etc.). + */ + + static char const* p_string [22] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "n Expression", + /* 15 = */ "Expression", + /* 16 = */ "n Function", + /* 17 = */ "Function", + /* 18 = */ "str sin(", + /* 19 = */ "t )", + /* 20 = */ "n Sinus", + /* 21 = */ "Sinus" + }; + + /* + * Grammar Start Expression + */ + + static void MAIN (RDE_PARAM p) { + sym_Expression (p); + return; + } + + /* + * value Symbol 'Expression' + */ + + static void sym_Expression (RDE_PARAM p) { + /* + * (Function) + */ + + if (rde_param_i_symbol_start_d (p, 15)) return ; + sym_Function (p); + rde_param_i_symbol_done_d_reduce (p, 15, 14); + return; + } + + /* + * value Symbol 'Function' + */ + + static void sym_Function (RDE_PARAM p) { + /* + * (Sinus) + */ + + if (rde_param_i_symbol_start_d (p, 17)) return ; + sym_Sinus (p); + rde_param_i_symbol_done_d_reduce (p, 17, 16); + return; + } + + /* + * value Symbol 'Sinus' + */ + + static void sym_Sinus (RDE_PARAM p) { + /* + * x + * "sin\(" + * (Expression) + * '\)' + */ + + if (rde_param_i_symbol_start_d (p, 21)) return ; + sequence_9 (p); + rde_param_i_symbol_done_d_reduce (p, 21, 20); + return; + } + + static void sequence_9 (RDE_PARAM p) { + /* + * x + * "sin\(" + * (Expression) + * '\)' + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_str (p, "sin(", 18); + if (rde_param_i_seq_void2value(p)) return; + sym_Expression (p); + if (rde_param_i_seq_value2value(p)) return; + rde_param_i_next_char (p, ")", 19); + rde_param_i_state_merge_value (p); + return; + } + + /* -*- c -*- */ + + typedef struct PARSERg { + long int counter; + char buf [50]; + } PARSERg; + + static void + PARSERgRelease (ClientData cd, Tcl_Interp* interp) + { + ckfree((char*) cd); + } + + static const char* + PARSERnewName (Tcl_Interp* interp) + { +#define KEY "tcllib/parser/PACKAGE/TEA" + + Tcl_InterpDeleteProc* proc = PARSERgRelease; + PARSERg* parserg; + + parserg = Tcl_GetAssocData (interp, KEY, &proc); + if (parserg == NULL) { + parserg = (PARSERg*) ckalloc (sizeof (PARSERg)); + parserg->counter = 0; + + Tcl_SetAssocData (interp, KEY, proc, + (ClientData) parserg); + } + + parserg->counter ++; + sprintf (parserg->buf, "PARSER%ld", parserg->counter); + return parserg->buf; +#undef KEY + } + + static void + PARSERdeleteCmd (ClientData clientData) + { + /* + * Release the whole PARSER + * (Low-level engine only actually). + */ + rde_param_del ((RDE_PARAM) clientData); + } + + + /* * ** *** ***** ******** ************* + ** Functions implementing the object methods, and helper. + */ + + static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp); + + static int parser_PARSE (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + int mode; + Tcl_Channel chan; + + if (objc != 3) { + Tcl_WrongNumArgs (interp, 2, objv, "chan"); + return TCL_ERROR; + } + + chan = Tcl_GetChannel(interp, + Tcl_GetString (objv[2]), + &mode); + + if (!chan) { + return TCL_ERROR; + } + + rde_param_reset (p, chan); + MAIN (p) ; /* Entrypoint for the generated code. */ + return COMPLETE (p, interp); + } + + static int parser_PARSET (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + char* buf; + int len; + + if (objc != 3) { + Tcl_WrongNumArgs (interp, 2, objv, "text"); + return TCL_ERROR; + } + + buf = Tcl_GetStringFromObj (objv[2], &len); + + rde_param_reset (p, NULL); + rde_param_data (p, buf, len); + MAIN (p) ; /* Entrypoint for the generated code. */ + return COMPLETE (p, interp); + } + + /* See also rde_critcl/m.c, param_COMPLETE() */ + static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) + { + if (rde_param_query_st (p)) { + long int ac; + Tcl_Obj** av; + + rde_param_query_ast (p, &ac, &av); + + if (ac > 1) { + Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); + + memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); + lv [0] = Tcl_NewObj (); + lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); + lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); + + Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); + ckfree ((char*) lv); + + } else if (ac == 0) { + /* + * Match, but no AST. This is possible if the grammar + * consists of only the start expression. + */ + Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); + } else { + Tcl_SetObjResult (interp, av [0]); + } + + return TCL_OK; + } else { + Tcl_Obj* xv [1]; + const ERROR_STATE* er = rde_param_query_er (p); + Tcl_Obj* res = rde_param_query_er_tcl (p, er); + /* res = list (location, list(msg)) */ + + /* Stick the exception type-tag before the existing elements */ + xv [0] = Tcl_NewStringObj ("pt::rde",-1); + Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); + + Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); + Tcl_SetObjResult (interp, res); + return TCL_ERROR; + } + } + + + /* * ** *** ***** ******** ************* + ** Object command, method dispatch. + */ + static int parser_objcmd (ClientData cd, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + RDE_PARAM p = (RDE_PARAM) cd; + int m, res; + + static CONST char* methods [] = { + "destroy", "parse", "parset", NULL + }; + enum methods { + M_DESTROY, M_PARSE, M_PARSET + }; + + if (objc < 2) { + Tcl_WrongNumArgs (interp, objc, objv, "option ?arg arg ...?"); + return TCL_ERROR; + } else if (Tcl_GetIndexFromObj (interp, objv [1], methods, "option", + 0, &m) != TCL_OK) { + return TCL_ERROR; + } + + /* Dispatch to methods. They check the #args in + * detail before performing the requested + * functionality + */ + + switch (m) { + case M_DESTROY: + if (objc != 2) { + Tcl_WrongNumArgs (interp, 2, objv, NULL); + return TCL_ERROR; + } + + Tcl_DeleteCommandFromToken(interp, (Tcl_Command) rde_param_query_clientdata (p)); + return TCL_OK; + + case M_PARSE: res = parser_PARSE (p, interp, objc, objv); break; + case M_PARSET: res = parser_PARSET (p, interp, objc, objv); break; + default: + /* Not coming to this place */ + ASSERT (0,"Reached unreachable location"); + } + + return res; + } + + /** * ** *** ***** ******** ************* + * Class command, i.e. object construction. + */ + static int ParserClassCmd (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const*objv) { + /* + * Syntax: No arguments beyond the name + */ + + RDE_PARAM parser; + CONST char* name; + Tcl_Obj* fqn; + Tcl_CmdInfo ci; + Tcl_Command c; + +#define USAGE "?name?" + + if ((objc != 2) && (objc != 1)) { + Tcl_WrongNumArgs (interp, 1, objv, USAGE); + return TCL_ERROR; + } + + if (objc < 2) { + name = PARSERnewName (interp); + } else { + name = Tcl_GetString (objv [1]); + } + + if (!Tcl_StringMatch (name, "::*")) { + /* Relative name. Prefix with current namespace */ + + Tcl_Eval (interp, "namespace current"); + fqn = Tcl_GetObjResult (interp); + fqn = Tcl_DuplicateObj (fqn); + Tcl_IncrRefCount (fqn); + + if (!Tcl_StringMatch (Tcl_GetString (fqn), "::")) { + Tcl_AppendToObj (fqn, "::", -1); + } + Tcl_AppendToObj (fqn, name, -1); + } else { + fqn = Tcl_NewStringObj (name, -1); + Tcl_IncrRefCount (fqn); + } + Tcl_ResetResult (interp); + + if (Tcl_GetCommandInfo (interp, + Tcl_GetString (fqn), + &ci)) { + Tcl_Obj* err; + + err = Tcl_NewObj (); + Tcl_AppendToObj (err, "command \"", -1); + Tcl_AppendObjToObj (err, fqn); + Tcl_AppendToObj (err, "\" already exists", -1); + + Tcl_DecrRefCount (fqn); + Tcl_SetObjResult (interp, err); + return TCL_ERROR; + } + + parser = rde_param_new (sizeof(p_string)/sizeof(char*), (char**) p_string); + c = Tcl_CreateObjCommand (interp, Tcl_GetString (fqn), + parser_objcmd, (ClientData) parser, + PARSERdeleteCmd); + rde_param_clientdata (parser, (ClientData) c); + Tcl_SetObjResult (interp, fqn); + Tcl_DecrRefCount (fqn); + return TCL_OK; + } + +int Package_Init(Tcl_Interp* interp) { + if (interp == 0) return TCL_ERROR; + + if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { + return TCL_ERROR; + } + + if (Tcl_CreateObjCommand(interp, "PARSER", ParserClassCmd , NULL, NULL) == NULL) { + Tcl_SetResult(interp, "Can't create constructor", NULL); + return TCL_ERROR; + } + + + Tcl_PkgProvide(interp, "PACKAGE", "0.1"); + + return TCL_OK; +} ADDED modules/pt/tests/data/ok/peg_cparam-tea/2_fun_arithmetic Index: modules/pt/tests/data/ok/peg_cparam-tea/2_fun_arithmetic ================================================================== --- /dev/null +++ modules/pt/tests/data/ok/peg_cparam-tea/2_fun_arithmetic @@ -0,0 +1,2412 @@ +/************************************************************ +** +** TEA-based C/PARAM implementation of the parsing +** expression grammar +** +** TEMPLATE +** +** Generated from file TEST +** for user unknown +** +* * ** *** ***** ******** ************* *********************/ + #include + #include + #include + #include + #define SCOPE static + +#line 1 "rde_critcl/util.h" + + #ifndef _RDE_UTIL_H + #define _RDE_UTIL_H 1 + #ifndef SCOPE + #define SCOPE + #endif + #define ALLOC(type) (type *) ckalloc (sizeof (type)) + #define NALLOC(n,type) (type *) ckalloc ((n) * sizeof (type)) + #undef RDE_DEBUG + #define RDE_DEBUG 1 + #undef RDE_TRACE + #ifdef RDE_DEBUG + #define STOPAFTER(x) { static int count = (x); count --; if (!count) { Tcl_Panic ("stop"); } } + #define XSTR(x) #x + #define STR(x) XSTR(x) + #define RANGEOK(i,n) ((0 <= (i)) && (i < (n))) + #define ASSERT(x,msg) if (!(x)) { Tcl_Panic (msg " (" #x "), in file " __FILE__ " @line " STR(__LINE__));} + #define ASSERT_BOUNDS(i,n) ASSERT (RANGEOK(i,n),"array index out of bounds: " STR(i) " >= " STR(n)) + #else + #define STOPAFTER(x) + #define ASSERT(x,msg) + #define ASSERT_BOUNDS(i,n) + #endif + #ifdef RDE_TRACE + SCOPE void trace_enter (const char* fun); + SCOPE void trace_return (const char *pat, ...); + SCOPE void trace_printf (const char *pat, ...); + #define ENTER(fun) trace_enter (fun) + #define RETURN(format,x) trace_return (format,x) ; return x + #define RETURNVOID trace_return ("%s","(void)") ; return + #define TRACE0(x) trace_printf0 x + #define TRACE(x) trace_printf x + #else + #define ENTER(fun) + #define RETURN(f,x) return x + #define RETURNVOID return + #define TRACE0(x) + #define TRACE(x) + #endif + #endif + + +#line 1 "rde_critcl/stack.h" + + #ifndef _RDE_DS_STACK_H + #define _RDE_DS_STACK_H 1 + typedef void (*RDE_STACK_CELL_FREE) (void* cell); + typedef struct RDE_STACK_* RDE_STACK; + static const int RDE_STACK_INITIAL_SIZE = 256; + #endif + + +#line 1 "rde_critcl/tc.h" + + #ifndef _RDE_DS_TC_H + #define _RDE_DS_TC_H 1 + typedef struct RDE_TC_* RDE_TC; + #endif + + +#line 1 "rde_critcl/param.h" + + #ifndef _RDE_DS_PARAM_H + #define _RDE_DS_PARAM_H 1 + typedef struct RDE_PARAM_* RDE_PARAM; + typedef struct ERROR_STATE { + int refCount; + long int loc; + RDE_STACK msg; + } ERROR_STATE; + typedef struct NC_STATE { + long int CL; + long int ST; + Tcl_Obj* SV; + ERROR_STATE* ER; + } NC_STATE; + #endif + + +#line 1 "rde_critcl/util.c" + + #ifdef RDE_TRACE + typedef struct F_STACK { + const char* str; + struct F_STACK* down; + } F_STACK; + static F_STACK* top = 0; + static int level = 0; + static void + push (const char* str) + { + F_STACK* new = ALLOC (F_STACK); + new->str = str; + new->down = top; + top = new; + level += 4; + } + static void + pop (void) + { + F_STACK* next = top->down; + level -= 4; + ckfree ((char*)top); + top = next; + } + static void + indent (void) + { + int i; + for (i = 0; i < level; i++) { + fwrite(" ", 1, 1, stdout); + fflush (stdout); + } + if (top) { + fwrite(top->str, 1, strlen(top->str), stdout); + fflush (stdout); + } + fwrite(" ", 1, 1, stdout); + fflush (stdout); + } + SCOPE void + trace_enter (const char* fun) + { + push (fun); + indent(); + fwrite("ENTER\n", 1, 6, stdout); + fflush (stdout); + } + static char msg [1024*1024]; + SCOPE void + trace_return (const char *pat, ...) + { + int len; + va_list args; + indent(); + fwrite("RETURN = ", 1, 9, stdout); + fflush (stdout); + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + pop(); + } + SCOPE void + trace_printf (const char *pat, ...) + { + int len; + va_list args; + indent(); + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + } + SCOPE void + trace_printf0 (const char *pat, ...) + { + int len; + va_list args; + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + } + #endif + + +#line 1 "rde_critcl/stack.c" + + typedef struct RDE_STACK_ { + long int max; + long int top; + RDE_STACK_CELL_FREE freeCellProc; + void** cell; + } RDE_STACK_; + + SCOPE RDE_STACK + rde_stack_new (RDE_STACK_CELL_FREE freeCellProc) + { + RDE_STACK s = ALLOC (RDE_STACK_); + s->cell = NALLOC (RDE_STACK_INITIAL_SIZE, void*); + s->max = RDE_STACK_INITIAL_SIZE; + s->top = 0; + s->freeCellProc = freeCellProc; + return s; + } + SCOPE void + rde_stack_del (RDE_STACK s) + { + if (s->freeCellProc && s->top) { + long int i; + for (i=0; i < s->top; i++) { + ASSERT_BOUNDS(i,s->max); + s->freeCellProc ( s->cell [i] ); + } + } + ckfree ((char*) s->cell); + ckfree ((char*) s); + } + SCOPE void + rde_stack_push (RDE_STACK s, void* item) + { + if (s->top >= s->max) { + long int new = s->max ? (2 * s->max) : RDE_STACK_INITIAL_SIZE; + void** cell = (void**) ckrealloc ((char*) s->cell, new * sizeof(void*)); + ASSERT (cell,"Memory allocation failure for RDE stack"); + s->max = new; + s->cell = cell; + } + ASSERT_BOUNDS(s->top,s->max); + s->cell [s->top] = item; + s->top ++; + } + SCOPE void* + rde_stack_top (RDE_STACK s) + { + ASSERT_BOUNDS(s->top-1,s->max); + return s->cell [s->top - 1]; + } + SCOPE void + rde_stack_pop (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad pop count"); + if (n == 0) return; + if (s->freeCellProc) { + while (n) { + s->top --; + ASSERT_BOUNDS(s->top,s->max); + s->freeCellProc ( s->cell [s->top] ); + n --; + } + } else { + s->top -= n; + } + } + SCOPE void + rde_stack_trim (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad trimsize"); + if (s->freeCellProc) { + while (s->top > n) { + s->top --; + ASSERT_BOUNDS(s->top,s->max); + s->freeCellProc ( s->cell [s->top] ); + } + } else { + s->top = n; + } + } + SCOPE void + rde_stack_drop (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad pop count"); + if (n == 0) return; + s->top -= n; + } + SCOPE void + rde_stack_move (RDE_STACK dst, RDE_STACK src) + { + ASSERT (dst->freeCellProc == src->freeCellProc, "Ownership mismatch"); + + while (src->top > 0) { + src->top --; + ASSERT_BOUNDS(src->top,src->max); + rde_stack_push (dst, src->cell [src->top] ); + } + } + SCOPE void + rde_stack_get (RDE_STACK s, long int* cn, void*** cc) + { + *cn = s->top; + *cc = s->cell; + } + SCOPE long int + rde_stack_size (RDE_STACK s) + { + return s->top; + } + + +#line 1 "rde_critcl/tc.c" + + typedef struct RDE_TC_ { + int max; + int num; + char* str; + RDE_STACK off; + } RDE_TC_; + + SCOPE RDE_TC + rde_tc_new (void) + { + RDE_TC tc = ALLOC (RDE_TC_); + tc->max = RDE_STACK_INITIAL_SIZE; + tc->num = 0; + tc->str = NALLOC (RDE_STACK_INITIAL_SIZE, char); + tc->off = rde_stack_new (NULL); + return tc; + } + SCOPE void + rde_tc_del (RDE_TC tc) + { + rde_stack_del (tc->off); + ckfree (tc->str); + ckfree ((char*) tc); + } + SCOPE long int + rde_tc_size (RDE_TC tc) + { + return rde_stack_size (tc->off); + } + SCOPE void + rde_tc_clear (RDE_TC tc) + { + tc->num = 0; + rde_stack_trim (tc->off, 0); + } + SCOPE char* + rde_tc_append (RDE_TC tc, char* string, long int len) + { + long int base = tc->num; + long int off = tc->num; + char* ch; + int clen; + Tcl_UniChar uni; + if (len < 0) { + len = strlen (string); + } + + if (!len) { + return tc->str + base; + } + + if ((tc->num + len) >= tc->max) { + int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); + char* str = ckrealloc (tc->str, new * sizeof(char)); + ASSERT (str,"Memory allocation failure for token character array"); + tc->max = new; + tc->str = str; + } + tc->num += len; + ASSERT_BOUNDS(tc->num,tc->max); + ASSERT_BOUNDS(off,tc->max); + ASSERT_BOUNDS(off+len-1,tc->max); + ASSERT_BOUNDS(off+len-1,tc->num); + memcpy (tc->str + off, string, len); + + ch = string; + while (ch < (string + len)) { + ASSERT_BOUNDS(off,tc->num); + rde_stack_push (tc->off, (void*) off); + clen = Tcl_UtfToUniChar (ch, &uni); + off += clen; + ch += clen; + } + return tc->str + base; + } + SCOPE void + rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) + { + long int oc, off, top, end; + void** ov; + rde_stack_get (tc->off, &oc, &ov); + ASSERT_BOUNDS(at,oc); + off = (long int) ov [at]; + if ((at+1) == oc) { + end = tc->num; + } else { + end = (long int) ov [at+1]; + } + TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); + ASSERT_BOUNDS(off,tc->num); + ASSERT_BOUNDS(end-1,tc->num); + *ch = tc->str + off; + *len = end - off; + } + SCOPE void + rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) + { + long int oc, off, top, end; + void** ov; + rde_stack_get (tc->off, &oc, &ov); + ASSERT_BOUNDS(at,oc); + ASSERT_BOUNDS(last,oc); + off = (long int) ov [at]; + if ((last+1) == oc) { + end = tc->num; + } else { + end = (long int) ov [last+1]; + } + TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); + ASSERT_BOUNDS(off,tc->num); + ASSERT_BOUNDS(end-1,tc->num); + *ch = tc->str + off; + *len = end - off; + } + + +#line 1 "rde_critcl/param.c" + + typedef struct RDE_PARAM_ { + Tcl_Channel IN; + Tcl_Obj* readbuf; + char* CC; + long int CC_len; + RDE_TC TC; + long int CL; + RDE_STACK LS; + ERROR_STATE* ER; + RDE_STACK ES; + long int ST; + Tcl_Obj* SV; + Tcl_HashTable NC; + + RDE_STACK ast ; + RDE_STACK mark ; + + long int numstr; + char** string; + + ClientData clientData; + } RDE_PARAM_; + typedef int (*UniCharClass) (int); + typedef enum test_class_id { + tc_alnum, + tc_alpha, + tc_ascii, + tc_control, + tc_ddigit, + tc_digit, + tc_graph, + tc_lower, + tc_printable, + tc_punct, + tc_space, + tc_upper, + tc_wordchar, + tc_xdigit + } test_class_id; + static void ast_node_free (void* n); + static void error_state_free (void* es); + static void error_set (RDE_PARAM p, long int s); + static void nc_clear (RDE_PARAM p); + static int UniCharIsAscii (int character); + static int UniCharIsHexDigit (int character); + static int UniCharIsDecDigit (int character); + static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); + static int er_int_compare (const void* a, const void* b); + #define SV_INIT(p) \ + p->SV = NULL; \ + TRACE (("SV_INIT (%p => %p)", (p), (p)->SV)) + #define SV_SET(p,newsv) \ + if (((p)->SV) != (newsv)) { \ + TRACE (("SV_CLEAR/set (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_DecrRefCount ((p)->SV); \ + } \ + (p)->SV = (newsv); \ + TRACE (("SV_SET (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_IncrRefCount ((p)->SV); \ + } \ + } + #define SV_CLEAR(p) \ + TRACE (("SV_CLEAR (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_DecrRefCount ((p)->SV); \ + } \ + (p)->SV = NULL + #define ER_INIT(p) \ + p->ER = NULL; \ + TRACE (("ER_INIT (%p => %p)", (p), (p)->ER)) + #define ER_CLEAR(p) \ + error_state_free ((p)->ER); \ + (p)->ER = NULL + SCOPE RDE_PARAM + rde_param_new (long int nstr, char** strings) + { + RDE_PARAM p; + ENTER ("rde_param_new"); + TRACE (("\tINT %d strings @ %p", nstr, strings)); + p = ALLOC (RDE_PARAM_); + p->numstr = nstr; + p->string = strings; + p->readbuf = Tcl_NewObj (); + Tcl_IncrRefCount (p->readbuf); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + Tcl_InitHashTable (&p->NC, TCL_ONE_WORD_KEYS); + p->IN = NULL; + p->CL = -1; + p->ST = 0; + ER_INIT (p); + SV_INIT (p); + p->CC = NULL; + p->CC_len = 0; + p->TC = rde_tc_new (); + p->ES = rde_stack_new (error_state_free); + p->LS = rde_stack_new (NULL); + p->ast = rde_stack_new (ast_node_free); + p->mark = rde_stack_new (NULL); + RETURN ("%p", p); + } + SCOPE void + rde_param_del (RDE_PARAM p) + { + ENTER ("rde_param_del"); + TRACE (("RDE_PARAM %p",p)); + ER_CLEAR (p); TRACE (("\ter_clear")); + SV_CLEAR (p); TRACE (("\tsv_clear")); + nc_clear (p); TRACE (("\tnc_clear")); + Tcl_DeleteHashTable (&p->NC); TRACE (("\tnc hashtable delete")); + rde_tc_del (p->TC); TRACE (("\ttc clear")); + rde_stack_del (p->ES); TRACE (("\tes clear")); + rde_stack_del (p->LS); TRACE (("\tls clear")); + rde_stack_del (p->ast); TRACE (("\tast clear")); + rde_stack_del (p->mark); TRACE (("\tmark clear")); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + Tcl_DecrRefCount (p->readbuf); + ckfree ((char*) p); + RETURNVOID; + } + SCOPE void + rde_param_reset (RDE_PARAM p, Tcl_Channel chan) + { + ENTER ("rde_param_reset"); + TRACE (("RDE_PARAM %p",p)); + TRACE (("Tcl_Channel %p",chan)); + p->IN = chan; + p->CL = -1; + p->ST = 0; + p->CC = NULL; + p->CC_len = 0; + ER_CLEAR (p); + SV_CLEAR (p); + nc_clear (p); + rde_tc_clear (p->TC); + rde_stack_trim (p->ES, 0); + rde_stack_trim (p->LS, 0); + rde_stack_trim (p->ast, 0); + rde_stack_trim (p->mark, 0); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + RETURNVOID; + } + SCOPE void + rde_param_update_strings (RDE_PARAM p, long int nstr, char** strings) + { + ENTER ("rde_param_update_strings"); + TRACE (("RDE_PARAM %p", p)); + TRACE (("INT %d strings", nstr)); + p->numstr = nstr; + p->string = strings; + RETURNVOID; + } + SCOPE void + rde_param_data (RDE_PARAM p, char* buf, long int len) + { + (void) rde_tc_append (p->TC, buf, len); + } + SCOPE void + rde_param_clientdata (RDE_PARAM p, ClientData clientData) + { + p->clientData = clientData; + } + static void + nc_clear (RDE_PARAM p) + { + Tcl_HashSearch hs; + Tcl_HashEntry* he; + Tcl_HashTable* tablePtr; + for(he = Tcl_FirstHashEntry(&p->NC, &hs); + he != NULL; + he = Tcl_FirstHashEntry(&p->NC, &hs)) { + Tcl_HashSearch hsc; + Tcl_HashEntry* hec; + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (he); + for(hec = Tcl_FirstHashEntry(tablePtr, &hsc); + hec != NULL; + hec = Tcl_NextHashEntry(&hsc)) { + NC_STATE* scs = Tcl_GetHashValue (hec); + error_state_free (scs->ER); + if (scs->SV) { Tcl_DecrRefCount (scs->SV); } + ckfree ((char*) scs); + } + Tcl_DeleteHashTable (tablePtr); + ckfree ((char*) tablePtr); + Tcl_DeleteHashEntry (he); + } + } + SCOPE ClientData + rde_param_query_clientdata (RDE_PARAM p) + { + return p->clientData; + } + SCOPE void + rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) + { + rde_stack_get (p->mark, mc, mv); + } + SCOPE void + rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) + { + rde_stack_get (p->ast, ac, (void***) av); + } + SCOPE const char* + rde_param_query_in (RDE_PARAM p) + { + return p->IN + ? Tcl_GetChannelName (p->IN) + : ""; + } + SCOPE const char* + rde_param_query_cc (RDE_PARAM p, long int* len) + { + *len = p->CC_len; + return p->CC; + } + SCOPE int + rde_param_query_cl (RDE_PARAM p) + { + return p->CL; + } + SCOPE const ERROR_STATE* + rde_param_query_er (RDE_PARAM p) + { + return p->ER; + } + SCOPE Tcl_Obj* + rde_param_query_er_tcl (RDE_PARAM p, const ERROR_STATE* er) + { + Tcl_Obj* res; + if (!er) { + + res = Tcl_NewStringObj ("", 0); + } else { + Tcl_Obj* ov [2]; + Tcl_Obj** mov; + long int mc, i, j; + void** mv; + int lastid; + const char* msg; + rde_stack_get (er->msg, &mc, &mv); + + qsort (mv, mc, sizeof (void*), er_int_compare); + + mov = NALLOC (mc, Tcl_Obj*); + lastid = -1; + for (i=0, j=0; i < mc; i++) { + ASSERT_BOUNDS (i,mc); + if (((long int) mv [i]) == lastid) continue; + lastid = (long int) mv [i]; + ASSERT_BOUNDS((long int) mv[i],p->numstr); + msg = p->string [(long int) mv[i]]; + ASSERT_BOUNDS (j,mc); + mov [j] = Tcl_NewStringObj (msg, -1); + j++; + } + + ov [0] = Tcl_NewIntObj (er->loc); + ov [1] = Tcl_NewListObj (j, mov); + res = Tcl_NewListObj (2, ov); + ckfree ((char*) mov); + } + return res; + } + SCOPE void + rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) + { + rde_stack_get (p->ES, ec, (void***) ev); + } + SCOPE void + rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) + { + rde_stack_get (p->LS, lc, lv); + } + SCOPE long int + rde_param_query_lstop (RDE_PARAM p) + { + (long int) rde_stack_top (p->LS); + } + SCOPE Tcl_HashTable* + rde_param_query_nc (RDE_PARAM p) + { + return &p->NC; + } + SCOPE int + rde_param_query_st (RDE_PARAM p) + { + return p->ST; + } + SCOPE Tcl_Obj* + rde_param_query_sv (RDE_PARAM p) + { + TRACE (("SV_QUERY %p => (%p)", (p), (p)->SV)); \ + return p->SV; + } + SCOPE long int + rde_param_query_tc_size (RDE_PARAM p) + { + return rde_tc_size (p->TC); + } + SCOPE void + rde_param_query_tc_get_s (RDE_PARAM p, long int at, long int last, char** ch, long int* len) + { + rde_tc_get_s (p->TC, at, last, ch, len); + } + SCOPE const char* + rde_param_query_string (RDE_PARAM p, long int id) + { + TRACE (("rde_param_query_string (RDE_PARAM %p, %d/%d)", p, id, p->numstr)); + ASSERT_BOUNDS(id,p->numstr); + return p->string [id]; + } + SCOPE void + rde_param_i_ast_pop_discard (RDE_PARAM p) + { + rde_stack_pop (p->mark, 1); + } + SCOPE void + rde_param_i_ast_pop_rewind (RDE_PARAM p) + { + long int trim = (long int) rde_stack_top (p->mark); + ENTER ("rde_param_i_ast_pop_rewind"); + TRACE (("RDE_PARAM %p",p)); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_ast_rewind (RDE_PARAM p) + { + long int trim = (long int) rde_stack_top (p->mark); + ENTER ("rde_param_i_ast_rewind"); + TRACE (("RDE_PARAM %p",p)); + rde_stack_trim (p->ast, trim); + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_ast_push (RDE_PARAM p) + { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + } + SCOPE void + rde_param_i_ast_value_push (RDE_PARAM p) + { + ENTER ("rde_param_i_ast_value_push"); + TRACE (("RDE_PARAM %p",p)); + ASSERT(p->SV,"Unable to push undefined semantic value"); + TRACE (("rde_param_i_ast_value_push %p => (%p)", p, p->SV)); + TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV->refCount, Tcl_GetString (p->SV))); + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + RETURNVOID; + } + static void + ast_node_free (void* n) + { + Tcl_DecrRefCount ((Tcl_Obj*) n); + } + SCOPE void + rde_param_i_error_clear (RDE_PARAM p) + { + ER_CLEAR (p); + } + SCOPE void + rde_param_i_error_nonterminal (RDE_PARAM p, long int s) + { + + return; + long int pos; + if (!p->ER) return; + pos = 1 + (long int) rde_stack_top (p->LS); + if (p->ER->loc != pos) return; + error_set (p, s); + p->ER->loc = pos; + } + SCOPE void + rde_param_i_error_pop_merge (RDE_PARAM p) + { + ERROR_STATE* top = (ERROR_STATE*) rde_stack_top (p->ES); + + if (top == p->ER) { + rde_stack_pop (p->ES, 1); + return; + } + + if (!top) { + rde_stack_pop (p->ES, 1); + return; + } + + if (!p->ER) { + rde_stack_drop (p->ES, 1); + p->ER = top; + + return; + } + + if (top->loc < p->ER->loc) { + rde_stack_pop (p->ES, 1); + return; + } + + if (top->loc > p->ER->loc) { + rde_stack_drop (p->ES, 1); + error_state_free (p->ER); + p->ER = top; + + return; + } + + rde_stack_move (p->ER->msg, top->msg); + rde_stack_pop (p->ES, 1); + } + SCOPE void + rde_param_i_error_push (RDE_PARAM p) + { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + static void + error_set (RDE_PARAM p, long int s) + { + error_state_free (p->ER); + p->ER = ALLOC (ERROR_STATE); + p->ER->refCount = 1; + p->ER->loc = p->CL; + p->ER->msg = rde_stack_new (NULL); + ASSERT_BOUNDS(s,p->numstr); + rde_stack_push (p->ER->msg, (void*) s); + } + static void + error_state_free (void* esx) + { + ERROR_STATE* es = esx; + if (!es) return; + es->refCount --; + if (es->refCount > 0) return; + rde_stack_del (es->msg); + ckfree ((char*) es); + } + SCOPE void + rde_param_i_loc_pop_discard (RDE_PARAM p) + { + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_loc_pop_rewind (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_loc_push (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + } + SCOPE void + rde_param_i_loc_rewind (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + } + SCOPE void + rde_param_i_input_next (RDE_PARAM p, long int m) + { + int leni; + char* ch; + ASSERT_BOUNDS(m,p->numstr); + p->CL ++; + if (p->CL < rde_tc_size (p->TC)) { + + rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); + + ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); + p->ST = 1; + ER_CLEAR (p); + return; + } + if (!p->IN || + Tcl_Eof (p->IN) || + (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { + + p->ST = 0; + error_set (p, m); + return; + } + + ch = Tcl_GetStringFromObj (p->readbuf, &leni); + ASSERT_BOUNDS (leni, TCL_UTF_MAX); + p->CC = rde_tc_append (p->TC, ch, leni); + p->CC_len = leni; + p->ST = 1; + ER_CLEAR (p); + } + SCOPE void + rde_param_i_status_fail (RDE_PARAM p) + { + p->ST = 0; + } + SCOPE void + rde_param_i_status_ok (RDE_PARAM p) + { + p->ST = 1; + } + SCOPE void + rde_param_i_status_negate (RDE_PARAM p) + { + p->ST = !p->ST; + } + SCOPE int + rde_param_i_symbol_restore (RDE_PARAM p, long int s) + { + NC_STATE* scs; + Tcl_HashEntry* hPtr; + Tcl_HashTable* tablePtr; + + hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); + if (!hPtr) { return 0; } + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); + hPtr = Tcl_FindHashEntry (tablePtr, (char*) s); + if (!hPtr) { return 0; } + + scs = Tcl_GetHashValue (hPtr); + p->CL = scs->CL; + p->ST = scs->ST; + error_state_free (p->ER); + p->ER = scs->ER; + if (p->ER) { p->ER->refCount ++; } + TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); + SV_SET (p, scs->SV); + return 1; + } + SCOPE void + rde_param_i_symbol_save (RDE_PARAM p, long int s) + { + long int at = (long int) rde_stack_top (p->LS); + NC_STATE* scs; + Tcl_HashEntry* hPtr; + Tcl_HashTable* tablePtr; + int isnew; + ENTER ("rde_param_i_symbol_save"); + TRACE (("RDE_PARAM %p",p)); + TRACE (("INT %d",s)); + + hPtr = Tcl_CreateHashEntry (&p->NC, (char*) at, &isnew); + if (isnew) { + tablePtr = ALLOC (Tcl_HashTable); + Tcl_InitHashTable (tablePtr, TCL_ONE_WORD_KEYS); + Tcl_SetHashValue (hPtr, tablePtr); + } else { + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); + } + hPtr = Tcl_CreateHashEntry (tablePtr, (char*) s, &isnew); + if (isnew) { + + scs = ALLOC (NC_STATE); + scs->CL = p->CL; + scs->ST = p->ST; + TRACE (("SV_CACHE (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "")); + scs->SV = p->SV; + if (scs->SV) { Tcl_IncrRefCount (scs->SV); } + scs->ER = p->ER; + if (scs->ER) { scs->ER->refCount ++; } + Tcl_SetHashValue (hPtr, scs); + } else { + + scs = (NC_STATE*) Tcl_GetHashValue (hPtr); + scs->CL = p->CL; + scs->ST = p->ST; + TRACE (("SV_CACHE/over (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "" )); + if (scs->SV) { Tcl_DecrRefCount (scs->SV); } + scs->SV = p->SV; + if (scs->SV) { Tcl_IncrRefCount (scs->SV); } + error_state_free (scs->ER); + scs->ER = p->ER; + if (scs->ER) { scs->ER->refCount ++; } + } + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_test_alnum (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsAlnum, tc_alnum); + } + SCOPE void + rde_param_i_test_alpha (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsAlpha, tc_alpha); + } + SCOPE void + rde_param_i_test_ascii (RDE_PARAM p) + { + test_class (p, UniCharIsAscii, tc_ascii); + } + SCOPE void + rde_param_i_test_control (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsControl, tc_control); + } + SCOPE void + rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) + { + ASSERT_BOUNDS(msg,p->numstr); + p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, msg); + p->CL --; + } + } + SCOPE void + rde_param_i_test_ddigit (RDE_PARAM p) + { + test_class (p, UniCharIsDecDigit, tc_ddigit); + } + SCOPE void + rde_param_i_test_digit (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsDigit, tc_digit); + } + SCOPE void + rde_param_i_test_graph (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsGraph, tc_graph); + } + SCOPE void + rde_param_i_test_lower (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsLower, tc_lower); + } + SCOPE void + rde_param_i_test_print (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsPrint, tc_printable); + } + SCOPE void + rde_param_i_test_punct (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsPunct, tc_punct); + } + SCOPE void + rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) + { + ASSERT_BOUNDS(msg,p->numstr); + p->ST = + (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && + (Tcl_UtfNcmp (p->CC, e, 1) <= 0); + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, msg); + p->CL --; + } + } + SCOPE void + rde_param_i_test_space (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsSpace, tc_space); + } + SCOPE void + rde_param_i_test_upper (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsUpper, tc_upper); + } + SCOPE void + rde_param_i_test_wordchar (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsWordChar, tc_wordchar); + } + SCOPE void + rde_param_i_test_xdigit (RDE_PARAM p) + { + test_class (p, UniCharIsHexDigit, tc_xdigit); + } + static void + test_class (RDE_PARAM p, UniCharClass class, test_class_id id) + { + Tcl_UniChar ch; + Tcl_UtfToUniChar(p->CC, &ch); + ASSERT_BOUNDS(id,p->numstr); + p->ST = !!class (ch); + + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, id); + p->CL --; + } + } + static int + UniCharIsAscii (int character) + { + return (character >= 0) && (character < 0x80); + } + static int + UniCharIsHexDigit (int character) + { + return (character >= 0) && (character < 0x80) && isxdigit(character); + } + static int + UniCharIsDecDigit (int character) + { + return (character >= 0) && (character < 0x80) && isdigit(character); + } + SCOPE void + rde_param_i_value_clear (RDE_PARAM p) + { + SV_CLEAR (p); + } + SCOPE void + rde_param_i_value_leaf (RDE_PARAM p, long int s) + { + Tcl_Obj* newsv; + Tcl_Obj* ov [3]; + long int pos = 1 + (long int) rde_stack_top (p->LS); + ASSERT_BOUNDS(s,p->numstr); + ov [0] = Tcl_NewStringObj (p->string[s], -1); + ov [1] = Tcl_NewIntObj (pos); + ov [2] = Tcl_NewIntObj (p->CL); + newsv = Tcl_NewListObj (3, ov); + TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); + SV_SET (p, newsv); + } + SCOPE void + rde_param_i_value_reduce (RDE_PARAM p, long int s) + { + Tcl_Obj* newsv; + int oc, i, j; + Tcl_Obj** ov; + long int ac; + Tcl_Obj** av; + long int pos = 1 + (long int) rde_stack_top (p->LS); + long int mark = (long int) rde_stack_top (p->mark); + long int asize = rde_stack_size (p->ast); + long int new = asize - mark; + ASSERT (new >= 0, "Bad number of elements to reduce"); + ov = NALLOC (3+new, Tcl_Obj*); + ASSERT_BOUNDS(s,p->numstr); + ov [0] = Tcl_NewStringObj (p->string[s], -1); + ov [1] = Tcl_NewIntObj (pos); + ov [2] = Tcl_NewIntObj (p->CL); + rde_stack_get (p->ast, &ac, (void***) &av); + for (i = 3, j = mark; j < asize; i++, j++) { + ASSERT_BOUNDS (i, 3+new); + ASSERT_BOUNDS (j, ac); + ov [i] = av [j]; + } + ASSERT (i == 3+new, "Reduction result incomplete"); + newsv = Tcl_NewListObj (3+new, ov); + TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); + SV_SET (p, newsv); + ckfree ((char*) ov); + } + static int + er_int_compare (const void* a, const void* b) + { + + const void** ael = (const void**) a; + const void** bel = (const void**) b; + long int avalue = (long int) *ael; + long int bvalue = (long int) *bel; + if (avalue < bvalue) { return -1; } + if (avalue > bvalue) { return 1; } + return 0; + } + SCOPE int + rde_param_i_symbol_start (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) { + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + return 1; + } + rde_stack_push (p->LS, (void*) p->CL); + return 0; + } + SCOPE int + rde_param_i_symbol_start_d (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) { + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + return 1; + } + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + return 0; + } + SCOPE int + rde_param_i_symbol_void_start (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) return 1; + rde_stack_push (p->LS, (void*) p->CL); + return 0; + } + SCOPE int + rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) return 1; + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + return 0; + } + SCOPE void + rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_reduce (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_leaf (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_leaf (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) + { + SV_CLEAR (p); + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) + { + SV_CLEAR (p); + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_char (p, c, m); + } + SCOPE void + rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_range (p, s, e, m); + } + SCOPE void + rde_param_i_next_alnum (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_alnum (p); + } + SCOPE void + rde_param_i_next_alpha (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_alpha (p); + } + SCOPE void + rde_param_i_next_ascii (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_ascii (p); + } + SCOPE void + rde_param_i_next_control (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_control (p); + } + SCOPE void + rde_param_i_next_ddigit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_ddigit (p); + } + SCOPE void + rde_param_i_next_digit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_digit (p); + } + SCOPE void + rde_param_i_next_graph (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_graph (p); + } + SCOPE void + rde_param_i_next_lower (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_lower (p); + } + SCOPE void + rde_param_i_next_print (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_print (p); + } + SCOPE void + rde_param_i_next_punct (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_punct (p); + } + SCOPE void + rde_param_i_next_space (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_space (p); + } + SCOPE void + rde_param_i_next_upper (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_upper (p); + } + SCOPE void + rde_param_i_next_wordchar (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_wordchar (p); + } + SCOPE void + rde_param_i_next_xdigit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_xdigit (p); + } + SCOPE void + rde_param_i_notahead_start_d (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + } + SCOPE void + rde_param_i_notahead_exit_d (RDE_PARAM p) + { + if (p->ST) { + rde_param_i_ast_pop_rewind (p); + } else { + rde_stack_pop (p->mark, 1); + } + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + p->ST = !p->ST; + } + SCOPE void + rde_param_i_notahead_exit (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + p->ST = !p->ST; + } + SCOPE void + rde_param_i_state_push_2 (RDE_PARAM p) + { + + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + SCOPE void + rde_param_i_state_push_void (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + ER_CLEAR (p); + rde_stack_push (p->ES, p->ER); + + } + SCOPE void + rde_param_i_state_push_value (RDE_PARAM p) + { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + rde_stack_push (p->LS, (void*) p->CL); + ER_CLEAR (p); + rde_stack_push (p->ES, p->ER); + + } + SCOPE void + rde_param_i_state_merge_ok (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + p->ST = 1; + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_state_merge_void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_state_merge_value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } + SCOPE int + rde_param_i_kleene_close (RDE_PARAM p) + { + int stop = !p->ST; + rde_param_i_error_pop_merge (p); + if (stop) { + p->ST = 1; + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + return stop; + } + SCOPE int + rde_param_i_kleene_abort (RDE_PARAM p) + { + int stop = !p->ST; + if (stop) { + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + return stop; + } + SCOPE int + rde_param_i_seq_void2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_seq_void2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_seq_value2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_bra_void2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->LS, 1); + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_void2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->LS, 1); + } else { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_value2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_value2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE void + rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) + { + int at = p->CL; + + while (*str) { + rde_param_i_input_next (p, m); + if (!p->ST) { + p->ER->loc = at+1; + p->CL = at; + return; + } + rde_param_i_test_char (p, str, m); + if (!p->ST) { + p->ER->loc = at+1; + p->CL = at; + return; + } + str = Tcl_UtfNext (str); + } + } + SCOPE void + rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + while (*class) { + p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; + if (p->ST) { + ER_CLEAR (p); + return; + } + class = Tcl_UtfNext (class); + } + error_set (p, m); + p->CL --; + } + + + /* + * Declaring the parse functions + */ + + static void sym_AddOp (RDE_PARAM p); + static void sym_Digit (RDE_PARAM p); + static void sequence_10 (RDE_PARAM p); + static void sequence_15 (RDE_PARAM p); + static void kleene_17 (RDE_PARAM p); + static void sequence_19 (RDE_PARAM p); + static void choice_21 (RDE_PARAM p); + static void sym_Expression (RDE_PARAM p); + static void sequence_27 (RDE_PARAM p); + static void kleene_29 (RDE_PARAM p); + static void sequence_31 (RDE_PARAM p); + static void sym_Factor (RDE_PARAM p); + static void sym_Function (RDE_PARAM p); + static void sym_MulOp (RDE_PARAM p); + static void optional_39 (RDE_PARAM p); + static void poskleene_42 (RDE_PARAM p); + static void sequence_44 (RDE_PARAM p); + static void sym_Number (RDE_PARAM p); + static void sym_Sign (RDE_PARAM p); + static void sequence_52 (RDE_PARAM p); + static void sym_Sinus (RDE_PARAM p); + static void sym_Term (RDE_PARAM p); + + /* + * Precomputed table of strings (symbols, error messages, etc.). + */ + + static char const* p_string [40] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "cl -+", + /* 15 = */ "n AddOp", + /* 16 = */ "AddOp", + /* 17 = */ "cl 0123456789", + /* 18 = */ "n Digit", + /* 19 = */ "Digit", + /* 20 = */ "t (", + /* 21 = */ "t )", + /* 22 = */ "n Expression", + /* 23 = */ "Expression", + /* 24 = */ "n Factor", + /* 25 = */ "Factor", + /* 26 = */ "n Function", + /* 27 = */ "Function", + /* 28 = */ "cl */", + /* 29 = */ "n MulOp", + /* 30 = */ "MulOp", + /* 31 = */ "n Number", + /* 32 = */ "Number", + /* 33 = */ "n Sign", + /* 34 = */ "Sign", + /* 35 = */ "str sin(", + /* 36 = */ "n Sinus", + /* 37 = */ "Sinus", + /* 38 = */ "n Term", + /* 39 = */ "Term" + }; + + /* + * Grammar Start Expression + */ + + static void MAIN (RDE_PARAM p) { + sym_Expression (p); + return; + } + + /* + * value Symbol 'AddOp' + */ + + static void sym_AddOp (RDE_PARAM p) { + /* + * [-+] + */ + + if (rde_param_i_symbol_start (p, 16)) return ; + rde_param_i_next_class (p, "-+", 14); + rde_param_i_symbol_done_leaf (p, 16, 15); + return; + } + + /* + * value Symbol 'Digit' + */ + + static void sym_Digit (RDE_PARAM p) { + /* + * [0123456789] + */ + + if (rde_param_i_symbol_start (p, 19)) return ; + rde_param_i_next_class (p, "0123456789", 17); + rde_param_i_symbol_done_leaf (p, 19, 18); + return; + } + + /* + * value Symbol 'Expression' + */ + + static void sym_Expression (RDE_PARAM p) { + /* + * / + * (Function) + * x + * '\(' + * (Expression) + * '\)' + * x + * (Factor) + * * + * x + * (MulOp) + * (Factor) + */ + + if (rde_param_i_symbol_start_d (p, 23)) return ; + choice_21 (p); + rde_param_i_symbol_done_d_reduce (p, 23, 22); + return; + } + + static void choice_21 (RDE_PARAM p) { + /* + * / + * (Function) + * x + * '\(' + * (Expression) + * '\)' + * x + * (Factor) + * * + * x + * (MulOp) + * (Factor) + */ + + rde_param_i_state_push_value (p); + sym_Function (p); + if (rde_param_i_bra_value2value(p)) return; + sequence_10 (p); + if (rde_param_i_bra_value2value(p)) return; + sequence_19 (p); + rde_param_i_state_merge_value (p); + return; + } + + static void sequence_10 (RDE_PARAM p) { + /* + * x + * '\(' + * (Expression) + * '\)' + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_char (p, "(", 20); + if (rde_param_i_seq_void2value(p)) return; + sym_Expression (p); + if (rde_param_i_seq_value2value(p)) return; + rde_param_i_next_char (p, ")", 21); + rde_param_i_state_merge_value (p); + return; + } + + static void sequence_19 (RDE_PARAM p) { + /* + * x + * (Factor) + * * + * x + * (MulOp) + * (Factor) + */ + + rde_param_i_state_push_value (p); + sym_Factor (p); + if (rde_param_i_seq_value2value(p)) return; + kleene_17 (p); + rde_param_i_state_merge_value (p); + return; + } + + static void kleene_17 (RDE_PARAM p) { + /* + * * + * x + * (MulOp) + * (Factor) + */ + + while (1) { + rde_param_i_state_push_2 (p); + sequence_15 (p); + if (rde_param_i_kleene_close(p)) return; + } + return; + } + + static void sequence_15 (RDE_PARAM p) { + /* + * x + * (MulOp) + * (Factor) + */ + + rde_param_i_state_push_value (p); + sym_MulOp (p); + if (rde_param_i_seq_value2value(p)) return; + sym_Factor (p); + rde_param_i_state_merge_value (p); + return; + } + + /* + * value Symbol 'Factor' + */ + + static void sym_Factor (RDE_PARAM p) { + /* + * x + * (Term) + * * + * x + * (AddOp) + * (Term) + */ + + if (rde_param_i_symbol_start_d (p, 25)) return ; + sequence_31 (p); + rde_param_i_symbol_done_d_reduce (p, 25, 24); + return; + } + + static void sequence_31 (RDE_PARAM p) { + /* + * x + * (Term) + * * + * x + * (AddOp) + * (Term) + */ + + rde_param_i_state_push_value (p); + sym_Term (p); + if (rde_param_i_seq_value2value(p)) return; + kleene_29 (p); + rde_param_i_state_merge_value (p); + return; + } + + static void kleene_29 (RDE_PARAM p) { + /* + * * + * x + * (AddOp) + * (Term) + */ + + while (1) { + rde_param_i_state_push_2 (p); + sequence_27 (p); + if (rde_param_i_kleene_close(p)) return; + } + return; + } + + static void sequence_27 (RDE_PARAM p) { + /* + * x + * (AddOp) + * (Term) + */ + + rde_param_i_state_push_value (p); + sym_AddOp (p); + if (rde_param_i_seq_value2value(p)) return; + sym_Term (p); + rde_param_i_state_merge_value (p); + return; + } + + /* + * value Symbol 'Function' + */ + + static void sym_Function (RDE_PARAM p) { + /* + * (Sinus) + */ + + if (rde_param_i_symbol_start_d (p, 27)) return ; + sym_Sinus (p); + rde_param_i_symbol_done_d_reduce (p, 27, 26); + return; + } + + /* + * value Symbol 'MulOp' + */ + + static void sym_MulOp (RDE_PARAM p) { + /* + * [\u002a\u002f] + */ + + if (rde_param_i_symbol_start (p, 30)) return ; + rde_param_i_next_class (p, "*/", 28); + rde_param_i_symbol_done_leaf (p, 30, 29); + return; + } + + /* + * value Symbol 'Number' + */ + + static void sym_Number (RDE_PARAM p) { + /* + * x + * ? + * (Sign) + * + + * (Digit) + */ + + if (rde_param_i_symbol_start_d (p, 32)) return ; + sequence_44 (p); + rde_param_i_symbol_done_d_reduce (p, 32, 31); + return; + } + + static void sequence_44 (RDE_PARAM p) { + /* + * x + * ? + * (Sign) + * + + * (Digit) + */ + + rde_param_i_state_push_value (p); + optional_39 (p); + if (rde_param_i_seq_value2value(p)) return; + poskleene_42 (p); + rde_param_i_state_merge_value (p); + return; + } + + static void optional_39 (RDE_PARAM p) { + /* + * ? + * (Sign) + */ + + rde_param_i_state_push_2 (p); + sym_Sign (p); + rde_param_i_state_merge_ok (p); + return; + } + + static void poskleene_42 (RDE_PARAM p) { + /* + * + + * (Digit) + */ + + rde_param_i_loc_push (p); + sym_Digit (p); + if (rde_param_i_kleene_abort(p)) return; + while (1) { + rde_param_i_state_push_2 (p); + sym_Digit (p); + if (rde_param_i_kleene_close(p)) return; + } + return; + } + + /* + * value Symbol 'Sign' + */ + + static void sym_Sign (RDE_PARAM p) { + /* + * [-+] + */ + + if (rde_param_i_symbol_start (p, 34)) return ; + rde_param_i_next_class (p, "-+", 14); + rde_param_i_symbol_done_leaf (p, 34, 33); + return; + } + + /* + * value Symbol 'Sinus' + */ + + static void sym_Sinus (RDE_PARAM p) { + /* + * x + * "sin\(" + * (Expression) + * '\)' + */ + + if (rde_param_i_symbol_start_d (p, 37)) return ; + sequence_52 (p); + rde_param_i_symbol_done_d_reduce (p, 37, 36); + return; + } + + static void sequence_52 (RDE_PARAM p) { + /* + * x + * "sin\(" + * (Expression) + * '\)' + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_str (p, "sin(", 35); + if (rde_param_i_seq_void2value(p)) return; + sym_Expression (p); + if (rde_param_i_seq_value2value(p)) return; + rde_param_i_next_char (p, ")", 21); + rde_param_i_state_merge_value (p); + return; + } + + /* + * value Symbol 'Term' + */ + + static void sym_Term (RDE_PARAM p) { + /* + * (Number) + */ + + if (rde_param_i_symbol_start_d (p, 39)) return ; + sym_Number (p); + rde_param_i_symbol_done_d_reduce (p, 39, 38); + return; + } + + /* -*- c -*- */ + + typedef struct PARSERg { + long int counter; + char buf [50]; + } PARSERg; + + static void + PARSERgRelease (ClientData cd, Tcl_Interp* interp) + { + ckfree((char*) cd); + } + + static const char* + PARSERnewName (Tcl_Interp* interp) + { +#define KEY "tcllib/parser/PACKAGE/TEA" + + Tcl_InterpDeleteProc* proc = PARSERgRelease; + PARSERg* parserg; + + parserg = Tcl_GetAssocData (interp, KEY, &proc); + if (parserg == NULL) { + parserg = (PARSERg*) ckalloc (sizeof (PARSERg)); + parserg->counter = 0; + + Tcl_SetAssocData (interp, KEY, proc, + (ClientData) parserg); + } + + parserg->counter ++; + sprintf (parserg->buf, "PARSER%ld", parserg->counter); + return parserg->buf; +#undef KEY + } + + static void + PARSERdeleteCmd (ClientData clientData) + { + /* + * Release the whole PARSER + * (Low-level engine only actually). + */ + rde_param_del ((RDE_PARAM) clientData); + } + + + /* * ** *** ***** ******** ************* + ** Functions implementing the object methods, and helper. + */ + + static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp); + + static int parser_PARSE (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + int mode; + Tcl_Channel chan; + + if (objc != 3) { + Tcl_WrongNumArgs (interp, 2, objv, "chan"); + return TCL_ERROR; + } + + chan = Tcl_GetChannel(interp, + Tcl_GetString (objv[2]), + &mode); + + if (!chan) { + return TCL_ERROR; + } + + rde_param_reset (p, chan); + MAIN (p) ; /* Entrypoint for the generated code. */ + return COMPLETE (p, interp); + } + + static int parser_PARSET (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + char* buf; + int len; + + if (objc != 3) { + Tcl_WrongNumArgs (interp, 2, objv, "text"); + return TCL_ERROR; + } + + buf = Tcl_GetStringFromObj (objv[2], &len); + + rde_param_reset (p, NULL); + rde_param_data (p, buf, len); + MAIN (p) ; /* Entrypoint for the generated code. */ + return COMPLETE (p, interp); + } + + /* See also rde_critcl/m.c, param_COMPLETE() */ + static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) + { + if (rde_param_query_st (p)) { + long int ac; + Tcl_Obj** av; + + rde_param_query_ast (p, &ac, &av); + + if (ac > 1) { + Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); + + memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); + lv [0] = Tcl_NewObj (); + lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); + lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); + + Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); + ckfree ((char*) lv); + + } else if (ac == 0) { + /* + * Match, but no AST. This is possible if the grammar + * consists of only the start expression. + */ + Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); + } else { + Tcl_SetObjResult (interp, av [0]); + } + + return TCL_OK; + } else { + Tcl_Obj* xv [1]; + const ERROR_STATE* er = rde_param_query_er (p); + Tcl_Obj* res = rde_param_query_er_tcl (p, er); + /* res = list (location, list(msg)) */ + + /* Stick the exception type-tag before the existing elements */ + xv [0] = Tcl_NewStringObj ("pt::rde",-1); + Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); + + Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); + Tcl_SetObjResult (interp, res); + return TCL_ERROR; + } + } + + + /* * ** *** ***** ******** ************* + ** Object command, method dispatch. + */ + static int parser_objcmd (ClientData cd, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + RDE_PARAM p = (RDE_PARAM) cd; + int m, res; + + static CONST char* methods [] = { + "destroy", "parse", "parset", NULL + }; + enum methods { + M_DESTROY, M_PARSE, M_PARSET + }; + + if (objc < 2) { + Tcl_WrongNumArgs (interp, objc, objv, "option ?arg arg ...?"); + return TCL_ERROR; + } else if (Tcl_GetIndexFromObj (interp, objv [1], methods, "option", + 0, &m) != TCL_OK) { + return TCL_ERROR; + } + + /* Dispatch to methods. They check the #args in + * detail before performing the requested + * functionality + */ + + switch (m) { + case M_DESTROY: + if (objc != 2) { + Tcl_WrongNumArgs (interp, 2, objv, NULL); + return TCL_ERROR; + } + + Tcl_DeleteCommandFromToken(interp, (Tcl_Command) rde_param_query_clientdata (p)); + return TCL_OK; + + case M_PARSE: res = parser_PARSE (p, interp, objc, objv); break; + case M_PARSET: res = parser_PARSET (p, interp, objc, objv); break; + default: + /* Not coming to this place */ + ASSERT (0,"Reached unreachable location"); + } + + return res; + } + + /** * ** *** ***** ******** ************* + * Class command, i.e. object construction. + */ + static int ParserClassCmd (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const*objv) { + /* + * Syntax: No arguments beyond the name + */ + + RDE_PARAM parser; + CONST char* name; + Tcl_Obj* fqn; + Tcl_CmdInfo ci; + Tcl_Command c; + +#define USAGE "?name?" + + if ((objc != 2) && (objc != 1)) { + Tcl_WrongNumArgs (interp, 1, objv, USAGE); + return TCL_ERROR; + } + + if (objc < 2) { + name = PARSERnewName (interp); + } else { + name = Tcl_GetString (objv [1]); + } + + if (!Tcl_StringMatch (name, "::*")) { + /* Relative name. Prefix with current namespace */ + + Tcl_Eval (interp, "namespace current"); + fqn = Tcl_GetObjResult (interp); + fqn = Tcl_DuplicateObj (fqn); + Tcl_IncrRefCount (fqn); + + if (!Tcl_StringMatch (Tcl_GetString (fqn), "::")) { + Tcl_AppendToObj (fqn, "::", -1); + } + Tcl_AppendToObj (fqn, name, -1); + } else { + fqn = Tcl_NewStringObj (name, -1); + Tcl_IncrRefCount (fqn); + } + Tcl_ResetResult (interp); + + if (Tcl_GetCommandInfo (interp, + Tcl_GetString (fqn), + &ci)) { + Tcl_Obj* err; + + err = Tcl_NewObj (); + Tcl_AppendToObj (err, "command \"", -1); + Tcl_AppendObjToObj (err, fqn); + Tcl_AppendToObj (err, "\" already exists", -1); + + Tcl_DecrRefCount (fqn); + Tcl_SetObjResult (interp, err); + return TCL_ERROR; + } + + parser = rde_param_new (sizeof(p_string)/sizeof(char*), (char**) p_string); + c = Tcl_CreateObjCommand (interp, Tcl_GetString (fqn), + parser_objcmd, (ClientData) parser, + PARSERdeleteCmd); + rde_param_clientdata (parser, (ClientData) c); + Tcl_SetObjResult (interp, fqn); + Tcl_DecrRefCount (fqn); + return TCL_OK; + } + +int Package_Init(Tcl_Interp* interp) { + if (interp == 0) return TCL_ERROR; + + if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { + return TCL_ERROR; + } + + if (Tcl_CreateObjCommand(interp, "PARSER", ParserClassCmd , NULL, NULL) == NULL) { + Tcl_SetResult(interp, "Can't create constructor", NULL); + return TCL_ERROR; + } + + + Tcl_PkgProvide(interp, "PACKAGE", "0.1"); + + return TCL_OK; +} ADDED modules/pt/tests/data/ok/peg_cparam-tea/3_peg_itself Index: modules/pt/tests/data/ok/peg_cparam-tea/3_peg_itself ================================================================== --- /dev/null +++ modules/pt/tests/data/ok/peg_cparam-tea/3_peg_itself @@ -0,0 +1,4951 @@ +/************************************************************ +** +** TEA-based C/PARAM implementation of the parsing +** expression grammar +** +** TEMPLATE +** +** Generated from file TEST +** for user unknown +** +* * ** *** ***** ******** ************* *********************/ + #include + #include + #include + #include + #define SCOPE static + +#line 1 "rde_critcl/util.h" + + #ifndef _RDE_UTIL_H + #define _RDE_UTIL_H 1 + #ifndef SCOPE + #define SCOPE + #endif + #define ALLOC(type) (type *) ckalloc (sizeof (type)) + #define NALLOC(n,type) (type *) ckalloc ((n) * sizeof (type)) + #undef RDE_DEBUG + #define RDE_DEBUG 1 + #undef RDE_TRACE + #ifdef RDE_DEBUG + #define STOPAFTER(x) { static int count = (x); count --; if (!count) { Tcl_Panic ("stop"); } } + #define XSTR(x) #x + #define STR(x) XSTR(x) + #define RANGEOK(i,n) ((0 <= (i)) && (i < (n))) + #define ASSERT(x,msg) if (!(x)) { Tcl_Panic (msg " (" #x "), in file " __FILE__ " @line " STR(__LINE__));} + #define ASSERT_BOUNDS(i,n) ASSERT (RANGEOK(i,n),"array index out of bounds: " STR(i) " >= " STR(n)) + #else + #define STOPAFTER(x) + #define ASSERT(x,msg) + #define ASSERT_BOUNDS(i,n) + #endif + #ifdef RDE_TRACE + SCOPE void trace_enter (const char* fun); + SCOPE void trace_return (const char *pat, ...); + SCOPE void trace_printf (const char *pat, ...); + #define ENTER(fun) trace_enter (fun) + #define RETURN(format,x) trace_return (format,x) ; return x + #define RETURNVOID trace_return ("%s","(void)") ; return + #define TRACE0(x) trace_printf0 x + #define TRACE(x) trace_printf x + #else + #define ENTER(fun) + #define RETURN(f,x) return x + #define RETURNVOID return + #define TRACE0(x) + #define TRACE(x) + #endif + #endif + + +#line 1 "rde_critcl/stack.h" + + #ifndef _RDE_DS_STACK_H + #define _RDE_DS_STACK_H 1 + typedef void (*RDE_STACK_CELL_FREE) (void* cell); + typedef struct RDE_STACK_* RDE_STACK; + static const int RDE_STACK_INITIAL_SIZE = 256; + #endif + + +#line 1 "rde_critcl/tc.h" + + #ifndef _RDE_DS_TC_H + #define _RDE_DS_TC_H 1 + typedef struct RDE_TC_* RDE_TC; + #endif + + +#line 1 "rde_critcl/param.h" + + #ifndef _RDE_DS_PARAM_H + #define _RDE_DS_PARAM_H 1 + typedef struct RDE_PARAM_* RDE_PARAM; + typedef struct ERROR_STATE { + int refCount; + long int loc; + RDE_STACK msg; + } ERROR_STATE; + typedef struct NC_STATE { + long int CL; + long int ST; + Tcl_Obj* SV; + ERROR_STATE* ER; + } NC_STATE; + #endif + + +#line 1 "rde_critcl/util.c" + + #ifdef RDE_TRACE + typedef struct F_STACK { + const char* str; + struct F_STACK* down; + } F_STACK; + static F_STACK* top = 0; + static int level = 0; + static void + push (const char* str) + { + F_STACK* new = ALLOC (F_STACK); + new->str = str; + new->down = top; + top = new; + level += 4; + } + static void + pop (void) + { + F_STACK* next = top->down; + level -= 4; + ckfree ((char*)top); + top = next; + } + static void + indent (void) + { + int i; + for (i = 0; i < level; i++) { + fwrite(" ", 1, 1, stdout); + fflush (stdout); + } + if (top) { + fwrite(top->str, 1, strlen(top->str), stdout); + fflush (stdout); + } + fwrite(" ", 1, 1, stdout); + fflush (stdout); + } + SCOPE void + trace_enter (const char* fun) + { + push (fun); + indent(); + fwrite("ENTER\n", 1, 6, stdout); + fflush (stdout); + } + static char msg [1024*1024]; + SCOPE void + trace_return (const char *pat, ...) + { + int len; + va_list args; + indent(); + fwrite("RETURN = ", 1, 9, stdout); + fflush (stdout); + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + pop(); + } + SCOPE void + trace_printf (const char *pat, ...) + { + int len; + va_list args; + indent(); + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + } + SCOPE void + trace_printf0 (const char *pat, ...) + { + int len; + va_list args; + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + } + #endif + + +#line 1 "rde_critcl/stack.c" + + typedef struct RDE_STACK_ { + long int max; + long int top; + RDE_STACK_CELL_FREE freeCellProc; + void** cell; + } RDE_STACK_; + + SCOPE RDE_STACK + rde_stack_new (RDE_STACK_CELL_FREE freeCellProc) + { + RDE_STACK s = ALLOC (RDE_STACK_); + s->cell = NALLOC (RDE_STACK_INITIAL_SIZE, void*); + s->max = RDE_STACK_INITIAL_SIZE; + s->top = 0; + s->freeCellProc = freeCellProc; + return s; + } + SCOPE void + rde_stack_del (RDE_STACK s) + { + if (s->freeCellProc && s->top) { + long int i; + for (i=0; i < s->top; i++) { + ASSERT_BOUNDS(i,s->max); + s->freeCellProc ( s->cell [i] ); + } + } + ckfree ((char*) s->cell); + ckfree ((char*) s); + } + SCOPE void + rde_stack_push (RDE_STACK s, void* item) + { + if (s->top >= s->max) { + long int new = s->max ? (2 * s->max) : RDE_STACK_INITIAL_SIZE; + void** cell = (void**) ckrealloc ((char*) s->cell, new * sizeof(void*)); + ASSERT (cell,"Memory allocation failure for RDE stack"); + s->max = new; + s->cell = cell; + } + ASSERT_BOUNDS(s->top,s->max); + s->cell [s->top] = item; + s->top ++; + } + SCOPE void* + rde_stack_top (RDE_STACK s) + { + ASSERT_BOUNDS(s->top-1,s->max); + return s->cell [s->top - 1]; + } + SCOPE void + rde_stack_pop (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad pop count"); + if (n == 0) return; + if (s->freeCellProc) { + while (n) { + s->top --; + ASSERT_BOUNDS(s->top,s->max); + s->freeCellProc ( s->cell [s->top] ); + n --; + } + } else { + s->top -= n; + } + } + SCOPE void + rde_stack_trim (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad trimsize"); + if (s->freeCellProc) { + while (s->top > n) { + s->top --; + ASSERT_BOUNDS(s->top,s->max); + s->freeCellProc ( s->cell [s->top] ); + } + } else { + s->top = n; + } + } + SCOPE void + rde_stack_drop (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad pop count"); + if (n == 0) return; + s->top -= n; + } + SCOPE void + rde_stack_move (RDE_STACK dst, RDE_STACK src) + { + ASSERT (dst->freeCellProc == src->freeCellProc, "Ownership mismatch"); + + while (src->top > 0) { + src->top --; + ASSERT_BOUNDS(src->top,src->max); + rde_stack_push (dst, src->cell [src->top] ); + } + } + SCOPE void + rde_stack_get (RDE_STACK s, long int* cn, void*** cc) + { + *cn = s->top; + *cc = s->cell; + } + SCOPE long int + rde_stack_size (RDE_STACK s) + { + return s->top; + } + + +#line 1 "rde_critcl/tc.c" + + typedef struct RDE_TC_ { + int max; + int num; + char* str; + RDE_STACK off; + } RDE_TC_; + + SCOPE RDE_TC + rde_tc_new (void) + { + RDE_TC tc = ALLOC (RDE_TC_); + tc->max = RDE_STACK_INITIAL_SIZE; + tc->num = 0; + tc->str = NALLOC (RDE_STACK_INITIAL_SIZE, char); + tc->off = rde_stack_new (NULL); + return tc; + } + SCOPE void + rde_tc_del (RDE_TC tc) + { + rde_stack_del (tc->off); + ckfree (tc->str); + ckfree ((char*) tc); + } + SCOPE long int + rde_tc_size (RDE_TC tc) + { + return rde_stack_size (tc->off); + } + SCOPE void + rde_tc_clear (RDE_TC tc) + { + tc->num = 0; + rde_stack_trim (tc->off, 0); + } + SCOPE char* + rde_tc_append (RDE_TC tc, char* string, long int len) + { + long int base = tc->num; + long int off = tc->num; + char* ch; + int clen; + Tcl_UniChar uni; + if (len < 0) { + len = strlen (string); + } + + if (!len) { + return tc->str + base; + } + + if ((tc->num + len) >= tc->max) { + int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); + char* str = ckrealloc (tc->str, new * sizeof(char)); + ASSERT (str,"Memory allocation failure for token character array"); + tc->max = new; + tc->str = str; + } + tc->num += len; + ASSERT_BOUNDS(tc->num,tc->max); + ASSERT_BOUNDS(off,tc->max); + ASSERT_BOUNDS(off+len-1,tc->max); + ASSERT_BOUNDS(off+len-1,tc->num); + memcpy (tc->str + off, string, len); + + ch = string; + while (ch < (string + len)) { + ASSERT_BOUNDS(off,tc->num); + rde_stack_push (tc->off, (void*) off); + clen = Tcl_UtfToUniChar (ch, &uni); + off += clen; + ch += clen; + } + return tc->str + base; + } + SCOPE void + rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) + { + long int oc, off, top, end; + void** ov; + rde_stack_get (tc->off, &oc, &ov); + ASSERT_BOUNDS(at,oc); + off = (long int) ov [at]; + if ((at+1) == oc) { + end = tc->num; + } else { + end = (long int) ov [at+1]; + } + TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); + ASSERT_BOUNDS(off,tc->num); + ASSERT_BOUNDS(end-1,tc->num); + *ch = tc->str + off; + *len = end - off; + } + SCOPE void + rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) + { + long int oc, off, top, end; + void** ov; + rde_stack_get (tc->off, &oc, &ov); + ASSERT_BOUNDS(at,oc); + ASSERT_BOUNDS(last,oc); + off = (long int) ov [at]; + if ((last+1) == oc) { + end = tc->num; + } else { + end = (long int) ov [last+1]; + } + TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); + ASSERT_BOUNDS(off,tc->num); + ASSERT_BOUNDS(end-1,tc->num); + *ch = tc->str + off; + *len = end - off; + } + + +#line 1 "rde_critcl/param.c" + + typedef struct RDE_PARAM_ { + Tcl_Channel IN; + Tcl_Obj* readbuf; + char* CC; + long int CC_len; + RDE_TC TC; + long int CL; + RDE_STACK LS; + ERROR_STATE* ER; + RDE_STACK ES; + long int ST; + Tcl_Obj* SV; + Tcl_HashTable NC; + + RDE_STACK ast ; + RDE_STACK mark ; + + long int numstr; + char** string; + + ClientData clientData; + } RDE_PARAM_; + typedef int (*UniCharClass) (int); + typedef enum test_class_id { + tc_alnum, + tc_alpha, + tc_ascii, + tc_control, + tc_ddigit, + tc_digit, + tc_graph, + tc_lower, + tc_printable, + tc_punct, + tc_space, + tc_upper, + tc_wordchar, + tc_xdigit + } test_class_id; + static void ast_node_free (void* n); + static void error_state_free (void* es); + static void error_set (RDE_PARAM p, long int s); + static void nc_clear (RDE_PARAM p); + static int UniCharIsAscii (int character); + static int UniCharIsHexDigit (int character); + static int UniCharIsDecDigit (int character); + static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); + static int er_int_compare (const void* a, const void* b); + #define SV_INIT(p) \ + p->SV = NULL; \ + TRACE (("SV_INIT (%p => %p)", (p), (p)->SV)) + #define SV_SET(p,newsv) \ + if (((p)->SV) != (newsv)) { \ + TRACE (("SV_CLEAR/set (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_DecrRefCount ((p)->SV); \ + } \ + (p)->SV = (newsv); \ + TRACE (("SV_SET (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_IncrRefCount ((p)->SV); \ + } \ + } + #define SV_CLEAR(p) \ + TRACE (("SV_CLEAR (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_DecrRefCount ((p)->SV); \ + } \ + (p)->SV = NULL + #define ER_INIT(p) \ + p->ER = NULL; \ + TRACE (("ER_INIT (%p => %p)", (p), (p)->ER)) + #define ER_CLEAR(p) \ + error_state_free ((p)->ER); \ + (p)->ER = NULL + SCOPE RDE_PARAM + rde_param_new (long int nstr, char** strings) + { + RDE_PARAM p; + ENTER ("rde_param_new"); + TRACE (("\tINT %d strings @ %p", nstr, strings)); + p = ALLOC (RDE_PARAM_); + p->numstr = nstr; + p->string = strings; + p->readbuf = Tcl_NewObj (); + Tcl_IncrRefCount (p->readbuf); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + Tcl_InitHashTable (&p->NC, TCL_ONE_WORD_KEYS); + p->IN = NULL; + p->CL = -1; + p->ST = 0; + ER_INIT (p); + SV_INIT (p); + p->CC = NULL; + p->CC_len = 0; + p->TC = rde_tc_new (); + p->ES = rde_stack_new (error_state_free); + p->LS = rde_stack_new (NULL); + p->ast = rde_stack_new (ast_node_free); + p->mark = rde_stack_new (NULL); + RETURN ("%p", p); + } + SCOPE void + rde_param_del (RDE_PARAM p) + { + ENTER ("rde_param_del"); + TRACE (("RDE_PARAM %p",p)); + ER_CLEAR (p); TRACE (("\ter_clear")); + SV_CLEAR (p); TRACE (("\tsv_clear")); + nc_clear (p); TRACE (("\tnc_clear")); + Tcl_DeleteHashTable (&p->NC); TRACE (("\tnc hashtable delete")); + rde_tc_del (p->TC); TRACE (("\ttc clear")); + rde_stack_del (p->ES); TRACE (("\tes clear")); + rde_stack_del (p->LS); TRACE (("\tls clear")); + rde_stack_del (p->ast); TRACE (("\tast clear")); + rde_stack_del (p->mark); TRACE (("\tmark clear")); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + Tcl_DecrRefCount (p->readbuf); + ckfree ((char*) p); + RETURNVOID; + } + SCOPE void + rde_param_reset (RDE_PARAM p, Tcl_Channel chan) + { + ENTER ("rde_param_reset"); + TRACE (("RDE_PARAM %p",p)); + TRACE (("Tcl_Channel %p",chan)); + p->IN = chan; + p->CL = -1; + p->ST = 0; + p->CC = NULL; + p->CC_len = 0; + ER_CLEAR (p); + SV_CLEAR (p); + nc_clear (p); + rde_tc_clear (p->TC); + rde_stack_trim (p->ES, 0); + rde_stack_trim (p->LS, 0); + rde_stack_trim (p->ast, 0); + rde_stack_trim (p->mark, 0); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + RETURNVOID; + } + SCOPE void + rde_param_update_strings (RDE_PARAM p, long int nstr, char** strings) + { + ENTER ("rde_param_update_strings"); + TRACE (("RDE_PARAM %p", p)); + TRACE (("INT %d strings", nstr)); + p->numstr = nstr; + p->string = strings; + RETURNVOID; + } + SCOPE void + rde_param_data (RDE_PARAM p, char* buf, long int len) + { + (void) rde_tc_append (p->TC, buf, len); + } + SCOPE void + rde_param_clientdata (RDE_PARAM p, ClientData clientData) + { + p->clientData = clientData; + } + static void + nc_clear (RDE_PARAM p) + { + Tcl_HashSearch hs; + Tcl_HashEntry* he; + Tcl_HashTable* tablePtr; + for(he = Tcl_FirstHashEntry(&p->NC, &hs); + he != NULL; + he = Tcl_FirstHashEntry(&p->NC, &hs)) { + Tcl_HashSearch hsc; + Tcl_HashEntry* hec; + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (he); + for(hec = Tcl_FirstHashEntry(tablePtr, &hsc); + hec != NULL; + hec = Tcl_NextHashEntry(&hsc)) { + NC_STATE* scs = Tcl_GetHashValue (hec); + error_state_free (scs->ER); + if (scs->SV) { Tcl_DecrRefCount (scs->SV); } + ckfree ((char*) scs); + } + Tcl_DeleteHashTable (tablePtr); + ckfree ((char*) tablePtr); + Tcl_DeleteHashEntry (he); + } + } + SCOPE ClientData + rde_param_query_clientdata (RDE_PARAM p) + { + return p->clientData; + } + SCOPE void + rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) + { + rde_stack_get (p->mark, mc, mv); + } + SCOPE void + rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) + { + rde_stack_get (p->ast, ac, (void***) av); + } + SCOPE const char* + rde_param_query_in (RDE_PARAM p) + { + return p->IN + ? Tcl_GetChannelName (p->IN) + : ""; + } + SCOPE const char* + rde_param_query_cc (RDE_PARAM p, long int* len) + { + *len = p->CC_len; + return p->CC; + } + SCOPE int + rde_param_query_cl (RDE_PARAM p) + { + return p->CL; + } + SCOPE const ERROR_STATE* + rde_param_query_er (RDE_PARAM p) + { + return p->ER; + } + SCOPE Tcl_Obj* + rde_param_query_er_tcl (RDE_PARAM p, const ERROR_STATE* er) + { + Tcl_Obj* res; + if (!er) { + + res = Tcl_NewStringObj ("", 0); + } else { + Tcl_Obj* ov [2]; + Tcl_Obj** mov; + long int mc, i, j; + void** mv; + int lastid; + const char* msg; + rde_stack_get (er->msg, &mc, &mv); + + qsort (mv, mc, sizeof (void*), er_int_compare); + + mov = NALLOC (mc, Tcl_Obj*); + lastid = -1; + for (i=0, j=0; i < mc; i++) { + ASSERT_BOUNDS (i,mc); + if (((long int) mv [i]) == lastid) continue; + lastid = (long int) mv [i]; + ASSERT_BOUNDS((long int) mv[i],p->numstr); + msg = p->string [(long int) mv[i]]; + ASSERT_BOUNDS (j,mc); + mov [j] = Tcl_NewStringObj (msg, -1); + j++; + } + + ov [0] = Tcl_NewIntObj (er->loc); + ov [1] = Tcl_NewListObj (j, mov); + res = Tcl_NewListObj (2, ov); + ckfree ((char*) mov); + } + return res; + } + SCOPE void + rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) + { + rde_stack_get (p->ES, ec, (void***) ev); + } + SCOPE void + rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) + { + rde_stack_get (p->LS, lc, lv); + } + SCOPE long int + rde_param_query_lstop (RDE_PARAM p) + { + (long int) rde_stack_top (p->LS); + } + SCOPE Tcl_HashTable* + rde_param_query_nc (RDE_PARAM p) + { + return &p->NC; + } + SCOPE int + rde_param_query_st (RDE_PARAM p) + { + return p->ST; + } + SCOPE Tcl_Obj* + rde_param_query_sv (RDE_PARAM p) + { + TRACE (("SV_QUERY %p => (%p)", (p), (p)->SV)); \ + return p->SV; + } + SCOPE long int + rde_param_query_tc_size (RDE_PARAM p) + { + return rde_tc_size (p->TC); + } + SCOPE void + rde_param_query_tc_get_s (RDE_PARAM p, long int at, long int last, char** ch, long int* len) + { + rde_tc_get_s (p->TC, at, last, ch, len); + } + SCOPE const char* + rde_param_query_string (RDE_PARAM p, long int id) + { + TRACE (("rde_param_query_string (RDE_PARAM %p, %d/%d)", p, id, p->numstr)); + ASSERT_BOUNDS(id,p->numstr); + return p->string [id]; + } + SCOPE void + rde_param_i_ast_pop_discard (RDE_PARAM p) + { + rde_stack_pop (p->mark, 1); + } + SCOPE void + rde_param_i_ast_pop_rewind (RDE_PARAM p) + { + long int trim = (long int) rde_stack_top (p->mark); + ENTER ("rde_param_i_ast_pop_rewind"); + TRACE (("RDE_PARAM %p",p)); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_ast_rewind (RDE_PARAM p) + { + long int trim = (long int) rde_stack_top (p->mark); + ENTER ("rde_param_i_ast_rewind"); + TRACE (("RDE_PARAM %p",p)); + rde_stack_trim (p->ast, trim); + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_ast_push (RDE_PARAM p) + { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + } + SCOPE void + rde_param_i_ast_value_push (RDE_PARAM p) + { + ENTER ("rde_param_i_ast_value_push"); + TRACE (("RDE_PARAM %p",p)); + ASSERT(p->SV,"Unable to push undefined semantic value"); + TRACE (("rde_param_i_ast_value_push %p => (%p)", p, p->SV)); + TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV->refCount, Tcl_GetString (p->SV))); + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + RETURNVOID; + } + static void + ast_node_free (void* n) + { + Tcl_DecrRefCount ((Tcl_Obj*) n); + } + SCOPE void + rde_param_i_error_clear (RDE_PARAM p) + { + ER_CLEAR (p); + } + SCOPE void + rde_param_i_error_nonterminal (RDE_PARAM p, long int s) + { + + return; + long int pos; + if (!p->ER) return; + pos = 1 + (long int) rde_stack_top (p->LS); + if (p->ER->loc != pos) return; + error_set (p, s); + p->ER->loc = pos; + } + SCOPE void + rde_param_i_error_pop_merge (RDE_PARAM p) + { + ERROR_STATE* top = (ERROR_STATE*) rde_stack_top (p->ES); + + if (top == p->ER) { + rde_stack_pop (p->ES, 1); + return; + } + + if (!top) { + rde_stack_pop (p->ES, 1); + return; + } + + if (!p->ER) { + rde_stack_drop (p->ES, 1); + p->ER = top; + + return; + } + + if (top->loc < p->ER->loc) { + rde_stack_pop (p->ES, 1); + return; + } + + if (top->loc > p->ER->loc) { + rde_stack_drop (p->ES, 1); + error_state_free (p->ER); + p->ER = top; + + return; + } + + rde_stack_move (p->ER->msg, top->msg); + rde_stack_pop (p->ES, 1); + } + SCOPE void + rde_param_i_error_push (RDE_PARAM p) + { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + static void + error_set (RDE_PARAM p, long int s) + { + error_state_free (p->ER); + p->ER = ALLOC (ERROR_STATE); + p->ER->refCount = 1; + p->ER->loc = p->CL; + p->ER->msg = rde_stack_new (NULL); + ASSERT_BOUNDS(s,p->numstr); + rde_stack_push (p->ER->msg, (void*) s); + } + static void + error_state_free (void* esx) + { + ERROR_STATE* es = esx; + if (!es) return; + es->refCount --; + if (es->refCount > 0) return; + rde_stack_del (es->msg); + ckfree ((char*) es); + } + SCOPE void + rde_param_i_loc_pop_discard (RDE_PARAM p) + { + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_loc_pop_rewind (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_loc_push (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + } + SCOPE void + rde_param_i_loc_rewind (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + } + SCOPE void + rde_param_i_input_next (RDE_PARAM p, long int m) + { + int leni; + char* ch; + ASSERT_BOUNDS(m,p->numstr); + p->CL ++; + if (p->CL < rde_tc_size (p->TC)) { + + rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); + + ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); + p->ST = 1; + ER_CLEAR (p); + return; + } + if (!p->IN || + Tcl_Eof (p->IN) || + (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { + + p->ST = 0; + error_set (p, m); + return; + } + + ch = Tcl_GetStringFromObj (p->readbuf, &leni); + ASSERT_BOUNDS (leni, TCL_UTF_MAX); + p->CC = rde_tc_append (p->TC, ch, leni); + p->CC_len = leni; + p->ST = 1; + ER_CLEAR (p); + } + SCOPE void + rde_param_i_status_fail (RDE_PARAM p) + { + p->ST = 0; + } + SCOPE void + rde_param_i_status_ok (RDE_PARAM p) + { + p->ST = 1; + } + SCOPE void + rde_param_i_status_negate (RDE_PARAM p) + { + p->ST = !p->ST; + } + SCOPE int + rde_param_i_symbol_restore (RDE_PARAM p, long int s) + { + NC_STATE* scs; + Tcl_HashEntry* hPtr; + Tcl_HashTable* tablePtr; + + hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); + if (!hPtr) { return 0; } + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); + hPtr = Tcl_FindHashEntry (tablePtr, (char*) s); + if (!hPtr) { return 0; } + + scs = Tcl_GetHashValue (hPtr); + p->CL = scs->CL; + p->ST = scs->ST; + error_state_free (p->ER); + p->ER = scs->ER; + if (p->ER) { p->ER->refCount ++; } + TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); + SV_SET (p, scs->SV); + return 1; + } + SCOPE void + rde_param_i_symbol_save (RDE_PARAM p, long int s) + { + long int at = (long int) rde_stack_top (p->LS); + NC_STATE* scs; + Tcl_HashEntry* hPtr; + Tcl_HashTable* tablePtr; + int isnew; + ENTER ("rde_param_i_symbol_save"); + TRACE (("RDE_PARAM %p",p)); + TRACE (("INT %d",s)); + + hPtr = Tcl_CreateHashEntry (&p->NC, (char*) at, &isnew); + if (isnew) { + tablePtr = ALLOC (Tcl_HashTable); + Tcl_InitHashTable (tablePtr, TCL_ONE_WORD_KEYS); + Tcl_SetHashValue (hPtr, tablePtr); + } else { + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); + } + hPtr = Tcl_CreateHashEntry (tablePtr, (char*) s, &isnew); + if (isnew) { + + scs = ALLOC (NC_STATE); + scs->CL = p->CL; + scs->ST = p->ST; + TRACE (("SV_CACHE (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "")); + scs->SV = p->SV; + if (scs->SV) { Tcl_IncrRefCount (scs->SV); } + scs->ER = p->ER; + if (scs->ER) { scs->ER->refCount ++; } + Tcl_SetHashValue (hPtr, scs); + } else { + + scs = (NC_STATE*) Tcl_GetHashValue (hPtr); + scs->CL = p->CL; + scs->ST = p->ST; + TRACE (("SV_CACHE/over (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "" )); + if (scs->SV) { Tcl_DecrRefCount (scs->SV); } + scs->SV = p->SV; + if (scs->SV) { Tcl_IncrRefCount (scs->SV); } + error_state_free (scs->ER); + scs->ER = p->ER; + if (scs->ER) { scs->ER->refCount ++; } + } + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_test_alnum (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsAlnum, tc_alnum); + } + SCOPE void + rde_param_i_test_alpha (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsAlpha, tc_alpha); + } + SCOPE void + rde_param_i_test_ascii (RDE_PARAM p) + { + test_class (p, UniCharIsAscii, tc_ascii); + } + SCOPE void + rde_param_i_test_control (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsControl, tc_control); + } + SCOPE void + rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) + { + ASSERT_BOUNDS(msg,p->numstr); + p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, msg); + p->CL --; + } + } + SCOPE void + rde_param_i_test_ddigit (RDE_PARAM p) + { + test_class (p, UniCharIsDecDigit, tc_ddigit); + } + SCOPE void + rde_param_i_test_digit (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsDigit, tc_digit); + } + SCOPE void + rde_param_i_test_graph (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsGraph, tc_graph); + } + SCOPE void + rde_param_i_test_lower (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsLower, tc_lower); + } + SCOPE void + rde_param_i_test_print (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsPrint, tc_printable); + } + SCOPE void + rde_param_i_test_punct (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsPunct, tc_punct); + } + SCOPE void + rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) + { + ASSERT_BOUNDS(msg,p->numstr); + p->ST = + (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && + (Tcl_UtfNcmp (p->CC, e, 1) <= 0); + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, msg); + p->CL --; + } + } + SCOPE void + rde_param_i_test_space (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsSpace, tc_space); + } + SCOPE void + rde_param_i_test_upper (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsUpper, tc_upper); + } + SCOPE void + rde_param_i_test_wordchar (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsWordChar, tc_wordchar); + } + SCOPE void + rde_param_i_test_xdigit (RDE_PARAM p) + { + test_class (p, UniCharIsHexDigit, tc_xdigit); + } + static void + test_class (RDE_PARAM p, UniCharClass class, test_class_id id) + { + Tcl_UniChar ch; + Tcl_UtfToUniChar(p->CC, &ch); + ASSERT_BOUNDS(id,p->numstr); + p->ST = !!class (ch); + + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, id); + p->CL --; + } + } + static int + UniCharIsAscii (int character) + { + return (character >= 0) && (character < 0x80); + } + static int + UniCharIsHexDigit (int character) + { + return (character >= 0) && (character < 0x80) && isxdigit(character); + } + static int + UniCharIsDecDigit (int character) + { + return (character >= 0) && (character < 0x80) && isdigit(character); + } + SCOPE void + rde_param_i_value_clear (RDE_PARAM p) + { + SV_CLEAR (p); + } + SCOPE void + rde_param_i_value_leaf (RDE_PARAM p, long int s) + { + Tcl_Obj* newsv; + Tcl_Obj* ov [3]; + long int pos = 1 + (long int) rde_stack_top (p->LS); + ASSERT_BOUNDS(s,p->numstr); + ov [0] = Tcl_NewStringObj (p->string[s], -1); + ov [1] = Tcl_NewIntObj (pos); + ov [2] = Tcl_NewIntObj (p->CL); + newsv = Tcl_NewListObj (3, ov); + TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); + SV_SET (p, newsv); + } + SCOPE void + rde_param_i_value_reduce (RDE_PARAM p, long int s) + { + Tcl_Obj* newsv; + int oc, i, j; + Tcl_Obj** ov; + long int ac; + Tcl_Obj** av; + long int pos = 1 + (long int) rde_stack_top (p->LS); + long int mark = (long int) rde_stack_top (p->mark); + long int asize = rde_stack_size (p->ast); + long int new = asize - mark; + ASSERT (new >= 0, "Bad number of elements to reduce"); + ov = NALLOC (3+new, Tcl_Obj*); + ASSERT_BOUNDS(s,p->numstr); + ov [0] = Tcl_NewStringObj (p->string[s], -1); + ov [1] = Tcl_NewIntObj (pos); + ov [2] = Tcl_NewIntObj (p->CL); + rde_stack_get (p->ast, &ac, (void***) &av); + for (i = 3, j = mark; j < asize; i++, j++) { + ASSERT_BOUNDS (i, 3+new); + ASSERT_BOUNDS (j, ac); + ov [i] = av [j]; + } + ASSERT (i == 3+new, "Reduction result incomplete"); + newsv = Tcl_NewListObj (3+new, ov); + TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); + SV_SET (p, newsv); + ckfree ((char*) ov); + } + static int + er_int_compare (const void* a, const void* b) + { + + const void** ael = (const void**) a; + const void** bel = (const void**) b; + long int avalue = (long int) *ael; + long int bvalue = (long int) *bel; + if (avalue < bvalue) { return -1; } + if (avalue > bvalue) { return 1; } + return 0; + } + SCOPE int + rde_param_i_symbol_start (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) { + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + return 1; + } + rde_stack_push (p->LS, (void*) p->CL); + return 0; + } + SCOPE int + rde_param_i_symbol_start_d (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) { + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + return 1; + } + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + return 0; + } + SCOPE int + rde_param_i_symbol_void_start (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) return 1; + rde_stack_push (p->LS, (void*) p->CL); + return 0; + } + SCOPE int + rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) return 1; + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + return 0; + } + SCOPE void + rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_reduce (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_leaf (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_leaf (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) + { + SV_CLEAR (p); + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) + { + SV_CLEAR (p); + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_char (p, c, m); + } + SCOPE void + rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_range (p, s, e, m); + } + SCOPE void + rde_param_i_next_alnum (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_alnum (p); + } + SCOPE void + rde_param_i_next_alpha (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_alpha (p); + } + SCOPE void + rde_param_i_next_ascii (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_ascii (p); + } + SCOPE void + rde_param_i_next_control (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_control (p); + } + SCOPE void + rde_param_i_next_ddigit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_ddigit (p); + } + SCOPE void + rde_param_i_next_digit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_digit (p); + } + SCOPE void + rde_param_i_next_graph (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_graph (p); + } + SCOPE void + rde_param_i_next_lower (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_lower (p); + } + SCOPE void + rde_param_i_next_print (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_print (p); + } + SCOPE void + rde_param_i_next_punct (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_punct (p); + } + SCOPE void + rde_param_i_next_space (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_space (p); + } + SCOPE void + rde_param_i_next_upper (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_upper (p); + } + SCOPE void + rde_param_i_next_wordchar (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_wordchar (p); + } + SCOPE void + rde_param_i_next_xdigit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_xdigit (p); + } + SCOPE void + rde_param_i_notahead_start_d (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + } + SCOPE void + rde_param_i_notahead_exit_d (RDE_PARAM p) + { + if (p->ST) { + rde_param_i_ast_pop_rewind (p); + } else { + rde_stack_pop (p->mark, 1); + } + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + p->ST = !p->ST; + } + SCOPE void + rde_param_i_notahead_exit (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + p->ST = !p->ST; + } + SCOPE void + rde_param_i_state_push_2 (RDE_PARAM p) + { + + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + SCOPE void + rde_param_i_state_push_void (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + ER_CLEAR (p); + rde_stack_push (p->ES, p->ER); + + } + SCOPE void + rde_param_i_state_push_value (RDE_PARAM p) + { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + rde_stack_push (p->LS, (void*) p->CL); + ER_CLEAR (p); + rde_stack_push (p->ES, p->ER); + + } + SCOPE void + rde_param_i_state_merge_ok (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + p->ST = 1; + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_state_merge_void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_state_merge_value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } + SCOPE int + rde_param_i_kleene_close (RDE_PARAM p) + { + int stop = !p->ST; + rde_param_i_error_pop_merge (p); + if (stop) { + p->ST = 1; + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + return stop; + } + SCOPE int + rde_param_i_kleene_abort (RDE_PARAM p) + { + int stop = !p->ST; + if (stop) { + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + return stop; + } + SCOPE int + rde_param_i_seq_void2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_seq_void2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_seq_value2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_bra_void2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->LS, 1); + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_void2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->LS, 1); + } else { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_value2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_value2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE void + rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) + { + int at = p->CL; + + while (*str) { + rde_param_i_input_next (p, m); + if (!p->ST) { + p->ER->loc = at+1; + p->CL = at; + return; + } + rde_param_i_test_char (p, str, m); + if (!p->ST) { + p->ER->loc = at+1; + p->CL = at; + return; + } + str = Tcl_UtfNext (str); + } + } + SCOPE void + rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + while (*class) { + p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; + if (p->ST) { + ER_CLEAR (p); + return; + } + class = Tcl_UtfNext (class); + } + error_set (p, m); + p->CL --; + } + + + /* + * Declaring the parse functions + */ + + static void sequence_4 (RDE_PARAM p); + static void sym_ALNUM (RDE_PARAM p); + static void sequence_9 (RDE_PARAM p); + static void sym_ALPHA (RDE_PARAM p); + static void sequence_14 (RDE_PARAM p); + static void sym_AND (RDE_PARAM p); + static void sym_APOSTROPH (RDE_PARAM p); + static void sequence_21 (RDE_PARAM p); + static void sym_ASCII (RDE_PARAM p); + static void choice_26 (RDE_PARAM p); + static void sequence_29 (RDE_PARAM p); + static void sym_Attribute (RDE_PARAM p); + static void choice_37 (RDE_PARAM p); + static void sym_Char (RDE_PARAM p); + static void sequence_44 (RDE_PARAM p); + static void sym_CharOctalFull (RDE_PARAM p); + static void optional_50 (RDE_PARAM p); + static void sequence_52 (RDE_PARAM p); + static void sym_CharOctalPart (RDE_PARAM p); + static void sequence_57 (RDE_PARAM p); + static void sym_CharSpecial (RDE_PARAM p); + static void notahead_61 (RDE_PARAM p); + static void sequence_64 (RDE_PARAM p); + static void sym_CharUnescaped (RDE_PARAM p); + static void optional_72 (RDE_PARAM p); + static void sequence_74 (RDE_PARAM p); + static void optional_76 (RDE_PARAM p); + static void sequence_78 (RDE_PARAM p); + static void optional_80 (RDE_PARAM p); + static void sequence_82 (RDE_PARAM p); + static void sym_CharUnicode (RDE_PARAM p); + static void notahead_87 (RDE_PARAM p); + static void sequence_90 (RDE_PARAM p); + static void kleene_92 (RDE_PARAM p); + static void sequence_96 (RDE_PARAM p); + static void sym_Class (RDE_PARAM p); + static void sequence_101 (RDE_PARAM p); + static void sym_CLOSE (RDE_PARAM p); + static void sym_CLOSEB (RDE_PARAM p); + static void sequence_108 (RDE_PARAM p); + static void sym_COLON (RDE_PARAM p); + static void notahead_113 (RDE_PARAM p); + static void sequence_116 (RDE_PARAM p); + static void kleene_118 (RDE_PARAM p); + static void sequence_121 (RDE_PARAM p); + static void sym_COMMENT (RDE_PARAM p); + static void sequence_126 (RDE_PARAM p); + static void sym_CONTROL (RDE_PARAM p); + static void sym_DAPOSTROPH (RDE_PARAM p); + static void sequence_133 (RDE_PARAM p); + static void sym_DDIGIT (RDE_PARAM p); + static void optional_137 (RDE_PARAM p); + static void sequence_143 (RDE_PARAM p); + static void sym_Definition (RDE_PARAM p); + static void sequence_148 (RDE_PARAM p); + static void sym_DIGIT (RDE_PARAM p); + static void sequence_153 (RDE_PARAM p); + static void sym_DOT (RDE_PARAM p); + static void notahead_157 (RDE_PARAM p); + static void sym_EOF (RDE_PARAM p); + static void sym_EOL (RDE_PARAM p); + static void sequence_165 (RDE_PARAM p); + static void kleene_167 (RDE_PARAM p); + static void sequence_169 (RDE_PARAM p); + static void sym_Expression (RDE_PARAM p); + static void sequence_176 (RDE_PARAM p); + static void sym_Final (RDE_PARAM p); + static void kleene_182 (RDE_PARAM p); + static void sequence_186 (RDE_PARAM p); + static void sym_Grammar (RDE_PARAM p); + static void sequence_191 (RDE_PARAM p); + static void sym_GRAPH (RDE_PARAM p); + static void sequence_197 (RDE_PARAM p); + static void sym_Header (RDE_PARAM p); + static void choice_202 (RDE_PARAM p); + static void choice_206 (RDE_PARAM p); + static void kleene_208 (RDE_PARAM p); + static void sequence_210 (RDE_PARAM p); + static void sym_Ident (RDE_PARAM p); + static void sequence_215 (RDE_PARAM p); + static void sym_Identifier (RDE_PARAM p); + static void sequence_220 (RDE_PARAM p); + static void sym_IS (RDE_PARAM p); + static void sequence_225 (RDE_PARAM p); + static void sym_LEAF (RDE_PARAM p); + static void notahead_230 (RDE_PARAM p); + static void sequence_233 (RDE_PARAM p); + static void kleene_235 (RDE_PARAM p); + static void sequence_239 (RDE_PARAM p); + static void notahead_243 (RDE_PARAM p); + static void sequence_246 (RDE_PARAM p); + static void kleene_248 (RDE_PARAM p); + static void sequence_252 (RDE_PARAM p); + static void choice_254 (RDE_PARAM p); + static void sym_Literal (RDE_PARAM p); + static void sequence_259 (RDE_PARAM p); + static void sym_LOWER (RDE_PARAM p); + static void sequence_264 (RDE_PARAM p); + static void sym_NOT (RDE_PARAM p); + static void sequence_269 (RDE_PARAM p); + static void sym_OPEN (RDE_PARAM p); + static void sym_OPENB (RDE_PARAM p); + static void notahead_278 (RDE_PARAM p); + static void sequence_281 (RDE_PARAM p); + static void sym_PEG (RDE_PARAM p); + static void sequence_286 (RDE_PARAM p); + static void sym_PLUS (RDE_PARAM p); + static void choice_291 (RDE_PARAM p); + static void optional_293 (RDE_PARAM p); + static void sequence_296 (RDE_PARAM p); + static void sym_Prefix (RDE_PARAM p); + static void sequence_317 (RDE_PARAM p); + static void choice_322 (RDE_PARAM p); + static void sym_Primary (RDE_PARAM p); + static void sequence_327 (RDE_PARAM p); + static void sym_PRINTABLE (RDE_PARAM p); + static void sequence_332 (RDE_PARAM p); + static void sym_PUNCT (RDE_PARAM p); + static void sequence_337 (RDE_PARAM p); + static void sym_QUESTION (RDE_PARAM p); + static void sequence_343 (RDE_PARAM p); + static void choice_346 (RDE_PARAM p); + static void sym_Range (RDE_PARAM p); + static void sequence_351 (RDE_PARAM p); + static void sym_SEMICOLON (RDE_PARAM p); + static void poskleene_355 (RDE_PARAM p); + static void sym_Sequence (RDE_PARAM p); + static void sequence_360 (RDE_PARAM p); + static void sym_SLASH (RDE_PARAM p); + static void sequence_365 (RDE_PARAM p); + static void sym_SPACE (RDE_PARAM p); + static void sequence_370 (RDE_PARAM p); + static void sym_STAR (RDE_PARAM p); + static void sym_StartExpr (RDE_PARAM p); + static void choice_382 (RDE_PARAM p); + static void optional_384 (RDE_PARAM p); + static void sequence_386 (RDE_PARAM p); + static void sym_Suffix (RDE_PARAM p); + static void sym_TO (RDE_PARAM p); + static void sequence_393 (RDE_PARAM p); + static void sym_UPPER (RDE_PARAM p); + static void sequence_398 (RDE_PARAM p); + static void sym_VOID (RDE_PARAM p); + static void choice_403 (RDE_PARAM p); + static void kleene_405 (RDE_PARAM p); + static void sym_WHITESPACE (RDE_PARAM p); + static void sequence_410 (RDE_PARAM p); + static void sym_WORDCHAR (RDE_PARAM p); + static void sequence_415 (RDE_PARAM p); + static void sym_XDIGIT (RDE_PARAM p); + + /* + * Precomputed table of strings (symbols, error messages, etc.). + */ + + static char const* p_string [178] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "str ", + /* 15 = */ "n ALNUM", + /* 16 = */ "ALNUM", + /* 17 = */ "str ", + /* 18 = */ "n ALPHA", + /* 19 = */ "ALPHA", + /* 20 = */ "t &", + /* 21 = */ "n AND", + /* 22 = */ "AND", + /* 23 = */ "t '", + /* 24 = */ "n APOSTROPH", + /* 25 = */ "APOSTROPH", + /* 26 = */ "str ", + /* 27 = */ "n ASCII", + /* 28 = */ "ASCII", + /* 29 = */ "n Attribute", + /* 30 = */ "Attribute", + /* 31 = */ "n Char", + /* 32 = */ "Char", + /* 33 = */ "t \\\\", + /* 34 = */ ".. 0 2", + /* 35 = */ ".. 0 7", + /* 36 = */ "n CharOctalFull", + /* 37 = */ "CharOctalFull", + /* 38 = */ "n CharOctalPart", + /* 39 = */ "CharOctalPart", + /* 40 = */ "cl nrt'\\\"\\[\\]\\\\", + /* 41 = */ "n CharSpecial", + /* 42 = */ "CharSpecial", + /* 43 = */ "dot", + /* 44 = */ "n CharUnescaped", + /* 45 = */ "CharUnescaped", + /* 46 = */ "str \173\\u\175", + /* 47 = */ "n CharUnicode", + /* 48 = */ "CharUnicode", + /* 49 = */ "n Class", + /* 50 = */ "Class", + /* 51 = */ "t )", + /* 52 = */ "n CLOSE", + /* 53 = */ "CLOSE", + /* 54 = */ "t \\]", + /* 55 = */ "n CLOSEB", + /* 56 = */ "CLOSEB", + /* 57 = */ "t :", + /* 58 = */ "n COLON", + /* 59 = */ "COLON", + /* 60 = */ "t #", + /* 61 = */ "n COMMENT", + /* 62 = */ "COMMENT", + /* 63 = */ "str ", + /* 64 = */ "n CONTROL", + /* 65 = */ "CONTROL", + /* 66 = */ "t \173\"\175", + /* 67 = */ "n DAPOSTROPH", + /* 68 = */ "DAPOSTROPH", + /* 69 = */ "str ", + /* 70 = */ "n DDIGIT", + /* 71 = */ "DDIGIT", + /* 72 = */ "n Definition", + /* 73 = */ "Definition", + /* 74 = */ "str ", + /* 75 = */ "n DIGIT", + /* 76 = */ "DIGIT", + /* 77 = */ "t .", + /* 78 = */ "n DOT", + /* 79 = */ "DOT", + /* 80 = */ "n EOF", + /* 81 = */ "EOF", + /* 82 = */ "cl \173\n\r\175", + /* 83 = */ "n EOL", + /* 84 = */ "EOL", + /* 85 = */ "n Expression", + /* 86 = */ "Expression", + /* 87 = */ "str END", + /* 88 = */ "n Final", + /* 89 = */ "Final", + /* 90 = */ "n Grammar", + /* 91 = */ "Grammar", + /* 92 = */ "str ", + /* 93 = */ "n GRAPH", + /* 94 = */ "GRAPH", + /* 95 = */ "n Header", + /* 96 = */ "Header", + /* 97 = */ "cl _:", + /* 98 = */ "n Ident", + /* 99 = */ "Ident", + /* 100 = */ "n Identifier", + /* 101 = */ "Identifier", + /* 102 = */ "str <-", + /* 103 = */ "n IS", + /* 104 = */ "IS", + /* 105 = */ "str leaf", + /* 106 = */ "n LEAF", + /* 107 = */ "LEAF", + /* 108 = */ "n Literal", + /* 109 = */ "Literal", + /* 110 = */ "str ", + /* 111 = */ "n LOWER", + /* 112 = */ "LOWER", + /* 113 = */ "t !", + /* 114 = */ "n NOT", + /* 115 = */ "NOT", + /* 116 = */ "t (", + /* 117 = */ "n OPEN", + /* 118 = */ "OPEN", + /* 119 = */ "t \173[\175", + /* 120 = */ "n OPENB", + /* 121 = */ "OPENB", + /* 122 = */ "str PEG", + /* 123 = */ "n PEG", + /* 124 = */ "PEG", + /* 125 = */ "t +", + /* 126 = */ "n PLUS", + /* 127 = */ "PLUS", + /* 128 = */ "n Prefix", + /* 129 = */ "Prefix", + /* 130 = */ "n Primary", + /* 131 = */ "Primary", + /* 132 = */ "str ", + /* 133 = */ "n PRINTABLE", + /* 134 = */ "PRINTABLE", + /* 135 = */ "str ", + /* 136 = */ "n PUNCT", + /* 137 = */ "PUNCT", + /* 138 = */ "t ?", + /* 139 = */ "n QUESTION", + /* 140 = */ "QUESTION", + /* 141 = */ "n Range", + /* 142 = */ "Range", + /* 143 = */ "t \173;\175", + /* 144 = */ "n SEMICOLON", + /* 145 = */ "SEMICOLON", + /* 146 = */ "n Sequence", + /* 147 = */ "Sequence", + /* 148 = */ "t /", + /* 149 = */ "n SLASH", + /* 150 = */ "SLASH", + /* 151 = */ "str ", + /* 152 = */ "n SPACE", + /* 153 = */ "SPACE", + /* 154 = */ "t *", + /* 155 = */ "n STAR", + /* 156 = */ "STAR", + /* 157 = */ "n StartExpr", + /* 158 = */ "StartExpr", + /* 159 = */ "n Suffix", + /* 160 = */ "Suffix", + /* 161 = */ "t -", + /* 162 = */ "n TO", + /* 163 = */ "TO", + /* 164 = */ "str ", + /* 165 = */ "n UPPER", + /* 166 = */ "UPPER", + /* 167 = */ "str void", + /* 168 = */ "n VOID", + /* 169 = */ "VOID", + /* 170 = */ "n WHITESPACE", + /* 171 = */ "WHITESPACE", + /* 172 = */ "str ", + /* 173 = */ "n WORDCHAR", + /* 174 = */ "WORDCHAR", + /* 175 = */ "str ", + /* 176 = */ "n XDIGIT", + /* 177 = */ "XDIGIT" + }; + + /* + * Grammar Start Expression + */ + + static void MAIN (RDE_PARAM p) { + sym_Grammar (p); + return; + } + + /* + * leaf Symbol 'ALNUM' + */ + + static void sym_ALNUM (RDE_PARAM p) { + /* + * x + * "" + * (WHITESPACE) + */ + + if (rde_param_i_symbol_start (p, 16)) return ; + sequence_4 (p); + rde_param_i_symbol_done_leaf (p, 16, 15); + return; + } + + static void sequence_4 (RDE_PARAM p) { + /* + * x + * "" + * (WHITESPACE) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_str (p, "", 14); + if (rde_param_i_seq_void2void(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_void (p); + return; + } + + /* + * leaf Symbol 'ALPHA' + */ + + static void sym_ALPHA (RDE_PARAM p) { + /* + * x + * "" + * (WHITESPACE) + */ + + if (rde_param_i_symbol_start (p, 19)) return ; + sequence_9 (p); + rde_param_i_symbol_done_leaf (p, 19, 18); + return; + } + + static void sequence_9 (RDE_PARAM p) { + /* + * x + * "" + * (WHITESPACE) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_str (p, "", 17); + if (rde_param_i_seq_void2void(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_void (p); + return; + } + + /* + * leaf Symbol 'AND' + */ + + static void sym_AND (RDE_PARAM p) { + /* + * x + * '&' + * (WHITESPACE) + */ + + if (rde_param_i_symbol_start (p, 22)) return ; + sequence_14 (p); + rde_param_i_symbol_done_leaf (p, 22, 21); + return; + } + + static void sequence_14 (RDE_PARAM p) { + /* + * x + * '&' + * (WHITESPACE) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_char (p, "&", 20); + if (rde_param_i_seq_void2void(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_void (p); + return; + } + + /* + * void Symbol 'APOSTROPH' + */ + + static void sym_APOSTROPH (RDE_PARAM p) { + /* + * ''' + */ + + if (rde_param_i_symbol_void_start (p, 25)) return ; + rde_param_i_next_char (p, "'", 23); + rde_param_i_symbol_done_void (p, 25, 24); + return; + } + + /* + * leaf Symbol 'ASCII' + */ + + static void sym_ASCII (RDE_PARAM p) { + /* + * x + * "" + * (WHITESPACE) + */ + + if (rde_param_i_symbol_start (p, 28)) return ; + sequence_21 (p); + rde_param_i_symbol_done_leaf (p, 28, 27); + return; + } + + static void sequence_21 (RDE_PARAM p) { + /* + * x + * "" + * (WHITESPACE) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_str (p, "", 26); + if (rde_param_i_seq_void2void(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_void (p); + return; + } + + /* + * value Symbol 'Attribute' + */ + + static void sym_Attribute (RDE_PARAM p) { + /* + * x + * / + * (VOID) + * (LEAF) + * (COLON) + */ + + if (rde_param_i_symbol_start_d (p, 30)) return ; + sequence_29 (p); + rde_param_i_symbol_done_d_reduce (p, 30, 29); + return; + } + + static void sequence_29 (RDE_PARAM p) { + /* + * x + * / + * (VOID) + * (LEAF) + * (COLON) + */ + + rde_param_i_state_push_value (p); + choice_26 (p); + if (rde_param_i_seq_value2value(p)) return; + sym_COLON (p); + rde_param_i_state_merge_value (p); + return; + } + + static void choice_26 (RDE_PARAM p) { + /* + * / + * (VOID) + * (LEAF) + */ + + rde_param_i_state_push_value (p); + sym_VOID (p); + if (rde_param_i_bra_value2value(p)) return; + sym_LEAF (p); + rde_param_i_state_merge_value (p); + return; + } + + /* + * value Symbol 'Char' + */ + + static void sym_Char (RDE_PARAM p) { + /* + * / + * (CharSpecial) + * (CharOctalFull) + * (CharOctalPart) + * (CharUnicode) + * (CharUnescaped) + */ + + if (rde_param_i_symbol_start_d (p, 32)) return ; + choice_37 (p); + rde_param_i_symbol_done_d_reduce (p, 32, 31); + return; + } + + static void choice_37 (RDE_PARAM p) { + /* + * / + * (CharSpecial) + * (CharOctalFull) + * (CharOctalPart) + * (CharUnicode) + * (CharUnescaped) + */ + + rde_param_i_state_push_value (p); + sym_CharSpecial (p); + if (rde_param_i_bra_value2value(p)) return; + sym_CharOctalFull (p); + if (rde_param_i_bra_value2value(p)) return; + sym_CharOctalPart (p); + if (rde_param_i_bra_value2value(p)) return; + sym_CharUnicode (p); + if (rde_param_i_bra_value2value(p)) return; + sym_CharUnescaped (p); + rde_param_i_state_merge_value (p); + return; + } + + /* + * leaf Symbol 'CharOctalFull' + */ + + static void sym_CharOctalFull (RDE_PARAM p) { + /* + * x + * '\' + * range (0 .. 2) + * range (0 .. 7) + * range (0 .. 7) + */ + + if (rde_param_i_symbol_start (p, 37)) return ; + sequence_44 (p); + rde_param_i_symbol_done_leaf (p, 37, 36); + return; + } + + static void sequence_44 (RDE_PARAM p) { + /* + * x + * '\' + * range (0 .. 2) + * range (0 .. 7) + * range (0 .. 7) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_char (p, "\\", 33); + if (rde_param_i_seq_void2void(p)) return; + rde_param_i_next_range (p, "0", "2", 34); + if (rde_param_i_seq_void2void(p)) return; + rde_param_i_next_range (p, "0", "7", 35); + if (rde_param_i_seq_void2void(p)) return; + rde_param_i_next_range (p, "0", "7", 35); + rde_param_i_state_merge_void (p); + return; + } + + /* + * leaf Symbol 'CharOctalPart' + */ + + static void sym_CharOctalPart (RDE_PARAM p) { + /* + * x + * '\' + * range (0 .. 7) + * ? + * range (0 .. 7) + */ + + if (rde_param_i_symbol_start (p, 39)) return ; + sequence_52 (p); + rde_param_i_symbol_done_leaf (p, 39, 38); + return; + } + + static void sequence_52 (RDE_PARAM p) { + /* + * x + * '\' + * range (0 .. 7) + * ? + * range (0 .. 7) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_char (p, "\\", 33); + if (rde_param_i_seq_void2void(p)) return; + rde_param_i_next_range (p, "0", "7", 35); + if (rde_param_i_seq_void2void(p)) return; + optional_50 (p); + rde_param_i_state_merge_void (p); + return; + } + + static void optional_50 (RDE_PARAM p) { + /* + * ? + * range (0 .. 7) + */ + + rde_param_i_state_push_2 (p); + rde_param_i_next_range (p, "0", "7", 35); + rde_param_i_state_merge_ok (p); + return; + } + + /* + * leaf Symbol 'CharSpecial' + */ + + static void sym_CharSpecial (RDE_PARAM p) { + /* + * x + * '\' + * [nrt'\"[]\] + */ + + if (rde_param_i_symbol_start (p, 42)) return ; + sequence_57 (p); + rde_param_i_symbol_done_leaf (p, 42, 41); + return; + } + + static void sequence_57 (RDE_PARAM p) { + /* + * x + * '\' + * [nrt'\"[]\] + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_char (p, "\\", 33); + if (rde_param_i_seq_void2void(p)) return; + rde_param_i_next_class (p, "nrt'\"[]\\", 40); + rde_param_i_state_merge_void (p); + return; + } + + /* + * leaf Symbol 'CharUnescaped' + */ + + static void sym_CharUnescaped (RDE_PARAM p) { + /* + * x + * ! + * '\' + * + */ + + if (rde_param_i_symbol_start (p, 45)) return ; + sequence_64 (p); + rde_param_i_symbol_done_leaf (p, 45, 44); + return; + } + + static void sequence_64 (RDE_PARAM p) { + /* + * x + * ! + * '\' + * + */ + + rde_param_i_state_push_void (p); + notahead_61 (p); + if (rde_param_i_seq_void2void(p)) return; + rde_param_i_input_next (p, 43); + rde_param_i_state_merge_void (p); + return; + } + + static void notahead_61 (RDE_PARAM p) { + /* + * ! + * '\' + */ + + rde_param_i_loc_push (p); + rde_param_i_next_char (p, "\\", 33); + rde_param_i_notahead_exit (p); + return; + } + + /* + * leaf Symbol 'CharUnicode' + */ + + static void sym_CharUnicode (RDE_PARAM p) { + /* + * x + * "\u" + * + * ? + * x + * + * ? + * x + * + * ? + * + */ + + if (rde_param_i_symbol_start (p, 48)) return ; + sequence_82 (p); + rde_param_i_symbol_done_leaf (p, 48, 47); + return; + } + + static void sequence_82 (RDE_PARAM p) { + /* + * x + * "\u" + * + * ? + * x + * + * ? + * x + * + * ? + * + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_str (p, "\\u", 46); + if (rde_param_i_seq_void2void(p)) return; + rde_param_i_next_xdigit (p, 13); + if (rde_param_i_seq_void2void(p)) return; + optional_80 (p); + rde_param_i_state_merge_void (p); + return; + } + + static void optional_80 (RDE_PARAM p) { + /* + * ? + * x + * + * ? + * x + * + * ? + * + */ + + rde_param_i_state_push_2 (p); + sequence_78 (p); + rde_param_i_state_merge_ok (p); + return; + } + + static void sequence_78 (RDE_PARAM p) { + /* + * x + * + * ? + * x + * + * ? + * + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_xdigit (p, 13); + if (rde_param_i_seq_void2void(p)) return; + optional_76 (p); + rde_param_i_state_merge_void (p); + return; + } + + static void optional_76 (RDE_PARAM p) { + /* + * ? + * x + * + * ? + * + */ + + rde_param_i_state_push_2 (p); + sequence_74 (p); + rde_param_i_state_merge_ok (p); + return; + } + + static void sequence_74 (RDE_PARAM p) { + /* + * x + * + * ? + * + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_xdigit (p, 13); + if (rde_param_i_seq_void2void(p)) return; + optional_72 (p); + rde_param_i_state_merge_void (p); + return; + } + + static void optional_72 (RDE_PARAM p) { + /* + * ? + * + */ + + rde_param_i_state_push_2 (p); + rde_param_i_next_xdigit (p, 13); + rde_param_i_state_merge_ok (p); + return; + } + + /* + * value Symbol 'Class' + */ + + static void sym_Class (RDE_PARAM p) { + /* + * x + * (OPENB) + * * + * x + * ! + * (CLOSEB) + * (Range) + * (CLOSEB) + * (WHITESPACE) + */ + + if (rde_param_i_symbol_start_d (p, 50)) return ; + sequence_96 (p); + rde_param_i_symbol_done_d_reduce (p, 50, 49); + return; + } + + static void sequence_96 (RDE_PARAM p) { + /* + * x + * (OPENB) + * * + * x + * ! + * (CLOSEB) + * (Range) + * (CLOSEB) + * (WHITESPACE) + */ + + rde_param_i_state_push_void (p); + sym_OPENB (p); + if (rde_param_i_seq_void2value(p)) return; + kleene_92 (p); + if (rde_param_i_seq_value2value(p)) return; + sym_CLOSEB (p); + if (rde_param_i_seq_value2value(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_value (p); + return; + } + + static void kleene_92 (RDE_PARAM p) { + /* + * * + * x + * ! + * (CLOSEB) + * (Range) + */ + + while (1) { + rde_param_i_state_push_2 (p); + sequence_90 (p); + if (rde_param_i_kleene_close(p)) return; + } + return; + } + + static void sequence_90 (RDE_PARAM p) { + /* + * x + * ! + * (CLOSEB) + * (Range) + */ + + rde_param_i_state_push_void (p); + notahead_87 (p); + if (rde_param_i_seq_void2value(p)) return; + sym_Range (p); + rde_param_i_state_merge_value (p); + return; + } + + static void notahead_87 (RDE_PARAM p) { + /* + * ! + * (CLOSEB) + */ + + rde_param_i_loc_push (p); + sym_CLOSEB (p); + rde_param_i_notahead_exit (p); + return; + } + + /* + * void Symbol 'CLOSE' + */ + + static void sym_CLOSE (RDE_PARAM p) { + /* + * x + * '\)' + * (WHITESPACE) + */ + + if (rde_param_i_symbol_void_start (p, 53)) return ; + sequence_101 (p); + rde_param_i_symbol_done_void (p, 53, 52); + return; + } + + static void sequence_101 (RDE_PARAM p) { + /* + * x + * '\)' + * (WHITESPACE) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_char (p, ")", 51); + if (rde_param_i_seq_void2void(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_void (p); + return; + } + + /* + * void Symbol 'CLOSEB' + */ + + static void sym_CLOSEB (RDE_PARAM p) { + /* + * ']' + */ + + if (rde_param_i_symbol_void_start (p, 56)) return ; + rde_param_i_next_char (p, "]", 54); + rde_param_i_symbol_done_void (p, 56, 55); + return; + } + + /* + * void Symbol 'COLON' + */ + + static void sym_COLON (RDE_PARAM p) { + /* + * x + * ':' + * (WHITESPACE) + */ + + if (rde_param_i_symbol_void_start (p, 59)) return ; + sequence_108 (p); + rde_param_i_symbol_done_void (p, 59, 58); + return; + } + + static void sequence_108 (RDE_PARAM p) { + /* + * x + * ':' + * (WHITESPACE) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_char (p, ":", 57); + if (rde_param_i_seq_void2void(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_void (p); + return; + } + + /* + * void Symbol 'COMMENT' + */ + + static void sym_COMMENT (RDE_PARAM p) { + /* + * x + * '#' + * * + * x + * ! + * (EOL) + * + * (EOL) + */ + + if (rde_param_i_symbol_void_start (p, 62)) return ; + sequence_121 (p); + rde_param_i_symbol_done_void (p, 62, 61); + return; + } + + static void sequence_121 (RDE_PARAM p) { + /* + * x + * '#' + * * + * x + * ! + * (EOL) + * + * (EOL) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_char (p, "#", 60); + if (rde_param_i_seq_void2void(p)) return; + kleene_118 (p); + if (rde_param_i_seq_void2void(p)) return; + sym_EOL (p); + rde_param_i_state_merge_void (p); + return; + } + + static void kleene_118 (RDE_PARAM p) { + /* + * * + * x + * ! + * (EOL) + * + */ + + while (1) { + rde_param_i_state_push_2 (p); + sequence_116 (p); + if (rde_param_i_kleene_close(p)) return; + } + return; + } + + static void sequence_116 (RDE_PARAM p) { + /* + * x + * ! + * (EOL) + * + */ + + rde_param_i_state_push_void (p); + notahead_113 (p); + if (rde_param_i_seq_void2void(p)) return; + rde_param_i_input_next (p, 43); + rde_param_i_state_merge_void (p); + return; + } + + static void notahead_113 (RDE_PARAM p) { + /* + * ! + * (EOL) + */ + + rde_param_i_loc_push (p); + sym_EOL (p); + rde_param_i_notahead_exit (p); + return; + } + + /* + * leaf Symbol 'CONTROL' + */ + + static void sym_CONTROL (RDE_PARAM p) { + /* + * x + * "" + * (WHITESPACE) + */ + + if (rde_param_i_symbol_start (p, 65)) return ; + sequence_126 (p); + rde_param_i_symbol_done_leaf (p, 65, 64); + return; + } + + static void sequence_126 (RDE_PARAM p) { + /* + * x + * "" + * (WHITESPACE) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_str (p, "", 63); + if (rde_param_i_seq_void2void(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_void (p); + return; + } + + /* + * void Symbol 'DAPOSTROPH' + */ + + static void sym_DAPOSTROPH (RDE_PARAM p) { + /* + * '\"' + */ + + if (rde_param_i_symbol_void_start (p, 68)) return ; + rde_param_i_next_char (p, "\"", 66); + rde_param_i_symbol_done_void (p, 68, 67); + return; + } + + /* + * leaf Symbol 'DDIGIT' + */ + + static void sym_DDIGIT (RDE_PARAM p) { + /* + * x + * "" + * (WHITESPACE) + */ + + if (rde_param_i_symbol_start (p, 71)) return ; + sequence_133 (p); + rde_param_i_symbol_done_leaf (p, 71, 70); + return; + } + + static void sequence_133 (RDE_PARAM p) { + /* + * x + * "" + * (WHITESPACE) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_str (p, "", 69); + if (rde_param_i_seq_void2void(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_void (p); + return; + } + + /* + * value Symbol 'Definition' + */ + + static void sym_Definition (RDE_PARAM p) { + /* + * x + * ? + * (Attribute) + * (Identifier) + * (IS) + * (Expression) + * (SEMICOLON) + */ + + if (rde_param_i_symbol_start_d (p, 73)) return ; + sequence_143 (p); + rde_param_i_symbol_done_d_reduce (p, 73, 72); + return; + } + + static void sequence_143 (RDE_PARAM p) { + /* + * x + * ? + * (Attribute) + * (Identifier) + * (IS) + * (Expression) + * (SEMICOLON) + */ + + rde_param_i_state_push_value (p); + optional_137 (p); + if (rde_param_i_seq_value2value(p)) return; + sym_Identifier (p); + if (rde_param_i_seq_value2value(p)) return; + sym_IS (p); + if (rde_param_i_seq_value2value(p)) return; + sym_Expression (p); + if (rde_param_i_seq_value2value(p)) return; + sym_SEMICOLON (p); + rde_param_i_state_merge_value (p); + return; + } + + static void optional_137 (RDE_PARAM p) { + /* + * ? + * (Attribute) + */ + + rde_param_i_state_push_2 (p); + sym_Attribute (p); + rde_param_i_state_merge_ok (p); + return; + } + + /* + * leaf Symbol 'DIGIT' + */ + + static void sym_DIGIT (RDE_PARAM p) { + /* + * x + * "" + * (WHITESPACE) + */ + + if (rde_param_i_symbol_start (p, 76)) return ; + sequence_148 (p); + rde_param_i_symbol_done_leaf (p, 76, 75); + return; + } + + static void sequence_148 (RDE_PARAM p) { + /* + * x + * "" + * (WHITESPACE) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_str (p, "", 74); + if (rde_param_i_seq_void2void(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_void (p); + return; + } + + /* + * leaf Symbol 'DOT' + */ + + static void sym_DOT (RDE_PARAM p) { + /* + * x + * '.' + * (WHITESPACE) + */ + + if (rde_param_i_symbol_start (p, 79)) return ; + sequence_153 (p); + rde_param_i_symbol_done_leaf (p, 79, 78); + return; + } + + static void sequence_153 (RDE_PARAM p) { + /* + * x + * '.' + * (WHITESPACE) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_char (p, ".", 77); + if (rde_param_i_seq_void2void(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_void (p); + return; + } + + /* + * void Symbol 'EOF' + */ + + static void sym_EOF (RDE_PARAM p) { + /* + * ! + * + */ + + if (rde_param_i_symbol_void_start (p, 81)) return ; + notahead_157 (p); + rde_param_i_symbol_done_void (p, 81, 80); + return; + } + + static void notahead_157 (RDE_PARAM p) { + /* + * ! + * + */ + + rde_param_i_loc_push (p); + rde_param_i_input_next (p, 43); + rde_param_i_notahead_exit (p); + return; + } + + /* + * void Symbol 'EOL' + */ + + static void sym_EOL (RDE_PARAM p) { + /* + * [\n\r] + */ + + if (rde_param_i_symbol_void_start (p, 84)) return ; + rde_param_i_next_class (p, "\n\r", 82); + rde_param_i_symbol_done_void (p, 84, 83); + return; + } + + /* + * value Symbol 'Expression' + */ + + static void sym_Expression (RDE_PARAM p) { + /* + * x + * (Sequence) + * * + * x + * (SLASH) + * (Sequence) + */ + + if (rde_param_i_symbol_start_d (p, 86)) return ; + sequence_169 (p); + rde_param_i_symbol_done_d_reduce (p, 86, 85); + return; + } + + static void sequence_169 (RDE_PARAM p) { + /* + * x + * (Sequence) + * * + * x + * (SLASH) + * (Sequence) + */ + + rde_param_i_state_push_value (p); + sym_Sequence (p); + if (rde_param_i_seq_value2value(p)) return; + kleene_167 (p); + rde_param_i_state_merge_value (p); + return; + } + + static void kleene_167 (RDE_PARAM p) { + /* + * * + * x + * (SLASH) + * (Sequence) + */ + + while (1) { + rde_param_i_state_push_2 (p); + sequence_165 (p); + if (rde_param_i_kleene_close(p)) return; + } + return; + } + + static void sequence_165 (RDE_PARAM p) { + /* + * x + * (SLASH) + * (Sequence) + */ + + rde_param_i_state_push_void (p); + sym_SLASH (p); + if (rde_param_i_seq_void2value(p)) return; + sym_Sequence (p); + rde_param_i_state_merge_value (p); + return; + } + + /* + * void Symbol 'Final' + */ + + static void sym_Final (RDE_PARAM p) { + /* + * x + * "END" + * (WHITESPACE) + * (SEMICOLON) + * (WHITESPACE) + */ + + if (rde_param_i_symbol_void_start (p, 89)) return ; + sequence_176 (p); + rde_param_i_symbol_done_void (p, 89, 88); + return; + } + + static void sequence_176 (RDE_PARAM p) { + /* + * x + * "END" + * (WHITESPACE) + * (SEMICOLON) + * (WHITESPACE) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_str (p, "END", 87); + if (rde_param_i_seq_void2void(p)) return; + sym_WHITESPACE (p); + if (rde_param_i_seq_void2void(p)) return; + sym_SEMICOLON (p); + if (rde_param_i_seq_void2void(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_void (p); + return; + } + + /* + * value Symbol 'Grammar' + */ + + static void sym_Grammar (RDE_PARAM p) { + /* + * x + * (WHITESPACE) + * (Header) + * * + * (Definition) + * (Final) + * (EOF) + */ + + if (rde_param_i_symbol_start_d (p, 91)) return ; + sequence_186 (p); + rde_param_i_symbol_done_d_reduce (p, 91, 90); + return; + } + + static void sequence_186 (RDE_PARAM p) { + /* + * x + * (WHITESPACE) + * (Header) + * * + * (Definition) + * (Final) + * (EOF) + */ + + rde_param_i_state_push_void (p); + sym_WHITESPACE (p); + if (rde_param_i_seq_void2value(p)) return; + sym_Header (p); + if (rde_param_i_seq_value2value(p)) return; + kleene_182 (p); + if (rde_param_i_seq_value2value(p)) return; + sym_Final (p); + if (rde_param_i_seq_value2value(p)) return; + sym_EOF (p); + rde_param_i_state_merge_value (p); + return; + } + + static void kleene_182 (RDE_PARAM p) { + /* + * * + * (Definition) + */ + + while (1) { + rde_param_i_state_push_2 (p); + sym_Definition (p); + if (rde_param_i_kleene_close(p)) return; + } + return; + } + + /* + * leaf Symbol 'GRAPH' + */ + + static void sym_GRAPH (RDE_PARAM p) { + /* + * x + * "" + * (WHITESPACE) + */ + + if (rde_param_i_symbol_start (p, 94)) return ; + sequence_191 (p); + rde_param_i_symbol_done_leaf (p, 94, 93); + return; + } + + static void sequence_191 (RDE_PARAM p) { + /* + * x + * "" + * (WHITESPACE) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_str (p, "", 92); + if (rde_param_i_seq_void2void(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_void (p); + return; + } + + /* + * value Symbol 'Header' + */ + + static void sym_Header (RDE_PARAM p) { + /* + * x + * (PEG) + * (Identifier) + * (StartExpr) + */ + + if (rde_param_i_symbol_start_d (p, 96)) return ; + sequence_197 (p); + rde_param_i_symbol_done_d_reduce (p, 96, 95); + return; + } + + static void sequence_197 (RDE_PARAM p) { + /* + * x + * (PEG) + * (Identifier) + * (StartExpr) + */ + + rde_param_i_state_push_void (p); + sym_PEG (p); + if (rde_param_i_seq_void2value(p)) return; + sym_Identifier (p); + if (rde_param_i_seq_value2value(p)) return; + sym_StartExpr (p); + rde_param_i_state_merge_value (p); + return; + } + + /* + * leaf Symbol 'Ident' + */ + + static void sym_Ident (RDE_PARAM p) { + /* + * x + * / + * [_:] + * + * * + * / + * [_:] + * + */ + + if (rde_param_i_symbol_start (p, 99)) return ; + sequence_210 (p); + rde_param_i_symbol_done_leaf (p, 99, 98); + return; + } + + static void sequence_210 (RDE_PARAM p) { + /* + * x + * / + * [_:] + * + * * + * / + * [_:] + * + */ + + rde_param_i_state_push_void (p); + choice_202 (p); + if (rde_param_i_seq_void2void(p)) return; + kleene_208 (p); + rde_param_i_state_merge_void (p); + return; + } + + static void choice_202 (RDE_PARAM p) { + /* + * / + * [_:] + * + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_class (p, "_:", 97); + if (rde_param_i_bra_void2void(p)) return; + rde_param_i_next_alpha (p, 1); + rde_param_i_state_merge_void (p); + return; + } + + static void kleene_208 (RDE_PARAM p) { + /* + * * + * / + * [_:] + * + */ + + while (1) { + rde_param_i_state_push_2 (p); + choice_206 (p); + if (rde_param_i_kleene_close(p)) return; + } + return; + } + + static void choice_206 (RDE_PARAM p) { + /* + * / + * [_:] + * + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_class (p, "_:", 97); + if (rde_param_i_bra_void2void(p)) return; + rde_param_i_next_alnum (p, 0); + rde_param_i_state_merge_void (p); + return; + } + + /* + * value Symbol 'Identifier' + */ + + static void sym_Identifier (RDE_PARAM p) { + /* + * x + * (Ident) + * (WHITESPACE) + */ + + if (rde_param_i_symbol_start_d (p, 101)) return ; + sequence_215 (p); + rde_param_i_symbol_done_d_reduce (p, 101, 100); + return; + } + + static void sequence_215 (RDE_PARAM p) { + /* + * x + * (Ident) + * (WHITESPACE) + */ + + rde_param_i_state_push_value (p); + sym_Ident (p); + if (rde_param_i_seq_value2value(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_value (p); + return; + } + + /* + * void Symbol 'IS' + */ + + static void sym_IS (RDE_PARAM p) { + /* + * x + * "<-" + * (WHITESPACE) + */ + + if (rde_param_i_symbol_void_start (p, 104)) return ; + sequence_220 (p); + rde_param_i_symbol_done_void (p, 104, 103); + return; + } + + static void sequence_220 (RDE_PARAM p) { + /* + * x + * "<-" + * (WHITESPACE) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_str (p, "<-", 102); + if (rde_param_i_seq_void2void(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_void (p); + return; + } + + /* + * leaf Symbol 'LEAF' + */ + + static void sym_LEAF (RDE_PARAM p) { + /* + * x + * "leaf" + * (WHITESPACE) + */ + + if (rde_param_i_symbol_start (p, 107)) return ; + sequence_225 (p); + rde_param_i_symbol_done_leaf (p, 107, 106); + return; + } + + static void sequence_225 (RDE_PARAM p) { + /* + * x + * "leaf" + * (WHITESPACE) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_str (p, "leaf", 105); + if (rde_param_i_seq_void2void(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_void (p); + return; + } + + /* + * value Symbol 'Literal' + */ + + static void sym_Literal (RDE_PARAM p) { + /* + * / + * x + * (APOSTROPH) + * * + * x + * ! + * (APOSTROPH) + * (Char) + * (APOSTROPH) + * (WHITESPACE) + * x + * (DAPOSTROPH) + * * + * x + * ! + * (DAPOSTROPH) + * (Char) + * (DAPOSTROPH) + * (WHITESPACE) + */ + + if (rde_param_i_symbol_start_d (p, 109)) return ; + choice_254 (p); + rde_param_i_symbol_done_d_reduce (p, 109, 108); + return; + } + + static void choice_254 (RDE_PARAM p) { + /* + * / + * x + * (APOSTROPH) + * * + * x + * ! + * (APOSTROPH) + * (Char) + * (APOSTROPH) + * (WHITESPACE) + * x + * (DAPOSTROPH) + * * + * x + * ! + * (DAPOSTROPH) + * (Char) + * (DAPOSTROPH) + * (WHITESPACE) + */ + + rde_param_i_state_push_value (p); + sequence_239 (p); + if (rde_param_i_bra_value2value(p)) return; + sequence_252 (p); + rde_param_i_state_merge_value (p); + return; + } + + static void sequence_239 (RDE_PARAM p) { + /* + * x + * (APOSTROPH) + * * + * x + * ! + * (APOSTROPH) + * (Char) + * (APOSTROPH) + * (WHITESPACE) + */ + + rde_param_i_state_push_void (p); + sym_APOSTROPH (p); + if (rde_param_i_seq_void2value(p)) return; + kleene_235 (p); + if (rde_param_i_seq_value2value(p)) return; + sym_APOSTROPH (p); + if (rde_param_i_seq_value2value(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_value (p); + return; + } + + static void kleene_235 (RDE_PARAM p) { + /* + * * + * x + * ! + * (APOSTROPH) + * (Char) + */ + + while (1) { + rde_param_i_state_push_2 (p); + sequence_233 (p); + if (rde_param_i_kleene_close(p)) return; + } + return; + } + + static void sequence_233 (RDE_PARAM p) { + /* + * x + * ! + * (APOSTROPH) + * (Char) + */ + + rde_param_i_state_push_void (p); + notahead_230 (p); + if (rde_param_i_seq_void2value(p)) return; + sym_Char (p); + rde_param_i_state_merge_value (p); + return; + } + + static void notahead_230 (RDE_PARAM p) { + /* + * ! + * (APOSTROPH) + */ + + rde_param_i_loc_push (p); + sym_APOSTROPH (p); + rde_param_i_notahead_exit (p); + return; + } + + static void sequence_252 (RDE_PARAM p) { + /* + * x + * (DAPOSTROPH) + * * + * x + * ! + * (DAPOSTROPH) + * (Char) + * (DAPOSTROPH) + * (WHITESPACE) + */ + + rde_param_i_state_push_void (p); + sym_DAPOSTROPH (p); + if (rde_param_i_seq_void2value(p)) return; + kleene_248 (p); + if (rde_param_i_seq_value2value(p)) return; + sym_DAPOSTROPH (p); + if (rde_param_i_seq_value2value(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_value (p); + return; + } + + static void kleene_248 (RDE_PARAM p) { + /* + * * + * x + * ! + * (DAPOSTROPH) + * (Char) + */ + + while (1) { + rde_param_i_state_push_2 (p); + sequence_246 (p); + if (rde_param_i_kleene_close(p)) return; + } + return; + } + + static void sequence_246 (RDE_PARAM p) { + /* + * x + * ! + * (DAPOSTROPH) + * (Char) + */ + + rde_param_i_state_push_void (p); + notahead_243 (p); + if (rde_param_i_seq_void2value(p)) return; + sym_Char (p); + rde_param_i_state_merge_value (p); + return; + } + + static void notahead_243 (RDE_PARAM p) { + /* + * ! + * (DAPOSTROPH) + */ + + rde_param_i_loc_push (p); + sym_DAPOSTROPH (p); + rde_param_i_notahead_exit (p); + return; + } + + /* + * leaf Symbol 'LOWER' + */ + + static void sym_LOWER (RDE_PARAM p) { + /* + * x + * "" + * (WHITESPACE) + */ + + if (rde_param_i_symbol_start (p, 112)) return ; + sequence_259 (p); + rde_param_i_symbol_done_leaf (p, 112, 111); + return; + } + + static void sequence_259 (RDE_PARAM p) { + /* + * x + * "" + * (WHITESPACE) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_str (p, "", 110); + if (rde_param_i_seq_void2void(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_void (p); + return; + } + + /* + * leaf Symbol 'NOT' + */ + + static void sym_NOT (RDE_PARAM p) { + /* + * x + * '!' + * (WHITESPACE) + */ + + if (rde_param_i_symbol_start (p, 115)) return ; + sequence_264 (p); + rde_param_i_symbol_done_leaf (p, 115, 114); + return; + } + + static void sequence_264 (RDE_PARAM p) { + /* + * x + * '!' + * (WHITESPACE) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_char (p, "!", 113); + if (rde_param_i_seq_void2void(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_void (p); + return; + } + + /* + * void Symbol 'OPEN' + */ + + static void sym_OPEN (RDE_PARAM p) { + /* + * x + * '\(' + * (WHITESPACE) + */ + + if (rde_param_i_symbol_void_start (p, 118)) return ; + sequence_269 (p); + rde_param_i_symbol_done_void (p, 118, 117); + return; + } + + static void sequence_269 (RDE_PARAM p) { + /* + * x + * '\(' + * (WHITESPACE) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_char (p, "(", 116); + if (rde_param_i_seq_void2void(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_void (p); + return; + } + + /* + * void Symbol 'OPENB' + */ + + static void sym_OPENB (RDE_PARAM p) { + /* + * '[' + */ + + if (rde_param_i_symbol_void_start (p, 121)) return ; + rde_param_i_next_char (p, "[", 119); + rde_param_i_symbol_done_void (p, 121, 120); + return; + } + + /* + * void Symbol 'PEG' + */ + + static void sym_PEG (RDE_PARAM p) { + /* + * x + * "PEG" + * ! + * / + * [_:] + * + * (WHITESPACE) + */ + + if (rde_param_i_symbol_void_start (p, 124)) return ; + sequence_281 (p); + rde_param_i_symbol_done_void (p, 124, 123); + return; + } + + static void sequence_281 (RDE_PARAM p) { + /* + * x + * "PEG" + * ! + * / + * [_:] + * + * (WHITESPACE) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_str (p, "PEG", 122); + if (rde_param_i_seq_void2void(p)) return; + notahead_278 (p); + if (rde_param_i_seq_void2void(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_void (p); + return; + } + + static void notahead_278 (RDE_PARAM p) { + /* + * ! + * / + * [_:] + * + */ + + rde_param_i_loc_push (p); + choice_206 (p); + rde_param_i_notahead_exit (p); + return; + } + + /* + * leaf Symbol 'PLUS' + */ + + static void sym_PLUS (RDE_PARAM p) { + /* + * x + * '+' + * (WHITESPACE) + */ + + if (rde_param_i_symbol_start (p, 127)) return ; + sequence_286 (p); + rde_param_i_symbol_done_leaf (p, 127, 126); + return; + } + + static void sequence_286 (RDE_PARAM p) { + /* + * x + * '+' + * (WHITESPACE) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_char (p, "+", 125); + if (rde_param_i_seq_void2void(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_void (p); + return; + } + + /* + * value Symbol 'Prefix' + */ + + static void sym_Prefix (RDE_PARAM p) { + /* + * x + * ? + * / + * (AND) + * (NOT) + * (Suffix) + */ + + if (rde_param_i_symbol_start_d (p, 129)) return ; + sequence_296 (p); + rde_param_i_symbol_done_d_reduce (p, 129, 128); + return; + } + + static void sequence_296 (RDE_PARAM p) { + /* + * x + * ? + * / + * (AND) + * (NOT) + * (Suffix) + */ + + rde_param_i_state_push_value (p); + optional_293 (p); + if (rde_param_i_seq_value2value(p)) return; + sym_Suffix (p); + rde_param_i_state_merge_value (p); + return; + } + + static void optional_293 (RDE_PARAM p) { + /* + * ? + * / + * (AND) + * (NOT) + */ + + rde_param_i_state_push_2 (p); + choice_291 (p); + rde_param_i_state_merge_ok (p); + return; + } + + static void choice_291 (RDE_PARAM p) { + /* + * / + * (AND) + * (NOT) + */ + + rde_param_i_state_push_value (p); + sym_AND (p); + if (rde_param_i_bra_value2value(p)) return; + sym_NOT (p); + rde_param_i_state_merge_value (p); + return; + } + + /* + * value Symbol 'Primary' + */ + + static void sym_Primary (RDE_PARAM p) { + /* + * / + * (ALNUM) + * (ALPHA) + * (ASCII) + * (CONTROL) + * (DDIGIT) + * (DIGIT) + * (GRAPH) + * (LOWER) + * (PRINTABLE) + * (PUNCT) + * (SPACE) + * (UPPER) + * (WORDCHAR) + * (XDIGIT) + * (Identifier) + * x + * (OPEN) + * (Expression) + * (CLOSE) + * (Literal) + * (Class) + * (DOT) + */ + + if (rde_param_i_symbol_start_d (p, 131)) return ; + choice_322 (p); + rde_param_i_symbol_done_d_reduce (p, 131, 130); + return; + } + + static void choice_322 (RDE_PARAM p) { + /* + * / + * (ALNUM) + * (ALPHA) + * (ASCII) + * (CONTROL) + * (DDIGIT) + * (DIGIT) + * (GRAPH) + * (LOWER) + * (PRINTABLE) + * (PUNCT) + * (SPACE) + * (UPPER) + * (WORDCHAR) + * (XDIGIT) + * (Identifier) + * x + * (OPEN) + * (Expression) + * (CLOSE) + * (Literal) + * (Class) + * (DOT) + */ + + rde_param_i_state_push_value (p); + sym_ALNUM (p); + if (rde_param_i_bra_value2value(p)) return; + sym_ALPHA (p); + if (rde_param_i_bra_value2value(p)) return; + sym_ASCII (p); + if (rde_param_i_bra_value2value(p)) return; + sym_CONTROL (p); + if (rde_param_i_bra_value2value(p)) return; + sym_DDIGIT (p); + if (rde_param_i_bra_value2value(p)) return; + sym_DIGIT (p); + if (rde_param_i_bra_value2value(p)) return; + sym_GRAPH (p); + if (rde_param_i_bra_value2value(p)) return; + sym_LOWER (p); + if (rde_param_i_bra_value2value(p)) return; + sym_PRINTABLE (p); + if (rde_param_i_bra_value2value(p)) return; + sym_PUNCT (p); + if (rde_param_i_bra_value2value(p)) return; + sym_SPACE (p); + if (rde_param_i_bra_value2value(p)) return; + sym_UPPER (p); + if (rde_param_i_bra_value2value(p)) return; + sym_WORDCHAR (p); + if (rde_param_i_bra_value2value(p)) return; + sym_XDIGIT (p); + if (rde_param_i_bra_value2value(p)) return; + sym_Identifier (p); + if (rde_param_i_bra_value2value(p)) return; + sequence_317 (p); + if (rde_param_i_bra_value2value(p)) return; + sym_Literal (p); + if (rde_param_i_bra_value2value(p)) return; + sym_Class (p); + if (rde_param_i_bra_value2value(p)) return; + sym_DOT (p); + rde_param_i_state_merge_value (p); + return; + } + + static void sequence_317 (RDE_PARAM p) { + /* + * x + * (OPEN) + * (Expression) + * (CLOSE) + */ + + rde_param_i_state_push_void (p); + sym_OPEN (p); + if (rde_param_i_seq_void2value(p)) return; + sym_Expression (p); + if (rde_param_i_seq_value2value(p)) return; + sym_CLOSE (p); + rde_param_i_state_merge_value (p); + return; + } + + /* + * leaf Symbol 'PRINTABLE' + */ + + static void sym_PRINTABLE (RDE_PARAM p) { + /* + * x + * "" + * (WHITESPACE) + */ + + if (rde_param_i_symbol_start (p, 134)) return ; + sequence_327 (p); + rde_param_i_symbol_done_leaf (p, 134, 133); + return; + } + + static void sequence_327 (RDE_PARAM p) { + /* + * x + * "" + * (WHITESPACE) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_str (p, "", 132); + if (rde_param_i_seq_void2void(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_void (p); + return; + } + + /* + * leaf Symbol 'PUNCT' + */ + + static void sym_PUNCT (RDE_PARAM p) { + /* + * x + * "" + * (WHITESPACE) + */ + + if (rde_param_i_symbol_start (p, 137)) return ; + sequence_332 (p); + rde_param_i_symbol_done_leaf (p, 137, 136); + return; + } + + static void sequence_332 (RDE_PARAM p) { + /* + * x + * "" + * (WHITESPACE) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_str (p, "", 135); + if (rde_param_i_seq_void2void(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_void (p); + return; + } + + /* + * leaf Symbol 'QUESTION' + */ + + static void sym_QUESTION (RDE_PARAM p) { + /* + * x + * '?' + * (WHITESPACE) + */ + + if (rde_param_i_symbol_start (p, 140)) return ; + sequence_337 (p); + rde_param_i_symbol_done_leaf (p, 140, 139); + return; + } + + static void sequence_337 (RDE_PARAM p) { + /* + * x + * '?' + * (WHITESPACE) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_char (p, "?", 138); + if (rde_param_i_seq_void2void(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_void (p); + return; + } + + /* + * value Symbol 'Range' + */ + + static void sym_Range (RDE_PARAM p) { + /* + * / + * x + * (Char) + * (TO) + * (Char) + * (Char) + */ + + if (rde_param_i_symbol_start_d (p, 142)) return ; + choice_346 (p); + rde_param_i_symbol_done_d_reduce (p, 142, 141); + return; + } + + static void choice_346 (RDE_PARAM p) { + /* + * / + * x + * (Char) + * (TO) + * (Char) + * (Char) + */ + + rde_param_i_state_push_value (p); + sequence_343 (p); + if (rde_param_i_bra_value2value(p)) return; + sym_Char (p); + rde_param_i_state_merge_value (p); + return; + } + + static void sequence_343 (RDE_PARAM p) { + /* + * x + * (Char) + * (TO) + * (Char) + */ + + rde_param_i_state_push_value (p); + sym_Char (p); + if (rde_param_i_seq_value2value(p)) return; + sym_TO (p); + if (rde_param_i_seq_value2value(p)) return; + sym_Char (p); + rde_param_i_state_merge_value (p); + return; + } + + /* + * void Symbol 'SEMICOLON' + */ + + static void sym_SEMICOLON (RDE_PARAM p) { + /* + * x + * ';' + * (WHITESPACE) + */ + + if (rde_param_i_symbol_void_start (p, 145)) return ; + sequence_351 (p); + rde_param_i_symbol_done_void (p, 145, 144); + return; + } + + static void sequence_351 (RDE_PARAM p) { + /* + * x + * ';' + * (WHITESPACE) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_char (p, ";", 143); + if (rde_param_i_seq_void2void(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_void (p); + return; + } + + /* + * value Symbol 'Sequence' + */ + + static void sym_Sequence (RDE_PARAM p) { + /* + * + + * (Prefix) + */ + + if (rde_param_i_symbol_start_d (p, 147)) return ; + poskleene_355 (p); + rde_param_i_symbol_done_d_reduce (p, 147, 146); + return; + } + + static void poskleene_355 (RDE_PARAM p) { + /* + * + + * (Prefix) + */ + + rde_param_i_loc_push (p); + sym_Prefix (p); + if (rde_param_i_kleene_abort(p)) return; + while (1) { + rde_param_i_state_push_2 (p); + sym_Prefix (p); + if (rde_param_i_kleene_close(p)) return; + } + return; + } + + /* + * void Symbol 'SLASH' + */ + + static void sym_SLASH (RDE_PARAM p) { + /* + * x + * '/' + * (WHITESPACE) + */ + + if (rde_param_i_symbol_void_start (p, 150)) return ; + sequence_360 (p); + rde_param_i_symbol_done_void (p, 150, 149); + return; + } + + static void sequence_360 (RDE_PARAM p) { + /* + * x + * '/' + * (WHITESPACE) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_char (p, "/", 148); + if (rde_param_i_seq_void2void(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_void (p); + return; + } + + /* + * leaf Symbol 'SPACE' + */ + + static void sym_SPACE (RDE_PARAM p) { + /* + * x + * "" + * (WHITESPACE) + */ + + if (rde_param_i_symbol_start (p, 153)) return ; + sequence_365 (p); + rde_param_i_symbol_done_leaf (p, 153, 152); + return; + } + + static void sequence_365 (RDE_PARAM p) { + /* + * x + * "" + * (WHITESPACE) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_str (p, "", 151); + if (rde_param_i_seq_void2void(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_void (p); + return; + } + + /* + * leaf Symbol 'STAR' + */ + + static void sym_STAR (RDE_PARAM p) { + /* + * x + * '*' + * (WHITESPACE) + */ + + if (rde_param_i_symbol_start (p, 156)) return ; + sequence_370 (p); + rde_param_i_symbol_done_leaf (p, 156, 155); + return; + } + + static void sequence_370 (RDE_PARAM p) { + /* + * x + * '*' + * (WHITESPACE) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_char (p, "*", 154); + if (rde_param_i_seq_void2void(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_void (p); + return; + } + + /* + * value Symbol 'StartExpr' + */ + + static void sym_StartExpr (RDE_PARAM p) { + /* + * x + * (OPEN) + * (Expression) + * (CLOSE) + */ + + if (rde_param_i_symbol_start_d (p, 158)) return ; + sequence_317 (p); + rde_param_i_symbol_done_d_reduce (p, 158, 157); + return; + } + + /* + * value Symbol 'Suffix' + */ + + static void sym_Suffix (RDE_PARAM p) { + /* + * x + * (Primary) + * ? + * / + * (QUESTION) + * (STAR) + * (PLUS) + */ + + if (rde_param_i_symbol_start_d (p, 160)) return ; + sequence_386 (p); + rde_param_i_symbol_done_d_reduce (p, 160, 159); + return; + } + + static void sequence_386 (RDE_PARAM p) { + /* + * x + * (Primary) + * ? + * / + * (QUESTION) + * (STAR) + * (PLUS) + */ + + rde_param_i_state_push_value (p); + sym_Primary (p); + if (rde_param_i_seq_value2value(p)) return; + optional_384 (p); + rde_param_i_state_merge_value (p); + return; + } + + static void optional_384 (RDE_PARAM p) { + /* + * ? + * / + * (QUESTION) + * (STAR) + * (PLUS) + */ + + rde_param_i_state_push_2 (p); + choice_382 (p); + rde_param_i_state_merge_ok (p); + return; + } + + static void choice_382 (RDE_PARAM p) { + /* + * / + * (QUESTION) + * (STAR) + * (PLUS) + */ + + rde_param_i_state_push_value (p); + sym_QUESTION (p); + if (rde_param_i_bra_value2value(p)) return; + sym_STAR (p); + if (rde_param_i_bra_value2value(p)) return; + sym_PLUS (p); + rde_param_i_state_merge_value (p); + return; + } + + /* + * void Symbol 'TO' + */ + + static void sym_TO (RDE_PARAM p) { + /* + * '-' + */ + + if (rde_param_i_symbol_void_start (p, 163)) return ; + rde_param_i_next_char (p, "-", 161); + rde_param_i_symbol_done_void (p, 163, 162); + return; + } + + /* + * leaf Symbol 'UPPER' + */ + + static void sym_UPPER (RDE_PARAM p) { + /* + * x + * "" + * (WHITESPACE) + */ + + if (rde_param_i_symbol_start (p, 166)) return ; + sequence_393 (p); + rde_param_i_symbol_done_leaf (p, 166, 165); + return; + } + + static void sequence_393 (RDE_PARAM p) { + /* + * x + * "" + * (WHITESPACE) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_str (p, "", 164); + if (rde_param_i_seq_void2void(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_void (p); + return; + } + + /* + * leaf Symbol 'VOID' + */ + + static void sym_VOID (RDE_PARAM p) { + /* + * x + * "void" + * (WHITESPACE) + */ + + if (rde_param_i_symbol_start (p, 169)) return ; + sequence_398 (p); + rde_param_i_symbol_done_leaf (p, 169, 168); + return; + } + + static void sequence_398 (RDE_PARAM p) { + /* + * x + * "void" + * (WHITESPACE) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_str (p, "void", 167); + if (rde_param_i_seq_void2void(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_void (p); + return; + } + + /* + * void Symbol 'WHITESPACE' + */ + + static void sym_WHITESPACE (RDE_PARAM p) { + /* + * * + * / + * + * (COMMENT) + */ + + if (rde_param_i_symbol_void_start (p, 171)) return ; + kleene_405 (p); + rde_param_i_symbol_done_void (p, 171, 170); + return; + } + + static void kleene_405 (RDE_PARAM p) { + /* + * * + * / + * + * (COMMENT) + */ + + while (1) { + rde_param_i_state_push_2 (p); + choice_403 (p); + if (rde_param_i_kleene_close(p)) return; + } + return; + } + + static void choice_403 (RDE_PARAM p) { + /* + * / + * + * (COMMENT) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_space (p, 10); + if (rde_param_i_bra_void2void(p)) return; + sym_COMMENT (p); + rde_param_i_state_merge_void (p); + return; + } + + /* + * leaf Symbol 'WORDCHAR' + */ + + static void sym_WORDCHAR (RDE_PARAM p) { + /* + * x + * "" + * (WHITESPACE) + */ + + if (rde_param_i_symbol_start (p, 174)) return ; + sequence_410 (p); + rde_param_i_symbol_done_leaf (p, 174, 173); + return; + } + + static void sequence_410 (RDE_PARAM p) { + /* + * x + * "" + * (WHITESPACE) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_str (p, "", 172); + if (rde_param_i_seq_void2void(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_void (p); + return; + } + + /* + * leaf Symbol 'XDIGIT' + */ + + static void sym_XDIGIT (RDE_PARAM p) { + /* + * x + * "" + * (WHITESPACE) + */ + + if (rde_param_i_symbol_start (p, 177)) return ; + sequence_415 (p); + rde_param_i_symbol_done_leaf (p, 177, 176); + return; + } + + static void sequence_415 (RDE_PARAM p) { + /* + * x + * "" + * (WHITESPACE) + */ + + rde_param_i_state_push_void (p); + rde_param_i_next_str (p, "", 175); + if (rde_param_i_seq_void2void(p)) return; + sym_WHITESPACE (p); + rde_param_i_state_merge_void (p); + return; + } + + /* -*- c -*- */ + + typedef struct PARSERg { + long int counter; + char buf [50]; + } PARSERg; + + static void + PARSERgRelease (ClientData cd, Tcl_Interp* interp) + { + ckfree((char*) cd); + } + + static const char* + PARSERnewName (Tcl_Interp* interp) + { +#define KEY "tcllib/parser/PACKAGE/TEA" + + Tcl_InterpDeleteProc* proc = PARSERgRelease; + PARSERg* parserg; + + parserg = Tcl_GetAssocData (interp, KEY, &proc); + if (parserg == NULL) { + parserg = (PARSERg*) ckalloc (sizeof (PARSERg)); + parserg->counter = 0; + + Tcl_SetAssocData (interp, KEY, proc, + (ClientData) parserg); + } + + parserg->counter ++; + sprintf (parserg->buf, "PARSER%ld", parserg->counter); + return parserg->buf; +#undef KEY + } + + static void + PARSERdeleteCmd (ClientData clientData) + { + /* + * Release the whole PARSER + * (Low-level engine only actually). + */ + rde_param_del ((RDE_PARAM) clientData); + } + + + /* * ** *** ***** ******** ************* + ** Functions implementing the object methods, and helper. + */ + + static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp); + + static int parser_PARSE (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + int mode; + Tcl_Channel chan; + + if (objc != 3) { + Tcl_WrongNumArgs (interp, 2, objv, "chan"); + return TCL_ERROR; + } + + chan = Tcl_GetChannel(interp, + Tcl_GetString (objv[2]), + &mode); + + if (!chan) { + return TCL_ERROR; + } + + rde_param_reset (p, chan); + MAIN (p) ; /* Entrypoint for the generated code. */ + return COMPLETE (p, interp); + } + + static int parser_PARSET (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + char* buf; + int len; + + if (objc != 3) { + Tcl_WrongNumArgs (interp, 2, objv, "text"); + return TCL_ERROR; + } + + buf = Tcl_GetStringFromObj (objv[2], &len); + + rde_param_reset (p, NULL); + rde_param_data (p, buf, len); + MAIN (p) ; /* Entrypoint for the generated code. */ + return COMPLETE (p, interp); + } + + /* See also rde_critcl/m.c, param_COMPLETE() */ + static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) + { + if (rde_param_query_st (p)) { + long int ac; + Tcl_Obj** av; + + rde_param_query_ast (p, &ac, &av); + + if (ac > 1) { + Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); + + memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); + lv [0] = Tcl_NewObj (); + lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); + lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); + + Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); + ckfree ((char*) lv); + + } else if (ac == 0) { + /* + * Match, but no AST. This is possible if the grammar + * consists of only the start expression. + */ + Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); + } else { + Tcl_SetObjResult (interp, av [0]); + } + + return TCL_OK; + } else { + Tcl_Obj* xv [1]; + const ERROR_STATE* er = rde_param_query_er (p); + Tcl_Obj* res = rde_param_query_er_tcl (p, er); + /* res = list (location, list(msg)) */ + + /* Stick the exception type-tag before the existing elements */ + xv [0] = Tcl_NewStringObj ("pt::rde",-1); + Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); + + Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); + Tcl_SetObjResult (interp, res); + return TCL_ERROR; + } + } + + + /* * ** *** ***** ******** ************* + ** Object command, method dispatch. + */ + static int parser_objcmd (ClientData cd, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + RDE_PARAM p = (RDE_PARAM) cd; + int m, res; + + static CONST char* methods [] = { + "destroy", "parse", "parset", NULL + }; + enum methods { + M_DESTROY, M_PARSE, M_PARSET + }; + + if (objc < 2) { + Tcl_WrongNumArgs (interp, objc, objv, "option ?arg arg ...?"); + return TCL_ERROR; + } else if (Tcl_GetIndexFromObj (interp, objv [1], methods, "option", + 0, &m) != TCL_OK) { + return TCL_ERROR; + } + + /* Dispatch to methods. They check the #args in + * detail before performing the requested + * functionality + */ + + switch (m) { + case M_DESTROY: + if (objc != 2) { + Tcl_WrongNumArgs (interp, 2, objv, NULL); + return TCL_ERROR; + } + + Tcl_DeleteCommandFromToken(interp, (Tcl_Command) rde_param_query_clientdata (p)); + return TCL_OK; + + case M_PARSE: res = parser_PARSE (p, interp, objc, objv); break; + case M_PARSET: res = parser_PARSET (p, interp, objc, objv); break; + default: + /* Not coming to this place */ + ASSERT (0,"Reached unreachable location"); + } + + return res; + } + + /** * ** *** ***** ******** ************* + * Class command, i.e. object construction. + */ + static int ParserClassCmd (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const*objv) { + /* + * Syntax: No arguments beyond the name + */ + + RDE_PARAM parser; + CONST char* name; + Tcl_Obj* fqn; + Tcl_CmdInfo ci; + Tcl_Command c; + +#define USAGE "?name?" + + if ((objc != 2) && (objc != 1)) { + Tcl_WrongNumArgs (interp, 1, objv, USAGE); + return TCL_ERROR; + } + + if (objc < 2) { + name = PARSERnewName (interp); + } else { + name = Tcl_GetString (objv [1]); + } + + if (!Tcl_StringMatch (name, "::*")) { + /* Relative name. Prefix with current namespace */ + + Tcl_Eval (interp, "namespace current"); + fqn = Tcl_GetObjResult (interp); + fqn = Tcl_DuplicateObj (fqn); + Tcl_IncrRefCount (fqn); + + if (!Tcl_StringMatch (Tcl_GetString (fqn), "::")) { + Tcl_AppendToObj (fqn, "::", -1); + } + Tcl_AppendToObj (fqn, name, -1); + } else { + fqn = Tcl_NewStringObj (name, -1); + Tcl_IncrRefCount (fqn); + } + Tcl_ResetResult (interp); + + if (Tcl_GetCommandInfo (interp, + Tcl_GetString (fqn), + &ci)) { + Tcl_Obj* err; + + err = Tcl_NewObj (); + Tcl_AppendToObj (err, "command \"", -1); + Tcl_AppendObjToObj (err, fqn); + Tcl_AppendToObj (err, "\" already exists", -1); + + Tcl_DecrRefCount (fqn); + Tcl_SetObjResult (interp, err); + return TCL_ERROR; + } + + parser = rde_param_new (sizeof(p_string)/sizeof(char*), (char**) p_string); + c = Tcl_CreateObjCommand (interp, Tcl_GetString (fqn), + parser_objcmd, (ClientData) parser, + PARSERdeleteCmd); + rde_param_clientdata (parser, (ClientData) c); + Tcl_SetObjResult (interp, fqn); + Tcl_DecrRefCount (fqn); + return TCL_OK; + } + +int Package_Init(Tcl_Interp* interp) { + if (interp == 0) return TCL_ERROR; + + if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { + return TCL_ERROR; + } + + if (Tcl_CreateObjCommand(interp, "PARSER", ParserClassCmd , NULL, NULL) == NULL) { + Tcl_SetResult(interp, "Can't create constructor", NULL); + return TCL_ERROR; + } + + + Tcl_PkgProvide(interp, "PACKAGE", "0.1"); + + return TCL_OK; +} ADDED modules/pt/tests/data/ok/peg_cparam-tea/4_choice Index: modules/pt/tests/data/ok/peg_cparam-tea/4_choice ================================================================== --- /dev/null +++ modules/pt/tests/data/ok/peg_cparam-tea/4_choice @@ -0,0 +1,1986 @@ +/************************************************************ +** +** TEA-based C/PARAM implementation of the parsing +** expression grammar +** +** TEMPLATE +** +** Generated from file TEST +** for user unknown +** +* * ** *** ***** ******** ************* *********************/ + #include + #include + #include + #include + #define SCOPE static + +#line 1 "rde_critcl/util.h" + + #ifndef _RDE_UTIL_H + #define _RDE_UTIL_H 1 + #ifndef SCOPE + #define SCOPE + #endif + #define ALLOC(type) (type *) ckalloc (sizeof (type)) + #define NALLOC(n,type) (type *) ckalloc ((n) * sizeof (type)) + #undef RDE_DEBUG + #define RDE_DEBUG 1 + #undef RDE_TRACE + #ifdef RDE_DEBUG + #define STOPAFTER(x) { static int count = (x); count --; if (!count) { Tcl_Panic ("stop"); } } + #define XSTR(x) #x + #define STR(x) XSTR(x) + #define RANGEOK(i,n) ((0 <= (i)) && (i < (n))) + #define ASSERT(x,msg) if (!(x)) { Tcl_Panic (msg " (" #x "), in file " __FILE__ " @line " STR(__LINE__));} + #define ASSERT_BOUNDS(i,n) ASSERT (RANGEOK(i,n),"array index out of bounds: " STR(i) " >= " STR(n)) + #else + #define STOPAFTER(x) + #define ASSERT(x,msg) + #define ASSERT_BOUNDS(i,n) + #endif + #ifdef RDE_TRACE + SCOPE void trace_enter (const char* fun); + SCOPE void trace_return (const char *pat, ...); + SCOPE void trace_printf (const char *pat, ...); + #define ENTER(fun) trace_enter (fun) + #define RETURN(format,x) trace_return (format,x) ; return x + #define RETURNVOID trace_return ("%s","(void)") ; return + #define TRACE0(x) trace_printf0 x + #define TRACE(x) trace_printf x + #else + #define ENTER(fun) + #define RETURN(f,x) return x + #define RETURNVOID return + #define TRACE0(x) + #define TRACE(x) + #endif + #endif + + +#line 1 "rde_critcl/stack.h" + + #ifndef _RDE_DS_STACK_H + #define _RDE_DS_STACK_H 1 + typedef void (*RDE_STACK_CELL_FREE) (void* cell); + typedef struct RDE_STACK_* RDE_STACK; + static const int RDE_STACK_INITIAL_SIZE = 256; + #endif + + +#line 1 "rde_critcl/tc.h" + + #ifndef _RDE_DS_TC_H + #define _RDE_DS_TC_H 1 + typedef struct RDE_TC_* RDE_TC; + #endif + + +#line 1 "rde_critcl/param.h" + + #ifndef _RDE_DS_PARAM_H + #define _RDE_DS_PARAM_H 1 + typedef struct RDE_PARAM_* RDE_PARAM; + typedef struct ERROR_STATE { + int refCount; + long int loc; + RDE_STACK msg; + } ERROR_STATE; + typedef struct NC_STATE { + long int CL; + long int ST; + Tcl_Obj* SV; + ERROR_STATE* ER; + } NC_STATE; + #endif + + +#line 1 "rde_critcl/util.c" + + #ifdef RDE_TRACE + typedef struct F_STACK { + const char* str; + struct F_STACK* down; + } F_STACK; + static F_STACK* top = 0; + static int level = 0; + static void + push (const char* str) + { + F_STACK* new = ALLOC (F_STACK); + new->str = str; + new->down = top; + top = new; + level += 4; + } + static void + pop (void) + { + F_STACK* next = top->down; + level -= 4; + ckfree ((char*)top); + top = next; + } + static void + indent (void) + { + int i; + for (i = 0; i < level; i++) { + fwrite(" ", 1, 1, stdout); + fflush (stdout); + } + if (top) { + fwrite(top->str, 1, strlen(top->str), stdout); + fflush (stdout); + } + fwrite(" ", 1, 1, stdout); + fflush (stdout); + } + SCOPE void + trace_enter (const char* fun) + { + push (fun); + indent(); + fwrite("ENTER\n", 1, 6, stdout); + fflush (stdout); + } + static char msg [1024*1024]; + SCOPE void + trace_return (const char *pat, ...) + { + int len; + va_list args; + indent(); + fwrite("RETURN = ", 1, 9, stdout); + fflush (stdout); + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + pop(); + } + SCOPE void + trace_printf (const char *pat, ...) + { + int len; + va_list args; + indent(); + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + } + SCOPE void + trace_printf0 (const char *pat, ...) + { + int len; + va_list args; + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + } + #endif + + +#line 1 "rde_critcl/stack.c" + + typedef struct RDE_STACK_ { + long int max; + long int top; + RDE_STACK_CELL_FREE freeCellProc; + void** cell; + } RDE_STACK_; + + SCOPE RDE_STACK + rde_stack_new (RDE_STACK_CELL_FREE freeCellProc) + { + RDE_STACK s = ALLOC (RDE_STACK_); + s->cell = NALLOC (RDE_STACK_INITIAL_SIZE, void*); + s->max = RDE_STACK_INITIAL_SIZE; + s->top = 0; + s->freeCellProc = freeCellProc; + return s; + } + SCOPE void + rde_stack_del (RDE_STACK s) + { + if (s->freeCellProc && s->top) { + long int i; + for (i=0; i < s->top; i++) { + ASSERT_BOUNDS(i,s->max); + s->freeCellProc ( s->cell [i] ); + } + } + ckfree ((char*) s->cell); + ckfree ((char*) s); + } + SCOPE void + rde_stack_push (RDE_STACK s, void* item) + { + if (s->top >= s->max) { + long int new = s->max ? (2 * s->max) : RDE_STACK_INITIAL_SIZE; + void** cell = (void**) ckrealloc ((char*) s->cell, new * sizeof(void*)); + ASSERT (cell,"Memory allocation failure for RDE stack"); + s->max = new; + s->cell = cell; + } + ASSERT_BOUNDS(s->top,s->max); + s->cell [s->top] = item; + s->top ++; + } + SCOPE void* + rde_stack_top (RDE_STACK s) + { + ASSERT_BOUNDS(s->top-1,s->max); + return s->cell [s->top - 1]; + } + SCOPE void + rde_stack_pop (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad pop count"); + if (n == 0) return; + if (s->freeCellProc) { + while (n) { + s->top --; + ASSERT_BOUNDS(s->top,s->max); + s->freeCellProc ( s->cell [s->top] ); + n --; + } + } else { + s->top -= n; + } + } + SCOPE void + rde_stack_trim (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad trimsize"); + if (s->freeCellProc) { + while (s->top > n) { + s->top --; + ASSERT_BOUNDS(s->top,s->max); + s->freeCellProc ( s->cell [s->top] ); + } + } else { + s->top = n; + } + } + SCOPE void + rde_stack_drop (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad pop count"); + if (n == 0) return; + s->top -= n; + } + SCOPE void + rde_stack_move (RDE_STACK dst, RDE_STACK src) + { + ASSERT (dst->freeCellProc == src->freeCellProc, "Ownership mismatch"); + + while (src->top > 0) { + src->top --; + ASSERT_BOUNDS(src->top,src->max); + rde_stack_push (dst, src->cell [src->top] ); + } + } + SCOPE void + rde_stack_get (RDE_STACK s, long int* cn, void*** cc) + { + *cn = s->top; + *cc = s->cell; + } + SCOPE long int + rde_stack_size (RDE_STACK s) + { + return s->top; + } + + +#line 1 "rde_critcl/tc.c" + + typedef struct RDE_TC_ { + int max; + int num; + char* str; + RDE_STACK off; + } RDE_TC_; + + SCOPE RDE_TC + rde_tc_new (void) + { + RDE_TC tc = ALLOC (RDE_TC_); + tc->max = RDE_STACK_INITIAL_SIZE; + tc->num = 0; + tc->str = NALLOC (RDE_STACK_INITIAL_SIZE, char); + tc->off = rde_stack_new (NULL); + return tc; + } + SCOPE void + rde_tc_del (RDE_TC tc) + { + rde_stack_del (tc->off); + ckfree (tc->str); + ckfree ((char*) tc); + } + SCOPE long int + rde_tc_size (RDE_TC tc) + { + return rde_stack_size (tc->off); + } + SCOPE void + rde_tc_clear (RDE_TC tc) + { + tc->num = 0; + rde_stack_trim (tc->off, 0); + } + SCOPE char* + rde_tc_append (RDE_TC tc, char* string, long int len) + { + long int base = tc->num; + long int off = tc->num; + char* ch; + int clen; + Tcl_UniChar uni; + if (len < 0) { + len = strlen (string); + } + + if (!len) { + return tc->str + base; + } + + if ((tc->num + len) >= tc->max) { + int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); + char* str = ckrealloc (tc->str, new * sizeof(char)); + ASSERT (str,"Memory allocation failure for token character array"); + tc->max = new; + tc->str = str; + } + tc->num += len; + ASSERT_BOUNDS(tc->num,tc->max); + ASSERT_BOUNDS(off,tc->max); + ASSERT_BOUNDS(off+len-1,tc->max); + ASSERT_BOUNDS(off+len-1,tc->num); + memcpy (tc->str + off, string, len); + + ch = string; + while (ch < (string + len)) { + ASSERT_BOUNDS(off,tc->num); + rde_stack_push (tc->off, (void*) off); + clen = Tcl_UtfToUniChar (ch, &uni); + off += clen; + ch += clen; + } + return tc->str + base; + } + SCOPE void + rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) + { + long int oc, off, top, end; + void** ov; + rde_stack_get (tc->off, &oc, &ov); + ASSERT_BOUNDS(at,oc); + off = (long int) ov [at]; + if ((at+1) == oc) { + end = tc->num; + } else { + end = (long int) ov [at+1]; + } + TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); + ASSERT_BOUNDS(off,tc->num); + ASSERT_BOUNDS(end-1,tc->num); + *ch = tc->str + off; + *len = end - off; + } + SCOPE void + rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) + { + long int oc, off, top, end; + void** ov; + rde_stack_get (tc->off, &oc, &ov); + ASSERT_BOUNDS(at,oc); + ASSERT_BOUNDS(last,oc); + off = (long int) ov [at]; + if ((last+1) == oc) { + end = tc->num; + } else { + end = (long int) ov [last+1]; + } + TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); + ASSERT_BOUNDS(off,tc->num); + ASSERT_BOUNDS(end-1,tc->num); + *ch = tc->str + off; + *len = end - off; + } + + +#line 1 "rde_critcl/param.c" + + typedef struct RDE_PARAM_ { + Tcl_Channel IN; + Tcl_Obj* readbuf; + char* CC; + long int CC_len; + RDE_TC TC; + long int CL; + RDE_STACK LS; + ERROR_STATE* ER; + RDE_STACK ES; + long int ST; + Tcl_Obj* SV; + Tcl_HashTable NC; + + RDE_STACK ast ; + RDE_STACK mark ; + + long int numstr; + char** string; + + ClientData clientData; + } RDE_PARAM_; + typedef int (*UniCharClass) (int); + typedef enum test_class_id { + tc_alnum, + tc_alpha, + tc_ascii, + tc_control, + tc_ddigit, + tc_digit, + tc_graph, + tc_lower, + tc_printable, + tc_punct, + tc_space, + tc_upper, + tc_wordchar, + tc_xdigit + } test_class_id; + static void ast_node_free (void* n); + static void error_state_free (void* es); + static void error_set (RDE_PARAM p, long int s); + static void nc_clear (RDE_PARAM p); + static int UniCharIsAscii (int character); + static int UniCharIsHexDigit (int character); + static int UniCharIsDecDigit (int character); + static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); + static int er_int_compare (const void* a, const void* b); + #define SV_INIT(p) \ + p->SV = NULL; \ + TRACE (("SV_INIT (%p => %p)", (p), (p)->SV)) + #define SV_SET(p,newsv) \ + if (((p)->SV) != (newsv)) { \ + TRACE (("SV_CLEAR/set (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_DecrRefCount ((p)->SV); \ + } \ + (p)->SV = (newsv); \ + TRACE (("SV_SET (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_IncrRefCount ((p)->SV); \ + } \ + } + #define SV_CLEAR(p) \ + TRACE (("SV_CLEAR (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_DecrRefCount ((p)->SV); \ + } \ + (p)->SV = NULL + #define ER_INIT(p) \ + p->ER = NULL; \ + TRACE (("ER_INIT (%p => %p)", (p), (p)->ER)) + #define ER_CLEAR(p) \ + error_state_free ((p)->ER); \ + (p)->ER = NULL + SCOPE RDE_PARAM + rde_param_new (long int nstr, char** strings) + { + RDE_PARAM p; + ENTER ("rde_param_new"); + TRACE (("\tINT %d strings @ %p", nstr, strings)); + p = ALLOC (RDE_PARAM_); + p->numstr = nstr; + p->string = strings; + p->readbuf = Tcl_NewObj (); + Tcl_IncrRefCount (p->readbuf); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + Tcl_InitHashTable (&p->NC, TCL_ONE_WORD_KEYS); + p->IN = NULL; + p->CL = -1; + p->ST = 0; + ER_INIT (p); + SV_INIT (p); + p->CC = NULL; + p->CC_len = 0; + p->TC = rde_tc_new (); + p->ES = rde_stack_new (error_state_free); + p->LS = rde_stack_new (NULL); + p->ast = rde_stack_new (ast_node_free); + p->mark = rde_stack_new (NULL); + RETURN ("%p", p); + } + SCOPE void + rde_param_del (RDE_PARAM p) + { + ENTER ("rde_param_del"); + TRACE (("RDE_PARAM %p",p)); + ER_CLEAR (p); TRACE (("\ter_clear")); + SV_CLEAR (p); TRACE (("\tsv_clear")); + nc_clear (p); TRACE (("\tnc_clear")); + Tcl_DeleteHashTable (&p->NC); TRACE (("\tnc hashtable delete")); + rde_tc_del (p->TC); TRACE (("\ttc clear")); + rde_stack_del (p->ES); TRACE (("\tes clear")); + rde_stack_del (p->LS); TRACE (("\tls clear")); + rde_stack_del (p->ast); TRACE (("\tast clear")); + rde_stack_del (p->mark); TRACE (("\tmark clear")); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + Tcl_DecrRefCount (p->readbuf); + ckfree ((char*) p); + RETURNVOID; + } + SCOPE void + rde_param_reset (RDE_PARAM p, Tcl_Channel chan) + { + ENTER ("rde_param_reset"); + TRACE (("RDE_PARAM %p",p)); + TRACE (("Tcl_Channel %p",chan)); + p->IN = chan; + p->CL = -1; + p->ST = 0; + p->CC = NULL; + p->CC_len = 0; + ER_CLEAR (p); + SV_CLEAR (p); + nc_clear (p); + rde_tc_clear (p->TC); + rde_stack_trim (p->ES, 0); + rde_stack_trim (p->LS, 0); + rde_stack_trim (p->ast, 0); + rde_stack_trim (p->mark, 0); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + RETURNVOID; + } + SCOPE void + rde_param_update_strings (RDE_PARAM p, long int nstr, char** strings) + { + ENTER ("rde_param_update_strings"); + TRACE (("RDE_PARAM %p", p)); + TRACE (("INT %d strings", nstr)); + p->numstr = nstr; + p->string = strings; + RETURNVOID; + } + SCOPE void + rde_param_data (RDE_PARAM p, char* buf, long int len) + { + (void) rde_tc_append (p->TC, buf, len); + } + SCOPE void + rde_param_clientdata (RDE_PARAM p, ClientData clientData) + { + p->clientData = clientData; + } + static void + nc_clear (RDE_PARAM p) + { + Tcl_HashSearch hs; + Tcl_HashEntry* he; + Tcl_HashTable* tablePtr; + for(he = Tcl_FirstHashEntry(&p->NC, &hs); + he != NULL; + he = Tcl_FirstHashEntry(&p->NC, &hs)) { + Tcl_HashSearch hsc; + Tcl_HashEntry* hec; + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (he); + for(hec = Tcl_FirstHashEntry(tablePtr, &hsc); + hec != NULL; + hec = Tcl_NextHashEntry(&hsc)) { + NC_STATE* scs = Tcl_GetHashValue (hec); + error_state_free (scs->ER); + if (scs->SV) { Tcl_DecrRefCount (scs->SV); } + ckfree ((char*) scs); + } + Tcl_DeleteHashTable (tablePtr); + ckfree ((char*) tablePtr); + Tcl_DeleteHashEntry (he); + } + } + SCOPE ClientData + rde_param_query_clientdata (RDE_PARAM p) + { + return p->clientData; + } + SCOPE void + rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) + { + rde_stack_get (p->mark, mc, mv); + } + SCOPE void + rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) + { + rde_stack_get (p->ast, ac, (void***) av); + } + SCOPE const char* + rde_param_query_in (RDE_PARAM p) + { + return p->IN + ? Tcl_GetChannelName (p->IN) + : ""; + } + SCOPE const char* + rde_param_query_cc (RDE_PARAM p, long int* len) + { + *len = p->CC_len; + return p->CC; + } + SCOPE int + rde_param_query_cl (RDE_PARAM p) + { + return p->CL; + } + SCOPE const ERROR_STATE* + rde_param_query_er (RDE_PARAM p) + { + return p->ER; + } + SCOPE Tcl_Obj* + rde_param_query_er_tcl (RDE_PARAM p, const ERROR_STATE* er) + { + Tcl_Obj* res; + if (!er) { + + res = Tcl_NewStringObj ("", 0); + } else { + Tcl_Obj* ov [2]; + Tcl_Obj** mov; + long int mc, i, j; + void** mv; + int lastid; + const char* msg; + rde_stack_get (er->msg, &mc, &mv); + + qsort (mv, mc, sizeof (void*), er_int_compare); + + mov = NALLOC (mc, Tcl_Obj*); + lastid = -1; + for (i=0, j=0; i < mc; i++) { + ASSERT_BOUNDS (i,mc); + if (((long int) mv [i]) == lastid) continue; + lastid = (long int) mv [i]; + ASSERT_BOUNDS((long int) mv[i],p->numstr); + msg = p->string [(long int) mv[i]]; + ASSERT_BOUNDS (j,mc); + mov [j] = Tcl_NewStringObj (msg, -1); + j++; + } + + ov [0] = Tcl_NewIntObj (er->loc); + ov [1] = Tcl_NewListObj (j, mov); + res = Tcl_NewListObj (2, ov); + ckfree ((char*) mov); + } + return res; + } + SCOPE void + rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) + { + rde_stack_get (p->ES, ec, (void***) ev); + } + SCOPE void + rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) + { + rde_stack_get (p->LS, lc, lv); + } + SCOPE long int + rde_param_query_lstop (RDE_PARAM p) + { + (long int) rde_stack_top (p->LS); + } + SCOPE Tcl_HashTable* + rde_param_query_nc (RDE_PARAM p) + { + return &p->NC; + } + SCOPE int + rde_param_query_st (RDE_PARAM p) + { + return p->ST; + } + SCOPE Tcl_Obj* + rde_param_query_sv (RDE_PARAM p) + { + TRACE (("SV_QUERY %p => (%p)", (p), (p)->SV)); \ + return p->SV; + } + SCOPE long int + rde_param_query_tc_size (RDE_PARAM p) + { + return rde_tc_size (p->TC); + } + SCOPE void + rde_param_query_tc_get_s (RDE_PARAM p, long int at, long int last, char** ch, long int* len) + { + rde_tc_get_s (p->TC, at, last, ch, len); + } + SCOPE const char* + rde_param_query_string (RDE_PARAM p, long int id) + { + TRACE (("rde_param_query_string (RDE_PARAM %p, %d/%d)", p, id, p->numstr)); + ASSERT_BOUNDS(id,p->numstr); + return p->string [id]; + } + SCOPE void + rde_param_i_ast_pop_discard (RDE_PARAM p) + { + rde_stack_pop (p->mark, 1); + } + SCOPE void + rde_param_i_ast_pop_rewind (RDE_PARAM p) + { + long int trim = (long int) rde_stack_top (p->mark); + ENTER ("rde_param_i_ast_pop_rewind"); + TRACE (("RDE_PARAM %p",p)); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_ast_rewind (RDE_PARAM p) + { + long int trim = (long int) rde_stack_top (p->mark); + ENTER ("rde_param_i_ast_rewind"); + TRACE (("RDE_PARAM %p",p)); + rde_stack_trim (p->ast, trim); + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_ast_push (RDE_PARAM p) + { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + } + SCOPE void + rde_param_i_ast_value_push (RDE_PARAM p) + { + ENTER ("rde_param_i_ast_value_push"); + TRACE (("RDE_PARAM %p",p)); + ASSERT(p->SV,"Unable to push undefined semantic value"); + TRACE (("rde_param_i_ast_value_push %p => (%p)", p, p->SV)); + TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV->refCount, Tcl_GetString (p->SV))); + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + RETURNVOID; + } + static void + ast_node_free (void* n) + { + Tcl_DecrRefCount ((Tcl_Obj*) n); + } + SCOPE void + rde_param_i_error_clear (RDE_PARAM p) + { + ER_CLEAR (p); + } + SCOPE void + rde_param_i_error_nonterminal (RDE_PARAM p, long int s) + { + + return; + long int pos; + if (!p->ER) return; + pos = 1 + (long int) rde_stack_top (p->LS); + if (p->ER->loc != pos) return; + error_set (p, s); + p->ER->loc = pos; + } + SCOPE void + rde_param_i_error_pop_merge (RDE_PARAM p) + { + ERROR_STATE* top = (ERROR_STATE*) rde_stack_top (p->ES); + + if (top == p->ER) { + rde_stack_pop (p->ES, 1); + return; + } + + if (!top) { + rde_stack_pop (p->ES, 1); + return; + } + + if (!p->ER) { + rde_stack_drop (p->ES, 1); + p->ER = top; + + return; + } + + if (top->loc < p->ER->loc) { + rde_stack_pop (p->ES, 1); + return; + } + + if (top->loc > p->ER->loc) { + rde_stack_drop (p->ES, 1); + error_state_free (p->ER); + p->ER = top; + + return; + } + + rde_stack_move (p->ER->msg, top->msg); + rde_stack_pop (p->ES, 1); + } + SCOPE void + rde_param_i_error_push (RDE_PARAM p) + { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + static void + error_set (RDE_PARAM p, long int s) + { + error_state_free (p->ER); + p->ER = ALLOC (ERROR_STATE); + p->ER->refCount = 1; + p->ER->loc = p->CL; + p->ER->msg = rde_stack_new (NULL); + ASSERT_BOUNDS(s,p->numstr); + rde_stack_push (p->ER->msg, (void*) s); + } + static void + error_state_free (void* esx) + { + ERROR_STATE* es = esx; + if (!es) return; + es->refCount --; + if (es->refCount > 0) return; + rde_stack_del (es->msg); + ckfree ((char*) es); + } + SCOPE void + rde_param_i_loc_pop_discard (RDE_PARAM p) + { + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_loc_pop_rewind (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_loc_push (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + } + SCOPE void + rde_param_i_loc_rewind (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + } + SCOPE void + rde_param_i_input_next (RDE_PARAM p, long int m) + { + int leni; + char* ch; + ASSERT_BOUNDS(m,p->numstr); + p->CL ++; + if (p->CL < rde_tc_size (p->TC)) { + + rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); + + ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); + p->ST = 1; + ER_CLEAR (p); + return; + } + if (!p->IN || + Tcl_Eof (p->IN) || + (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { + + p->ST = 0; + error_set (p, m); + return; + } + + ch = Tcl_GetStringFromObj (p->readbuf, &leni); + ASSERT_BOUNDS (leni, TCL_UTF_MAX); + p->CC = rde_tc_append (p->TC, ch, leni); + p->CC_len = leni; + p->ST = 1; + ER_CLEAR (p); + } + SCOPE void + rde_param_i_status_fail (RDE_PARAM p) + { + p->ST = 0; + } + SCOPE void + rde_param_i_status_ok (RDE_PARAM p) + { + p->ST = 1; + } + SCOPE void + rde_param_i_status_negate (RDE_PARAM p) + { + p->ST = !p->ST; + } + SCOPE int + rde_param_i_symbol_restore (RDE_PARAM p, long int s) + { + NC_STATE* scs; + Tcl_HashEntry* hPtr; + Tcl_HashTable* tablePtr; + + hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); + if (!hPtr) { return 0; } + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); + hPtr = Tcl_FindHashEntry (tablePtr, (char*) s); + if (!hPtr) { return 0; } + + scs = Tcl_GetHashValue (hPtr); + p->CL = scs->CL; + p->ST = scs->ST; + error_state_free (p->ER); + p->ER = scs->ER; + if (p->ER) { p->ER->refCount ++; } + TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); + SV_SET (p, scs->SV); + return 1; + } + SCOPE void + rde_param_i_symbol_save (RDE_PARAM p, long int s) + { + long int at = (long int) rde_stack_top (p->LS); + NC_STATE* scs; + Tcl_HashEntry* hPtr; + Tcl_HashTable* tablePtr; + int isnew; + ENTER ("rde_param_i_symbol_save"); + TRACE (("RDE_PARAM %p",p)); + TRACE (("INT %d",s)); + + hPtr = Tcl_CreateHashEntry (&p->NC, (char*) at, &isnew); + if (isnew) { + tablePtr = ALLOC (Tcl_HashTable); + Tcl_InitHashTable (tablePtr, TCL_ONE_WORD_KEYS); + Tcl_SetHashValue (hPtr, tablePtr); + } else { + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); + } + hPtr = Tcl_CreateHashEntry (tablePtr, (char*) s, &isnew); + if (isnew) { + + scs = ALLOC (NC_STATE); + scs->CL = p->CL; + scs->ST = p->ST; + TRACE (("SV_CACHE (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "")); + scs->SV = p->SV; + if (scs->SV) { Tcl_IncrRefCount (scs->SV); } + scs->ER = p->ER; + if (scs->ER) { scs->ER->refCount ++; } + Tcl_SetHashValue (hPtr, scs); + } else { + + scs = (NC_STATE*) Tcl_GetHashValue (hPtr); + scs->CL = p->CL; + scs->ST = p->ST; + TRACE (("SV_CACHE/over (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "" )); + if (scs->SV) { Tcl_DecrRefCount (scs->SV); } + scs->SV = p->SV; + if (scs->SV) { Tcl_IncrRefCount (scs->SV); } + error_state_free (scs->ER); + scs->ER = p->ER; + if (scs->ER) { scs->ER->refCount ++; } + } + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_test_alnum (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsAlnum, tc_alnum); + } + SCOPE void + rde_param_i_test_alpha (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsAlpha, tc_alpha); + } + SCOPE void + rde_param_i_test_ascii (RDE_PARAM p) + { + test_class (p, UniCharIsAscii, tc_ascii); + } + SCOPE void + rde_param_i_test_control (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsControl, tc_control); + } + SCOPE void + rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) + { + ASSERT_BOUNDS(msg,p->numstr); + p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, msg); + p->CL --; + } + } + SCOPE void + rde_param_i_test_ddigit (RDE_PARAM p) + { + test_class (p, UniCharIsDecDigit, tc_ddigit); + } + SCOPE void + rde_param_i_test_digit (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsDigit, tc_digit); + } + SCOPE void + rde_param_i_test_graph (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsGraph, tc_graph); + } + SCOPE void + rde_param_i_test_lower (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsLower, tc_lower); + } + SCOPE void + rde_param_i_test_print (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsPrint, tc_printable); + } + SCOPE void + rde_param_i_test_punct (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsPunct, tc_punct); + } + SCOPE void + rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) + { + ASSERT_BOUNDS(msg,p->numstr); + p->ST = + (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && + (Tcl_UtfNcmp (p->CC, e, 1) <= 0); + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, msg); + p->CL --; + } + } + SCOPE void + rde_param_i_test_space (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsSpace, tc_space); + } + SCOPE void + rde_param_i_test_upper (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsUpper, tc_upper); + } + SCOPE void + rde_param_i_test_wordchar (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsWordChar, tc_wordchar); + } + SCOPE void + rde_param_i_test_xdigit (RDE_PARAM p) + { + test_class (p, UniCharIsHexDigit, tc_xdigit); + } + static void + test_class (RDE_PARAM p, UniCharClass class, test_class_id id) + { + Tcl_UniChar ch; + Tcl_UtfToUniChar(p->CC, &ch); + ASSERT_BOUNDS(id,p->numstr); + p->ST = !!class (ch); + + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, id); + p->CL --; + } + } + static int + UniCharIsAscii (int character) + { + return (character >= 0) && (character < 0x80); + } + static int + UniCharIsHexDigit (int character) + { + return (character >= 0) && (character < 0x80) && isxdigit(character); + } + static int + UniCharIsDecDigit (int character) + { + return (character >= 0) && (character < 0x80) && isdigit(character); + } + SCOPE void + rde_param_i_value_clear (RDE_PARAM p) + { + SV_CLEAR (p); + } + SCOPE void + rde_param_i_value_leaf (RDE_PARAM p, long int s) + { + Tcl_Obj* newsv; + Tcl_Obj* ov [3]; + long int pos = 1 + (long int) rde_stack_top (p->LS); + ASSERT_BOUNDS(s,p->numstr); + ov [0] = Tcl_NewStringObj (p->string[s], -1); + ov [1] = Tcl_NewIntObj (pos); + ov [2] = Tcl_NewIntObj (p->CL); + newsv = Tcl_NewListObj (3, ov); + TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); + SV_SET (p, newsv); + } + SCOPE void + rde_param_i_value_reduce (RDE_PARAM p, long int s) + { + Tcl_Obj* newsv; + int oc, i, j; + Tcl_Obj** ov; + long int ac; + Tcl_Obj** av; + long int pos = 1 + (long int) rde_stack_top (p->LS); + long int mark = (long int) rde_stack_top (p->mark); + long int asize = rde_stack_size (p->ast); + long int new = asize - mark; + ASSERT (new >= 0, "Bad number of elements to reduce"); + ov = NALLOC (3+new, Tcl_Obj*); + ASSERT_BOUNDS(s,p->numstr); + ov [0] = Tcl_NewStringObj (p->string[s], -1); + ov [1] = Tcl_NewIntObj (pos); + ov [2] = Tcl_NewIntObj (p->CL); + rde_stack_get (p->ast, &ac, (void***) &av); + for (i = 3, j = mark; j < asize; i++, j++) { + ASSERT_BOUNDS (i, 3+new); + ASSERT_BOUNDS (j, ac); + ov [i] = av [j]; + } + ASSERT (i == 3+new, "Reduction result incomplete"); + newsv = Tcl_NewListObj (3+new, ov); + TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); + SV_SET (p, newsv); + ckfree ((char*) ov); + } + static int + er_int_compare (const void* a, const void* b) + { + + const void** ael = (const void**) a; + const void** bel = (const void**) b; + long int avalue = (long int) *ael; + long int bvalue = (long int) *bel; + if (avalue < bvalue) { return -1; } + if (avalue > bvalue) { return 1; } + return 0; + } + SCOPE int + rde_param_i_symbol_start (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) { + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + return 1; + } + rde_stack_push (p->LS, (void*) p->CL); + return 0; + } + SCOPE int + rde_param_i_symbol_start_d (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) { + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + return 1; + } + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + return 0; + } + SCOPE int + rde_param_i_symbol_void_start (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) return 1; + rde_stack_push (p->LS, (void*) p->CL); + return 0; + } + SCOPE int + rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) return 1; + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + return 0; + } + SCOPE void + rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_reduce (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_leaf (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_leaf (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) + { + SV_CLEAR (p); + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) + { + SV_CLEAR (p); + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_char (p, c, m); + } + SCOPE void + rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_range (p, s, e, m); + } + SCOPE void + rde_param_i_next_alnum (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_alnum (p); + } + SCOPE void + rde_param_i_next_alpha (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_alpha (p); + } + SCOPE void + rde_param_i_next_ascii (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_ascii (p); + } + SCOPE void + rde_param_i_next_control (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_control (p); + } + SCOPE void + rde_param_i_next_ddigit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_ddigit (p); + } + SCOPE void + rde_param_i_next_digit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_digit (p); + } + SCOPE void + rde_param_i_next_graph (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_graph (p); + } + SCOPE void + rde_param_i_next_lower (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_lower (p); + } + SCOPE void + rde_param_i_next_print (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_print (p); + } + SCOPE void + rde_param_i_next_punct (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_punct (p); + } + SCOPE void + rde_param_i_next_space (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_space (p); + } + SCOPE void + rde_param_i_next_upper (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_upper (p); + } + SCOPE void + rde_param_i_next_wordchar (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_wordchar (p); + } + SCOPE void + rde_param_i_next_xdigit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_xdigit (p); + } + SCOPE void + rde_param_i_notahead_start_d (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + } + SCOPE void + rde_param_i_notahead_exit_d (RDE_PARAM p) + { + if (p->ST) { + rde_param_i_ast_pop_rewind (p); + } else { + rde_stack_pop (p->mark, 1); + } + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + p->ST = !p->ST; + } + SCOPE void + rde_param_i_notahead_exit (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + p->ST = !p->ST; + } + SCOPE void + rde_param_i_state_push_2 (RDE_PARAM p) + { + + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + SCOPE void + rde_param_i_state_push_void (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + ER_CLEAR (p); + rde_stack_push (p->ES, p->ER); + + } + SCOPE void + rde_param_i_state_push_value (RDE_PARAM p) + { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + rde_stack_push (p->LS, (void*) p->CL); + ER_CLEAR (p); + rde_stack_push (p->ES, p->ER); + + } + SCOPE void + rde_param_i_state_merge_ok (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + p->ST = 1; + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_state_merge_void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_state_merge_value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } + SCOPE int + rde_param_i_kleene_close (RDE_PARAM p) + { + int stop = !p->ST; + rde_param_i_error_pop_merge (p); + if (stop) { + p->ST = 1; + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + return stop; + } + SCOPE int + rde_param_i_kleene_abort (RDE_PARAM p) + { + int stop = !p->ST; + if (stop) { + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + return stop; + } + SCOPE int + rde_param_i_seq_void2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_seq_void2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_seq_value2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_bra_void2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->LS, 1); + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_void2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->LS, 1); + } else { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_value2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_value2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE void + rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) + { + int at = p->CL; + + while (*str) { + rde_param_i_input_next (p, m); + if (!p->ST) { + p->ER->loc = at+1; + p->CL = at; + return; + } + rde_param_i_test_char (p, str, m); + if (!p->ST) { + p->ER->loc = at+1; + p->CL = at; + return; + } + str = Tcl_UtfNext (str); + } + } + SCOPE void + rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + while (*class) { + p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; + if (p->ST) { + ER_CLEAR (p); + return; + } + class = Tcl_UtfNext (class); + } + error_set (p, m); + p->CL --; + } + + + /* + * Declaring the parse functions + */ + + + /* + * Precomputed table of strings (symbols, error messages, etc.). + */ + + static char const* p_string [15] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "cl abc" + }; + + /* + * Grammar Start Expression + */ + + static void MAIN (RDE_PARAM p) { + rde_param_i_next_class (p, "abc", 14); + return; + } + + /* -*- c -*- */ + + typedef struct PARSERg { + long int counter; + char buf [50]; + } PARSERg; + + static void + PARSERgRelease (ClientData cd, Tcl_Interp* interp) + { + ckfree((char*) cd); + } + + static const char* + PARSERnewName (Tcl_Interp* interp) + { +#define KEY "tcllib/parser/PACKAGE/TEA" + + Tcl_InterpDeleteProc* proc = PARSERgRelease; + PARSERg* parserg; + + parserg = Tcl_GetAssocData (interp, KEY, &proc); + if (parserg == NULL) { + parserg = (PARSERg*) ckalloc (sizeof (PARSERg)); + parserg->counter = 0; + + Tcl_SetAssocData (interp, KEY, proc, + (ClientData) parserg); + } + + parserg->counter ++; + sprintf (parserg->buf, "PARSER%ld", parserg->counter); + return parserg->buf; +#undef KEY + } + + static void + PARSERdeleteCmd (ClientData clientData) + { + /* + * Release the whole PARSER + * (Low-level engine only actually). + */ + rde_param_del ((RDE_PARAM) clientData); + } + + + /* * ** *** ***** ******** ************* + ** Functions implementing the object methods, and helper. + */ + + static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp); + + static int parser_PARSE (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + int mode; + Tcl_Channel chan; + + if (objc != 3) { + Tcl_WrongNumArgs (interp, 2, objv, "chan"); + return TCL_ERROR; + } + + chan = Tcl_GetChannel(interp, + Tcl_GetString (objv[2]), + &mode); + + if (!chan) { + return TCL_ERROR; + } + + rde_param_reset (p, chan); + MAIN (p) ; /* Entrypoint for the generated code. */ + return COMPLETE (p, interp); + } + + static int parser_PARSET (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + char* buf; + int len; + + if (objc != 3) { + Tcl_WrongNumArgs (interp, 2, objv, "text"); + return TCL_ERROR; + } + + buf = Tcl_GetStringFromObj (objv[2], &len); + + rde_param_reset (p, NULL); + rde_param_data (p, buf, len); + MAIN (p) ; /* Entrypoint for the generated code. */ + return COMPLETE (p, interp); + } + + /* See also rde_critcl/m.c, param_COMPLETE() */ + static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) + { + if (rde_param_query_st (p)) { + long int ac; + Tcl_Obj** av; + + rde_param_query_ast (p, &ac, &av); + + if (ac > 1) { + Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); + + memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); + lv [0] = Tcl_NewObj (); + lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); + lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); + + Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); + ckfree ((char*) lv); + + } else if (ac == 0) { + /* + * Match, but no AST. This is possible if the grammar + * consists of only the start expression. + */ + Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); + } else { + Tcl_SetObjResult (interp, av [0]); + } + + return TCL_OK; + } else { + Tcl_Obj* xv [1]; + const ERROR_STATE* er = rde_param_query_er (p); + Tcl_Obj* res = rde_param_query_er_tcl (p, er); + /* res = list (location, list(msg)) */ + + /* Stick the exception type-tag before the existing elements */ + xv [0] = Tcl_NewStringObj ("pt::rde",-1); + Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); + + Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); + Tcl_SetObjResult (interp, res); + return TCL_ERROR; + } + } + + + /* * ** *** ***** ******** ************* + ** Object command, method dispatch. + */ + static int parser_objcmd (ClientData cd, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + RDE_PARAM p = (RDE_PARAM) cd; + int m, res; + + static CONST char* methods [] = { + "destroy", "parse", "parset", NULL + }; + enum methods { + M_DESTROY, M_PARSE, M_PARSET + }; + + if (objc < 2) { + Tcl_WrongNumArgs (interp, objc, objv, "option ?arg arg ...?"); + return TCL_ERROR; + } else if (Tcl_GetIndexFromObj (interp, objv [1], methods, "option", + 0, &m) != TCL_OK) { + return TCL_ERROR; + } + + /* Dispatch to methods. They check the #args in + * detail before performing the requested + * functionality + */ + + switch (m) { + case M_DESTROY: + if (objc != 2) { + Tcl_WrongNumArgs (interp, 2, objv, NULL); + return TCL_ERROR; + } + + Tcl_DeleteCommandFromToken(interp, (Tcl_Command) rde_param_query_clientdata (p)); + return TCL_OK; + + case M_PARSE: res = parser_PARSE (p, interp, objc, objv); break; + case M_PARSET: res = parser_PARSET (p, interp, objc, objv); break; + default: + /* Not coming to this place */ + ASSERT (0,"Reached unreachable location"); + } + + return res; + } + + /** * ** *** ***** ******** ************* + * Class command, i.e. object construction. + */ + static int ParserClassCmd (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const*objv) { + /* + * Syntax: No arguments beyond the name + */ + + RDE_PARAM parser; + CONST char* name; + Tcl_Obj* fqn; + Tcl_CmdInfo ci; + Tcl_Command c; + +#define USAGE "?name?" + + if ((objc != 2) && (objc != 1)) { + Tcl_WrongNumArgs (interp, 1, objv, USAGE); + return TCL_ERROR; + } + + if (objc < 2) { + name = PARSERnewName (interp); + } else { + name = Tcl_GetString (objv [1]); + } + + if (!Tcl_StringMatch (name, "::*")) { + /* Relative name. Prefix with current namespace */ + + Tcl_Eval (interp, "namespace current"); + fqn = Tcl_GetObjResult (interp); + fqn = Tcl_DuplicateObj (fqn); + Tcl_IncrRefCount (fqn); + + if (!Tcl_StringMatch (Tcl_GetString (fqn), "::")) { + Tcl_AppendToObj (fqn, "::", -1); + } + Tcl_AppendToObj (fqn, name, -1); + } else { + fqn = Tcl_NewStringObj (name, -1); + Tcl_IncrRefCount (fqn); + } + Tcl_ResetResult (interp); + + if (Tcl_GetCommandInfo (interp, + Tcl_GetString (fqn), + &ci)) { + Tcl_Obj* err; + + err = Tcl_NewObj (); + Tcl_AppendToObj (err, "command \"", -1); + Tcl_AppendObjToObj (err, fqn); + Tcl_AppendToObj (err, "\" already exists", -1); + + Tcl_DecrRefCount (fqn); + Tcl_SetObjResult (interp, err); + return TCL_ERROR; + } + + parser = rde_param_new (sizeof(p_string)/sizeof(char*), (char**) p_string); + c = Tcl_CreateObjCommand (interp, Tcl_GetString (fqn), + parser_objcmd, (ClientData) parser, + PARSERdeleteCmd); + rde_param_clientdata (parser, (ClientData) c); + Tcl_SetObjResult (interp, fqn); + Tcl_DecrRefCount (fqn); + return TCL_OK; + } + +int Package_Init(Tcl_Interp* interp) { + if (interp == 0) return TCL_ERROR; + + if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { + return TCL_ERROR; + } + + if (Tcl_CreateObjCommand(interp, "PARSER", ParserClassCmd , NULL, NULL) == NULL) { + Tcl_SetResult(interp, "Can't create constructor", NULL); + return TCL_ERROR; + } + + + Tcl_PkgProvide(interp, "PACKAGE", "0.1"); + + return TCL_OK; +} ADDED modules/pt/tests/data/ok/peg_cparam-tea/5_sequence Index: modules/pt/tests/data/ok/peg_cparam-tea/5_sequence ================================================================== --- /dev/null +++ modules/pt/tests/data/ok/peg_cparam-tea/5_sequence @@ -0,0 +1,1986 @@ +/************************************************************ +** +** TEA-based C/PARAM implementation of the parsing +** expression grammar +** +** TEMPLATE +** +** Generated from file TEST +** for user unknown +** +* * ** *** ***** ******** ************* *********************/ + #include + #include + #include + #include + #define SCOPE static + +#line 1 "rde_critcl/util.h" + + #ifndef _RDE_UTIL_H + #define _RDE_UTIL_H 1 + #ifndef SCOPE + #define SCOPE + #endif + #define ALLOC(type) (type *) ckalloc (sizeof (type)) + #define NALLOC(n,type) (type *) ckalloc ((n) * sizeof (type)) + #undef RDE_DEBUG + #define RDE_DEBUG 1 + #undef RDE_TRACE + #ifdef RDE_DEBUG + #define STOPAFTER(x) { static int count = (x); count --; if (!count) { Tcl_Panic ("stop"); } } + #define XSTR(x) #x + #define STR(x) XSTR(x) + #define RANGEOK(i,n) ((0 <= (i)) && (i < (n))) + #define ASSERT(x,msg) if (!(x)) { Tcl_Panic (msg " (" #x "), in file " __FILE__ " @line " STR(__LINE__));} + #define ASSERT_BOUNDS(i,n) ASSERT (RANGEOK(i,n),"array index out of bounds: " STR(i) " >= " STR(n)) + #else + #define STOPAFTER(x) + #define ASSERT(x,msg) + #define ASSERT_BOUNDS(i,n) + #endif + #ifdef RDE_TRACE + SCOPE void trace_enter (const char* fun); + SCOPE void trace_return (const char *pat, ...); + SCOPE void trace_printf (const char *pat, ...); + #define ENTER(fun) trace_enter (fun) + #define RETURN(format,x) trace_return (format,x) ; return x + #define RETURNVOID trace_return ("%s","(void)") ; return + #define TRACE0(x) trace_printf0 x + #define TRACE(x) trace_printf x + #else + #define ENTER(fun) + #define RETURN(f,x) return x + #define RETURNVOID return + #define TRACE0(x) + #define TRACE(x) + #endif + #endif + + +#line 1 "rde_critcl/stack.h" + + #ifndef _RDE_DS_STACK_H + #define _RDE_DS_STACK_H 1 + typedef void (*RDE_STACK_CELL_FREE) (void* cell); + typedef struct RDE_STACK_* RDE_STACK; + static const int RDE_STACK_INITIAL_SIZE = 256; + #endif + + +#line 1 "rde_critcl/tc.h" + + #ifndef _RDE_DS_TC_H + #define _RDE_DS_TC_H 1 + typedef struct RDE_TC_* RDE_TC; + #endif + + +#line 1 "rde_critcl/param.h" + + #ifndef _RDE_DS_PARAM_H + #define _RDE_DS_PARAM_H 1 + typedef struct RDE_PARAM_* RDE_PARAM; + typedef struct ERROR_STATE { + int refCount; + long int loc; + RDE_STACK msg; + } ERROR_STATE; + typedef struct NC_STATE { + long int CL; + long int ST; + Tcl_Obj* SV; + ERROR_STATE* ER; + } NC_STATE; + #endif + + +#line 1 "rde_critcl/util.c" + + #ifdef RDE_TRACE + typedef struct F_STACK { + const char* str; + struct F_STACK* down; + } F_STACK; + static F_STACK* top = 0; + static int level = 0; + static void + push (const char* str) + { + F_STACK* new = ALLOC (F_STACK); + new->str = str; + new->down = top; + top = new; + level += 4; + } + static void + pop (void) + { + F_STACK* next = top->down; + level -= 4; + ckfree ((char*)top); + top = next; + } + static void + indent (void) + { + int i; + for (i = 0; i < level; i++) { + fwrite(" ", 1, 1, stdout); + fflush (stdout); + } + if (top) { + fwrite(top->str, 1, strlen(top->str), stdout); + fflush (stdout); + } + fwrite(" ", 1, 1, stdout); + fflush (stdout); + } + SCOPE void + trace_enter (const char* fun) + { + push (fun); + indent(); + fwrite("ENTER\n", 1, 6, stdout); + fflush (stdout); + } + static char msg [1024*1024]; + SCOPE void + trace_return (const char *pat, ...) + { + int len; + va_list args; + indent(); + fwrite("RETURN = ", 1, 9, stdout); + fflush (stdout); + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + pop(); + } + SCOPE void + trace_printf (const char *pat, ...) + { + int len; + va_list args; + indent(); + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + } + SCOPE void + trace_printf0 (const char *pat, ...) + { + int len; + va_list args; + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + } + #endif + + +#line 1 "rde_critcl/stack.c" + + typedef struct RDE_STACK_ { + long int max; + long int top; + RDE_STACK_CELL_FREE freeCellProc; + void** cell; + } RDE_STACK_; + + SCOPE RDE_STACK + rde_stack_new (RDE_STACK_CELL_FREE freeCellProc) + { + RDE_STACK s = ALLOC (RDE_STACK_); + s->cell = NALLOC (RDE_STACK_INITIAL_SIZE, void*); + s->max = RDE_STACK_INITIAL_SIZE; + s->top = 0; + s->freeCellProc = freeCellProc; + return s; + } + SCOPE void + rde_stack_del (RDE_STACK s) + { + if (s->freeCellProc && s->top) { + long int i; + for (i=0; i < s->top; i++) { + ASSERT_BOUNDS(i,s->max); + s->freeCellProc ( s->cell [i] ); + } + } + ckfree ((char*) s->cell); + ckfree ((char*) s); + } + SCOPE void + rde_stack_push (RDE_STACK s, void* item) + { + if (s->top >= s->max) { + long int new = s->max ? (2 * s->max) : RDE_STACK_INITIAL_SIZE; + void** cell = (void**) ckrealloc ((char*) s->cell, new * sizeof(void*)); + ASSERT (cell,"Memory allocation failure for RDE stack"); + s->max = new; + s->cell = cell; + } + ASSERT_BOUNDS(s->top,s->max); + s->cell [s->top] = item; + s->top ++; + } + SCOPE void* + rde_stack_top (RDE_STACK s) + { + ASSERT_BOUNDS(s->top-1,s->max); + return s->cell [s->top - 1]; + } + SCOPE void + rde_stack_pop (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad pop count"); + if (n == 0) return; + if (s->freeCellProc) { + while (n) { + s->top --; + ASSERT_BOUNDS(s->top,s->max); + s->freeCellProc ( s->cell [s->top] ); + n --; + } + } else { + s->top -= n; + } + } + SCOPE void + rde_stack_trim (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad trimsize"); + if (s->freeCellProc) { + while (s->top > n) { + s->top --; + ASSERT_BOUNDS(s->top,s->max); + s->freeCellProc ( s->cell [s->top] ); + } + } else { + s->top = n; + } + } + SCOPE void + rde_stack_drop (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad pop count"); + if (n == 0) return; + s->top -= n; + } + SCOPE void + rde_stack_move (RDE_STACK dst, RDE_STACK src) + { + ASSERT (dst->freeCellProc == src->freeCellProc, "Ownership mismatch"); + + while (src->top > 0) { + src->top --; + ASSERT_BOUNDS(src->top,src->max); + rde_stack_push (dst, src->cell [src->top] ); + } + } + SCOPE void + rde_stack_get (RDE_STACK s, long int* cn, void*** cc) + { + *cn = s->top; + *cc = s->cell; + } + SCOPE long int + rde_stack_size (RDE_STACK s) + { + return s->top; + } + + +#line 1 "rde_critcl/tc.c" + + typedef struct RDE_TC_ { + int max; + int num; + char* str; + RDE_STACK off; + } RDE_TC_; + + SCOPE RDE_TC + rde_tc_new (void) + { + RDE_TC tc = ALLOC (RDE_TC_); + tc->max = RDE_STACK_INITIAL_SIZE; + tc->num = 0; + tc->str = NALLOC (RDE_STACK_INITIAL_SIZE, char); + tc->off = rde_stack_new (NULL); + return tc; + } + SCOPE void + rde_tc_del (RDE_TC tc) + { + rde_stack_del (tc->off); + ckfree (tc->str); + ckfree ((char*) tc); + } + SCOPE long int + rde_tc_size (RDE_TC tc) + { + return rde_stack_size (tc->off); + } + SCOPE void + rde_tc_clear (RDE_TC tc) + { + tc->num = 0; + rde_stack_trim (tc->off, 0); + } + SCOPE char* + rde_tc_append (RDE_TC tc, char* string, long int len) + { + long int base = tc->num; + long int off = tc->num; + char* ch; + int clen; + Tcl_UniChar uni; + if (len < 0) { + len = strlen (string); + } + + if (!len) { + return tc->str + base; + } + + if ((tc->num + len) >= tc->max) { + int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); + char* str = ckrealloc (tc->str, new * sizeof(char)); + ASSERT (str,"Memory allocation failure for token character array"); + tc->max = new; + tc->str = str; + } + tc->num += len; + ASSERT_BOUNDS(tc->num,tc->max); + ASSERT_BOUNDS(off,tc->max); + ASSERT_BOUNDS(off+len-1,tc->max); + ASSERT_BOUNDS(off+len-1,tc->num); + memcpy (tc->str + off, string, len); + + ch = string; + while (ch < (string + len)) { + ASSERT_BOUNDS(off,tc->num); + rde_stack_push (tc->off, (void*) off); + clen = Tcl_UtfToUniChar (ch, &uni); + off += clen; + ch += clen; + } + return tc->str + base; + } + SCOPE void + rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) + { + long int oc, off, top, end; + void** ov; + rde_stack_get (tc->off, &oc, &ov); + ASSERT_BOUNDS(at,oc); + off = (long int) ov [at]; + if ((at+1) == oc) { + end = tc->num; + } else { + end = (long int) ov [at+1]; + } + TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); + ASSERT_BOUNDS(off,tc->num); + ASSERT_BOUNDS(end-1,tc->num); + *ch = tc->str + off; + *len = end - off; + } + SCOPE void + rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) + { + long int oc, off, top, end; + void** ov; + rde_stack_get (tc->off, &oc, &ov); + ASSERT_BOUNDS(at,oc); + ASSERT_BOUNDS(last,oc); + off = (long int) ov [at]; + if ((last+1) == oc) { + end = tc->num; + } else { + end = (long int) ov [last+1]; + } + TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); + ASSERT_BOUNDS(off,tc->num); + ASSERT_BOUNDS(end-1,tc->num); + *ch = tc->str + off; + *len = end - off; + } + + +#line 1 "rde_critcl/param.c" + + typedef struct RDE_PARAM_ { + Tcl_Channel IN; + Tcl_Obj* readbuf; + char* CC; + long int CC_len; + RDE_TC TC; + long int CL; + RDE_STACK LS; + ERROR_STATE* ER; + RDE_STACK ES; + long int ST; + Tcl_Obj* SV; + Tcl_HashTable NC; + + RDE_STACK ast ; + RDE_STACK mark ; + + long int numstr; + char** string; + + ClientData clientData; + } RDE_PARAM_; + typedef int (*UniCharClass) (int); + typedef enum test_class_id { + tc_alnum, + tc_alpha, + tc_ascii, + tc_control, + tc_ddigit, + tc_digit, + tc_graph, + tc_lower, + tc_printable, + tc_punct, + tc_space, + tc_upper, + tc_wordchar, + tc_xdigit + } test_class_id; + static void ast_node_free (void* n); + static void error_state_free (void* es); + static void error_set (RDE_PARAM p, long int s); + static void nc_clear (RDE_PARAM p); + static int UniCharIsAscii (int character); + static int UniCharIsHexDigit (int character); + static int UniCharIsDecDigit (int character); + static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); + static int er_int_compare (const void* a, const void* b); + #define SV_INIT(p) \ + p->SV = NULL; \ + TRACE (("SV_INIT (%p => %p)", (p), (p)->SV)) + #define SV_SET(p,newsv) \ + if (((p)->SV) != (newsv)) { \ + TRACE (("SV_CLEAR/set (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_DecrRefCount ((p)->SV); \ + } \ + (p)->SV = (newsv); \ + TRACE (("SV_SET (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_IncrRefCount ((p)->SV); \ + } \ + } + #define SV_CLEAR(p) \ + TRACE (("SV_CLEAR (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_DecrRefCount ((p)->SV); \ + } \ + (p)->SV = NULL + #define ER_INIT(p) \ + p->ER = NULL; \ + TRACE (("ER_INIT (%p => %p)", (p), (p)->ER)) + #define ER_CLEAR(p) \ + error_state_free ((p)->ER); \ + (p)->ER = NULL + SCOPE RDE_PARAM + rde_param_new (long int nstr, char** strings) + { + RDE_PARAM p; + ENTER ("rde_param_new"); + TRACE (("\tINT %d strings @ %p", nstr, strings)); + p = ALLOC (RDE_PARAM_); + p->numstr = nstr; + p->string = strings; + p->readbuf = Tcl_NewObj (); + Tcl_IncrRefCount (p->readbuf); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + Tcl_InitHashTable (&p->NC, TCL_ONE_WORD_KEYS); + p->IN = NULL; + p->CL = -1; + p->ST = 0; + ER_INIT (p); + SV_INIT (p); + p->CC = NULL; + p->CC_len = 0; + p->TC = rde_tc_new (); + p->ES = rde_stack_new (error_state_free); + p->LS = rde_stack_new (NULL); + p->ast = rde_stack_new (ast_node_free); + p->mark = rde_stack_new (NULL); + RETURN ("%p", p); + } + SCOPE void + rde_param_del (RDE_PARAM p) + { + ENTER ("rde_param_del"); + TRACE (("RDE_PARAM %p",p)); + ER_CLEAR (p); TRACE (("\ter_clear")); + SV_CLEAR (p); TRACE (("\tsv_clear")); + nc_clear (p); TRACE (("\tnc_clear")); + Tcl_DeleteHashTable (&p->NC); TRACE (("\tnc hashtable delete")); + rde_tc_del (p->TC); TRACE (("\ttc clear")); + rde_stack_del (p->ES); TRACE (("\tes clear")); + rde_stack_del (p->LS); TRACE (("\tls clear")); + rde_stack_del (p->ast); TRACE (("\tast clear")); + rde_stack_del (p->mark); TRACE (("\tmark clear")); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + Tcl_DecrRefCount (p->readbuf); + ckfree ((char*) p); + RETURNVOID; + } + SCOPE void + rde_param_reset (RDE_PARAM p, Tcl_Channel chan) + { + ENTER ("rde_param_reset"); + TRACE (("RDE_PARAM %p",p)); + TRACE (("Tcl_Channel %p",chan)); + p->IN = chan; + p->CL = -1; + p->ST = 0; + p->CC = NULL; + p->CC_len = 0; + ER_CLEAR (p); + SV_CLEAR (p); + nc_clear (p); + rde_tc_clear (p->TC); + rde_stack_trim (p->ES, 0); + rde_stack_trim (p->LS, 0); + rde_stack_trim (p->ast, 0); + rde_stack_trim (p->mark, 0); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + RETURNVOID; + } + SCOPE void + rde_param_update_strings (RDE_PARAM p, long int nstr, char** strings) + { + ENTER ("rde_param_update_strings"); + TRACE (("RDE_PARAM %p", p)); + TRACE (("INT %d strings", nstr)); + p->numstr = nstr; + p->string = strings; + RETURNVOID; + } + SCOPE void + rde_param_data (RDE_PARAM p, char* buf, long int len) + { + (void) rde_tc_append (p->TC, buf, len); + } + SCOPE void + rde_param_clientdata (RDE_PARAM p, ClientData clientData) + { + p->clientData = clientData; + } + static void + nc_clear (RDE_PARAM p) + { + Tcl_HashSearch hs; + Tcl_HashEntry* he; + Tcl_HashTable* tablePtr; + for(he = Tcl_FirstHashEntry(&p->NC, &hs); + he != NULL; + he = Tcl_FirstHashEntry(&p->NC, &hs)) { + Tcl_HashSearch hsc; + Tcl_HashEntry* hec; + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (he); + for(hec = Tcl_FirstHashEntry(tablePtr, &hsc); + hec != NULL; + hec = Tcl_NextHashEntry(&hsc)) { + NC_STATE* scs = Tcl_GetHashValue (hec); + error_state_free (scs->ER); + if (scs->SV) { Tcl_DecrRefCount (scs->SV); } + ckfree ((char*) scs); + } + Tcl_DeleteHashTable (tablePtr); + ckfree ((char*) tablePtr); + Tcl_DeleteHashEntry (he); + } + } + SCOPE ClientData + rde_param_query_clientdata (RDE_PARAM p) + { + return p->clientData; + } + SCOPE void + rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) + { + rde_stack_get (p->mark, mc, mv); + } + SCOPE void + rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) + { + rde_stack_get (p->ast, ac, (void***) av); + } + SCOPE const char* + rde_param_query_in (RDE_PARAM p) + { + return p->IN + ? Tcl_GetChannelName (p->IN) + : ""; + } + SCOPE const char* + rde_param_query_cc (RDE_PARAM p, long int* len) + { + *len = p->CC_len; + return p->CC; + } + SCOPE int + rde_param_query_cl (RDE_PARAM p) + { + return p->CL; + } + SCOPE const ERROR_STATE* + rde_param_query_er (RDE_PARAM p) + { + return p->ER; + } + SCOPE Tcl_Obj* + rde_param_query_er_tcl (RDE_PARAM p, const ERROR_STATE* er) + { + Tcl_Obj* res; + if (!er) { + + res = Tcl_NewStringObj ("", 0); + } else { + Tcl_Obj* ov [2]; + Tcl_Obj** mov; + long int mc, i, j; + void** mv; + int lastid; + const char* msg; + rde_stack_get (er->msg, &mc, &mv); + + qsort (mv, mc, sizeof (void*), er_int_compare); + + mov = NALLOC (mc, Tcl_Obj*); + lastid = -1; + for (i=0, j=0; i < mc; i++) { + ASSERT_BOUNDS (i,mc); + if (((long int) mv [i]) == lastid) continue; + lastid = (long int) mv [i]; + ASSERT_BOUNDS((long int) mv[i],p->numstr); + msg = p->string [(long int) mv[i]]; + ASSERT_BOUNDS (j,mc); + mov [j] = Tcl_NewStringObj (msg, -1); + j++; + } + + ov [0] = Tcl_NewIntObj (er->loc); + ov [1] = Tcl_NewListObj (j, mov); + res = Tcl_NewListObj (2, ov); + ckfree ((char*) mov); + } + return res; + } + SCOPE void + rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) + { + rde_stack_get (p->ES, ec, (void***) ev); + } + SCOPE void + rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) + { + rde_stack_get (p->LS, lc, lv); + } + SCOPE long int + rde_param_query_lstop (RDE_PARAM p) + { + (long int) rde_stack_top (p->LS); + } + SCOPE Tcl_HashTable* + rde_param_query_nc (RDE_PARAM p) + { + return &p->NC; + } + SCOPE int + rde_param_query_st (RDE_PARAM p) + { + return p->ST; + } + SCOPE Tcl_Obj* + rde_param_query_sv (RDE_PARAM p) + { + TRACE (("SV_QUERY %p => (%p)", (p), (p)->SV)); \ + return p->SV; + } + SCOPE long int + rde_param_query_tc_size (RDE_PARAM p) + { + return rde_tc_size (p->TC); + } + SCOPE void + rde_param_query_tc_get_s (RDE_PARAM p, long int at, long int last, char** ch, long int* len) + { + rde_tc_get_s (p->TC, at, last, ch, len); + } + SCOPE const char* + rde_param_query_string (RDE_PARAM p, long int id) + { + TRACE (("rde_param_query_string (RDE_PARAM %p, %d/%d)", p, id, p->numstr)); + ASSERT_BOUNDS(id,p->numstr); + return p->string [id]; + } + SCOPE void + rde_param_i_ast_pop_discard (RDE_PARAM p) + { + rde_stack_pop (p->mark, 1); + } + SCOPE void + rde_param_i_ast_pop_rewind (RDE_PARAM p) + { + long int trim = (long int) rde_stack_top (p->mark); + ENTER ("rde_param_i_ast_pop_rewind"); + TRACE (("RDE_PARAM %p",p)); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_ast_rewind (RDE_PARAM p) + { + long int trim = (long int) rde_stack_top (p->mark); + ENTER ("rde_param_i_ast_rewind"); + TRACE (("RDE_PARAM %p",p)); + rde_stack_trim (p->ast, trim); + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_ast_push (RDE_PARAM p) + { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + } + SCOPE void + rde_param_i_ast_value_push (RDE_PARAM p) + { + ENTER ("rde_param_i_ast_value_push"); + TRACE (("RDE_PARAM %p",p)); + ASSERT(p->SV,"Unable to push undefined semantic value"); + TRACE (("rde_param_i_ast_value_push %p => (%p)", p, p->SV)); + TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV->refCount, Tcl_GetString (p->SV))); + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + RETURNVOID; + } + static void + ast_node_free (void* n) + { + Tcl_DecrRefCount ((Tcl_Obj*) n); + } + SCOPE void + rde_param_i_error_clear (RDE_PARAM p) + { + ER_CLEAR (p); + } + SCOPE void + rde_param_i_error_nonterminal (RDE_PARAM p, long int s) + { + + return; + long int pos; + if (!p->ER) return; + pos = 1 + (long int) rde_stack_top (p->LS); + if (p->ER->loc != pos) return; + error_set (p, s); + p->ER->loc = pos; + } + SCOPE void + rde_param_i_error_pop_merge (RDE_PARAM p) + { + ERROR_STATE* top = (ERROR_STATE*) rde_stack_top (p->ES); + + if (top == p->ER) { + rde_stack_pop (p->ES, 1); + return; + } + + if (!top) { + rde_stack_pop (p->ES, 1); + return; + } + + if (!p->ER) { + rde_stack_drop (p->ES, 1); + p->ER = top; + + return; + } + + if (top->loc < p->ER->loc) { + rde_stack_pop (p->ES, 1); + return; + } + + if (top->loc > p->ER->loc) { + rde_stack_drop (p->ES, 1); + error_state_free (p->ER); + p->ER = top; + + return; + } + + rde_stack_move (p->ER->msg, top->msg); + rde_stack_pop (p->ES, 1); + } + SCOPE void + rde_param_i_error_push (RDE_PARAM p) + { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + static void + error_set (RDE_PARAM p, long int s) + { + error_state_free (p->ER); + p->ER = ALLOC (ERROR_STATE); + p->ER->refCount = 1; + p->ER->loc = p->CL; + p->ER->msg = rde_stack_new (NULL); + ASSERT_BOUNDS(s,p->numstr); + rde_stack_push (p->ER->msg, (void*) s); + } + static void + error_state_free (void* esx) + { + ERROR_STATE* es = esx; + if (!es) return; + es->refCount --; + if (es->refCount > 0) return; + rde_stack_del (es->msg); + ckfree ((char*) es); + } + SCOPE void + rde_param_i_loc_pop_discard (RDE_PARAM p) + { + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_loc_pop_rewind (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_loc_push (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + } + SCOPE void + rde_param_i_loc_rewind (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + } + SCOPE void + rde_param_i_input_next (RDE_PARAM p, long int m) + { + int leni; + char* ch; + ASSERT_BOUNDS(m,p->numstr); + p->CL ++; + if (p->CL < rde_tc_size (p->TC)) { + + rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); + + ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); + p->ST = 1; + ER_CLEAR (p); + return; + } + if (!p->IN || + Tcl_Eof (p->IN) || + (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { + + p->ST = 0; + error_set (p, m); + return; + } + + ch = Tcl_GetStringFromObj (p->readbuf, &leni); + ASSERT_BOUNDS (leni, TCL_UTF_MAX); + p->CC = rde_tc_append (p->TC, ch, leni); + p->CC_len = leni; + p->ST = 1; + ER_CLEAR (p); + } + SCOPE void + rde_param_i_status_fail (RDE_PARAM p) + { + p->ST = 0; + } + SCOPE void + rde_param_i_status_ok (RDE_PARAM p) + { + p->ST = 1; + } + SCOPE void + rde_param_i_status_negate (RDE_PARAM p) + { + p->ST = !p->ST; + } + SCOPE int + rde_param_i_symbol_restore (RDE_PARAM p, long int s) + { + NC_STATE* scs; + Tcl_HashEntry* hPtr; + Tcl_HashTable* tablePtr; + + hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); + if (!hPtr) { return 0; } + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); + hPtr = Tcl_FindHashEntry (tablePtr, (char*) s); + if (!hPtr) { return 0; } + + scs = Tcl_GetHashValue (hPtr); + p->CL = scs->CL; + p->ST = scs->ST; + error_state_free (p->ER); + p->ER = scs->ER; + if (p->ER) { p->ER->refCount ++; } + TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); + SV_SET (p, scs->SV); + return 1; + } + SCOPE void + rde_param_i_symbol_save (RDE_PARAM p, long int s) + { + long int at = (long int) rde_stack_top (p->LS); + NC_STATE* scs; + Tcl_HashEntry* hPtr; + Tcl_HashTable* tablePtr; + int isnew; + ENTER ("rde_param_i_symbol_save"); + TRACE (("RDE_PARAM %p",p)); + TRACE (("INT %d",s)); + + hPtr = Tcl_CreateHashEntry (&p->NC, (char*) at, &isnew); + if (isnew) { + tablePtr = ALLOC (Tcl_HashTable); + Tcl_InitHashTable (tablePtr, TCL_ONE_WORD_KEYS); + Tcl_SetHashValue (hPtr, tablePtr); + } else { + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); + } + hPtr = Tcl_CreateHashEntry (tablePtr, (char*) s, &isnew); + if (isnew) { + + scs = ALLOC (NC_STATE); + scs->CL = p->CL; + scs->ST = p->ST; + TRACE (("SV_CACHE (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "")); + scs->SV = p->SV; + if (scs->SV) { Tcl_IncrRefCount (scs->SV); } + scs->ER = p->ER; + if (scs->ER) { scs->ER->refCount ++; } + Tcl_SetHashValue (hPtr, scs); + } else { + + scs = (NC_STATE*) Tcl_GetHashValue (hPtr); + scs->CL = p->CL; + scs->ST = p->ST; + TRACE (("SV_CACHE/over (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "" )); + if (scs->SV) { Tcl_DecrRefCount (scs->SV); } + scs->SV = p->SV; + if (scs->SV) { Tcl_IncrRefCount (scs->SV); } + error_state_free (scs->ER); + scs->ER = p->ER; + if (scs->ER) { scs->ER->refCount ++; } + } + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_test_alnum (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsAlnum, tc_alnum); + } + SCOPE void + rde_param_i_test_alpha (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsAlpha, tc_alpha); + } + SCOPE void + rde_param_i_test_ascii (RDE_PARAM p) + { + test_class (p, UniCharIsAscii, tc_ascii); + } + SCOPE void + rde_param_i_test_control (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsControl, tc_control); + } + SCOPE void + rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) + { + ASSERT_BOUNDS(msg,p->numstr); + p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, msg); + p->CL --; + } + } + SCOPE void + rde_param_i_test_ddigit (RDE_PARAM p) + { + test_class (p, UniCharIsDecDigit, tc_ddigit); + } + SCOPE void + rde_param_i_test_digit (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsDigit, tc_digit); + } + SCOPE void + rde_param_i_test_graph (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsGraph, tc_graph); + } + SCOPE void + rde_param_i_test_lower (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsLower, tc_lower); + } + SCOPE void + rde_param_i_test_print (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsPrint, tc_printable); + } + SCOPE void + rde_param_i_test_punct (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsPunct, tc_punct); + } + SCOPE void + rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) + { + ASSERT_BOUNDS(msg,p->numstr); + p->ST = + (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && + (Tcl_UtfNcmp (p->CC, e, 1) <= 0); + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, msg); + p->CL --; + } + } + SCOPE void + rde_param_i_test_space (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsSpace, tc_space); + } + SCOPE void + rde_param_i_test_upper (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsUpper, tc_upper); + } + SCOPE void + rde_param_i_test_wordchar (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsWordChar, tc_wordchar); + } + SCOPE void + rde_param_i_test_xdigit (RDE_PARAM p) + { + test_class (p, UniCharIsHexDigit, tc_xdigit); + } + static void + test_class (RDE_PARAM p, UniCharClass class, test_class_id id) + { + Tcl_UniChar ch; + Tcl_UtfToUniChar(p->CC, &ch); + ASSERT_BOUNDS(id,p->numstr); + p->ST = !!class (ch); + + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, id); + p->CL --; + } + } + static int + UniCharIsAscii (int character) + { + return (character >= 0) && (character < 0x80); + } + static int + UniCharIsHexDigit (int character) + { + return (character >= 0) && (character < 0x80) && isxdigit(character); + } + static int + UniCharIsDecDigit (int character) + { + return (character >= 0) && (character < 0x80) && isdigit(character); + } + SCOPE void + rde_param_i_value_clear (RDE_PARAM p) + { + SV_CLEAR (p); + } + SCOPE void + rde_param_i_value_leaf (RDE_PARAM p, long int s) + { + Tcl_Obj* newsv; + Tcl_Obj* ov [3]; + long int pos = 1 + (long int) rde_stack_top (p->LS); + ASSERT_BOUNDS(s,p->numstr); + ov [0] = Tcl_NewStringObj (p->string[s], -1); + ov [1] = Tcl_NewIntObj (pos); + ov [2] = Tcl_NewIntObj (p->CL); + newsv = Tcl_NewListObj (3, ov); + TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); + SV_SET (p, newsv); + } + SCOPE void + rde_param_i_value_reduce (RDE_PARAM p, long int s) + { + Tcl_Obj* newsv; + int oc, i, j; + Tcl_Obj** ov; + long int ac; + Tcl_Obj** av; + long int pos = 1 + (long int) rde_stack_top (p->LS); + long int mark = (long int) rde_stack_top (p->mark); + long int asize = rde_stack_size (p->ast); + long int new = asize - mark; + ASSERT (new >= 0, "Bad number of elements to reduce"); + ov = NALLOC (3+new, Tcl_Obj*); + ASSERT_BOUNDS(s,p->numstr); + ov [0] = Tcl_NewStringObj (p->string[s], -1); + ov [1] = Tcl_NewIntObj (pos); + ov [2] = Tcl_NewIntObj (p->CL); + rde_stack_get (p->ast, &ac, (void***) &av); + for (i = 3, j = mark; j < asize; i++, j++) { + ASSERT_BOUNDS (i, 3+new); + ASSERT_BOUNDS (j, ac); + ov [i] = av [j]; + } + ASSERT (i == 3+new, "Reduction result incomplete"); + newsv = Tcl_NewListObj (3+new, ov); + TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); + SV_SET (p, newsv); + ckfree ((char*) ov); + } + static int + er_int_compare (const void* a, const void* b) + { + + const void** ael = (const void**) a; + const void** bel = (const void**) b; + long int avalue = (long int) *ael; + long int bvalue = (long int) *bel; + if (avalue < bvalue) { return -1; } + if (avalue > bvalue) { return 1; } + return 0; + } + SCOPE int + rde_param_i_symbol_start (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) { + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + return 1; + } + rde_stack_push (p->LS, (void*) p->CL); + return 0; + } + SCOPE int + rde_param_i_symbol_start_d (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) { + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + return 1; + } + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + return 0; + } + SCOPE int + rde_param_i_symbol_void_start (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) return 1; + rde_stack_push (p->LS, (void*) p->CL); + return 0; + } + SCOPE int + rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) return 1; + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + return 0; + } + SCOPE void + rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_reduce (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_leaf (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_leaf (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) + { + SV_CLEAR (p); + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) + { + SV_CLEAR (p); + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_char (p, c, m); + } + SCOPE void + rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_range (p, s, e, m); + } + SCOPE void + rde_param_i_next_alnum (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_alnum (p); + } + SCOPE void + rde_param_i_next_alpha (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_alpha (p); + } + SCOPE void + rde_param_i_next_ascii (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_ascii (p); + } + SCOPE void + rde_param_i_next_control (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_control (p); + } + SCOPE void + rde_param_i_next_ddigit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_ddigit (p); + } + SCOPE void + rde_param_i_next_digit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_digit (p); + } + SCOPE void + rde_param_i_next_graph (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_graph (p); + } + SCOPE void + rde_param_i_next_lower (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_lower (p); + } + SCOPE void + rde_param_i_next_print (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_print (p); + } + SCOPE void + rde_param_i_next_punct (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_punct (p); + } + SCOPE void + rde_param_i_next_space (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_space (p); + } + SCOPE void + rde_param_i_next_upper (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_upper (p); + } + SCOPE void + rde_param_i_next_wordchar (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_wordchar (p); + } + SCOPE void + rde_param_i_next_xdigit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_xdigit (p); + } + SCOPE void + rde_param_i_notahead_start_d (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + } + SCOPE void + rde_param_i_notahead_exit_d (RDE_PARAM p) + { + if (p->ST) { + rde_param_i_ast_pop_rewind (p); + } else { + rde_stack_pop (p->mark, 1); + } + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + p->ST = !p->ST; + } + SCOPE void + rde_param_i_notahead_exit (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + p->ST = !p->ST; + } + SCOPE void + rde_param_i_state_push_2 (RDE_PARAM p) + { + + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + SCOPE void + rde_param_i_state_push_void (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + ER_CLEAR (p); + rde_stack_push (p->ES, p->ER); + + } + SCOPE void + rde_param_i_state_push_value (RDE_PARAM p) + { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + rde_stack_push (p->LS, (void*) p->CL); + ER_CLEAR (p); + rde_stack_push (p->ES, p->ER); + + } + SCOPE void + rde_param_i_state_merge_ok (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + p->ST = 1; + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_state_merge_void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_state_merge_value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } + SCOPE int + rde_param_i_kleene_close (RDE_PARAM p) + { + int stop = !p->ST; + rde_param_i_error_pop_merge (p); + if (stop) { + p->ST = 1; + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + return stop; + } + SCOPE int + rde_param_i_kleene_abort (RDE_PARAM p) + { + int stop = !p->ST; + if (stop) { + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + return stop; + } + SCOPE int + rde_param_i_seq_void2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_seq_void2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_seq_value2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_bra_void2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->LS, 1); + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_void2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->LS, 1); + } else { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_value2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_value2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE void + rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) + { + int at = p->CL; + + while (*str) { + rde_param_i_input_next (p, m); + if (!p->ST) { + p->ER->loc = at+1; + p->CL = at; + return; + } + rde_param_i_test_char (p, str, m); + if (!p->ST) { + p->ER->loc = at+1; + p->CL = at; + return; + } + str = Tcl_UtfNext (str); + } + } + SCOPE void + rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + while (*class) { + p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; + if (p->ST) { + ER_CLEAR (p); + return; + } + class = Tcl_UtfNext (class); + } + error_set (p, m); + p->CL --; + } + + + /* + * Declaring the parse functions + */ + + + /* + * Precomputed table of strings (symbols, error messages, etc.). + */ + + static char const* p_string [15] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "str abc" + }; + + /* + * Grammar Start Expression + */ + + static void MAIN (RDE_PARAM p) { + rde_param_i_next_str (p, "abc", 14); + return; + } + + /* -*- c -*- */ + + typedef struct PARSERg { + long int counter; + char buf [50]; + } PARSERg; + + static void + PARSERgRelease (ClientData cd, Tcl_Interp* interp) + { + ckfree((char*) cd); + } + + static const char* + PARSERnewName (Tcl_Interp* interp) + { +#define KEY "tcllib/parser/PACKAGE/TEA" + + Tcl_InterpDeleteProc* proc = PARSERgRelease; + PARSERg* parserg; + + parserg = Tcl_GetAssocData (interp, KEY, &proc); + if (parserg == NULL) { + parserg = (PARSERg*) ckalloc (sizeof (PARSERg)); + parserg->counter = 0; + + Tcl_SetAssocData (interp, KEY, proc, + (ClientData) parserg); + } + + parserg->counter ++; + sprintf (parserg->buf, "PARSER%ld", parserg->counter); + return parserg->buf; +#undef KEY + } + + static void + PARSERdeleteCmd (ClientData clientData) + { + /* + * Release the whole PARSER + * (Low-level engine only actually). + */ + rde_param_del ((RDE_PARAM) clientData); + } + + + /* * ** *** ***** ******** ************* + ** Functions implementing the object methods, and helper. + */ + + static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp); + + static int parser_PARSE (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + int mode; + Tcl_Channel chan; + + if (objc != 3) { + Tcl_WrongNumArgs (interp, 2, objv, "chan"); + return TCL_ERROR; + } + + chan = Tcl_GetChannel(interp, + Tcl_GetString (objv[2]), + &mode); + + if (!chan) { + return TCL_ERROR; + } + + rde_param_reset (p, chan); + MAIN (p) ; /* Entrypoint for the generated code. */ + return COMPLETE (p, interp); + } + + static int parser_PARSET (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + char* buf; + int len; + + if (objc != 3) { + Tcl_WrongNumArgs (interp, 2, objv, "text"); + return TCL_ERROR; + } + + buf = Tcl_GetStringFromObj (objv[2], &len); + + rde_param_reset (p, NULL); + rde_param_data (p, buf, len); + MAIN (p) ; /* Entrypoint for the generated code. */ + return COMPLETE (p, interp); + } + + /* See also rde_critcl/m.c, param_COMPLETE() */ + static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) + { + if (rde_param_query_st (p)) { + long int ac; + Tcl_Obj** av; + + rde_param_query_ast (p, &ac, &av); + + if (ac > 1) { + Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); + + memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); + lv [0] = Tcl_NewObj (); + lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); + lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); + + Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); + ckfree ((char*) lv); + + } else if (ac == 0) { + /* + * Match, but no AST. This is possible if the grammar + * consists of only the start expression. + */ + Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); + } else { + Tcl_SetObjResult (interp, av [0]); + } + + return TCL_OK; + } else { + Tcl_Obj* xv [1]; + const ERROR_STATE* er = rde_param_query_er (p); + Tcl_Obj* res = rde_param_query_er_tcl (p, er); + /* res = list (location, list(msg)) */ + + /* Stick the exception type-tag before the existing elements */ + xv [0] = Tcl_NewStringObj ("pt::rde",-1); + Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); + + Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); + Tcl_SetObjResult (interp, res); + return TCL_ERROR; + } + } + + + /* * ** *** ***** ******** ************* + ** Object command, method dispatch. + */ + static int parser_objcmd (ClientData cd, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + RDE_PARAM p = (RDE_PARAM) cd; + int m, res; + + static CONST char* methods [] = { + "destroy", "parse", "parset", NULL + }; + enum methods { + M_DESTROY, M_PARSE, M_PARSET + }; + + if (objc < 2) { + Tcl_WrongNumArgs (interp, objc, objv, "option ?arg arg ...?"); + return TCL_ERROR; + } else if (Tcl_GetIndexFromObj (interp, objv [1], methods, "option", + 0, &m) != TCL_OK) { + return TCL_ERROR; + } + + /* Dispatch to methods. They check the #args in + * detail before performing the requested + * functionality + */ + + switch (m) { + case M_DESTROY: + if (objc != 2) { + Tcl_WrongNumArgs (interp, 2, objv, NULL); + return TCL_ERROR; + } + + Tcl_DeleteCommandFromToken(interp, (Tcl_Command) rde_param_query_clientdata (p)); + return TCL_OK; + + case M_PARSE: res = parser_PARSE (p, interp, objc, objv); break; + case M_PARSET: res = parser_PARSET (p, interp, objc, objv); break; + default: + /* Not coming to this place */ + ASSERT (0,"Reached unreachable location"); + } + + return res; + } + + /** * ** *** ***** ******** ************* + * Class command, i.e. object construction. + */ + static int ParserClassCmd (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const*objv) { + /* + * Syntax: No arguments beyond the name + */ + + RDE_PARAM parser; + CONST char* name; + Tcl_Obj* fqn; + Tcl_CmdInfo ci; + Tcl_Command c; + +#define USAGE "?name?" + + if ((objc != 2) && (objc != 1)) { + Tcl_WrongNumArgs (interp, 1, objv, USAGE); + return TCL_ERROR; + } + + if (objc < 2) { + name = PARSERnewName (interp); + } else { + name = Tcl_GetString (objv [1]); + } + + if (!Tcl_StringMatch (name, "::*")) { + /* Relative name. Prefix with current namespace */ + + Tcl_Eval (interp, "namespace current"); + fqn = Tcl_GetObjResult (interp); + fqn = Tcl_DuplicateObj (fqn); + Tcl_IncrRefCount (fqn); + + if (!Tcl_StringMatch (Tcl_GetString (fqn), "::")) { + Tcl_AppendToObj (fqn, "::", -1); + } + Tcl_AppendToObj (fqn, name, -1); + } else { + fqn = Tcl_NewStringObj (name, -1); + Tcl_IncrRefCount (fqn); + } + Tcl_ResetResult (interp); + + if (Tcl_GetCommandInfo (interp, + Tcl_GetString (fqn), + &ci)) { + Tcl_Obj* err; + + err = Tcl_NewObj (); + Tcl_AppendToObj (err, "command \"", -1); + Tcl_AppendObjToObj (err, fqn); + Tcl_AppendToObj (err, "\" already exists", -1); + + Tcl_DecrRefCount (fqn); + Tcl_SetObjResult (interp, err); + return TCL_ERROR; + } + + parser = rde_param_new (sizeof(p_string)/sizeof(char*), (char**) p_string); + c = Tcl_CreateObjCommand (interp, Tcl_GetString (fqn), + parser_objcmd, (ClientData) parser, + PARSERdeleteCmd); + rde_param_clientdata (parser, (ClientData) c); + Tcl_SetObjResult (interp, fqn); + Tcl_DecrRefCount (fqn); + return TCL_OK; + } + +int Package_Init(Tcl_Interp* interp) { + if (interp == 0) return TCL_ERROR; + + if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { + return TCL_ERROR; + } + + if (Tcl_CreateObjCommand(interp, "PARSER", ParserClassCmd , NULL, NULL) == NULL) { + Tcl_SetResult(interp, "Can't create constructor", NULL); + return TCL_ERROR; + } + + + Tcl_PkgProvide(interp, "PACKAGE", "0.1"); + + return TCL_OK; +} ADDED modules/pt/tests/data/ok/peg_cparam-tea/6_optional Index: modules/pt/tests/data/ok/peg_cparam-tea/6_optional ================================================================== --- /dev/null +++ modules/pt/tests/data/ok/peg_cparam-tea/6_optional @@ -0,0 +1,1999 @@ +/************************************************************ +** +** TEA-based C/PARAM implementation of the parsing +** expression grammar +** +** TEMPLATE +** +** Generated from file TEST +** for user unknown +** +* * ** *** ***** ******** ************* *********************/ + #include + #include + #include + #include + #define SCOPE static + +#line 1 "rde_critcl/util.h" + + #ifndef _RDE_UTIL_H + #define _RDE_UTIL_H 1 + #ifndef SCOPE + #define SCOPE + #endif + #define ALLOC(type) (type *) ckalloc (sizeof (type)) + #define NALLOC(n,type) (type *) ckalloc ((n) * sizeof (type)) + #undef RDE_DEBUG + #define RDE_DEBUG 1 + #undef RDE_TRACE + #ifdef RDE_DEBUG + #define STOPAFTER(x) { static int count = (x); count --; if (!count) { Tcl_Panic ("stop"); } } + #define XSTR(x) #x + #define STR(x) XSTR(x) + #define RANGEOK(i,n) ((0 <= (i)) && (i < (n))) + #define ASSERT(x,msg) if (!(x)) { Tcl_Panic (msg " (" #x "), in file " __FILE__ " @line " STR(__LINE__));} + #define ASSERT_BOUNDS(i,n) ASSERT (RANGEOK(i,n),"array index out of bounds: " STR(i) " >= " STR(n)) + #else + #define STOPAFTER(x) + #define ASSERT(x,msg) + #define ASSERT_BOUNDS(i,n) + #endif + #ifdef RDE_TRACE + SCOPE void trace_enter (const char* fun); + SCOPE void trace_return (const char *pat, ...); + SCOPE void trace_printf (const char *pat, ...); + #define ENTER(fun) trace_enter (fun) + #define RETURN(format,x) trace_return (format,x) ; return x + #define RETURNVOID trace_return ("%s","(void)") ; return + #define TRACE0(x) trace_printf0 x + #define TRACE(x) trace_printf x + #else + #define ENTER(fun) + #define RETURN(f,x) return x + #define RETURNVOID return + #define TRACE0(x) + #define TRACE(x) + #endif + #endif + + +#line 1 "rde_critcl/stack.h" + + #ifndef _RDE_DS_STACK_H + #define _RDE_DS_STACK_H 1 + typedef void (*RDE_STACK_CELL_FREE) (void* cell); + typedef struct RDE_STACK_* RDE_STACK; + static const int RDE_STACK_INITIAL_SIZE = 256; + #endif + + +#line 1 "rde_critcl/tc.h" + + #ifndef _RDE_DS_TC_H + #define _RDE_DS_TC_H 1 + typedef struct RDE_TC_* RDE_TC; + #endif + + +#line 1 "rde_critcl/param.h" + + #ifndef _RDE_DS_PARAM_H + #define _RDE_DS_PARAM_H 1 + typedef struct RDE_PARAM_* RDE_PARAM; + typedef struct ERROR_STATE { + int refCount; + long int loc; + RDE_STACK msg; + } ERROR_STATE; + typedef struct NC_STATE { + long int CL; + long int ST; + Tcl_Obj* SV; + ERROR_STATE* ER; + } NC_STATE; + #endif + + +#line 1 "rde_critcl/util.c" + + #ifdef RDE_TRACE + typedef struct F_STACK { + const char* str; + struct F_STACK* down; + } F_STACK; + static F_STACK* top = 0; + static int level = 0; + static void + push (const char* str) + { + F_STACK* new = ALLOC (F_STACK); + new->str = str; + new->down = top; + top = new; + level += 4; + } + static void + pop (void) + { + F_STACK* next = top->down; + level -= 4; + ckfree ((char*)top); + top = next; + } + static void + indent (void) + { + int i; + for (i = 0; i < level; i++) { + fwrite(" ", 1, 1, stdout); + fflush (stdout); + } + if (top) { + fwrite(top->str, 1, strlen(top->str), stdout); + fflush (stdout); + } + fwrite(" ", 1, 1, stdout); + fflush (stdout); + } + SCOPE void + trace_enter (const char* fun) + { + push (fun); + indent(); + fwrite("ENTER\n", 1, 6, stdout); + fflush (stdout); + } + static char msg [1024*1024]; + SCOPE void + trace_return (const char *pat, ...) + { + int len; + va_list args; + indent(); + fwrite("RETURN = ", 1, 9, stdout); + fflush (stdout); + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + pop(); + } + SCOPE void + trace_printf (const char *pat, ...) + { + int len; + va_list args; + indent(); + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + } + SCOPE void + trace_printf0 (const char *pat, ...) + { + int len; + va_list args; + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + } + #endif + + +#line 1 "rde_critcl/stack.c" + + typedef struct RDE_STACK_ { + long int max; + long int top; + RDE_STACK_CELL_FREE freeCellProc; + void** cell; + } RDE_STACK_; + + SCOPE RDE_STACK + rde_stack_new (RDE_STACK_CELL_FREE freeCellProc) + { + RDE_STACK s = ALLOC (RDE_STACK_); + s->cell = NALLOC (RDE_STACK_INITIAL_SIZE, void*); + s->max = RDE_STACK_INITIAL_SIZE; + s->top = 0; + s->freeCellProc = freeCellProc; + return s; + } + SCOPE void + rde_stack_del (RDE_STACK s) + { + if (s->freeCellProc && s->top) { + long int i; + for (i=0; i < s->top; i++) { + ASSERT_BOUNDS(i,s->max); + s->freeCellProc ( s->cell [i] ); + } + } + ckfree ((char*) s->cell); + ckfree ((char*) s); + } + SCOPE void + rde_stack_push (RDE_STACK s, void* item) + { + if (s->top >= s->max) { + long int new = s->max ? (2 * s->max) : RDE_STACK_INITIAL_SIZE; + void** cell = (void**) ckrealloc ((char*) s->cell, new * sizeof(void*)); + ASSERT (cell,"Memory allocation failure for RDE stack"); + s->max = new; + s->cell = cell; + } + ASSERT_BOUNDS(s->top,s->max); + s->cell [s->top] = item; + s->top ++; + } + SCOPE void* + rde_stack_top (RDE_STACK s) + { + ASSERT_BOUNDS(s->top-1,s->max); + return s->cell [s->top - 1]; + } + SCOPE void + rde_stack_pop (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad pop count"); + if (n == 0) return; + if (s->freeCellProc) { + while (n) { + s->top --; + ASSERT_BOUNDS(s->top,s->max); + s->freeCellProc ( s->cell [s->top] ); + n --; + } + } else { + s->top -= n; + } + } + SCOPE void + rde_stack_trim (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad trimsize"); + if (s->freeCellProc) { + while (s->top > n) { + s->top --; + ASSERT_BOUNDS(s->top,s->max); + s->freeCellProc ( s->cell [s->top] ); + } + } else { + s->top = n; + } + } + SCOPE void + rde_stack_drop (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad pop count"); + if (n == 0) return; + s->top -= n; + } + SCOPE void + rde_stack_move (RDE_STACK dst, RDE_STACK src) + { + ASSERT (dst->freeCellProc == src->freeCellProc, "Ownership mismatch"); + + while (src->top > 0) { + src->top --; + ASSERT_BOUNDS(src->top,src->max); + rde_stack_push (dst, src->cell [src->top] ); + } + } + SCOPE void + rde_stack_get (RDE_STACK s, long int* cn, void*** cc) + { + *cn = s->top; + *cc = s->cell; + } + SCOPE long int + rde_stack_size (RDE_STACK s) + { + return s->top; + } + + +#line 1 "rde_critcl/tc.c" + + typedef struct RDE_TC_ { + int max; + int num; + char* str; + RDE_STACK off; + } RDE_TC_; + + SCOPE RDE_TC + rde_tc_new (void) + { + RDE_TC tc = ALLOC (RDE_TC_); + tc->max = RDE_STACK_INITIAL_SIZE; + tc->num = 0; + tc->str = NALLOC (RDE_STACK_INITIAL_SIZE, char); + tc->off = rde_stack_new (NULL); + return tc; + } + SCOPE void + rde_tc_del (RDE_TC tc) + { + rde_stack_del (tc->off); + ckfree (tc->str); + ckfree ((char*) tc); + } + SCOPE long int + rde_tc_size (RDE_TC tc) + { + return rde_stack_size (tc->off); + } + SCOPE void + rde_tc_clear (RDE_TC tc) + { + tc->num = 0; + rde_stack_trim (tc->off, 0); + } + SCOPE char* + rde_tc_append (RDE_TC tc, char* string, long int len) + { + long int base = tc->num; + long int off = tc->num; + char* ch; + int clen; + Tcl_UniChar uni; + if (len < 0) { + len = strlen (string); + } + + if (!len) { + return tc->str + base; + } + + if ((tc->num + len) >= tc->max) { + int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); + char* str = ckrealloc (tc->str, new * sizeof(char)); + ASSERT (str,"Memory allocation failure for token character array"); + tc->max = new; + tc->str = str; + } + tc->num += len; + ASSERT_BOUNDS(tc->num,tc->max); + ASSERT_BOUNDS(off,tc->max); + ASSERT_BOUNDS(off+len-1,tc->max); + ASSERT_BOUNDS(off+len-1,tc->num); + memcpy (tc->str + off, string, len); + + ch = string; + while (ch < (string + len)) { + ASSERT_BOUNDS(off,tc->num); + rde_stack_push (tc->off, (void*) off); + clen = Tcl_UtfToUniChar (ch, &uni); + off += clen; + ch += clen; + } + return tc->str + base; + } + SCOPE void + rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) + { + long int oc, off, top, end; + void** ov; + rde_stack_get (tc->off, &oc, &ov); + ASSERT_BOUNDS(at,oc); + off = (long int) ov [at]; + if ((at+1) == oc) { + end = tc->num; + } else { + end = (long int) ov [at+1]; + } + TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); + ASSERT_BOUNDS(off,tc->num); + ASSERT_BOUNDS(end-1,tc->num); + *ch = tc->str + off; + *len = end - off; + } + SCOPE void + rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) + { + long int oc, off, top, end; + void** ov; + rde_stack_get (tc->off, &oc, &ov); + ASSERT_BOUNDS(at,oc); + ASSERT_BOUNDS(last,oc); + off = (long int) ov [at]; + if ((last+1) == oc) { + end = tc->num; + } else { + end = (long int) ov [last+1]; + } + TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); + ASSERT_BOUNDS(off,tc->num); + ASSERT_BOUNDS(end-1,tc->num); + *ch = tc->str + off; + *len = end - off; + } + + +#line 1 "rde_critcl/param.c" + + typedef struct RDE_PARAM_ { + Tcl_Channel IN; + Tcl_Obj* readbuf; + char* CC; + long int CC_len; + RDE_TC TC; + long int CL; + RDE_STACK LS; + ERROR_STATE* ER; + RDE_STACK ES; + long int ST; + Tcl_Obj* SV; + Tcl_HashTable NC; + + RDE_STACK ast ; + RDE_STACK mark ; + + long int numstr; + char** string; + + ClientData clientData; + } RDE_PARAM_; + typedef int (*UniCharClass) (int); + typedef enum test_class_id { + tc_alnum, + tc_alpha, + tc_ascii, + tc_control, + tc_ddigit, + tc_digit, + tc_graph, + tc_lower, + tc_printable, + tc_punct, + tc_space, + tc_upper, + tc_wordchar, + tc_xdigit + } test_class_id; + static void ast_node_free (void* n); + static void error_state_free (void* es); + static void error_set (RDE_PARAM p, long int s); + static void nc_clear (RDE_PARAM p); + static int UniCharIsAscii (int character); + static int UniCharIsHexDigit (int character); + static int UniCharIsDecDigit (int character); + static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); + static int er_int_compare (const void* a, const void* b); + #define SV_INIT(p) \ + p->SV = NULL; \ + TRACE (("SV_INIT (%p => %p)", (p), (p)->SV)) + #define SV_SET(p,newsv) \ + if (((p)->SV) != (newsv)) { \ + TRACE (("SV_CLEAR/set (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_DecrRefCount ((p)->SV); \ + } \ + (p)->SV = (newsv); \ + TRACE (("SV_SET (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_IncrRefCount ((p)->SV); \ + } \ + } + #define SV_CLEAR(p) \ + TRACE (("SV_CLEAR (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_DecrRefCount ((p)->SV); \ + } \ + (p)->SV = NULL + #define ER_INIT(p) \ + p->ER = NULL; \ + TRACE (("ER_INIT (%p => %p)", (p), (p)->ER)) + #define ER_CLEAR(p) \ + error_state_free ((p)->ER); \ + (p)->ER = NULL + SCOPE RDE_PARAM + rde_param_new (long int nstr, char** strings) + { + RDE_PARAM p; + ENTER ("rde_param_new"); + TRACE (("\tINT %d strings @ %p", nstr, strings)); + p = ALLOC (RDE_PARAM_); + p->numstr = nstr; + p->string = strings; + p->readbuf = Tcl_NewObj (); + Tcl_IncrRefCount (p->readbuf); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + Tcl_InitHashTable (&p->NC, TCL_ONE_WORD_KEYS); + p->IN = NULL; + p->CL = -1; + p->ST = 0; + ER_INIT (p); + SV_INIT (p); + p->CC = NULL; + p->CC_len = 0; + p->TC = rde_tc_new (); + p->ES = rde_stack_new (error_state_free); + p->LS = rde_stack_new (NULL); + p->ast = rde_stack_new (ast_node_free); + p->mark = rde_stack_new (NULL); + RETURN ("%p", p); + } + SCOPE void + rde_param_del (RDE_PARAM p) + { + ENTER ("rde_param_del"); + TRACE (("RDE_PARAM %p",p)); + ER_CLEAR (p); TRACE (("\ter_clear")); + SV_CLEAR (p); TRACE (("\tsv_clear")); + nc_clear (p); TRACE (("\tnc_clear")); + Tcl_DeleteHashTable (&p->NC); TRACE (("\tnc hashtable delete")); + rde_tc_del (p->TC); TRACE (("\ttc clear")); + rde_stack_del (p->ES); TRACE (("\tes clear")); + rde_stack_del (p->LS); TRACE (("\tls clear")); + rde_stack_del (p->ast); TRACE (("\tast clear")); + rde_stack_del (p->mark); TRACE (("\tmark clear")); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + Tcl_DecrRefCount (p->readbuf); + ckfree ((char*) p); + RETURNVOID; + } + SCOPE void + rde_param_reset (RDE_PARAM p, Tcl_Channel chan) + { + ENTER ("rde_param_reset"); + TRACE (("RDE_PARAM %p",p)); + TRACE (("Tcl_Channel %p",chan)); + p->IN = chan; + p->CL = -1; + p->ST = 0; + p->CC = NULL; + p->CC_len = 0; + ER_CLEAR (p); + SV_CLEAR (p); + nc_clear (p); + rde_tc_clear (p->TC); + rde_stack_trim (p->ES, 0); + rde_stack_trim (p->LS, 0); + rde_stack_trim (p->ast, 0); + rde_stack_trim (p->mark, 0); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + RETURNVOID; + } + SCOPE void + rde_param_update_strings (RDE_PARAM p, long int nstr, char** strings) + { + ENTER ("rde_param_update_strings"); + TRACE (("RDE_PARAM %p", p)); + TRACE (("INT %d strings", nstr)); + p->numstr = nstr; + p->string = strings; + RETURNVOID; + } + SCOPE void + rde_param_data (RDE_PARAM p, char* buf, long int len) + { + (void) rde_tc_append (p->TC, buf, len); + } + SCOPE void + rde_param_clientdata (RDE_PARAM p, ClientData clientData) + { + p->clientData = clientData; + } + static void + nc_clear (RDE_PARAM p) + { + Tcl_HashSearch hs; + Tcl_HashEntry* he; + Tcl_HashTable* tablePtr; + for(he = Tcl_FirstHashEntry(&p->NC, &hs); + he != NULL; + he = Tcl_FirstHashEntry(&p->NC, &hs)) { + Tcl_HashSearch hsc; + Tcl_HashEntry* hec; + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (he); + for(hec = Tcl_FirstHashEntry(tablePtr, &hsc); + hec != NULL; + hec = Tcl_NextHashEntry(&hsc)) { + NC_STATE* scs = Tcl_GetHashValue (hec); + error_state_free (scs->ER); + if (scs->SV) { Tcl_DecrRefCount (scs->SV); } + ckfree ((char*) scs); + } + Tcl_DeleteHashTable (tablePtr); + ckfree ((char*) tablePtr); + Tcl_DeleteHashEntry (he); + } + } + SCOPE ClientData + rde_param_query_clientdata (RDE_PARAM p) + { + return p->clientData; + } + SCOPE void + rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) + { + rde_stack_get (p->mark, mc, mv); + } + SCOPE void + rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) + { + rde_stack_get (p->ast, ac, (void***) av); + } + SCOPE const char* + rde_param_query_in (RDE_PARAM p) + { + return p->IN + ? Tcl_GetChannelName (p->IN) + : ""; + } + SCOPE const char* + rde_param_query_cc (RDE_PARAM p, long int* len) + { + *len = p->CC_len; + return p->CC; + } + SCOPE int + rde_param_query_cl (RDE_PARAM p) + { + return p->CL; + } + SCOPE const ERROR_STATE* + rde_param_query_er (RDE_PARAM p) + { + return p->ER; + } + SCOPE Tcl_Obj* + rde_param_query_er_tcl (RDE_PARAM p, const ERROR_STATE* er) + { + Tcl_Obj* res; + if (!er) { + + res = Tcl_NewStringObj ("", 0); + } else { + Tcl_Obj* ov [2]; + Tcl_Obj** mov; + long int mc, i, j; + void** mv; + int lastid; + const char* msg; + rde_stack_get (er->msg, &mc, &mv); + + qsort (mv, mc, sizeof (void*), er_int_compare); + + mov = NALLOC (mc, Tcl_Obj*); + lastid = -1; + for (i=0, j=0; i < mc; i++) { + ASSERT_BOUNDS (i,mc); + if (((long int) mv [i]) == lastid) continue; + lastid = (long int) mv [i]; + ASSERT_BOUNDS((long int) mv[i],p->numstr); + msg = p->string [(long int) mv[i]]; + ASSERT_BOUNDS (j,mc); + mov [j] = Tcl_NewStringObj (msg, -1); + j++; + } + + ov [0] = Tcl_NewIntObj (er->loc); + ov [1] = Tcl_NewListObj (j, mov); + res = Tcl_NewListObj (2, ov); + ckfree ((char*) mov); + } + return res; + } + SCOPE void + rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) + { + rde_stack_get (p->ES, ec, (void***) ev); + } + SCOPE void + rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) + { + rde_stack_get (p->LS, lc, lv); + } + SCOPE long int + rde_param_query_lstop (RDE_PARAM p) + { + (long int) rde_stack_top (p->LS); + } + SCOPE Tcl_HashTable* + rde_param_query_nc (RDE_PARAM p) + { + return &p->NC; + } + SCOPE int + rde_param_query_st (RDE_PARAM p) + { + return p->ST; + } + SCOPE Tcl_Obj* + rde_param_query_sv (RDE_PARAM p) + { + TRACE (("SV_QUERY %p => (%p)", (p), (p)->SV)); \ + return p->SV; + } + SCOPE long int + rde_param_query_tc_size (RDE_PARAM p) + { + return rde_tc_size (p->TC); + } + SCOPE void + rde_param_query_tc_get_s (RDE_PARAM p, long int at, long int last, char** ch, long int* len) + { + rde_tc_get_s (p->TC, at, last, ch, len); + } + SCOPE const char* + rde_param_query_string (RDE_PARAM p, long int id) + { + TRACE (("rde_param_query_string (RDE_PARAM %p, %d/%d)", p, id, p->numstr)); + ASSERT_BOUNDS(id,p->numstr); + return p->string [id]; + } + SCOPE void + rde_param_i_ast_pop_discard (RDE_PARAM p) + { + rde_stack_pop (p->mark, 1); + } + SCOPE void + rde_param_i_ast_pop_rewind (RDE_PARAM p) + { + long int trim = (long int) rde_stack_top (p->mark); + ENTER ("rde_param_i_ast_pop_rewind"); + TRACE (("RDE_PARAM %p",p)); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_ast_rewind (RDE_PARAM p) + { + long int trim = (long int) rde_stack_top (p->mark); + ENTER ("rde_param_i_ast_rewind"); + TRACE (("RDE_PARAM %p",p)); + rde_stack_trim (p->ast, trim); + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_ast_push (RDE_PARAM p) + { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + } + SCOPE void + rde_param_i_ast_value_push (RDE_PARAM p) + { + ENTER ("rde_param_i_ast_value_push"); + TRACE (("RDE_PARAM %p",p)); + ASSERT(p->SV,"Unable to push undefined semantic value"); + TRACE (("rde_param_i_ast_value_push %p => (%p)", p, p->SV)); + TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV->refCount, Tcl_GetString (p->SV))); + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + RETURNVOID; + } + static void + ast_node_free (void* n) + { + Tcl_DecrRefCount ((Tcl_Obj*) n); + } + SCOPE void + rde_param_i_error_clear (RDE_PARAM p) + { + ER_CLEAR (p); + } + SCOPE void + rde_param_i_error_nonterminal (RDE_PARAM p, long int s) + { + + return; + long int pos; + if (!p->ER) return; + pos = 1 + (long int) rde_stack_top (p->LS); + if (p->ER->loc != pos) return; + error_set (p, s); + p->ER->loc = pos; + } + SCOPE void + rde_param_i_error_pop_merge (RDE_PARAM p) + { + ERROR_STATE* top = (ERROR_STATE*) rde_stack_top (p->ES); + + if (top == p->ER) { + rde_stack_pop (p->ES, 1); + return; + } + + if (!top) { + rde_stack_pop (p->ES, 1); + return; + } + + if (!p->ER) { + rde_stack_drop (p->ES, 1); + p->ER = top; + + return; + } + + if (top->loc < p->ER->loc) { + rde_stack_pop (p->ES, 1); + return; + } + + if (top->loc > p->ER->loc) { + rde_stack_drop (p->ES, 1); + error_state_free (p->ER); + p->ER = top; + + return; + } + + rde_stack_move (p->ER->msg, top->msg); + rde_stack_pop (p->ES, 1); + } + SCOPE void + rde_param_i_error_push (RDE_PARAM p) + { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + static void + error_set (RDE_PARAM p, long int s) + { + error_state_free (p->ER); + p->ER = ALLOC (ERROR_STATE); + p->ER->refCount = 1; + p->ER->loc = p->CL; + p->ER->msg = rde_stack_new (NULL); + ASSERT_BOUNDS(s,p->numstr); + rde_stack_push (p->ER->msg, (void*) s); + } + static void + error_state_free (void* esx) + { + ERROR_STATE* es = esx; + if (!es) return; + es->refCount --; + if (es->refCount > 0) return; + rde_stack_del (es->msg); + ckfree ((char*) es); + } + SCOPE void + rde_param_i_loc_pop_discard (RDE_PARAM p) + { + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_loc_pop_rewind (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_loc_push (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + } + SCOPE void + rde_param_i_loc_rewind (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + } + SCOPE void + rde_param_i_input_next (RDE_PARAM p, long int m) + { + int leni; + char* ch; + ASSERT_BOUNDS(m,p->numstr); + p->CL ++; + if (p->CL < rde_tc_size (p->TC)) { + + rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); + + ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); + p->ST = 1; + ER_CLEAR (p); + return; + } + if (!p->IN || + Tcl_Eof (p->IN) || + (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { + + p->ST = 0; + error_set (p, m); + return; + } + + ch = Tcl_GetStringFromObj (p->readbuf, &leni); + ASSERT_BOUNDS (leni, TCL_UTF_MAX); + p->CC = rde_tc_append (p->TC, ch, leni); + p->CC_len = leni; + p->ST = 1; + ER_CLEAR (p); + } + SCOPE void + rde_param_i_status_fail (RDE_PARAM p) + { + p->ST = 0; + } + SCOPE void + rde_param_i_status_ok (RDE_PARAM p) + { + p->ST = 1; + } + SCOPE void + rde_param_i_status_negate (RDE_PARAM p) + { + p->ST = !p->ST; + } + SCOPE int + rde_param_i_symbol_restore (RDE_PARAM p, long int s) + { + NC_STATE* scs; + Tcl_HashEntry* hPtr; + Tcl_HashTable* tablePtr; + + hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); + if (!hPtr) { return 0; } + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); + hPtr = Tcl_FindHashEntry (tablePtr, (char*) s); + if (!hPtr) { return 0; } + + scs = Tcl_GetHashValue (hPtr); + p->CL = scs->CL; + p->ST = scs->ST; + error_state_free (p->ER); + p->ER = scs->ER; + if (p->ER) { p->ER->refCount ++; } + TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); + SV_SET (p, scs->SV); + return 1; + } + SCOPE void + rde_param_i_symbol_save (RDE_PARAM p, long int s) + { + long int at = (long int) rde_stack_top (p->LS); + NC_STATE* scs; + Tcl_HashEntry* hPtr; + Tcl_HashTable* tablePtr; + int isnew; + ENTER ("rde_param_i_symbol_save"); + TRACE (("RDE_PARAM %p",p)); + TRACE (("INT %d",s)); + + hPtr = Tcl_CreateHashEntry (&p->NC, (char*) at, &isnew); + if (isnew) { + tablePtr = ALLOC (Tcl_HashTable); + Tcl_InitHashTable (tablePtr, TCL_ONE_WORD_KEYS); + Tcl_SetHashValue (hPtr, tablePtr); + } else { + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); + } + hPtr = Tcl_CreateHashEntry (tablePtr, (char*) s, &isnew); + if (isnew) { + + scs = ALLOC (NC_STATE); + scs->CL = p->CL; + scs->ST = p->ST; + TRACE (("SV_CACHE (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "")); + scs->SV = p->SV; + if (scs->SV) { Tcl_IncrRefCount (scs->SV); } + scs->ER = p->ER; + if (scs->ER) { scs->ER->refCount ++; } + Tcl_SetHashValue (hPtr, scs); + } else { + + scs = (NC_STATE*) Tcl_GetHashValue (hPtr); + scs->CL = p->CL; + scs->ST = p->ST; + TRACE (("SV_CACHE/over (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "" )); + if (scs->SV) { Tcl_DecrRefCount (scs->SV); } + scs->SV = p->SV; + if (scs->SV) { Tcl_IncrRefCount (scs->SV); } + error_state_free (scs->ER); + scs->ER = p->ER; + if (scs->ER) { scs->ER->refCount ++; } + } + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_test_alnum (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsAlnum, tc_alnum); + } + SCOPE void + rde_param_i_test_alpha (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsAlpha, tc_alpha); + } + SCOPE void + rde_param_i_test_ascii (RDE_PARAM p) + { + test_class (p, UniCharIsAscii, tc_ascii); + } + SCOPE void + rde_param_i_test_control (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsControl, tc_control); + } + SCOPE void + rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) + { + ASSERT_BOUNDS(msg,p->numstr); + p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, msg); + p->CL --; + } + } + SCOPE void + rde_param_i_test_ddigit (RDE_PARAM p) + { + test_class (p, UniCharIsDecDigit, tc_ddigit); + } + SCOPE void + rde_param_i_test_digit (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsDigit, tc_digit); + } + SCOPE void + rde_param_i_test_graph (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsGraph, tc_graph); + } + SCOPE void + rde_param_i_test_lower (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsLower, tc_lower); + } + SCOPE void + rde_param_i_test_print (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsPrint, tc_printable); + } + SCOPE void + rde_param_i_test_punct (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsPunct, tc_punct); + } + SCOPE void + rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) + { + ASSERT_BOUNDS(msg,p->numstr); + p->ST = + (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && + (Tcl_UtfNcmp (p->CC, e, 1) <= 0); + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, msg); + p->CL --; + } + } + SCOPE void + rde_param_i_test_space (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsSpace, tc_space); + } + SCOPE void + rde_param_i_test_upper (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsUpper, tc_upper); + } + SCOPE void + rde_param_i_test_wordchar (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsWordChar, tc_wordchar); + } + SCOPE void + rde_param_i_test_xdigit (RDE_PARAM p) + { + test_class (p, UniCharIsHexDigit, tc_xdigit); + } + static void + test_class (RDE_PARAM p, UniCharClass class, test_class_id id) + { + Tcl_UniChar ch; + Tcl_UtfToUniChar(p->CC, &ch); + ASSERT_BOUNDS(id,p->numstr); + p->ST = !!class (ch); + + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, id); + p->CL --; + } + } + static int + UniCharIsAscii (int character) + { + return (character >= 0) && (character < 0x80); + } + static int + UniCharIsHexDigit (int character) + { + return (character >= 0) && (character < 0x80) && isxdigit(character); + } + static int + UniCharIsDecDigit (int character) + { + return (character >= 0) && (character < 0x80) && isdigit(character); + } + SCOPE void + rde_param_i_value_clear (RDE_PARAM p) + { + SV_CLEAR (p); + } + SCOPE void + rde_param_i_value_leaf (RDE_PARAM p, long int s) + { + Tcl_Obj* newsv; + Tcl_Obj* ov [3]; + long int pos = 1 + (long int) rde_stack_top (p->LS); + ASSERT_BOUNDS(s,p->numstr); + ov [0] = Tcl_NewStringObj (p->string[s], -1); + ov [1] = Tcl_NewIntObj (pos); + ov [2] = Tcl_NewIntObj (p->CL); + newsv = Tcl_NewListObj (3, ov); + TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); + SV_SET (p, newsv); + } + SCOPE void + rde_param_i_value_reduce (RDE_PARAM p, long int s) + { + Tcl_Obj* newsv; + int oc, i, j; + Tcl_Obj** ov; + long int ac; + Tcl_Obj** av; + long int pos = 1 + (long int) rde_stack_top (p->LS); + long int mark = (long int) rde_stack_top (p->mark); + long int asize = rde_stack_size (p->ast); + long int new = asize - mark; + ASSERT (new >= 0, "Bad number of elements to reduce"); + ov = NALLOC (3+new, Tcl_Obj*); + ASSERT_BOUNDS(s,p->numstr); + ov [0] = Tcl_NewStringObj (p->string[s], -1); + ov [1] = Tcl_NewIntObj (pos); + ov [2] = Tcl_NewIntObj (p->CL); + rde_stack_get (p->ast, &ac, (void***) &av); + for (i = 3, j = mark; j < asize; i++, j++) { + ASSERT_BOUNDS (i, 3+new); + ASSERT_BOUNDS (j, ac); + ov [i] = av [j]; + } + ASSERT (i == 3+new, "Reduction result incomplete"); + newsv = Tcl_NewListObj (3+new, ov); + TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); + SV_SET (p, newsv); + ckfree ((char*) ov); + } + static int + er_int_compare (const void* a, const void* b) + { + + const void** ael = (const void**) a; + const void** bel = (const void**) b; + long int avalue = (long int) *ael; + long int bvalue = (long int) *bel; + if (avalue < bvalue) { return -1; } + if (avalue > bvalue) { return 1; } + return 0; + } + SCOPE int + rde_param_i_symbol_start (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) { + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + return 1; + } + rde_stack_push (p->LS, (void*) p->CL); + return 0; + } + SCOPE int + rde_param_i_symbol_start_d (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) { + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + return 1; + } + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + return 0; + } + SCOPE int + rde_param_i_symbol_void_start (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) return 1; + rde_stack_push (p->LS, (void*) p->CL); + return 0; + } + SCOPE int + rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) return 1; + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + return 0; + } + SCOPE void + rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_reduce (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_leaf (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_leaf (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) + { + SV_CLEAR (p); + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) + { + SV_CLEAR (p); + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_char (p, c, m); + } + SCOPE void + rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_range (p, s, e, m); + } + SCOPE void + rde_param_i_next_alnum (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_alnum (p); + } + SCOPE void + rde_param_i_next_alpha (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_alpha (p); + } + SCOPE void + rde_param_i_next_ascii (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_ascii (p); + } + SCOPE void + rde_param_i_next_control (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_control (p); + } + SCOPE void + rde_param_i_next_ddigit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_ddigit (p); + } + SCOPE void + rde_param_i_next_digit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_digit (p); + } + SCOPE void + rde_param_i_next_graph (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_graph (p); + } + SCOPE void + rde_param_i_next_lower (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_lower (p); + } + SCOPE void + rde_param_i_next_print (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_print (p); + } + SCOPE void + rde_param_i_next_punct (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_punct (p); + } + SCOPE void + rde_param_i_next_space (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_space (p); + } + SCOPE void + rde_param_i_next_upper (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_upper (p); + } + SCOPE void + rde_param_i_next_wordchar (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_wordchar (p); + } + SCOPE void + rde_param_i_next_xdigit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_xdigit (p); + } + SCOPE void + rde_param_i_notahead_start_d (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + } + SCOPE void + rde_param_i_notahead_exit_d (RDE_PARAM p) + { + if (p->ST) { + rde_param_i_ast_pop_rewind (p); + } else { + rde_stack_pop (p->mark, 1); + } + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + p->ST = !p->ST; + } + SCOPE void + rde_param_i_notahead_exit (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + p->ST = !p->ST; + } + SCOPE void + rde_param_i_state_push_2 (RDE_PARAM p) + { + + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + SCOPE void + rde_param_i_state_push_void (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + ER_CLEAR (p); + rde_stack_push (p->ES, p->ER); + + } + SCOPE void + rde_param_i_state_push_value (RDE_PARAM p) + { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + rde_stack_push (p->LS, (void*) p->CL); + ER_CLEAR (p); + rde_stack_push (p->ES, p->ER); + + } + SCOPE void + rde_param_i_state_merge_ok (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + p->ST = 1; + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_state_merge_void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_state_merge_value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } + SCOPE int + rde_param_i_kleene_close (RDE_PARAM p) + { + int stop = !p->ST; + rde_param_i_error_pop_merge (p); + if (stop) { + p->ST = 1; + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + return stop; + } + SCOPE int + rde_param_i_kleene_abort (RDE_PARAM p) + { + int stop = !p->ST; + if (stop) { + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + return stop; + } + SCOPE int + rde_param_i_seq_void2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_seq_void2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_seq_value2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_bra_void2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->LS, 1); + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_void2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->LS, 1); + } else { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_value2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_value2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE void + rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) + { + int at = p->CL; + + while (*str) { + rde_param_i_input_next (p, m); + if (!p->ST) { + p->ER->loc = at+1; + p->CL = at; + return; + } + rde_param_i_test_char (p, str, m); + if (!p->ST) { + p->ER->loc = at+1; + p->CL = at; + return; + } + str = Tcl_UtfNext (str); + } + } + SCOPE void + rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + while (*class) { + p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; + if (p->ST) { + ER_CLEAR (p); + return; + } + class = Tcl_UtfNext (class); + } + error_set (p, m); + p->CL --; + } + + + /* + * Declaring the parse functions + */ + + static void optional_2 (RDE_PARAM p); + + /* + * Precomputed table of strings (symbols, error messages, etc.). + */ + + static char const* p_string [15] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "t a" + }; + + /* + * Grammar Start Expression + */ + + static void MAIN (RDE_PARAM p) { + optional_2 (p); + return; + } + + static void optional_2 (RDE_PARAM p) { + /* + * ? + * 'a' + */ + + rde_param_i_state_push_2 (p); + rde_param_i_next_char (p, "a", 14); + rde_param_i_state_merge_ok (p); + return; + } + + /* -*- c -*- */ + + typedef struct PARSERg { + long int counter; + char buf [50]; + } PARSERg; + + static void + PARSERgRelease (ClientData cd, Tcl_Interp* interp) + { + ckfree((char*) cd); + } + + static const char* + PARSERnewName (Tcl_Interp* interp) + { +#define KEY "tcllib/parser/PACKAGE/TEA" + + Tcl_InterpDeleteProc* proc = PARSERgRelease; + PARSERg* parserg; + + parserg = Tcl_GetAssocData (interp, KEY, &proc); + if (parserg == NULL) { + parserg = (PARSERg*) ckalloc (sizeof (PARSERg)); + parserg->counter = 0; + + Tcl_SetAssocData (interp, KEY, proc, + (ClientData) parserg); + } + + parserg->counter ++; + sprintf (parserg->buf, "PARSER%ld", parserg->counter); + return parserg->buf; +#undef KEY + } + + static void + PARSERdeleteCmd (ClientData clientData) + { + /* + * Release the whole PARSER + * (Low-level engine only actually). + */ + rde_param_del ((RDE_PARAM) clientData); + } + + + /* * ** *** ***** ******** ************* + ** Functions implementing the object methods, and helper. + */ + + static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp); + + static int parser_PARSE (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + int mode; + Tcl_Channel chan; + + if (objc != 3) { + Tcl_WrongNumArgs (interp, 2, objv, "chan"); + return TCL_ERROR; + } + + chan = Tcl_GetChannel(interp, + Tcl_GetString (objv[2]), + &mode); + + if (!chan) { + return TCL_ERROR; + } + + rde_param_reset (p, chan); + MAIN (p) ; /* Entrypoint for the generated code. */ + return COMPLETE (p, interp); + } + + static int parser_PARSET (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + char* buf; + int len; + + if (objc != 3) { + Tcl_WrongNumArgs (interp, 2, objv, "text"); + return TCL_ERROR; + } + + buf = Tcl_GetStringFromObj (objv[2], &len); + + rde_param_reset (p, NULL); + rde_param_data (p, buf, len); + MAIN (p) ; /* Entrypoint for the generated code. */ + return COMPLETE (p, interp); + } + + /* See also rde_critcl/m.c, param_COMPLETE() */ + static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) + { + if (rde_param_query_st (p)) { + long int ac; + Tcl_Obj** av; + + rde_param_query_ast (p, &ac, &av); + + if (ac > 1) { + Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); + + memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); + lv [0] = Tcl_NewObj (); + lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); + lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); + + Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); + ckfree ((char*) lv); + + } else if (ac == 0) { + /* + * Match, but no AST. This is possible if the grammar + * consists of only the start expression. + */ + Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); + } else { + Tcl_SetObjResult (interp, av [0]); + } + + return TCL_OK; + } else { + Tcl_Obj* xv [1]; + const ERROR_STATE* er = rde_param_query_er (p); + Tcl_Obj* res = rde_param_query_er_tcl (p, er); + /* res = list (location, list(msg)) */ + + /* Stick the exception type-tag before the existing elements */ + xv [0] = Tcl_NewStringObj ("pt::rde",-1); + Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); + + Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); + Tcl_SetObjResult (interp, res); + return TCL_ERROR; + } + } + + + /* * ** *** ***** ******** ************* + ** Object command, method dispatch. + */ + static int parser_objcmd (ClientData cd, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + RDE_PARAM p = (RDE_PARAM) cd; + int m, res; + + static CONST char* methods [] = { + "destroy", "parse", "parset", NULL + }; + enum methods { + M_DESTROY, M_PARSE, M_PARSET + }; + + if (objc < 2) { + Tcl_WrongNumArgs (interp, objc, objv, "option ?arg arg ...?"); + return TCL_ERROR; + } else if (Tcl_GetIndexFromObj (interp, objv [1], methods, "option", + 0, &m) != TCL_OK) { + return TCL_ERROR; + } + + /* Dispatch to methods. They check the #args in + * detail before performing the requested + * functionality + */ + + switch (m) { + case M_DESTROY: + if (objc != 2) { + Tcl_WrongNumArgs (interp, 2, objv, NULL); + return TCL_ERROR; + } + + Tcl_DeleteCommandFromToken(interp, (Tcl_Command) rde_param_query_clientdata (p)); + return TCL_OK; + + case M_PARSE: res = parser_PARSE (p, interp, objc, objv); break; + case M_PARSET: res = parser_PARSET (p, interp, objc, objv); break; + default: + /* Not coming to this place */ + ASSERT (0,"Reached unreachable location"); + } + + return res; + } + + /** * ** *** ***** ******** ************* + * Class command, i.e. object construction. + */ + static int ParserClassCmd (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const*objv) { + /* + * Syntax: No arguments beyond the name + */ + + RDE_PARAM parser; + CONST char* name; + Tcl_Obj* fqn; + Tcl_CmdInfo ci; + Tcl_Command c; + +#define USAGE "?name?" + + if ((objc != 2) && (objc != 1)) { + Tcl_WrongNumArgs (interp, 1, objv, USAGE); + return TCL_ERROR; + } + + if (objc < 2) { + name = PARSERnewName (interp); + } else { + name = Tcl_GetString (objv [1]); + } + + if (!Tcl_StringMatch (name, "::*")) { + /* Relative name. Prefix with current namespace */ + + Tcl_Eval (interp, "namespace current"); + fqn = Tcl_GetObjResult (interp); + fqn = Tcl_DuplicateObj (fqn); + Tcl_IncrRefCount (fqn); + + if (!Tcl_StringMatch (Tcl_GetString (fqn), "::")) { + Tcl_AppendToObj (fqn, "::", -1); + } + Tcl_AppendToObj (fqn, name, -1); + } else { + fqn = Tcl_NewStringObj (name, -1); + Tcl_IncrRefCount (fqn); + } + Tcl_ResetResult (interp); + + if (Tcl_GetCommandInfo (interp, + Tcl_GetString (fqn), + &ci)) { + Tcl_Obj* err; + + err = Tcl_NewObj (); + Tcl_AppendToObj (err, "command \"", -1); + Tcl_AppendObjToObj (err, fqn); + Tcl_AppendToObj (err, "\" already exists", -1); + + Tcl_DecrRefCount (fqn); + Tcl_SetObjResult (interp, err); + return TCL_ERROR; + } + + parser = rde_param_new (sizeof(p_string)/sizeof(char*), (char**) p_string); + c = Tcl_CreateObjCommand (interp, Tcl_GetString (fqn), + parser_objcmd, (ClientData) parser, + PARSERdeleteCmd); + rde_param_clientdata (parser, (ClientData) c); + Tcl_SetObjResult (interp, fqn); + Tcl_DecrRefCount (fqn); + return TCL_OK; + } + +int Package_Init(Tcl_Interp* interp) { + if (interp == 0) return TCL_ERROR; + + if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { + return TCL_ERROR; + } + + if (Tcl_CreateObjCommand(interp, "PARSER", ParserClassCmd , NULL, NULL) == NULL) { + Tcl_SetResult(interp, "Can't create constructor", NULL); + return TCL_ERROR; + } + + + Tcl_PkgProvide(interp, "PACKAGE", "0.1"); + + return TCL_OK; +} ADDED modules/pt/tests/data/ok/peg_cparam-tea/7_kleene Index: modules/pt/tests/data/ok/peg_cparam-tea/7_kleene ================================================================== --- /dev/null +++ modules/pt/tests/data/ok/peg_cparam-tea/7_kleene @@ -0,0 +1,2001 @@ +/************************************************************ +** +** TEA-based C/PARAM implementation of the parsing +** expression grammar +** +** TEMPLATE +** +** Generated from file TEST +** for user unknown +** +* * ** *** ***** ******** ************* *********************/ + #include + #include + #include + #include + #define SCOPE static + +#line 1 "rde_critcl/util.h" + + #ifndef _RDE_UTIL_H + #define _RDE_UTIL_H 1 + #ifndef SCOPE + #define SCOPE + #endif + #define ALLOC(type) (type *) ckalloc (sizeof (type)) + #define NALLOC(n,type) (type *) ckalloc ((n) * sizeof (type)) + #undef RDE_DEBUG + #define RDE_DEBUG 1 + #undef RDE_TRACE + #ifdef RDE_DEBUG + #define STOPAFTER(x) { static int count = (x); count --; if (!count) { Tcl_Panic ("stop"); } } + #define XSTR(x) #x + #define STR(x) XSTR(x) + #define RANGEOK(i,n) ((0 <= (i)) && (i < (n))) + #define ASSERT(x,msg) if (!(x)) { Tcl_Panic (msg " (" #x "), in file " __FILE__ " @line " STR(__LINE__));} + #define ASSERT_BOUNDS(i,n) ASSERT (RANGEOK(i,n),"array index out of bounds: " STR(i) " >= " STR(n)) + #else + #define STOPAFTER(x) + #define ASSERT(x,msg) + #define ASSERT_BOUNDS(i,n) + #endif + #ifdef RDE_TRACE + SCOPE void trace_enter (const char* fun); + SCOPE void trace_return (const char *pat, ...); + SCOPE void trace_printf (const char *pat, ...); + #define ENTER(fun) trace_enter (fun) + #define RETURN(format,x) trace_return (format,x) ; return x + #define RETURNVOID trace_return ("%s","(void)") ; return + #define TRACE0(x) trace_printf0 x + #define TRACE(x) trace_printf x + #else + #define ENTER(fun) + #define RETURN(f,x) return x + #define RETURNVOID return + #define TRACE0(x) + #define TRACE(x) + #endif + #endif + + +#line 1 "rde_critcl/stack.h" + + #ifndef _RDE_DS_STACK_H + #define _RDE_DS_STACK_H 1 + typedef void (*RDE_STACK_CELL_FREE) (void* cell); + typedef struct RDE_STACK_* RDE_STACK; + static const int RDE_STACK_INITIAL_SIZE = 256; + #endif + + +#line 1 "rde_critcl/tc.h" + + #ifndef _RDE_DS_TC_H + #define _RDE_DS_TC_H 1 + typedef struct RDE_TC_* RDE_TC; + #endif + + +#line 1 "rde_critcl/param.h" + + #ifndef _RDE_DS_PARAM_H + #define _RDE_DS_PARAM_H 1 + typedef struct RDE_PARAM_* RDE_PARAM; + typedef struct ERROR_STATE { + int refCount; + long int loc; + RDE_STACK msg; + } ERROR_STATE; + typedef struct NC_STATE { + long int CL; + long int ST; + Tcl_Obj* SV; + ERROR_STATE* ER; + } NC_STATE; + #endif + + +#line 1 "rde_critcl/util.c" + + #ifdef RDE_TRACE + typedef struct F_STACK { + const char* str; + struct F_STACK* down; + } F_STACK; + static F_STACK* top = 0; + static int level = 0; + static void + push (const char* str) + { + F_STACK* new = ALLOC (F_STACK); + new->str = str; + new->down = top; + top = new; + level += 4; + } + static void + pop (void) + { + F_STACK* next = top->down; + level -= 4; + ckfree ((char*)top); + top = next; + } + static void + indent (void) + { + int i; + for (i = 0; i < level; i++) { + fwrite(" ", 1, 1, stdout); + fflush (stdout); + } + if (top) { + fwrite(top->str, 1, strlen(top->str), stdout); + fflush (stdout); + } + fwrite(" ", 1, 1, stdout); + fflush (stdout); + } + SCOPE void + trace_enter (const char* fun) + { + push (fun); + indent(); + fwrite("ENTER\n", 1, 6, stdout); + fflush (stdout); + } + static char msg [1024*1024]; + SCOPE void + trace_return (const char *pat, ...) + { + int len; + va_list args; + indent(); + fwrite("RETURN = ", 1, 9, stdout); + fflush (stdout); + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + pop(); + } + SCOPE void + trace_printf (const char *pat, ...) + { + int len; + va_list args; + indent(); + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + } + SCOPE void + trace_printf0 (const char *pat, ...) + { + int len; + va_list args; + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + } + #endif + + +#line 1 "rde_critcl/stack.c" + + typedef struct RDE_STACK_ { + long int max; + long int top; + RDE_STACK_CELL_FREE freeCellProc; + void** cell; + } RDE_STACK_; + + SCOPE RDE_STACK + rde_stack_new (RDE_STACK_CELL_FREE freeCellProc) + { + RDE_STACK s = ALLOC (RDE_STACK_); + s->cell = NALLOC (RDE_STACK_INITIAL_SIZE, void*); + s->max = RDE_STACK_INITIAL_SIZE; + s->top = 0; + s->freeCellProc = freeCellProc; + return s; + } + SCOPE void + rde_stack_del (RDE_STACK s) + { + if (s->freeCellProc && s->top) { + long int i; + for (i=0; i < s->top; i++) { + ASSERT_BOUNDS(i,s->max); + s->freeCellProc ( s->cell [i] ); + } + } + ckfree ((char*) s->cell); + ckfree ((char*) s); + } + SCOPE void + rde_stack_push (RDE_STACK s, void* item) + { + if (s->top >= s->max) { + long int new = s->max ? (2 * s->max) : RDE_STACK_INITIAL_SIZE; + void** cell = (void**) ckrealloc ((char*) s->cell, new * sizeof(void*)); + ASSERT (cell,"Memory allocation failure for RDE stack"); + s->max = new; + s->cell = cell; + } + ASSERT_BOUNDS(s->top,s->max); + s->cell [s->top] = item; + s->top ++; + } + SCOPE void* + rde_stack_top (RDE_STACK s) + { + ASSERT_BOUNDS(s->top-1,s->max); + return s->cell [s->top - 1]; + } + SCOPE void + rde_stack_pop (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad pop count"); + if (n == 0) return; + if (s->freeCellProc) { + while (n) { + s->top --; + ASSERT_BOUNDS(s->top,s->max); + s->freeCellProc ( s->cell [s->top] ); + n --; + } + } else { + s->top -= n; + } + } + SCOPE void + rde_stack_trim (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad trimsize"); + if (s->freeCellProc) { + while (s->top > n) { + s->top --; + ASSERT_BOUNDS(s->top,s->max); + s->freeCellProc ( s->cell [s->top] ); + } + } else { + s->top = n; + } + } + SCOPE void + rde_stack_drop (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad pop count"); + if (n == 0) return; + s->top -= n; + } + SCOPE void + rde_stack_move (RDE_STACK dst, RDE_STACK src) + { + ASSERT (dst->freeCellProc == src->freeCellProc, "Ownership mismatch"); + + while (src->top > 0) { + src->top --; + ASSERT_BOUNDS(src->top,src->max); + rde_stack_push (dst, src->cell [src->top] ); + } + } + SCOPE void + rde_stack_get (RDE_STACK s, long int* cn, void*** cc) + { + *cn = s->top; + *cc = s->cell; + } + SCOPE long int + rde_stack_size (RDE_STACK s) + { + return s->top; + } + + +#line 1 "rde_critcl/tc.c" + + typedef struct RDE_TC_ { + int max; + int num; + char* str; + RDE_STACK off; + } RDE_TC_; + + SCOPE RDE_TC + rde_tc_new (void) + { + RDE_TC tc = ALLOC (RDE_TC_); + tc->max = RDE_STACK_INITIAL_SIZE; + tc->num = 0; + tc->str = NALLOC (RDE_STACK_INITIAL_SIZE, char); + tc->off = rde_stack_new (NULL); + return tc; + } + SCOPE void + rde_tc_del (RDE_TC tc) + { + rde_stack_del (tc->off); + ckfree (tc->str); + ckfree ((char*) tc); + } + SCOPE long int + rde_tc_size (RDE_TC tc) + { + return rde_stack_size (tc->off); + } + SCOPE void + rde_tc_clear (RDE_TC tc) + { + tc->num = 0; + rde_stack_trim (tc->off, 0); + } + SCOPE char* + rde_tc_append (RDE_TC tc, char* string, long int len) + { + long int base = tc->num; + long int off = tc->num; + char* ch; + int clen; + Tcl_UniChar uni; + if (len < 0) { + len = strlen (string); + } + + if (!len) { + return tc->str + base; + } + + if ((tc->num + len) >= tc->max) { + int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); + char* str = ckrealloc (tc->str, new * sizeof(char)); + ASSERT (str,"Memory allocation failure for token character array"); + tc->max = new; + tc->str = str; + } + tc->num += len; + ASSERT_BOUNDS(tc->num,tc->max); + ASSERT_BOUNDS(off,tc->max); + ASSERT_BOUNDS(off+len-1,tc->max); + ASSERT_BOUNDS(off+len-1,tc->num); + memcpy (tc->str + off, string, len); + + ch = string; + while (ch < (string + len)) { + ASSERT_BOUNDS(off,tc->num); + rde_stack_push (tc->off, (void*) off); + clen = Tcl_UtfToUniChar (ch, &uni); + off += clen; + ch += clen; + } + return tc->str + base; + } + SCOPE void + rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) + { + long int oc, off, top, end; + void** ov; + rde_stack_get (tc->off, &oc, &ov); + ASSERT_BOUNDS(at,oc); + off = (long int) ov [at]; + if ((at+1) == oc) { + end = tc->num; + } else { + end = (long int) ov [at+1]; + } + TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); + ASSERT_BOUNDS(off,tc->num); + ASSERT_BOUNDS(end-1,tc->num); + *ch = tc->str + off; + *len = end - off; + } + SCOPE void + rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) + { + long int oc, off, top, end; + void** ov; + rde_stack_get (tc->off, &oc, &ov); + ASSERT_BOUNDS(at,oc); + ASSERT_BOUNDS(last,oc); + off = (long int) ov [at]; + if ((last+1) == oc) { + end = tc->num; + } else { + end = (long int) ov [last+1]; + } + TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); + ASSERT_BOUNDS(off,tc->num); + ASSERT_BOUNDS(end-1,tc->num); + *ch = tc->str + off; + *len = end - off; + } + + +#line 1 "rde_critcl/param.c" + + typedef struct RDE_PARAM_ { + Tcl_Channel IN; + Tcl_Obj* readbuf; + char* CC; + long int CC_len; + RDE_TC TC; + long int CL; + RDE_STACK LS; + ERROR_STATE* ER; + RDE_STACK ES; + long int ST; + Tcl_Obj* SV; + Tcl_HashTable NC; + + RDE_STACK ast ; + RDE_STACK mark ; + + long int numstr; + char** string; + + ClientData clientData; + } RDE_PARAM_; + typedef int (*UniCharClass) (int); + typedef enum test_class_id { + tc_alnum, + tc_alpha, + tc_ascii, + tc_control, + tc_ddigit, + tc_digit, + tc_graph, + tc_lower, + tc_printable, + tc_punct, + tc_space, + tc_upper, + tc_wordchar, + tc_xdigit + } test_class_id; + static void ast_node_free (void* n); + static void error_state_free (void* es); + static void error_set (RDE_PARAM p, long int s); + static void nc_clear (RDE_PARAM p); + static int UniCharIsAscii (int character); + static int UniCharIsHexDigit (int character); + static int UniCharIsDecDigit (int character); + static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); + static int er_int_compare (const void* a, const void* b); + #define SV_INIT(p) \ + p->SV = NULL; \ + TRACE (("SV_INIT (%p => %p)", (p), (p)->SV)) + #define SV_SET(p,newsv) \ + if (((p)->SV) != (newsv)) { \ + TRACE (("SV_CLEAR/set (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_DecrRefCount ((p)->SV); \ + } \ + (p)->SV = (newsv); \ + TRACE (("SV_SET (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_IncrRefCount ((p)->SV); \ + } \ + } + #define SV_CLEAR(p) \ + TRACE (("SV_CLEAR (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_DecrRefCount ((p)->SV); \ + } \ + (p)->SV = NULL + #define ER_INIT(p) \ + p->ER = NULL; \ + TRACE (("ER_INIT (%p => %p)", (p), (p)->ER)) + #define ER_CLEAR(p) \ + error_state_free ((p)->ER); \ + (p)->ER = NULL + SCOPE RDE_PARAM + rde_param_new (long int nstr, char** strings) + { + RDE_PARAM p; + ENTER ("rde_param_new"); + TRACE (("\tINT %d strings @ %p", nstr, strings)); + p = ALLOC (RDE_PARAM_); + p->numstr = nstr; + p->string = strings; + p->readbuf = Tcl_NewObj (); + Tcl_IncrRefCount (p->readbuf); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + Tcl_InitHashTable (&p->NC, TCL_ONE_WORD_KEYS); + p->IN = NULL; + p->CL = -1; + p->ST = 0; + ER_INIT (p); + SV_INIT (p); + p->CC = NULL; + p->CC_len = 0; + p->TC = rde_tc_new (); + p->ES = rde_stack_new (error_state_free); + p->LS = rde_stack_new (NULL); + p->ast = rde_stack_new (ast_node_free); + p->mark = rde_stack_new (NULL); + RETURN ("%p", p); + } + SCOPE void + rde_param_del (RDE_PARAM p) + { + ENTER ("rde_param_del"); + TRACE (("RDE_PARAM %p",p)); + ER_CLEAR (p); TRACE (("\ter_clear")); + SV_CLEAR (p); TRACE (("\tsv_clear")); + nc_clear (p); TRACE (("\tnc_clear")); + Tcl_DeleteHashTable (&p->NC); TRACE (("\tnc hashtable delete")); + rde_tc_del (p->TC); TRACE (("\ttc clear")); + rde_stack_del (p->ES); TRACE (("\tes clear")); + rde_stack_del (p->LS); TRACE (("\tls clear")); + rde_stack_del (p->ast); TRACE (("\tast clear")); + rde_stack_del (p->mark); TRACE (("\tmark clear")); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + Tcl_DecrRefCount (p->readbuf); + ckfree ((char*) p); + RETURNVOID; + } + SCOPE void + rde_param_reset (RDE_PARAM p, Tcl_Channel chan) + { + ENTER ("rde_param_reset"); + TRACE (("RDE_PARAM %p",p)); + TRACE (("Tcl_Channel %p",chan)); + p->IN = chan; + p->CL = -1; + p->ST = 0; + p->CC = NULL; + p->CC_len = 0; + ER_CLEAR (p); + SV_CLEAR (p); + nc_clear (p); + rde_tc_clear (p->TC); + rde_stack_trim (p->ES, 0); + rde_stack_trim (p->LS, 0); + rde_stack_trim (p->ast, 0); + rde_stack_trim (p->mark, 0); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + RETURNVOID; + } + SCOPE void + rde_param_update_strings (RDE_PARAM p, long int nstr, char** strings) + { + ENTER ("rde_param_update_strings"); + TRACE (("RDE_PARAM %p", p)); + TRACE (("INT %d strings", nstr)); + p->numstr = nstr; + p->string = strings; + RETURNVOID; + } + SCOPE void + rde_param_data (RDE_PARAM p, char* buf, long int len) + { + (void) rde_tc_append (p->TC, buf, len); + } + SCOPE void + rde_param_clientdata (RDE_PARAM p, ClientData clientData) + { + p->clientData = clientData; + } + static void + nc_clear (RDE_PARAM p) + { + Tcl_HashSearch hs; + Tcl_HashEntry* he; + Tcl_HashTable* tablePtr; + for(he = Tcl_FirstHashEntry(&p->NC, &hs); + he != NULL; + he = Tcl_FirstHashEntry(&p->NC, &hs)) { + Tcl_HashSearch hsc; + Tcl_HashEntry* hec; + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (he); + for(hec = Tcl_FirstHashEntry(tablePtr, &hsc); + hec != NULL; + hec = Tcl_NextHashEntry(&hsc)) { + NC_STATE* scs = Tcl_GetHashValue (hec); + error_state_free (scs->ER); + if (scs->SV) { Tcl_DecrRefCount (scs->SV); } + ckfree ((char*) scs); + } + Tcl_DeleteHashTable (tablePtr); + ckfree ((char*) tablePtr); + Tcl_DeleteHashEntry (he); + } + } + SCOPE ClientData + rde_param_query_clientdata (RDE_PARAM p) + { + return p->clientData; + } + SCOPE void + rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) + { + rde_stack_get (p->mark, mc, mv); + } + SCOPE void + rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) + { + rde_stack_get (p->ast, ac, (void***) av); + } + SCOPE const char* + rde_param_query_in (RDE_PARAM p) + { + return p->IN + ? Tcl_GetChannelName (p->IN) + : ""; + } + SCOPE const char* + rde_param_query_cc (RDE_PARAM p, long int* len) + { + *len = p->CC_len; + return p->CC; + } + SCOPE int + rde_param_query_cl (RDE_PARAM p) + { + return p->CL; + } + SCOPE const ERROR_STATE* + rde_param_query_er (RDE_PARAM p) + { + return p->ER; + } + SCOPE Tcl_Obj* + rde_param_query_er_tcl (RDE_PARAM p, const ERROR_STATE* er) + { + Tcl_Obj* res; + if (!er) { + + res = Tcl_NewStringObj ("", 0); + } else { + Tcl_Obj* ov [2]; + Tcl_Obj** mov; + long int mc, i, j; + void** mv; + int lastid; + const char* msg; + rde_stack_get (er->msg, &mc, &mv); + + qsort (mv, mc, sizeof (void*), er_int_compare); + + mov = NALLOC (mc, Tcl_Obj*); + lastid = -1; + for (i=0, j=0; i < mc; i++) { + ASSERT_BOUNDS (i,mc); + if (((long int) mv [i]) == lastid) continue; + lastid = (long int) mv [i]; + ASSERT_BOUNDS((long int) mv[i],p->numstr); + msg = p->string [(long int) mv[i]]; + ASSERT_BOUNDS (j,mc); + mov [j] = Tcl_NewStringObj (msg, -1); + j++; + } + + ov [0] = Tcl_NewIntObj (er->loc); + ov [1] = Tcl_NewListObj (j, mov); + res = Tcl_NewListObj (2, ov); + ckfree ((char*) mov); + } + return res; + } + SCOPE void + rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) + { + rde_stack_get (p->ES, ec, (void***) ev); + } + SCOPE void + rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) + { + rde_stack_get (p->LS, lc, lv); + } + SCOPE long int + rde_param_query_lstop (RDE_PARAM p) + { + (long int) rde_stack_top (p->LS); + } + SCOPE Tcl_HashTable* + rde_param_query_nc (RDE_PARAM p) + { + return &p->NC; + } + SCOPE int + rde_param_query_st (RDE_PARAM p) + { + return p->ST; + } + SCOPE Tcl_Obj* + rde_param_query_sv (RDE_PARAM p) + { + TRACE (("SV_QUERY %p => (%p)", (p), (p)->SV)); \ + return p->SV; + } + SCOPE long int + rde_param_query_tc_size (RDE_PARAM p) + { + return rde_tc_size (p->TC); + } + SCOPE void + rde_param_query_tc_get_s (RDE_PARAM p, long int at, long int last, char** ch, long int* len) + { + rde_tc_get_s (p->TC, at, last, ch, len); + } + SCOPE const char* + rde_param_query_string (RDE_PARAM p, long int id) + { + TRACE (("rde_param_query_string (RDE_PARAM %p, %d/%d)", p, id, p->numstr)); + ASSERT_BOUNDS(id,p->numstr); + return p->string [id]; + } + SCOPE void + rde_param_i_ast_pop_discard (RDE_PARAM p) + { + rde_stack_pop (p->mark, 1); + } + SCOPE void + rde_param_i_ast_pop_rewind (RDE_PARAM p) + { + long int trim = (long int) rde_stack_top (p->mark); + ENTER ("rde_param_i_ast_pop_rewind"); + TRACE (("RDE_PARAM %p",p)); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_ast_rewind (RDE_PARAM p) + { + long int trim = (long int) rde_stack_top (p->mark); + ENTER ("rde_param_i_ast_rewind"); + TRACE (("RDE_PARAM %p",p)); + rde_stack_trim (p->ast, trim); + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_ast_push (RDE_PARAM p) + { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + } + SCOPE void + rde_param_i_ast_value_push (RDE_PARAM p) + { + ENTER ("rde_param_i_ast_value_push"); + TRACE (("RDE_PARAM %p",p)); + ASSERT(p->SV,"Unable to push undefined semantic value"); + TRACE (("rde_param_i_ast_value_push %p => (%p)", p, p->SV)); + TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV->refCount, Tcl_GetString (p->SV))); + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + RETURNVOID; + } + static void + ast_node_free (void* n) + { + Tcl_DecrRefCount ((Tcl_Obj*) n); + } + SCOPE void + rde_param_i_error_clear (RDE_PARAM p) + { + ER_CLEAR (p); + } + SCOPE void + rde_param_i_error_nonterminal (RDE_PARAM p, long int s) + { + + return; + long int pos; + if (!p->ER) return; + pos = 1 + (long int) rde_stack_top (p->LS); + if (p->ER->loc != pos) return; + error_set (p, s); + p->ER->loc = pos; + } + SCOPE void + rde_param_i_error_pop_merge (RDE_PARAM p) + { + ERROR_STATE* top = (ERROR_STATE*) rde_stack_top (p->ES); + + if (top == p->ER) { + rde_stack_pop (p->ES, 1); + return; + } + + if (!top) { + rde_stack_pop (p->ES, 1); + return; + } + + if (!p->ER) { + rde_stack_drop (p->ES, 1); + p->ER = top; + + return; + } + + if (top->loc < p->ER->loc) { + rde_stack_pop (p->ES, 1); + return; + } + + if (top->loc > p->ER->loc) { + rde_stack_drop (p->ES, 1); + error_state_free (p->ER); + p->ER = top; + + return; + } + + rde_stack_move (p->ER->msg, top->msg); + rde_stack_pop (p->ES, 1); + } + SCOPE void + rde_param_i_error_push (RDE_PARAM p) + { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + static void + error_set (RDE_PARAM p, long int s) + { + error_state_free (p->ER); + p->ER = ALLOC (ERROR_STATE); + p->ER->refCount = 1; + p->ER->loc = p->CL; + p->ER->msg = rde_stack_new (NULL); + ASSERT_BOUNDS(s,p->numstr); + rde_stack_push (p->ER->msg, (void*) s); + } + static void + error_state_free (void* esx) + { + ERROR_STATE* es = esx; + if (!es) return; + es->refCount --; + if (es->refCount > 0) return; + rde_stack_del (es->msg); + ckfree ((char*) es); + } + SCOPE void + rde_param_i_loc_pop_discard (RDE_PARAM p) + { + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_loc_pop_rewind (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_loc_push (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + } + SCOPE void + rde_param_i_loc_rewind (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + } + SCOPE void + rde_param_i_input_next (RDE_PARAM p, long int m) + { + int leni; + char* ch; + ASSERT_BOUNDS(m,p->numstr); + p->CL ++; + if (p->CL < rde_tc_size (p->TC)) { + + rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); + + ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); + p->ST = 1; + ER_CLEAR (p); + return; + } + if (!p->IN || + Tcl_Eof (p->IN) || + (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { + + p->ST = 0; + error_set (p, m); + return; + } + + ch = Tcl_GetStringFromObj (p->readbuf, &leni); + ASSERT_BOUNDS (leni, TCL_UTF_MAX); + p->CC = rde_tc_append (p->TC, ch, leni); + p->CC_len = leni; + p->ST = 1; + ER_CLEAR (p); + } + SCOPE void + rde_param_i_status_fail (RDE_PARAM p) + { + p->ST = 0; + } + SCOPE void + rde_param_i_status_ok (RDE_PARAM p) + { + p->ST = 1; + } + SCOPE void + rde_param_i_status_negate (RDE_PARAM p) + { + p->ST = !p->ST; + } + SCOPE int + rde_param_i_symbol_restore (RDE_PARAM p, long int s) + { + NC_STATE* scs; + Tcl_HashEntry* hPtr; + Tcl_HashTable* tablePtr; + + hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); + if (!hPtr) { return 0; } + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); + hPtr = Tcl_FindHashEntry (tablePtr, (char*) s); + if (!hPtr) { return 0; } + + scs = Tcl_GetHashValue (hPtr); + p->CL = scs->CL; + p->ST = scs->ST; + error_state_free (p->ER); + p->ER = scs->ER; + if (p->ER) { p->ER->refCount ++; } + TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); + SV_SET (p, scs->SV); + return 1; + } + SCOPE void + rde_param_i_symbol_save (RDE_PARAM p, long int s) + { + long int at = (long int) rde_stack_top (p->LS); + NC_STATE* scs; + Tcl_HashEntry* hPtr; + Tcl_HashTable* tablePtr; + int isnew; + ENTER ("rde_param_i_symbol_save"); + TRACE (("RDE_PARAM %p",p)); + TRACE (("INT %d",s)); + + hPtr = Tcl_CreateHashEntry (&p->NC, (char*) at, &isnew); + if (isnew) { + tablePtr = ALLOC (Tcl_HashTable); + Tcl_InitHashTable (tablePtr, TCL_ONE_WORD_KEYS); + Tcl_SetHashValue (hPtr, tablePtr); + } else { + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); + } + hPtr = Tcl_CreateHashEntry (tablePtr, (char*) s, &isnew); + if (isnew) { + + scs = ALLOC (NC_STATE); + scs->CL = p->CL; + scs->ST = p->ST; + TRACE (("SV_CACHE (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "")); + scs->SV = p->SV; + if (scs->SV) { Tcl_IncrRefCount (scs->SV); } + scs->ER = p->ER; + if (scs->ER) { scs->ER->refCount ++; } + Tcl_SetHashValue (hPtr, scs); + } else { + + scs = (NC_STATE*) Tcl_GetHashValue (hPtr); + scs->CL = p->CL; + scs->ST = p->ST; + TRACE (("SV_CACHE/over (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "" )); + if (scs->SV) { Tcl_DecrRefCount (scs->SV); } + scs->SV = p->SV; + if (scs->SV) { Tcl_IncrRefCount (scs->SV); } + error_state_free (scs->ER); + scs->ER = p->ER; + if (scs->ER) { scs->ER->refCount ++; } + } + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_test_alnum (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsAlnum, tc_alnum); + } + SCOPE void + rde_param_i_test_alpha (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsAlpha, tc_alpha); + } + SCOPE void + rde_param_i_test_ascii (RDE_PARAM p) + { + test_class (p, UniCharIsAscii, tc_ascii); + } + SCOPE void + rde_param_i_test_control (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsControl, tc_control); + } + SCOPE void + rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) + { + ASSERT_BOUNDS(msg,p->numstr); + p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, msg); + p->CL --; + } + } + SCOPE void + rde_param_i_test_ddigit (RDE_PARAM p) + { + test_class (p, UniCharIsDecDigit, tc_ddigit); + } + SCOPE void + rde_param_i_test_digit (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsDigit, tc_digit); + } + SCOPE void + rde_param_i_test_graph (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsGraph, tc_graph); + } + SCOPE void + rde_param_i_test_lower (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsLower, tc_lower); + } + SCOPE void + rde_param_i_test_print (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsPrint, tc_printable); + } + SCOPE void + rde_param_i_test_punct (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsPunct, tc_punct); + } + SCOPE void + rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) + { + ASSERT_BOUNDS(msg,p->numstr); + p->ST = + (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && + (Tcl_UtfNcmp (p->CC, e, 1) <= 0); + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, msg); + p->CL --; + } + } + SCOPE void + rde_param_i_test_space (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsSpace, tc_space); + } + SCOPE void + rde_param_i_test_upper (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsUpper, tc_upper); + } + SCOPE void + rde_param_i_test_wordchar (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsWordChar, tc_wordchar); + } + SCOPE void + rde_param_i_test_xdigit (RDE_PARAM p) + { + test_class (p, UniCharIsHexDigit, tc_xdigit); + } + static void + test_class (RDE_PARAM p, UniCharClass class, test_class_id id) + { + Tcl_UniChar ch; + Tcl_UtfToUniChar(p->CC, &ch); + ASSERT_BOUNDS(id,p->numstr); + p->ST = !!class (ch); + + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, id); + p->CL --; + } + } + static int + UniCharIsAscii (int character) + { + return (character >= 0) && (character < 0x80); + } + static int + UniCharIsHexDigit (int character) + { + return (character >= 0) && (character < 0x80) && isxdigit(character); + } + static int + UniCharIsDecDigit (int character) + { + return (character >= 0) && (character < 0x80) && isdigit(character); + } + SCOPE void + rde_param_i_value_clear (RDE_PARAM p) + { + SV_CLEAR (p); + } + SCOPE void + rde_param_i_value_leaf (RDE_PARAM p, long int s) + { + Tcl_Obj* newsv; + Tcl_Obj* ov [3]; + long int pos = 1 + (long int) rde_stack_top (p->LS); + ASSERT_BOUNDS(s,p->numstr); + ov [0] = Tcl_NewStringObj (p->string[s], -1); + ov [1] = Tcl_NewIntObj (pos); + ov [2] = Tcl_NewIntObj (p->CL); + newsv = Tcl_NewListObj (3, ov); + TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); + SV_SET (p, newsv); + } + SCOPE void + rde_param_i_value_reduce (RDE_PARAM p, long int s) + { + Tcl_Obj* newsv; + int oc, i, j; + Tcl_Obj** ov; + long int ac; + Tcl_Obj** av; + long int pos = 1 + (long int) rde_stack_top (p->LS); + long int mark = (long int) rde_stack_top (p->mark); + long int asize = rde_stack_size (p->ast); + long int new = asize - mark; + ASSERT (new >= 0, "Bad number of elements to reduce"); + ov = NALLOC (3+new, Tcl_Obj*); + ASSERT_BOUNDS(s,p->numstr); + ov [0] = Tcl_NewStringObj (p->string[s], -1); + ov [1] = Tcl_NewIntObj (pos); + ov [2] = Tcl_NewIntObj (p->CL); + rde_stack_get (p->ast, &ac, (void***) &av); + for (i = 3, j = mark; j < asize; i++, j++) { + ASSERT_BOUNDS (i, 3+new); + ASSERT_BOUNDS (j, ac); + ov [i] = av [j]; + } + ASSERT (i == 3+new, "Reduction result incomplete"); + newsv = Tcl_NewListObj (3+new, ov); + TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); + SV_SET (p, newsv); + ckfree ((char*) ov); + } + static int + er_int_compare (const void* a, const void* b) + { + + const void** ael = (const void**) a; + const void** bel = (const void**) b; + long int avalue = (long int) *ael; + long int bvalue = (long int) *bel; + if (avalue < bvalue) { return -1; } + if (avalue > bvalue) { return 1; } + return 0; + } + SCOPE int + rde_param_i_symbol_start (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) { + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + return 1; + } + rde_stack_push (p->LS, (void*) p->CL); + return 0; + } + SCOPE int + rde_param_i_symbol_start_d (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) { + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + return 1; + } + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + return 0; + } + SCOPE int + rde_param_i_symbol_void_start (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) return 1; + rde_stack_push (p->LS, (void*) p->CL); + return 0; + } + SCOPE int + rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) return 1; + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + return 0; + } + SCOPE void + rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_reduce (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_leaf (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_leaf (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) + { + SV_CLEAR (p); + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) + { + SV_CLEAR (p); + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_char (p, c, m); + } + SCOPE void + rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_range (p, s, e, m); + } + SCOPE void + rde_param_i_next_alnum (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_alnum (p); + } + SCOPE void + rde_param_i_next_alpha (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_alpha (p); + } + SCOPE void + rde_param_i_next_ascii (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_ascii (p); + } + SCOPE void + rde_param_i_next_control (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_control (p); + } + SCOPE void + rde_param_i_next_ddigit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_ddigit (p); + } + SCOPE void + rde_param_i_next_digit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_digit (p); + } + SCOPE void + rde_param_i_next_graph (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_graph (p); + } + SCOPE void + rde_param_i_next_lower (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_lower (p); + } + SCOPE void + rde_param_i_next_print (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_print (p); + } + SCOPE void + rde_param_i_next_punct (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_punct (p); + } + SCOPE void + rde_param_i_next_space (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_space (p); + } + SCOPE void + rde_param_i_next_upper (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_upper (p); + } + SCOPE void + rde_param_i_next_wordchar (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_wordchar (p); + } + SCOPE void + rde_param_i_next_xdigit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_xdigit (p); + } + SCOPE void + rde_param_i_notahead_start_d (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + } + SCOPE void + rde_param_i_notahead_exit_d (RDE_PARAM p) + { + if (p->ST) { + rde_param_i_ast_pop_rewind (p); + } else { + rde_stack_pop (p->mark, 1); + } + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + p->ST = !p->ST; + } + SCOPE void + rde_param_i_notahead_exit (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + p->ST = !p->ST; + } + SCOPE void + rde_param_i_state_push_2 (RDE_PARAM p) + { + + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + SCOPE void + rde_param_i_state_push_void (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + ER_CLEAR (p); + rde_stack_push (p->ES, p->ER); + + } + SCOPE void + rde_param_i_state_push_value (RDE_PARAM p) + { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + rde_stack_push (p->LS, (void*) p->CL); + ER_CLEAR (p); + rde_stack_push (p->ES, p->ER); + + } + SCOPE void + rde_param_i_state_merge_ok (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + p->ST = 1; + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_state_merge_void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_state_merge_value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } + SCOPE int + rde_param_i_kleene_close (RDE_PARAM p) + { + int stop = !p->ST; + rde_param_i_error_pop_merge (p); + if (stop) { + p->ST = 1; + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + return stop; + } + SCOPE int + rde_param_i_kleene_abort (RDE_PARAM p) + { + int stop = !p->ST; + if (stop) { + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + return stop; + } + SCOPE int + rde_param_i_seq_void2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_seq_void2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_seq_value2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_bra_void2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->LS, 1); + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_void2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->LS, 1); + } else { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_value2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_value2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE void + rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) + { + int at = p->CL; + + while (*str) { + rde_param_i_input_next (p, m); + if (!p->ST) { + p->ER->loc = at+1; + p->CL = at; + return; + } + rde_param_i_test_char (p, str, m); + if (!p->ST) { + p->ER->loc = at+1; + p->CL = at; + return; + } + str = Tcl_UtfNext (str); + } + } + SCOPE void + rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + while (*class) { + p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; + if (p->ST) { + ER_CLEAR (p); + return; + } + class = Tcl_UtfNext (class); + } + error_set (p, m); + p->CL --; + } + + + /* + * Declaring the parse functions + */ + + static void kleene_2 (RDE_PARAM p); + + /* + * Precomputed table of strings (symbols, error messages, etc.). + */ + + static char const* p_string [15] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "t a" + }; + + /* + * Grammar Start Expression + */ + + static void MAIN (RDE_PARAM p) { + kleene_2 (p); + return; + } + + static void kleene_2 (RDE_PARAM p) { + /* + * * + * 'a' + */ + + while (1) { + rde_param_i_state_push_2 (p); + rde_param_i_next_char (p, "a", 14); + if (rde_param_i_kleene_close(p)) return; + } + return; + } + + /* -*- c -*- */ + + typedef struct PARSERg { + long int counter; + char buf [50]; + } PARSERg; + + static void + PARSERgRelease (ClientData cd, Tcl_Interp* interp) + { + ckfree((char*) cd); + } + + static const char* + PARSERnewName (Tcl_Interp* interp) + { +#define KEY "tcllib/parser/PACKAGE/TEA" + + Tcl_InterpDeleteProc* proc = PARSERgRelease; + PARSERg* parserg; + + parserg = Tcl_GetAssocData (interp, KEY, &proc); + if (parserg == NULL) { + parserg = (PARSERg*) ckalloc (sizeof (PARSERg)); + parserg->counter = 0; + + Tcl_SetAssocData (interp, KEY, proc, + (ClientData) parserg); + } + + parserg->counter ++; + sprintf (parserg->buf, "PARSER%ld", parserg->counter); + return parserg->buf; +#undef KEY + } + + static void + PARSERdeleteCmd (ClientData clientData) + { + /* + * Release the whole PARSER + * (Low-level engine only actually). + */ + rde_param_del ((RDE_PARAM) clientData); + } + + + /* * ** *** ***** ******** ************* + ** Functions implementing the object methods, and helper. + */ + + static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp); + + static int parser_PARSE (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + int mode; + Tcl_Channel chan; + + if (objc != 3) { + Tcl_WrongNumArgs (interp, 2, objv, "chan"); + return TCL_ERROR; + } + + chan = Tcl_GetChannel(interp, + Tcl_GetString (objv[2]), + &mode); + + if (!chan) { + return TCL_ERROR; + } + + rde_param_reset (p, chan); + MAIN (p) ; /* Entrypoint for the generated code. */ + return COMPLETE (p, interp); + } + + static int parser_PARSET (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + char* buf; + int len; + + if (objc != 3) { + Tcl_WrongNumArgs (interp, 2, objv, "text"); + return TCL_ERROR; + } + + buf = Tcl_GetStringFromObj (objv[2], &len); + + rde_param_reset (p, NULL); + rde_param_data (p, buf, len); + MAIN (p) ; /* Entrypoint for the generated code. */ + return COMPLETE (p, interp); + } + + /* See also rde_critcl/m.c, param_COMPLETE() */ + static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) + { + if (rde_param_query_st (p)) { + long int ac; + Tcl_Obj** av; + + rde_param_query_ast (p, &ac, &av); + + if (ac > 1) { + Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); + + memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); + lv [0] = Tcl_NewObj (); + lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); + lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); + + Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); + ckfree ((char*) lv); + + } else if (ac == 0) { + /* + * Match, but no AST. This is possible if the grammar + * consists of only the start expression. + */ + Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); + } else { + Tcl_SetObjResult (interp, av [0]); + } + + return TCL_OK; + } else { + Tcl_Obj* xv [1]; + const ERROR_STATE* er = rde_param_query_er (p); + Tcl_Obj* res = rde_param_query_er_tcl (p, er); + /* res = list (location, list(msg)) */ + + /* Stick the exception type-tag before the existing elements */ + xv [0] = Tcl_NewStringObj ("pt::rde",-1); + Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); + + Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); + Tcl_SetObjResult (interp, res); + return TCL_ERROR; + } + } + + + /* * ** *** ***** ******** ************* + ** Object command, method dispatch. + */ + static int parser_objcmd (ClientData cd, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + RDE_PARAM p = (RDE_PARAM) cd; + int m, res; + + static CONST char* methods [] = { + "destroy", "parse", "parset", NULL + }; + enum methods { + M_DESTROY, M_PARSE, M_PARSET + }; + + if (objc < 2) { + Tcl_WrongNumArgs (interp, objc, objv, "option ?arg arg ...?"); + return TCL_ERROR; + } else if (Tcl_GetIndexFromObj (interp, objv [1], methods, "option", + 0, &m) != TCL_OK) { + return TCL_ERROR; + } + + /* Dispatch to methods. They check the #args in + * detail before performing the requested + * functionality + */ + + switch (m) { + case M_DESTROY: + if (objc != 2) { + Tcl_WrongNumArgs (interp, 2, objv, NULL); + return TCL_ERROR; + } + + Tcl_DeleteCommandFromToken(interp, (Tcl_Command) rde_param_query_clientdata (p)); + return TCL_OK; + + case M_PARSE: res = parser_PARSE (p, interp, objc, objv); break; + case M_PARSET: res = parser_PARSET (p, interp, objc, objv); break; + default: + /* Not coming to this place */ + ASSERT (0,"Reached unreachable location"); + } + + return res; + } + + /** * ** *** ***** ******** ************* + * Class command, i.e. object construction. + */ + static int ParserClassCmd (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const*objv) { + /* + * Syntax: No arguments beyond the name + */ + + RDE_PARAM parser; + CONST char* name; + Tcl_Obj* fqn; + Tcl_CmdInfo ci; + Tcl_Command c; + +#define USAGE "?name?" + + if ((objc != 2) && (objc != 1)) { + Tcl_WrongNumArgs (interp, 1, objv, USAGE); + return TCL_ERROR; + } + + if (objc < 2) { + name = PARSERnewName (interp); + } else { + name = Tcl_GetString (objv [1]); + } + + if (!Tcl_StringMatch (name, "::*")) { + /* Relative name. Prefix with current namespace */ + + Tcl_Eval (interp, "namespace current"); + fqn = Tcl_GetObjResult (interp); + fqn = Tcl_DuplicateObj (fqn); + Tcl_IncrRefCount (fqn); + + if (!Tcl_StringMatch (Tcl_GetString (fqn), "::")) { + Tcl_AppendToObj (fqn, "::", -1); + } + Tcl_AppendToObj (fqn, name, -1); + } else { + fqn = Tcl_NewStringObj (name, -1); + Tcl_IncrRefCount (fqn); + } + Tcl_ResetResult (interp); + + if (Tcl_GetCommandInfo (interp, + Tcl_GetString (fqn), + &ci)) { + Tcl_Obj* err; + + err = Tcl_NewObj (); + Tcl_AppendToObj (err, "command \"", -1); + Tcl_AppendObjToObj (err, fqn); + Tcl_AppendToObj (err, "\" already exists", -1); + + Tcl_DecrRefCount (fqn); + Tcl_SetObjResult (interp, err); + return TCL_ERROR; + } + + parser = rde_param_new (sizeof(p_string)/sizeof(char*), (char**) p_string); + c = Tcl_CreateObjCommand (interp, Tcl_GetString (fqn), + parser_objcmd, (ClientData) parser, + PARSERdeleteCmd); + rde_param_clientdata (parser, (ClientData) c); + Tcl_SetObjResult (interp, fqn); + Tcl_DecrRefCount (fqn); + return TCL_OK; + } + +int Package_Init(Tcl_Interp* interp) { + if (interp == 0) return TCL_ERROR; + + if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { + return TCL_ERROR; + } + + if (Tcl_CreateObjCommand(interp, "PARSER", ParserClassCmd , NULL, NULL) == NULL) { + Tcl_SetResult(interp, "Can't create constructor", NULL); + return TCL_ERROR; + } + + + Tcl_PkgProvide(interp, "PACKAGE", "0.1"); + + return TCL_OK; +} ADDED modules/pt/tests/data/ok/peg_cparam-tea/8_pkleene Index: modules/pt/tests/data/ok/peg_cparam-tea/8_pkleene ================================================================== --- /dev/null +++ modules/pt/tests/data/ok/peg_cparam-tea/8_pkleene @@ -0,0 +1,2004 @@ +/************************************************************ +** +** TEA-based C/PARAM implementation of the parsing +** expression grammar +** +** TEMPLATE +** +** Generated from file TEST +** for user unknown +** +* * ** *** ***** ******** ************* *********************/ + #include + #include + #include + #include + #define SCOPE static + +#line 1 "rde_critcl/util.h" + + #ifndef _RDE_UTIL_H + #define _RDE_UTIL_H 1 + #ifndef SCOPE + #define SCOPE + #endif + #define ALLOC(type) (type *) ckalloc (sizeof (type)) + #define NALLOC(n,type) (type *) ckalloc ((n) * sizeof (type)) + #undef RDE_DEBUG + #define RDE_DEBUG 1 + #undef RDE_TRACE + #ifdef RDE_DEBUG + #define STOPAFTER(x) { static int count = (x); count --; if (!count) { Tcl_Panic ("stop"); } } + #define XSTR(x) #x + #define STR(x) XSTR(x) + #define RANGEOK(i,n) ((0 <= (i)) && (i < (n))) + #define ASSERT(x,msg) if (!(x)) { Tcl_Panic (msg " (" #x "), in file " __FILE__ " @line " STR(__LINE__));} + #define ASSERT_BOUNDS(i,n) ASSERT (RANGEOK(i,n),"array index out of bounds: " STR(i) " >= " STR(n)) + #else + #define STOPAFTER(x) + #define ASSERT(x,msg) + #define ASSERT_BOUNDS(i,n) + #endif + #ifdef RDE_TRACE + SCOPE void trace_enter (const char* fun); + SCOPE void trace_return (const char *pat, ...); + SCOPE void trace_printf (const char *pat, ...); + #define ENTER(fun) trace_enter (fun) + #define RETURN(format,x) trace_return (format,x) ; return x + #define RETURNVOID trace_return ("%s","(void)") ; return + #define TRACE0(x) trace_printf0 x + #define TRACE(x) trace_printf x + #else + #define ENTER(fun) + #define RETURN(f,x) return x + #define RETURNVOID return + #define TRACE0(x) + #define TRACE(x) + #endif + #endif + + +#line 1 "rde_critcl/stack.h" + + #ifndef _RDE_DS_STACK_H + #define _RDE_DS_STACK_H 1 + typedef void (*RDE_STACK_CELL_FREE) (void* cell); + typedef struct RDE_STACK_* RDE_STACK; + static const int RDE_STACK_INITIAL_SIZE = 256; + #endif + + +#line 1 "rde_critcl/tc.h" + + #ifndef _RDE_DS_TC_H + #define _RDE_DS_TC_H 1 + typedef struct RDE_TC_* RDE_TC; + #endif + + +#line 1 "rde_critcl/param.h" + + #ifndef _RDE_DS_PARAM_H + #define _RDE_DS_PARAM_H 1 + typedef struct RDE_PARAM_* RDE_PARAM; + typedef struct ERROR_STATE { + int refCount; + long int loc; + RDE_STACK msg; + } ERROR_STATE; + typedef struct NC_STATE { + long int CL; + long int ST; + Tcl_Obj* SV; + ERROR_STATE* ER; + } NC_STATE; + #endif + + +#line 1 "rde_critcl/util.c" + + #ifdef RDE_TRACE + typedef struct F_STACK { + const char* str; + struct F_STACK* down; + } F_STACK; + static F_STACK* top = 0; + static int level = 0; + static void + push (const char* str) + { + F_STACK* new = ALLOC (F_STACK); + new->str = str; + new->down = top; + top = new; + level += 4; + } + static void + pop (void) + { + F_STACK* next = top->down; + level -= 4; + ckfree ((char*)top); + top = next; + } + static void + indent (void) + { + int i; + for (i = 0; i < level; i++) { + fwrite(" ", 1, 1, stdout); + fflush (stdout); + } + if (top) { + fwrite(top->str, 1, strlen(top->str), stdout); + fflush (stdout); + } + fwrite(" ", 1, 1, stdout); + fflush (stdout); + } + SCOPE void + trace_enter (const char* fun) + { + push (fun); + indent(); + fwrite("ENTER\n", 1, 6, stdout); + fflush (stdout); + } + static char msg [1024*1024]; + SCOPE void + trace_return (const char *pat, ...) + { + int len; + va_list args; + indent(); + fwrite("RETURN = ", 1, 9, stdout); + fflush (stdout); + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + pop(); + } + SCOPE void + trace_printf (const char *pat, ...) + { + int len; + va_list args; + indent(); + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + } + SCOPE void + trace_printf0 (const char *pat, ...) + { + int len; + va_list args; + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + } + #endif + + +#line 1 "rde_critcl/stack.c" + + typedef struct RDE_STACK_ { + long int max; + long int top; + RDE_STACK_CELL_FREE freeCellProc; + void** cell; + } RDE_STACK_; + + SCOPE RDE_STACK + rde_stack_new (RDE_STACK_CELL_FREE freeCellProc) + { + RDE_STACK s = ALLOC (RDE_STACK_); + s->cell = NALLOC (RDE_STACK_INITIAL_SIZE, void*); + s->max = RDE_STACK_INITIAL_SIZE; + s->top = 0; + s->freeCellProc = freeCellProc; + return s; + } + SCOPE void + rde_stack_del (RDE_STACK s) + { + if (s->freeCellProc && s->top) { + long int i; + for (i=0; i < s->top; i++) { + ASSERT_BOUNDS(i,s->max); + s->freeCellProc ( s->cell [i] ); + } + } + ckfree ((char*) s->cell); + ckfree ((char*) s); + } + SCOPE void + rde_stack_push (RDE_STACK s, void* item) + { + if (s->top >= s->max) { + long int new = s->max ? (2 * s->max) : RDE_STACK_INITIAL_SIZE; + void** cell = (void**) ckrealloc ((char*) s->cell, new * sizeof(void*)); + ASSERT (cell,"Memory allocation failure for RDE stack"); + s->max = new; + s->cell = cell; + } + ASSERT_BOUNDS(s->top,s->max); + s->cell [s->top] = item; + s->top ++; + } + SCOPE void* + rde_stack_top (RDE_STACK s) + { + ASSERT_BOUNDS(s->top-1,s->max); + return s->cell [s->top - 1]; + } + SCOPE void + rde_stack_pop (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad pop count"); + if (n == 0) return; + if (s->freeCellProc) { + while (n) { + s->top --; + ASSERT_BOUNDS(s->top,s->max); + s->freeCellProc ( s->cell [s->top] ); + n --; + } + } else { + s->top -= n; + } + } + SCOPE void + rde_stack_trim (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad trimsize"); + if (s->freeCellProc) { + while (s->top > n) { + s->top --; + ASSERT_BOUNDS(s->top,s->max); + s->freeCellProc ( s->cell [s->top] ); + } + } else { + s->top = n; + } + } + SCOPE void + rde_stack_drop (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad pop count"); + if (n == 0) return; + s->top -= n; + } + SCOPE void + rde_stack_move (RDE_STACK dst, RDE_STACK src) + { + ASSERT (dst->freeCellProc == src->freeCellProc, "Ownership mismatch"); + + while (src->top > 0) { + src->top --; + ASSERT_BOUNDS(src->top,src->max); + rde_stack_push (dst, src->cell [src->top] ); + } + } + SCOPE void + rde_stack_get (RDE_STACK s, long int* cn, void*** cc) + { + *cn = s->top; + *cc = s->cell; + } + SCOPE long int + rde_stack_size (RDE_STACK s) + { + return s->top; + } + + +#line 1 "rde_critcl/tc.c" + + typedef struct RDE_TC_ { + int max; + int num; + char* str; + RDE_STACK off; + } RDE_TC_; + + SCOPE RDE_TC + rde_tc_new (void) + { + RDE_TC tc = ALLOC (RDE_TC_); + tc->max = RDE_STACK_INITIAL_SIZE; + tc->num = 0; + tc->str = NALLOC (RDE_STACK_INITIAL_SIZE, char); + tc->off = rde_stack_new (NULL); + return tc; + } + SCOPE void + rde_tc_del (RDE_TC tc) + { + rde_stack_del (tc->off); + ckfree (tc->str); + ckfree ((char*) tc); + } + SCOPE long int + rde_tc_size (RDE_TC tc) + { + return rde_stack_size (tc->off); + } + SCOPE void + rde_tc_clear (RDE_TC tc) + { + tc->num = 0; + rde_stack_trim (tc->off, 0); + } + SCOPE char* + rde_tc_append (RDE_TC tc, char* string, long int len) + { + long int base = tc->num; + long int off = tc->num; + char* ch; + int clen; + Tcl_UniChar uni; + if (len < 0) { + len = strlen (string); + } + + if (!len) { + return tc->str + base; + } + + if ((tc->num + len) >= tc->max) { + int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); + char* str = ckrealloc (tc->str, new * sizeof(char)); + ASSERT (str,"Memory allocation failure for token character array"); + tc->max = new; + tc->str = str; + } + tc->num += len; + ASSERT_BOUNDS(tc->num,tc->max); + ASSERT_BOUNDS(off,tc->max); + ASSERT_BOUNDS(off+len-1,tc->max); + ASSERT_BOUNDS(off+len-1,tc->num); + memcpy (tc->str + off, string, len); + + ch = string; + while (ch < (string + len)) { + ASSERT_BOUNDS(off,tc->num); + rde_stack_push (tc->off, (void*) off); + clen = Tcl_UtfToUniChar (ch, &uni); + off += clen; + ch += clen; + } + return tc->str + base; + } + SCOPE void + rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) + { + long int oc, off, top, end; + void** ov; + rde_stack_get (tc->off, &oc, &ov); + ASSERT_BOUNDS(at,oc); + off = (long int) ov [at]; + if ((at+1) == oc) { + end = tc->num; + } else { + end = (long int) ov [at+1]; + } + TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); + ASSERT_BOUNDS(off,tc->num); + ASSERT_BOUNDS(end-1,tc->num); + *ch = tc->str + off; + *len = end - off; + } + SCOPE void + rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) + { + long int oc, off, top, end; + void** ov; + rde_stack_get (tc->off, &oc, &ov); + ASSERT_BOUNDS(at,oc); + ASSERT_BOUNDS(last,oc); + off = (long int) ov [at]; + if ((last+1) == oc) { + end = tc->num; + } else { + end = (long int) ov [last+1]; + } + TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); + ASSERT_BOUNDS(off,tc->num); + ASSERT_BOUNDS(end-1,tc->num); + *ch = tc->str + off; + *len = end - off; + } + + +#line 1 "rde_critcl/param.c" + + typedef struct RDE_PARAM_ { + Tcl_Channel IN; + Tcl_Obj* readbuf; + char* CC; + long int CC_len; + RDE_TC TC; + long int CL; + RDE_STACK LS; + ERROR_STATE* ER; + RDE_STACK ES; + long int ST; + Tcl_Obj* SV; + Tcl_HashTable NC; + + RDE_STACK ast ; + RDE_STACK mark ; + + long int numstr; + char** string; + + ClientData clientData; + } RDE_PARAM_; + typedef int (*UniCharClass) (int); + typedef enum test_class_id { + tc_alnum, + tc_alpha, + tc_ascii, + tc_control, + tc_ddigit, + tc_digit, + tc_graph, + tc_lower, + tc_printable, + tc_punct, + tc_space, + tc_upper, + tc_wordchar, + tc_xdigit + } test_class_id; + static void ast_node_free (void* n); + static void error_state_free (void* es); + static void error_set (RDE_PARAM p, long int s); + static void nc_clear (RDE_PARAM p); + static int UniCharIsAscii (int character); + static int UniCharIsHexDigit (int character); + static int UniCharIsDecDigit (int character); + static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); + static int er_int_compare (const void* a, const void* b); + #define SV_INIT(p) \ + p->SV = NULL; \ + TRACE (("SV_INIT (%p => %p)", (p), (p)->SV)) + #define SV_SET(p,newsv) \ + if (((p)->SV) != (newsv)) { \ + TRACE (("SV_CLEAR/set (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_DecrRefCount ((p)->SV); \ + } \ + (p)->SV = (newsv); \ + TRACE (("SV_SET (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_IncrRefCount ((p)->SV); \ + } \ + } + #define SV_CLEAR(p) \ + TRACE (("SV_CLEAR (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_DecrRefCount ((p)->SV); \ + } \ + (p)->SV = NULL + #define ER_INIT(p) \ + p->ER = NULL; \ + TRACE (("ER_INIT (%p => %p)", (p), (p)->ER)) + #define ER_CLEAR(p) \ + error_state_free ((p)->ER); \ + (p)->ER = NULL + SCOPE RDE_PARAM + rde_param_new (long int nstr, char** strings) + { + RDE_PARAM p; + ENTER ("rde_param_new"); + TRACE (("\tINT %d strings @ %p", nstr, strings)); + p = ALLOC (RDE_PARAM_); + p->numstr = nstr; + p->string = strings; + p->readbuf = Tcl_NewObj (); + Tcl_IncrRefCount (p->readbuf); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + Tcl_InitHashTable (&p->NC, TCL_ONE_WORD_KEYS); + p->IN = NULL; + p->CL = -1; + p->ST = 0; + ER_INIT (p); + SV_INIT (p); + p->CC = NULL; + p->CC_len = 0; + p->TC = rde_tc_new (); + p->ES = rde_stack_new (error_state_free); + p->LS = rde_stack_new (NULL); + p->ast = rde_stack_new (ast_node_free); + p->mark = rde_stack_new (NULL); + RETURN ("%p", p); + } + SCOPE void + rde_param_del (RDE_PARAM p) + { + ENTER ("rde_param_del"); + TRACE (("RDE_PARAM %p",p)); + ER_CLEAR (p); TRACE (("\ter_clear")); + SV_CLEAR (p); TRACE (("\tsv_clear")); + nc_clear (p); TRACE (("\tnc_clear")); + Tcl_DeleteHashTable (&p->NC); TRACE (("\tnc hashtable delete")); + rde_tc_del (p->TC); TRACE (("\ttc clear")); + rde_stack_del (p->ES); TRACE (("\tes clear")); + rde_stack_del (p->LS); TRACE (("\tls clear")); + rde_stack_del (p->ast); TRACE (("\tast clear")); + rde_stack_del (p->mark); TRACE (("\tmark clear")); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + Tcl_DecrRefCount (p->readbuf); + ckfree ((char*) p); + RETURNVOID; + } + SCOPE void + rde_param_reset (RDE_PARAM p, Tcl_Channel chan) + { + ENTER ("rde_param_reset"); + TRACE (("RDE_PARAM %p",p)); + TRACE (("Tcl_Channel %p",chan)); + p->IN = chan; + p->CL = -1; + p->ST = 0; + p->CC = NULL; + p->CC_len = 0; + ER_CLEAR (p); + SV_CLEAR (p); + nc_clear (p); + rde_tc_clear (p->TC); + rde_stack_trim (p->ES, 0); + rde_stack_trim (p->LS, 0); + rde_stack_trim (p->ast, 0); + rde_stack_trim (p->mark, 0); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + RETURNVOID; + } + SCOPE void + rde_param_update_strings (RDE_PARAM p, long int nstr, char** strings) + { + ENTER ("rde_param_update_strings"); + TRACE (("RDE_PARAM %p", p)); + TRACE (("INT %d strings", nstr)); + p->numstr = nstr; + p->string = strings; + RETURNVOID; + } + SCOPE void + rde_param_data (RDE_PARAM p, char* buf, long int len) + { + (void) rde_tc_append (p->TC, buf, len); + } + SCOPE void + rde_param_clientdata (RDE_PARAM p, ClientData clientData) + { + p->clientData = clientData; + } + static void + nc_clear (RDE_PARAM p) + { + Tcl_HashSearch hs; + Tcl_HashEntry* he; + Tcl_HashTable* tablePtr; + for(he = Tcl_FirstHashEntry(&p->NC, &hs); + he != NULL; + he = Tcl_FirstHashEntry(&p->NC, &hs)) { + Tcl_HashSearch hsc; + Tcl_HashEntry* hec; + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (he); + for(hec = Tcl_FirstHashEntry(tablePtr, &hsc); + hec != NULL; + hec = Tcl_NextHashEntry(&hsc)) { + NC_STATE* scs = Tcl_GetHashValue (hec); + error_state_free (scs->ER); + if (scs->SV) { Tcl_DecrRefCount (scs->SV); } + ckfree ((char*) scs); + } + Tcl_DeleteHashTable (tablePtr); + ckfree ((char*) tablePtr); + Tcl_DeleteHashEntry (he); + } + } + SCOPE ClientData + rde_param_query_clientdata (RDE_PARAM p) + { + return p->clientData; + } + SCOPE void + rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) + { + rde_stack_get (p->mark, mc, mv); + } + SCOPE void + rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) + { + rde_stack_get (p->ast, ac, (void***) av); + } + SCOPE const char* + rde_param_query_in (RDE_PARAM p) + { + return p->IN + ? Tcl_GetChannelName (p->IN) + : ""; + } + SCOPE const char* + rde_param_query_cc (RDE_PARAM p, long int* len) + { + *len = p->CC_len; + return p->CC; + } + SCOPE int + rde_param_query_cl (RDE_PARAM p) + { + return p->CL; + } + SCOPE const ERROR_STATE* + rde_param_query_er (RDE_PARAM p) + { + return p->ER; + } + SCOPE Tcl_Obj* + rde_param_query_er_tcl (RDE_PARAM p, const ERROR_STATE* er) + { + Tcl_Obj* res; + if (!er) { + + res = Tcl_NewStringObj ("", 0); + } else { + Tcl_Obj* ov [2]; + Tcl_Obj** mov; + long int mc, i, j; + void** mv; + int lastid; + const char* msg; + rde_stack_get (er->msg, &mc, &mv); + + qsort (mv, mc, sizeof (void*), er_int_compare); + + mov = NALLOC (mc, Tcl_Obj*); + lastid = -1; + for (i=0, j=0; i < mc; i++) { + ASSERT_BOUNDS (i,mc); + if (((long int) mv [i]) == lastid) continue; + lastid = (long int) mv [i]; + ASSERT_BOUNDS((long int) mv[i],p->numstr); + msg = p->string [(long int) mv[i]]; + ASSERT_BOUNDS (j,mc); + mov [j] = Tcl_NewStringObj (msg, -1); + j++; + } + + ov [0] = Tcl_NewIntObj (er->loc); + ov [1] = Tcl_NewListObj (j, mov); + res = Tcl_NewListObj (2, ov); + ckfree ((char*) mov); + } + return res; + } + SCOPE void + rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) + { + rde_stack_get (p->ES, ec, (void***) ev); + } + SCOPE void + rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) + { + rde_stack_get (p->LS, lc, lv); + } + SCOPE long int + rde_param_query_lstop (RDE_PARAM p) + { + (long int) rde_stack_top (p->LS); + } + SCOPE Tcl_HashTable* + rde_param_query_nc (RDE_PARAM p) + { + return &p->NC; + } + SCOPE int + rde_param_query_st (RDE_PARAM p) + { + return p->ST; + } + SCOPE Tcl_Obj* + rde_param_query_sv (RDE_PARAM p) + { + TRACE (("SV_QUERY %p => (%p)", (p), (p)->SV)); \ + return p->SV; + } + SCOPE long int + rde_param_query_tc_size (RDE_PARAM p) + { + return rde_tc_size (p->TC); + } + SCOPE void + rde_param_query_tc_get_s (RDE_PARAM p, long int at, long int last, char** ch, long int* len) + { + rde_tc_get_s (p->TC, at, last, ch, len); + } + SCOPE const char* + rde_param_query_string (RDE_PARAM p, long int id) + { + TRACE (("rde_param_query_string (RDE_PARAM %p, %d/%d)", p, id, p->numstr)); + ASSERT_BOUNDS(id,p->numstr); + return p->string [id]; + } + SCOPE void + rde_param_i_ast_pop_discard (RDE_PARAM p) + { + rde_stack_pop (p->mark, 1); + } + SCOPE void + rde_param_i_ast_pop_rewind (RDE_PARAM p) + { + long int trim = (long int) rde_stack_top (p->mark); + ENTER ("rde_param_i_ast_pop_rewind"); + TRACE (("RDE_PARAM %p",p)); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_ast_rewind (RDE_PARAM p) + { + long int trim = (long int) rde_stack_top (p->mark); + ENTER ("rde_param_i_ast_rewind"); + TRACE (("RDE_PARAM %p",p)); + rde_stack_trim (p->ast, trim); + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_ast_push (RDE_PARAM p) + { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + } + SCOPE void + rde_param_i_ast_value_push (RDE_PARAM p) + { + ENTER ("rde_param_i_ast_value_push"); + TRACE (("RDE_PARAM %p",p)); + ASSERT(p->SV,"Unable to push undefined semantic value"); + TRACE (("rde_param_i_ast_value_push %p => (%p)", p, p->SV)); + TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV->refCount, Tcl_GetString (p->SV))); + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + RETURNVOID; + } + static void + ast_node_free (void* n) + { + Tcl_DecrRefCount ((Tcl_Obj*) n); + } + SCOPE void + rde_param_i_error_clear (RDE_PARAM p) + { + ER_CLEAR (p); + } + SCOPE void + rde_param_i_error_nonterminal (RDE_PARAM p, long int s) + { + + return; + long int pos; + if (!p->ER) return; + pos = 1 + (long int) rde_stack_top (p->LS); + if (p->ER->loc != pos) return; + error_set (p, s); + p->ER->loc = pos; + } + SCOPE void + rde_param_i_error_pop_merge (RDE_PARAM p) + { + ERROR_STATE* top = (ERROR_STATE*) rde_stack_top (p->ES); + + if (top == p->ER) { + rde_stack_pop (p->ES, 1); + return; + } + + if (!top) { + rde_stack_pop (p->ES, 1); + return; + } + + if (!p->ER) { + rde_stack_drop (p->ES, 1); + p->ER = top; + + return; + } + + if (top->loc < p->ER->loc) { + rde_stack_pop (p->ES, 1); + return; + } + + if (top->loc > p->ER->loc) { + rde_stack_drop (p->ES, 1); + error_state_free (p->ER); + p->ER = top; + + return; + } + + rde_stack_move (p->ER->msg, top->msg); + rde_stack_pop (p->ES, 1); + } + SCOPE void + rde_param_i_error_push (RDE_PARAM p) + { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + static void + error_set (RDE_PARAM p, long int s) + { + error_state_free (p->ER); + p->ER = ALLOC (ERROR_STATE); + p->ER->refCount = 1; + p->ER->loc = p->CL; + p->ER->msg = rde_stack_new (NULL); + ASSERT_BOUNDS(s,p->numstr); + rde_stack_push (p->ER->msg, (void*) s); + } + static void + error_state_free (void* esx) + { + ERROR_STATE* es = esx; + if (!es) return; + es->refCount --; + if (es->refCount > 0) return; + rde_stack_del (es->msg); + ckfree ((char*) es); + } + SCOPE void + rde_param_i_loc_pop_discard (RDE_PARAM p) + { + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_loc_pop_rewind (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_loc_push (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + } + SCOPE void + rde_param_i_loc_rewind (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + } + SCOPE void + rde_param_i_input_next (RDE_PARAM p, long int m) + { + int leni; + char* ch; + ASSERT_BOUNDS(m,p->numstr); + p->CL ++; + if (p->CL < rde_tc_size (p->TC)) { + + rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); + + ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); + p->ST = 1; + ER_CLEAR (p); + return; + } + if (!p->IN || + Tcl_Eof (p->IN) || + (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { + + p->ST = 0; + error_set (p, m); + return; + } + + ch = Tcl_GetStringFromObj (p->readbuf, &leni); + ASSERT_BOUNDS (leni, TCL_UTF_MAX); + p->CC = rde_tc_append (p->TC, ch, leni); + p->CC_len = leni; + p->ST = 1; + ER_CLEAR (p); + } + SCOPE void + rde_param_i_status_fail (RDE_PARAM p) + { + p->ST = 0; + } + SCOPE void + rde_param_i_status_ok (RDE_PARAM p) + { + p->ST = 1; + } + SCOPE void + rde_param_i_status_negate (RDE_PARAM p) + { + p->ST = !p->ST; + } + SCOPE int + rde_param_i_symbol_restore (RDE_PARAM p, long int s) + { + NC_STATE* scs; + Tcl_HashEntry* hPtr; + Tcl_HashTable* tablePtr; + + hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); + if (!hPtr) { return 0; } + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); + hPtr = Tcl_FindHashEntry (tablePtr, (char*) s); + if (!hPtr) { return 0; } + + scs = Tcl_GetHashValue (hPtr); + p->CL = scs->CL; + p->ST = scs->ST; + error_state_free (p->ER); + p->ER = scs->ER; + if (p->ER) { p->ER->refCount ++; } + TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); + SV_SET (p, scs->SV); + return 1; + } + SCOPE void + rde_param_i_symbol_save (RDE_PARAM p, long int s) + { + long int at = (long int) rde_stack_top (p->LS); + NC_STATE* scs; + Tcl_HashEntry* hPtr; + Tcl_HashTable* tablePtr; + int isnew; + ENTER ("rde_param_i_symbol_save"); + TRACE (("RDE_PARAM %p",p)); + TRACE (("INT %d",s)); + + hPtr = Tcl_CreateHashEntry (&p->NC, (char*) at, &isnew); + if (isnew) { + tablePtr = ALLOC (Tcl_HashTable); + Tcl_InitHashTable (tablePtr, TCL_ONE_WORD_KEYS); + Tcl_SetHashValue (hPtr, tablePtr); + } else { + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); + } + hPtr = Tcl_CreateHashEntry (tablePtr, (char*) s, &isnew); + if (isnew) { + + scs = ALLOC (NC_STATE); + scs->CL = p->CL; + scs->ST = p->ST; + TRACE (("SV_CACHE (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "")); + scs->SV = p->SV; + if (scs->SV) { Tcl_IncrRefCount (scs->SV); } + scs->ER = p->ER; + if (scs->ER) { scs->ER->refCount ++; } + Tcl_SetHashValue (hPtr, scs); + } else { + + scs = (NC_STATE*) Tcl_GetHashValue (hPtr); + scs->CL = p->CL; + scs->ST = p->ST; + TRACE (("SV_CACHE/over (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "" )); + if (scs->SV) { Tcl_DecrRefCount (scs->SV); } + scs->SV = p->SV; + if (scs->SV) { Tcl_IncrRefCount (scs->SV); } + error_state_free (scs->ER); + scs->ER = p->ER; + if (scs->ER) { scs->ER->refCount ++; } + } + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_test_alnum (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsAlnum, tc_alnum); + } + SCOPE void + rde_param_i_test_alpha (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsAlpha, tc_alpha); + } + SCOPE void + rde_param_i_test_ascii (RDE_PARAM p) + { + test_class (p, UniCharIsAscii, tc_ascii); + } + SCOPE void + rde_param_i_test_control (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsControl, tc_control); + } + SCOPE void + rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) + { + ASSERT_BOUNDS(msg,p->numstr); + p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, msg); + p->CL --; + } + } + SCOPE void + rde_param_i_test_ddigit (RDE_PARAM p) + { + test_class (p, UniCharIsDecDigit, tc_ddigit); + } + SCOPE void + rde_param_i_test_digit (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsDigit, tc_digit); + } + SCOPE void + rde_param_i_test_graph (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsGraph, tc_graph); + } + SCOPE void + rde_param_i_test_lower (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsLower, tc_lower); + } + SCOPE void + rde_param_i_test_print (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsPrint, tc_printable); + } + SCOPE void + rde_param_i_test_punct (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsPunct, tc_punct); + } + SCOPE void + rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) + { + ASSERT_BOUNDS(msg,p->numstr); + p->ST = + (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && + (Tcl_UtfNcmp (p->CC, e, 1) <= 0); + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, msg); + p->CL --; + } + } + SCOPE void + rde_param_i_test_space (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsSpace, tc_space); + } + SCOPE void + rde_param_i_test_upper (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsUpper, tc_upper); + } + SCOPE void + rde_param_i_test_wordchar (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsWordChar, tc_wordchar); + } + SCOPE void + rde_param_i_test_xdigit (RDE_PARAM p) + { + test_class (p, UniCharIsHexDigit, tc_xdigit); + } + static void + test_class (RDE_PARAM p, UniCharClass class, test_class_id id) + { + Tcl_UniChar ch; + Tcl_UtfToUniChar(p->CC, &ch); + ASSERT_BOUNDS(id,p->numstr); + p->ST = !!class (ch); + + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, id); + p->CL --; + } + } + static int + UniCharIsAscii (int character) + { + return (character >= 0) && (character < 0x80); + } + static int + UniCharIsHexDigit (int character) + { + return (character >= 0) && (character < 0x80) && isxdigit(character); + } + static int + UniCharIsDecDigit (int character) + { + return (character >= 0) && (character < 0x80) && isdigit(character); + } + SCOPE void + rde_param_i_value_clear (RDE_PARAM p) + { + SV_CLEAR (p); + } + SCOPE void + rde_param_i_value_leaf (RDE_PARAM p, long int s) + { + Tcl_Obj* newsv; + Tcl_Obj* ov [3]; + long int pos = 1 + (long int) rde_stack_top (p->LS); + ASSERT_BOUNDS(s,p->numstr); + ov [0] = Tcl_NewStringObj (p->string[s], -1); + ov [1] = Tcl_NewIntObj (pos); + ov [2] = Tcl_NewIntObj (p->CL); + newsv = Tcl_NewListObj (3, ov); + TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); + SV_SET (p, newsv); + } + SCOPE void + rde_param_i_value_reduce (RDE_PARAM p, long int s) + { + Tcl_Obj* newsv; + int oc, i, j; + Tcl_Obj** ov; + long int ac; + Tcl_Obj** av; + long int pos = 1 + (long int) rde_stack_top (p->LS); + long int mark = (long int) rde_stack_top (p->mark); + long int asize = rde_stack_size (p->ast); + long int new = asize - mark; + ASSERT (new >= 0, "Bad number of elements to reduce"); + ov = NALLOC (3+new, Tcl_Obj*); + ASSERT_BOUNDS(s,p->numstr); + ov [0] = Tcl_NewStringObj (p->string[s], -1); + ov [1] = Tcl_NewIntObj (pos); + ov [2] = Tcl_NewIntObj (p->CL); + rde_stack_get (p->ast, &ac, (void***) &av); + for (i = 3, j = mark; j < asize; i++, j++) { + ASSERT_BOUNDS (i, 3+new); + ASSERT_BOUNDS (j, ac); + ov [i] = av [j]; + } + ASSERT (i == 3+new, "Reduction result incomplete"); + newsv = Tcl_NewListObj (3+new, ov); + TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); + SV_SET (p, newsv); + ckfree ((char*) ov); + } + static int + er_int_compare (const void* a, const void* b) + { + + const void** ael = (const void**) a; + const void** bel = (const void**) b; + long int avalue = (long int) *ael; + long int bvalue = (long int) *bel; + if (avalue < bvalue) { return -1; } + if (avalue > bvalue) { return 1; } + return 0; + } + SCOPE int + rde_param_i_symbol_start (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) { + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + return 1; + } + rde_stack_push (p->LS, (void*) p->CL); + return 0; + } + SCOPE int + rde_param_i_symbol_start_d (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) { + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + return 1; + } + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + return 0; + } + SCOPE int + rde_param_i_symbol_void_start (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) return 1; + rde_stack_push (p->LS, (void*) p->CL); + return 0; + } + SCOPE int + rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) return 1; + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + return 0; + } + SCOPE void + rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_reduce (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_leaf (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_leaf (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) + { + SV_CLEAR (p); + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) + { + SV_CLEAR (p); + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_char (p, c, m); + } + SCOPE void + rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_range (p, s, e, m); + } + SCOPE void + rde_param_i_next_alnum (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_alnum (p); + } + SCOPE void + rde_param_i_next_alpha (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_alpha (p); + } + SCOPE void + rde_param_i_next_ascii (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_ascii (p); + } + SCOPE void + rde_param_i_next_control (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_control (p); + } + SCOPE void + rde_param_i_next_ddigit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_ddigit (p); + } + SCOPE void + rde_param_i_next_digit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_digit (p); + } + SCOPE void + rde_param_i_next_graph (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_graph (p); + } + SCOPE void + rde_param_i_next_lower (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_lower (p); + } + SCOPE void + rde_param_i_next_print (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_print (p); + } + SCOPE void + rde_param_i_next_punct (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_punct (p); + } + SCOPE void + rde_param_i_next_space (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_space (p); + } + SCOPE void + rde_param_i_next_upper (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_upper (p); + } + SCOPE void + rde_param_i_next_wordchar (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_wordchar (p); + } + SCOPE void + rde_param_i_next_xdigit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_xdigit (p); + } + SCOPE void + rde_param_i_notahead_start_d (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + } + SCOPE void + rde_param_i_notahead_exit_d (RDE_PARAM p) + { + if (p->ST) { + rde_param_i_ast_pop_rewind (p); + } else { + rde_stack_pop (p->mark, 1); + } + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + p->ST = !p->ST; + } + SCOPE void + rde_param_i_notahead_exit (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + p->ST = !p->ST; + } + SCOPE void + rde_param_i_state_push_2 (RDE_PARAM p) + { + + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + SCOPE void + rde_param_i_state_push_void (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + ER_CLEAR (p); + rde_stack_push (p->ES, p->ER); + + } + SCOPE void + rde_param_i_state_push_value (RDE_PARAM p) + { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + rde_stack_push (p->LS, (void*) p->CL); + ER_CLEAR (p); + rde_stack_push (p->ES, p->ER); + + } + SCOPE void + rde_param_i_state_merge_ok (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + p->ST = 1; + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_state_merge_void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_state_merge_value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } + SCOPE int + rde_param_i_kleene_close (RDE_PARAM p) + { + int stop = !p->ST; + rde_param_i_error_pop_merge (p); + if (stop) { + p->ST = 1; + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + return stop; + } + SCOPE int + rde_param_i_kleene_abort (RDE_PARAM p) + { + int stop = !p->ST; + if (stop) { + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + return stop; + } + SCOPE int + rde_param_i_seq_void2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_seq_void2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_seq_value2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_bra_void2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->LS, 1); + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_void2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->LS, 1); + } else { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_value2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_value2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE void + rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) + { + int at = p->CL; + + while (*str) { + rde_param_i_input_next (p, m); + if (!p->ST) { + p->ER->loc = at+1; + p->CL = at; + return; + } + rde_param_i_test_char (p, str, m); + if (!p->ST) { + p->ER->loc = at+1; + p->CL = at; + return; + } + str = Tcl_UtfNext (str); + } + } + SCOPE void + rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + while (*class) { + p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; + if (p->ST) { + ER_CLEAR (p); + return; + } + class = Tcl_UtfNext (class); + } + error_set (p, m); + p->CL --; + } + + + /* + * Declaring the parse functions + */ + + static void poskleene_2 (RDE_PARAM p); + + /* + * Precomputed table of strings (symbols, error messages, etc.). + */ + + static char const* p_string [15] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "t a" + }; + + /* + * Grammar Start Expression + */ + + static void MAIN (RDE_PARAM p) { + poskleene_2 (p); + return; + } + + static void poskleene_2 (RDE_PARAM p) { + /* + * + + * 'a' + */ + + rde_param_i_loc_push (p); + rde_param_i_next_char (p, "a", 14); + if (rde_param_i_kleene_abort(p)) return; + while (1) { + rde_param_i_state_push_2 (p); + rde_param_i_next_char (p, "a", 14); + if (rde_param_i_kleene_close(p)) return; + } + return; + } + + /* -*- c -*- */ + + typedef struct PARSERg { + long int counter; + char buf [50]; + } PARSERg; + + static void + PARSERgRelease (ClientData cd, Tcl_Interp* interp) + { + ckfree((char*) cd); + } + + static const char* + PARSERnewName (Tcl_Interp* interp) + { +#define KEY "tcllib/parser/PACKAGE/TEA" + + Tcl_InterpDeleteProc* proc = PARSERgRelease; + PARSERg* parserg; + + parserg = Tcl_GetAssocData (interp, KEY, &proc); + if (parserg == NULL) { + parserg = (PARSERg*) ckalloc (sizeof (PARSERg)); + parserg->counter = 0; + + Tcl_SetAssocData (interp, KEY, proc, + (ClientData) parserg); + } + + parserg->counter ++; + sprintf (parserg->buf, "PARSER%ld", parserg->counter); + return parserg->buf; +#undef KEY + } + + static void + PARSERdeleteCmd (ClientData clientData) + { + /* + * Release the whole PARSER + * (Low-level engine only actually). + */ + rde_param_del ((RDE_PARAM) clientData); + } + + + /* * ** *** ***** ******** ************* + ** Functions implementing the object methods, and helper. + */ + + static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp); + + static int parser_PARSE (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + int mode; + Tcl_Channel chan; + + if (objc != 3) { + Tcl_WrongNumArgs (interp, 2, objv, "chan"); + return TCL_ERROR; + } + + chan = Tcl_GetChannel(interp, + Tcl_GetString (objv[2]), + &mode); + + if (!chan) { + return TCL_ERROR; + } + + rde_param_reset (p, chan); + MAIN (p) ; /* Entrypoint for the generated code. */ + return COMPLETE (p, interp); + } + + static int parser_PARSET (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + char* buf; + int len; + + if (objc != 3) { + Tcl_WrongNumArgs (interp, 2, objv, "text"); + return TCL_ERROR; + } + + buf = Tcl_GetStringFromObj (objv[2], &len); + + rde_param_reset (p, NULL); + rde_param_data (p, buf, len); + MAIN (p) ; /* Entrypoint for the generated code. */ + return COMPLETE (p, interp); + } + + /* See also rde_critcl/m.c, param_COMPLETE() */ + static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) + { + if (rde_param_query_st (p)) { + long int ac; + Tcl_Obj** av; + + rde_param_query_ast (p, &ac, &av); + + if (ac > 1) { + Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); + + memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); + lv [0] = Tcl_NewObj (); + lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); + lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); + + Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); + ckfree ((char*) lv); + + } else if (ac == 0) { + /* + * Match, but no AST. This is possible if the grammar + * consists of only the start expression. + */ + Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); + } else { + Tcl_SetObjResult (interp, av [0]); + } + + return TCL_OK; + } else { + Tcl_Obj* xv [1]; + const ERROR_STATE* er = rde_param_query_er (p); + Tcl_Obj* res = rde_param_query_er_tcl (p, er); + /* res = list (location, list(msg)) */ + + /* Stick the exception type-tag before the existing elements */ + xv [0] = Tcl_NewStringObj ("pt::rde",-1); + Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); + + Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); + Tcl_SetObjResult (interp, res); + return TCL_ERROR; + } + } + + + /* * ** *** ***** ******** ************* + ** Object command, method dispatch. + */ + static int parser_objcmd (ClientData cd, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + RDE_PARAM p = (RDE_PARAM) cd; + int m, res; + + static CONST char* methods [] = { + "destroy", "parse", "parset", NULL + }; + enum methods { + M_DESTROY, M_PARSE, M_PARSET + }; + + if (objc < 2) { + Tcl_WrongNumArgs (interp, objc, objv, "option ?arg arg ...?"); + return TCL_ERROR; + } else if (Tcl_GetIndexFromObj (interp, objv [1], methods, "option", + 0, &m) != TCL_OK) { + return TCL_ERROR; + } + + /* Dispatch to methods. They check the #args in + * detail before performing the requested + * functionality + */ + + switch (m) { + case M_DESTROY: + if (objc != 2) { + Tcl_WrongNumArgs (interp, 2, objv, NULL); + return TCL_ERROR; + } + + Tcl_DeleteCommandFromToken(interp, (Tcl_Command) rde_param_query_clientdata (p)); + return TCL_OK; + + case M_PARSE: res = parser_PARSE (p, interp, objc, objv); break; + case M_PARSET: res = parser_PARSET (p, interp, objc, objv); break; + default: + /* Not coming to this place */ + ASSERT (0,"Reached unreachable location"); + } + + return res; + } + + /** * ** *** ***** ******** ************* + * Class command, i.e. object construction. + */ + static int ParserClassCmd (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const*objv) { + /* + * Syntax: No arguments beyond the name + */ + + RDE_PARAM parser; + CONST char* name; + Tcl_Obj* fqn; + Tcl_CmdInfo ci; + Tcl_Command c; + +#define USAGE "?name?" + + if ((objc != 2) && (objc != 1)) { + Tcl_WrongNumArgs (interp, 1, objv, USAGE); + return TCL_ERROR; + } + + if (objc < 2) { + name = PARSERnewName (interp); + } else { + name = Tcl_GetString (objv [1]); + } + + if (!Tcl_StringMatch (name, "::*")) { + /* Relative name. Prefix with current namespace */ + + Tcl_Eval (interp, "namespace current"); + fqn = Tcl_GetObjResult (interp); + fqn = Tcl_DuplicateObj (fqn); + Tcl_IncrRefCount (fqn); + + if (!Tcl_StringMatch (Tcl_GetString (fqn), "::")) { + Tcl_AppendToObj (fqn, "::", -1); + } + Tcl_AppendToObj (fqn, name, -1); + } else { + fqn = Tcl_NewStringObj (name, -1); + Tcl_IncrRefCount (fqn); + } + Tcl_ResetResult (interp); + + if (Tcl_GetCommandInfo (interp, + Tcl_GetString (fqn), + &ci)) { + Tcl_Obj* err; + + err = Tcl_NewObj (); + Tcl_AppendToObj (err, "command \"", -1); + Tcl_AppendObjToObj (err, fqn); + Tcl_AppendToObj (err, "\" already exists", -1); + + Tcl_DecrRefCount (fqn); + Tcl_SetObjResult (interp, err); + return TCL_ERROR; + } + + parser = rde_param_new (sizeof(p_string)/sizeof(char*), (char**) p_string); + c = Tcl_CreateObjCommand (interp, Tcl_GetString (fqn), + parser_objcmd, (ClientData) parser, + PARSERdeleteCmd); + rde_param_clientdata (parser, (ClientData) c); + Tcl_SetObjResult (interp, fqn); + Tcl_DecrRefCount (fqn); + return TCL_OK; + } + +int Package_Init(Tcl_Interp* interp) { + if (interp == 0) return TCL_ERROR; + + if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { + return TCL_ERROR; + } + + if (Tcl_CreateObjCommand(interp, "PARSER", ParserClassCmd , NULL, NULL) == NULL) { + Tcl_SetResult(interp, "Can't create constructor", NULL); + return TCL_ERROR; + } + + + Tcl_PkgProvide(interp, "PACKAGE", "0.1"); + + return TCL_OK; +} ADDED modules/pt/tests/data/ok/peg_cparam-tea/9_ahead Index: modules/pt/tests/data/ok/peg_cparam-tea/9_ahead ================================================================== --- /dev/null +++ modules/pt/tests/data/ok/peg_cparam-tea/9_ahead @@ -0,0 +1,2038 @@ +/************************************************************ +** +** TEA-based C/PARAM implementation of the parsing +** expression grammar +** +** TEMPLATE +** +** Generated from file TEST +** for user unknown +** +* * ** *** ***** ******** ************* *********************/ + #include + #include + #include + #include + #define SCOPE static + +#line 1 "rde_critcl/util.h" + + #ifndef _RDE_UTIL_H + #define _RDE_UTIL_H 1 + #ifndef SCOPE + #define SCOPE + #endif + #define ALLOC(type) (type *) ckalloc (sizeof (type)) + #define NALLOC(n,type) (type *) ckalloc ((n) * sizeof (type)) + #undef RDE_DEBUG + #define RDE_DEBUG 1 + #undef RDE_TRACE + #ifdef RDE_DEBUG + #define STOPAFTER(x) { static int count = (x); count --; if (!count) { Tcl_Panic ("stop"); } } + #define XSTR(x) #x + #define STR(x) XSTR(x) + #define RANGEOK(i,n) ((0 <= (i)) && (i < (n))) + #define ASSERT(x,msg) if (!(x)) { Tcl_Panic (msg " (" #x "), in file " __FILE__ " @line " STR(__LINE__));} + #define ASSERT_BOUNDS(i,n) ASSERT (RANGEOK(i,n),"array index out of bounds: " STR(i) " >= " STR(n)) + #else + #define STOPAFTER(x) + #define ASSERT(x,msg) + #define ASSERT_BOUNDS(i,n) + #endif + #ifdef RDE_TRACE + SCOPE void trace_enter (const char* fun); + SCOPE void trace_return (const char *pat, ...); + SCOPE void trace_printf (const char *pat, ...); + #define ENTER(fun) trace_enter (fun) + #define RETURN(format,x) trace_return (format,x) ; return x + #define RETURNVOID trace_return ("%s","(void)") ; return + #define TRACE0(x) trace_printf0 x + #define TRACE(x) trace_printf x + #else + #define ENTER(fun) + #define RETURN(f,x) return x + #define RETURNVOID return + #define TRACE0(x) + #define TRACE(x) + #endif + #endif + + +#line 1 "rde_critcl/stack.h" + + #ifndef _RDE_DS_STACK_H + #define _RDE_DS_STACK_H 1 + typedef void (*RDE_STACK_CELL_FREE) (void* cell); + typedef struct RDE_STACK_* RDE_STACK; + static const int RDE_STACK_INITIAL_SIZE = 256; + #endif + + +#line 1 "rde_critcl/tc.h" + + #ifndef _RDE_DS_TC_H + #define _RDE_DS_TC_H 1 + typedef struct RDE_TC_* RDE_TC; + #endif + + +#line 1 "rde_critcl/param.h" + + #ifndef _RDE_DS_PARAM_H + #define _RDE_DS_PARAM_H 1 + typedef struct RDE_PARAM_* RDE_PARAM; + typedef struct ERROR_STATE { + int refCount; + long int loc; + RDE_STACK msg; + } ERROR_STATE; + typedef struct NC_STATE { + long int CL; + long int ST; + Tcl_Obj* SV; + ERROR_STATE* ER; + } NC_STATE; + #endif + + +#line 1 "rde_critcl/util.c" + + #ifdef RDE_TRACE + typedef struct F_STACK { + const char* str; + struct F_STACK* down; + } F_STACK; + static F_STACK* top = 0; + static int level = 0; + static void + push (const char* str) + { + F_STACK* new = ALLOC (F_STACK); + new->str = str; + new->down = top; + top = new; + level += 4; + } + static void + pop (void) + { + F_STACK* next = top->down; + level -= 4; + ckfree ((char*)top); + top = next; + } + static void + indent (void) + { + int i; + for (i = 0; i < level; i++) { + fwrite(" ", 1, 1, stdout); + fflush (stdout); + } + if (top) { + fwrite(top->str, 1, strlen(top->str), stdout); + fflush (stdout); + } + fwrite(" ", 1, 1, stdout); + fflush (stdout); + } + SCOPE void + trace_enter (const char* fun) + { + push (fun); + indent(); + fwrite("ENTER\n", 1, 6, stdout); + fflush (stdout); + } + static char msg [1024*1024]; + SCOPE void + trace_return (const char *pat, ...) + { + int len; + va_list args; + indent(); + fwrite("RETURN = ", 1, 9, stdout); + fflush (stdout); + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + pop(); + } + SCOPE void + trace_printf (const char *pat, ...) + { + int len; + va_list args; + indent(); + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + } + SCOPE void + trace_printf0 (const char *pat, ...) + { + int len; + va_list args; + va_start(args, pat); + len = vsprintf(msg, pat, args); + va_end(args); + msg[len++] = '\n'; + msg[len] = '\0'; + fwrite(msg, 1, len, stdout); + fflush (stdout); + } + #endif + + +#line 1 "rde_critcl/stack.c" + + typedef struct RDE_STACK_ { + long int max; + long int top; + RDE_STACK_CELL_FREE freeCellProc; + void** cell; + } RDE_STACK_; + + SCOPE RDE_STACK + rde_stack_new (RDE_STACK_CELL_FREE freeCellProc) + { + RDE_STACK s = ALLOC (RDE_STACK_); + s->cell = NALLOC (RDE_STACK_INITIAL_SIZE, void*); + s->max = RDE_STACK_INITIAL_SIZE; + s->top = 0; + s->freeCellProc = freeCellProc; + return s; + } + SCOPE void + rde_stack_del (RDE_STACK s) + { + if (s->freeCellProc && s->top) { + long int i; + for (i=0; i < s->top; i++) { + ASSERT_BOUNDS(i,s->max); + s->freeCellProc ( s->cell [i] ); + } + } + ckfree ((char*) s->cell); + ckfree ((char*) s); + } + SCOPE void + rde_stack_push (RDE_STACK s, void* item) + { + if (s->top >= s->max) { + long int new = s->max ? (2 * s->max) : RDE_STACK_INITIAL_SIZE; + void** cell = (void**) ckrealloc ((char*) s->cell, new * sizeof(void*)); + ASSERT (cell,"Memory allocation failure for RDE stack"); + s->max = new; + s->cell = cell; + } + ASSERT_BOUNDS(s->top,s->max); + s->cell [s->top] = item; + s->top ++; + } + SCOPE void* + rde_stack_top (RDE_STACK s) + { + ASSERT_BOUNDS(s->top-1,s->max); + return s->cell [s->top - 1]; + } + SCOPE void + rde_stack_pop (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad pop count"); + if (n == 0) return; + if (s->freeCellProc) { + while (n) { + s->top --; + ASSERT_BOUNDS(s->top,s->max); + s->freeCellProc ( s->cell [s->top] ); + n --; + } + } else { + s->top -= n; + } + } + SCOPE void + rde_stack_trim (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad trimsize"); + if (s->freeCellProc) { + while (s->top > n) { + s->top --; + ASSERT_BOUNDS(s->top,s->max); + s->freeCellProc ( s->cell [s->top] ); + } + } else { + s->top = n; + } + } + SCOPE void + rde_stack_drop (RDE_STACK s, long int n) + { + ASSERT (n >= 0, "Bad pop count"); + if (n == 0) return; + s->top -= n; + } + SCOPE void + rde_stack_move (RDE_STACK dst, RDE_STACK src) + { + ASSERT (dst->freeCellProc == src->freeCellProc, "Ownership mismatch"); + + while (src->top > 0) { + src->top --; + ASSERT_BOUNDS(src->top,src->max); + rde_stack_push (dst, src->cell [src->top] ); + } + } + SCOPE void + rde_stack_get (RDE_STACK s, long int* cn, void*** cc) + { + *cn = s->top; + *cc = s->cell; + } + SCOPE long int + rde_stack_size (RDE_STACK s) + { + return s->top; + } + + +#line 1 "rde_critcl/tc.c" + + typedef struct RDE_TC_ { + int max; + int num; + char* str; + RDE_STACK off; + } RDE_TC_; + + SCOPE RDE_TC + rde_tc_new (void) + { + RDE_TC tc = ALLOC (RDE_TC_); + tc->max = RDE_STACK_INITIAL_SIZE; + tc->num = 0; + tc->str = NALLOC (RDE_STACK_INITIAL_SIZE, char); + tc->off = rde_stack_new (NULL); + return tc; + } + SCOPE void + rde_tc_del (RDE_TC tc) + { + rde_stack_del (tc->off); + ckfree (tc->str); + ckfree ((char*) tc); + } + SCOPE long int + rde_tc_size (RDE_TC tc) + { + return rde_stack_size (tc->off); + } + SCOPE void + rde_tc_clear (RDE_TC tc) + { + tc->num = 0; + rde_stack_trim (tc->off, 0); + } + SCOPE char* + rde_tc_append (RDE_TC tc, char* string, long int len) + { + long int base = tc->num; + long int off = tc->num; + char* ch; + int clen; + Tcl_UniChar uni; + if (len < 0) { + len = strlen (string); + } + + if (!len) { + return tc->str + base; + } + + if ((tc->num + len) >= tc->max) { + int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); + char* str = ckrealloc (tc->str, new * sizeof(char)); + ASSERT (str,"Memory allocation failure for token character array"); + tc->max = new; + tc->str = str; + } + tc->num += len; + ASSERT_BOUNDS(tc->num,tc->max); + ASSERT_BOUNDS(off,tc->max); + ASSERT_BOUNDS(off+len-1,tc->max); + ASSERT_BOUNDS(off+len-1,tc->num); + memcpy (tc->str + off, string, len); + + ch = string; + while (ch < (string + len)) { + ASSERT_BOUNDS(off,tc->num); + rde_stack_push (tc->off, (void*) off); + clen = Tcl_UtfToUniChar (ch, &uni); + off += clen; + ch += clen; + } + return tc->str + base; + } + SCOPE void + rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) + { + long int oc, off, top, end; + void** ov; + rde_stack_get (tc->off, &oc, &ov); + ASSERT_BOUNDS(at,oc); + off = (long int) ov [at]; + if ((at+1) == oc) { + end = tc->num; + } else { + end = (long int) ov [at+1]; + } + TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); + ASSERT_BOUNDS(off,tc->num); + ASSERT_BOUNDS(end-1,tc->num); + *ch = tc->str + off; + *len = end - off; + } + SCOPE void + rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) + { + long int oc, off, top, end; + void** ov; + rde_stack_get (tc->off, &oc, &ov); + ASSERT_BOUNDS(at,oc); + ASSERT_BOUNDS(last,oc); + off = (long int) ov [at]; + if ((last+1) == oc) { + end = tc->num; + } else { + end = (long int) ov [last+1]; + } + TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); + ASSERT_BOUNDS(off,tc->num); + ASSERT_BOUNDS(end-1,tc->num); + *ch = tc->str + off; + *len = end - off; + } + + +#line 1 "rde_critcl/param.c" + + typedef struct RDE_PARAM_ { + Tcl_Channel IN; + Tcl_Obj* readbuf; + char* CC; + long int CC_len; + RDE_TC TC; + long int CL; + RDE_STACK LS; + ERROR_STATE* ER; + RDE_STACK ES; + long int ST; + Tcl_Obj* SV; + Tcl_HashTable NC; + + RDE_STACK ast ; + RDE_STACK mark ; + + long int numstr; + char** string; + + ClientData clientData; + } RDE_PARAM_; + typedef int (*UniCharClass) (int); + typedef enum test_class_id { + tc_alnum, + tc_alpha, + tc_ascii, + tc_control, + tc_ddigit, + tc_digit, + tc_graph, + tc_lower, + tc_printable, + tc_punct, + tc_space, + tc_upper, + tc_wordchar, + tc_xdigit + } test_class_id; + static void ast_node_free (void* n); + static void error_state_free (void* es); + static void error_set (RDE_PARAM p, long int s); + static void nc_clear (RDE_PARAM p); + static int UniCharIsAscii (int character); + static int UniCharIsHexDigit (int character); + static int UniCharIsDecDigit (int character); + static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); + static int er_int_compare (const void* a, const void* b); + #define SV_INIT(p) \ + p->SV = NULL; \ + TRACE (("SV_INIT (%p => %p)", (p), (p)->SV)) + #define SV_SET(p,newsv) \ + if (((p)->SV) != (newsv)) { \ + TRACE (("SV_CLEAR/set (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_DecrRefCount ((p)->SV); \ + } \ + (p)->SV = (newsv); \ + TRACE (("SV_SET (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_IncrRefCount ((p)->SV); \ + } \ + } + #define SV_CLEAR(p) \ + TRACE (("SV_CLEAR (%p => %p)", (p), (p)->SV)); \ + if ((p)->SV) { \ + Tcl_DecrRefCount ((p)->SV); \ + } \ + (p)->SV = NULL + #define ER_INIT(p) \ + p->ER = NULL; \ + TRACE (("ER_INIT (%p => %p)", (p), (p)->ER)) + #define ER_CLEAR(p) \ + error_state_free ((p)->ER); \ + (p)->ER = NULL + SCOPE RDE_PARAM + rde_param_new (long int nstr, char** strings) + { + RDE_PARAM p; + ENTER ("rde_param_new"); + TRACE (("\tINT %d strings @ %p", nstr, strings)); + p = ALLOC (RDE_PARAM_); + p->numstr = nstr; + p->string = strings; + p->readbuf = Tcl_NewObj (); + Tcl_IncrRefCount (p->readbuf); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + Tcl_InitHashTable (&p->NC, TCL_ONE_WORD_KEYS); + p->IN = NULL; + p->CL = -1; + p->ST = 0; + ER_INIT (p); + SV_INIT (p); + p->CC = NULL; + p->CC_len = 0; + p->TC = rde_tc_new (); + p->ES = rde_stack_new (error_state_free); + p->LS = rde_stack_new (NULL); + p->ast = rde_stack_new (ast_node_free); + p->mark = rde_stack_new (NULL); + RETURN ("%p", p); + } + SCOPE void + rde_param_del (RDE_PARAM p) + { + ENTER ("rde_param_del"); + TRACE (("RDE_PARAM %p",p)); + ER_CLEAR (p); TRACE (("\ter_clear")); + SV_CLEAR (p); TRACE (("\tsv_clear")); + nc_clear (p); TRACE (("\tnc_clear")); + Tcl_DeleteHashTable (&p->NC); TRACE (("\tnc hashtable delete")); + rde_tc_del (p->TC); TRACE (("\ttc clear")); + rde_stack_del (p->ES); TRACE (("\tes clear")); + rde_stack_del (p->LS); TRACE (("\tls clear")); + rde_stack_del (p->ast); TRACE (("\tast clear")); + rde_stack_del (p->mark); TRACE (("\tmark clear")); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + Tcl_DecrRefCount (p->readbuf); + ckfree ((char*) p); + RETURNVOID; + } + SCOPE void + rde_param_reset (RDE_PARAM p, Tcl_Channel chan) + { + ENTER ("rde_param_reset"); + TRACE (("RDE_PARAM %p",p)); + TRACE (("Tcl_Channel %p",chan)); + p->IN = chan; + p->CL = -1; + p->ST = 0; + p->CC = NULL; + p->CC_len = 0; + ER_CLEAR (p); + SV_CLEAR (p); + nc_clear (p); + rde_tc_clear (p->TC); + rde_stack_trim (p->ES, 0); + rde_stack_trim (p->LS, 0); + rde_stack_trim (p->ast, 0); + rde_stack_trim (p->mark, 0); + TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); + RETURNVOID; + } + SCOPE void + rde_param_update_strings (RDE_PARAM p, long int nstr, char** strings) + { + ENTER ("rde_param_update_strings"); + TRACE (("RDE_PARAM %p", p)); + TRACE (("INT %d strings", nstr)); + p->numstr = nstr; + p->string = strings; + RETURNVOID; + } + SCOPE void + rde_param_data (RDE_PARAM p, char* buf, long int len) + { + (void) rde_tc_append (p->TC, buf, len); + } + SCOPE void + rde_param_clientdata (RDE_PARAM p, ClientData clientData) + { + p->clientData = clientData; + } + static void + nc_clear (RDE_PARAM p) + { + Tcl_HashSearch hs; + Tcl_HashEntry* he; + Tcl_HashTable* tablePtr; + for(he = Tcl_FirstHashEntry(&p->NC, &hs); + he != NULL; + he = Tcl_FirstHashEntry(&p->NC, &hs)) { + Tcl_HashSearch hsc; + Tcl_HashEntry* hec; + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (he); + for(hec = Tcl_FirstHashEntry(tablePtr, &hsc); + hec != NULL; + hec = Tcl_NextHashEntry(&hsc)) { + NC_STATE* scs = Tcl_GetHashValue (hec); + error_state_free (scs->ER); + if (scs->SV) { Tcl_DecrRefCount (scs->SV); } + ckfree ((char*) scs); + } + Tcl_DeleteHashTable (tablePtr); + ckfree ((char*) tablePtr); + Tcl_DeleteHashEntry (he); + } + } + SCOPE ClientData + rde_param_query_clientdata (RDE_PARAM p) + { + return p->clientData; + } + SCOPE void + rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) + { + rde_stack_get (p->mark, mc, mv); + } + SCOPE void + rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) + { + rde_stack_get (p->ast, ac, (void***) av); + } + SCOPE const char* + rde_param_query_in (RDE_PARAM p) + { + return p->IN + ? Tcl_GetChannelName (p->IN) + : ""; + } + SCOPE const char* + rde_param_query_cc (RDE_PARAM p, long int* len) + { + *len = p->CC_len; + return p->CC; + } + SCOPE int + rde_param_query_cl (RDE_PARAM p) + { + return p->CL; + } + SCOPE const ERROR_STATE* + rde_param_query_er (RDE_PARAM p) + { + return p->ER; + } + SCOPE Tcl_Obj* + rde_param_query_er_tcl (RDE_PARAM p, const ERROR_STATE* er) + { + Tcl_Obj* res; + if (!er) { + + res = Tcl_NewStringObj ("", 0); + } else { + Tcl_Obj* ov [2]; + Tcl_Obj** mov; + long int mc, i, j; + void** mv; + int lastid; + const char* msg; + rde_stack_get (er->msg, &mc, &mv); + + qsort (mv, mc, sizeof (void*), er_int_compare); + + mov = NALLOC (mc, Tcl_Obj*); + lastid = -1; + for (i=0, j=0; i < mc; i++) { + ASSERT_BOUNDS (i,mc); + if (((long int) mv [i]) == lastid) continue; + lastid = (long int) mv [i]; + ASSERT_BOUNDS((long int) mv[i],p->numstr); + msg = p->string [(long int) mv[i]]; + ASSERT_BOUNDS (j,mc); + mov [j] = Tcl_NewStringObj (msg, -1); + j++; + } + + ov [0] = Tcl_NewIntObj (er->loc); + ov [1] = Tcl_NewListObj (j, mov); + res = Tcl_NewListObj (2, ov); + ckfree ((char*) mov); + } + return res; + } + SCOPE void + rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) + { + rde_stack_get (p->ES, ec, (void***) ev); + } + SCOPE void + rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) + { + rde_stack_get (p->LS, lc, lv); + } + SCOPE long int + rde_param_query_lstop (RDE_PARAM p) + { + (long int) rde_stack_top (p->LS); + } + SCOPE Tcl_HashTable* + rde_param_query_nc (RDE_PARAM p) + { + return &p->NC; + } + SCOPE int + rde_param_query_st (RDE_PARAM p) + { + return p->ST; + } + SCOPE Tcl_Obj* + rde_param_query_sv (RDE_PARAM p) + { + TRACE (("SV_QUERY %p => (%p)", (p), (p)->SV)); \ + return p->SV; + } + SCOPE long int + rde_param_query_tc_size (RDE_PARAM p) + { + return rde_tc_size (p->TC); + } + SCOPE void + rde_param_query_tc_get_s (RDE_PARAM p, long int at, long int last, char** ch, long int* len) + { + rde_tc_get_s (p->TC, at, last, ch, len); + } + SCOPE const char* + rde_param_query_string (RDE_PARAM p, long int id) + { + TRACE (("rde_param_query_string (RDE_PARAM %p, %d/%d)", p, id, p->numstr)); + ASSERT_BOUNDS(id,p->numstr); + return p->string [id]; + } + SCOPE void + rde_param_i_ast_pop_discard (RDE_PARAM p) + { + rde_stack_pop (p->mark, 1); + } + SCOPE void + rde_param_i_ast_pop_rewind (RDE_PARAM p) + { + long int trim = (long int) rde_stack_top (p->mark); + ENTER ("rde_param_i_ast_pop_rewind"); + TRACE (("RDE_PARAM %p",p)); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_ast_rewind (RDE_PARAM p) + { + long int trim = (long int) rde_stack_top (p->mark); + ENTER ("rde_param_i_ast_rewind"); + TRACE (("RDE_PARAM %p",p)); + rde_stack_trim (p->ast, trim); + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_ast_push (RDE_PARAM p) + { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + } + SCOPE void + rde_param_i_ast_value_push (RDE_PARAM p) + { + ENTER ("rde_param_i_ast_value_push"); + TRACE (("RDE_PARAM %p",p)); + ASSERT(p->SV,"Unable to push undefined semantic value"); + TRACE (("rde_param_i_ast_value_push %p => (%p)", p, p->SV)); + TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV->refCount, Tcl_GetString (p->SV))); + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + RETURNVOID; + } + static void + ast_node_free (void* n) + { + Tcl_DecrRefCount ((Tcl_Obj*) n); + } + SCOPE void + rde_param_i_error_clear (RDE_PARAM p) + { + ER_CLEAR (p); + } + SCOPE void + rde_param_i_error_nonterminal (RDE_PARAM p, long int s) + { + + return; + long int pos; + if (!p->ER) return; + pos = 1 + (long int) rde_stack_top (p->LS); + if (p->ER->loc != pos) return; + error_set (p, s); + p->ER->loc = pos; + } + SCOPE void + rde_param_i_error_pop_merge (RDE_PARAM p) + { + ERROR_STATE* top = (ERROR_STATE*) rde_stack_top (p->ES); + + if (top == p->ER) { + rde_stack_pop (p->ES, 1); + return; + } + + if (!top) { + rde_stack_pop (p->ES, 1); + return; + } + + if (!p->ER) { + rde_stack_drop (p->ES, 1); + p->ER = top; + + return; + } + + if (top->loc < p->ER->loc) { + rde_stack_pop (p->ES, 1); + return; + } + + if (top->loc > p->ER->loc) { + rde_stack_drop (p->ES, 1); + error_state_free (p->ER); + p->ER = top; + + return; + } + + rde_stack_move (p->ER->msg, top->msg); + rde_stack_pop (p->ES, 1); + } + SCOPE void + rde_param_i_error_push (RDE_PARAM p) + { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + static void + error_set (RDE_PARAM p, long int s) + { + error_state_free (p->ER); + p->ER = ALLOC (ERROR_STATE); + p->ER->refCount = 1; + p->ER->loc = p->CL; + p->ER->msg = rde_stack_new (NULL); + ASSERT_BOUNDS(s,p->numstr); + rde_stack_push (p->ER->msg, (void*) s); + } + static void + error_state_free (void* esx) + { + ERROR_STATE* es = esx; + if (!es) return; + es->refCount --; + if (es->refCount > 0) return; + rde_stack_del (es->msg); + ckfree ((char*) es); + } + SCOPE void + rde_param_i_loc_pop_discard (RDE_PARAM p) + { + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_loc_pop_rewind (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_loc_push (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + } + SCOPE void + rde_param_i_loc_rewind (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + } + SCOPE void + rde_param_i_input_next (RDE_PARAM p, long int m) + { + int leni; + char* ch; + ASSERT_BOUNDS(m,p->numstr); + p->CL ++; + if (p->CL < rde_tc_size (p->TC)) { + + rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); + + ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); + p->ST = 1; + ER_CLEAR (p); + return; + } + if (!p->IN || + Tcl_Eof (p->IN) || + (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { + + p->ST = 0; + error_set (p, m); + return; + } + + ch = Tcl_GetStringFromObj (p->readbuf, &leni); + ASSERT_BOUNDS (leni, TCL_UTF_MAX); + p->CC = rde_tc_append (p->TC, ch, leni); + p->CC_len = leni; + p->ST = 1; + ER_CLEAR (p); + } + SCOPE void + rde_param_i_status_fail (RDE_PARAM p) + { + p->ST = 0; + } + SCOPE void + rde_param_i_status_ok (RDE_PARAM p) + { + p->ST = 1; + } + SCOPE void + rde_param_i_status_negate (RDE_PARAM p) + { + p->ST = !p->ST; + } + SCOPE int + rde_param_i_symbol_restore (RDE_PARAM p, long int s) + { + NC_STATE* scs; + Tcl_HashEntry* hPtr; + Tcl_HashTable* tablePtr; + + hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); + if (!hPtr) { return 0; } + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); + hPtr = Tcl_FindHashEntry (tablePtr, (char*) s); + if (!hPtr) { return 0; } + + scs = Tcl_GetHashValue (hPtr); + p->CL = scs->CL; + p->ST = scs->ST; + error_state_free (p->ER); + p->ER = scs->ER; + if (p->ER) { p->ER->refCount ++; } + TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); + SV_SET (p, scs->SV); + return 1; + } + SCOPE void + rde_param_i_symbol_save (RDE_PARAM p, long int s) + { + long int at = (long int) rde_stack_top (p->LS); + NC_STATE* scs; + Tcl_HashEntry* hPtr; + Tcl_HashTable* tablePtr; + int isnew; + ENTER ("rde_param_i_symbol_save"); + TRACE (("RDE_PARAM %p",p)); + TRACE (("INT %d",s)); + + hPtr = Tcl_CreateHashEntry (&p->NC, (char*) at, &isnew); + if (isnew) { + tablePtr = ALLOC (Tcl_HashTable); + Tcl_InitHashTable (tablePtr, TCL_ONE_WORD_KEYS); + Tcl_SetHashValue (hPtr, tablePtr); + } else { + tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); + } + hPtr = Tcl_CreateHashEntry (tablePtr, (char*) s, &isnew); + if (isnew) { + + scs = ALLOC (NC_STATE); + scs->CL = p->CL; + scs->ST = p->ST; + TRACE (("SV_CACHE (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "")); + scs->SV = p->SV; + if (scs->SV) { Tcl_IncrRefCount (scs->SV); } + scs->ER = p->ER; + if (scs->ER) { scs->ER->refCount ++; } + Tcl_SetHashValue (hPtr, scs); + } else { + + scs = (NC_STATE*) Tcl_GetHashValue (hPtr); + scs->CL = p->CL; + scs->ST = p->ST; + TRACE (("SV_CACHE/over (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "" )); + if (scs->SV) { Tcl_DecrRefCount (scs->SV); } + scs->SV = p->SV; + if (scs->SV) { Tcl_IncrRefCount (scs->SV); } + error_state_free (scs->ER); + scs->ER = p->ER; + if (scs->ER) { scs->ER->refCount ++; } + } + TRACE (("SV = (%p rc%d '%s')", + p->SV, + p->SV ? p->SV->refCount : -1, + p->SV ? Tcl_GetString (p->SV) : "")); + RETURNVOID; + } + SCOPE void + rde_param_i_test_alnum (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsAlnum, tc_alnum); + } + SCOPE void + rde_param_i_test_alpha (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsAlpha, tc_alpha); + } + SCOPE void + rde_param_i_test_ascii (RDE_PARAM p) + { + test_class (p, UniCharIsAscii, tc_ascii); + } + SCOPE void + rde_param_i_test_control (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsControl, tc_control); + } + SCOPE void + rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) + { + ASSERT_BOUNDS(msg,p->numstr); + p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, msg); + p->CL --; + } + } + SCOPE void + rde_param_i_test_ddigit (RDE_PARAM p) + { + test_class (p, UniCharIsDecDigit, tc_ddigit); + } + SCOPE void + rde_param_i_test_digit (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsDigit, tc_digit); + } + SCOPE void + rde_param_i_test_graph (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsGraph, tc_graph); + } + SCOPE void + rde_param_i_test_lower (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsLower, tc_lower); + } + SCOPE void + rde_param_i_test_print (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsPrint, tc_printable); + } + SCOPE void + rde_param_i_test_punct (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsPunct, tc_punct); + } + SCOPE void + rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) + { + ASSERT_BOUNDS(msg,p->numstr); + p->ST = + (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && + (Tcl_UtfNcmp (p->CC, e, 1) <= 0); + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, msg); + p->CL --; + } + } + SCOPE void + rde_param_i_test_space (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsSpace, tc_space); + } + SCOPE void + rde_param_i_test_upper (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsUpper, tc_upper); + } + SCOPE void + rde_param_i_test_wordchar (RDE_PARAM p) + { + test_class (p, Tcl_UniCharIsWordChar, tc_wordchar); + } + SCOPE void + rde_param_i_test_xdigit (RDE_PARAM p) + { + test_class (p, UniCharIsHexDigit, tc_xdigit); + } + static void + test_class (RDE_PARAM p, UniCharClass class, test_class_id id) + { + Tcl_UniChar ch; + Tcl_UtfToUniChar(p->CC, &ch); + ASSERT_BOUNDS(id,p->numstr); + p->ST = !!class (ch); + + if (p->ST) { + ER_CLEAR (p); + } else { + error_set (p, id); + p->CL --; + } + } + static int + UniCharIsAscii (int character) + { + return (character >= 0) && (character < 0x80); + } + static int + UniCharIsHexDigit (int character) + { + return (character >= 0) && (character < 0x80) && isxdigit(character); + } + static int + UniCharIsDecDigit (int character) + { + return (character >= 0) && (character < 0x80) && isdigit(character); + } + SCOPE void + rde_param_i_value_clear (RDE_PARAM p) + { + SV_CLEAR (p); + } + SCOPE void + rde_param_i_value_leaf (RDE_PARAM p, long int s) + { + Tcl_Obj* newsv; + Tcl_Obj* ov [3]; + long int pos = 1 + (long int) rde_stack_top (p->LS); + ASSERT_BOUNDS(s,p->numstr); + ov [0] = Tcl_NewStringObj (p->string[s], -1); + ov [1] = Tcl_NewIntObj (pos); + ov [2] = Tcl_NewIntObj (p->CL); + newsv = Tcl_NewListObj (3, ov); + TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); + SV_SET (p, newsv); + } + SCOPE void + rde_param_i_value_reduce (RDE_PARAM p, long int s) + { + Tcl_Obj* newsv; + int oc, i, j; + Tcl_Obj** ov; + long int ac; + Tcl_Obj** av; + long int pos = 1 + (long int) rde_stack_top (p->LS); + long int mark = (long int) rde_stack_top (p->mark); + long int asize = rde_stack_size (p->ast); + long int new = asize - mark; + ASSERT (new >= 0, "Bad number of elements to reduce"); + ov = NALLOC (3+new, Tcl_Obj*); + ASSERT_BOUNDS(s,p->numstr); + ov [0] = Tcl_NewStringObj (p->string[s], -1); + ov [1] = Tcl_NewIntObj (pos); + ov [2] = Tcl_NewIntObj (p->CL); + rde_stack_get (p->ast, &ac, (void***) &av); + for (i = 3, j = mark; j < asize; i++, j++) { + ASSERT_BOUNDS (i, 3+new); + ASSERT_BOUNDS (j, ac); + ov [i] = av [j]; + } + ASSERT (i == 3+new, "Reduction result incomplete"); + newsv = Tcl_NewListObj (3+new, ov); + TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); + SV_SET (p, newsv); + ckfree ((char*) ov); + } + static int + er_int_compare (const void* a, const void* b) + { + + const void** ael = (const void**) a; + const void** bel = (const void**) b; + long int avalue = (long int) *ael; + long int bvalue = (long int) *bel; + if (avalue < bvalue) { return -1; } + if (avalue > bvalue) { return 1; } + return 0; + } + SCOPE int + rde_param_i_symbol_start (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) { + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + return 1; + } + rde_stack_push (p->LS, (void*) p->CL); + return 0; + } + SCOPE int + rde_param_i_symbol_start_d (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) { + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + return 1; + } + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + return 0; + } + SCOPE int + rde_param_i_symbol_void_start (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) return 1; + rde_stack_push (p->LS, (void*) p->CL); + return 0; + } + SCOPE int + rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) + { + if (rde_param_i_symbol_restore (p, s)) return 1; + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + return 0; + } + SCOPE void + rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_reduce (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_leaf (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) + { + if (p->ST) { + rde_param_i_value_leaf (p, s); + } else { + SV_CLEAR (p); + } + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + if (p->ST) { + rde_stack_push (p->ast, p->SV); + Tcl_IncrRefCount (p->SV); + } + } + SCOPE void + rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) + { + SV_CLEAR (p); + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) + { + SV_CLEAR (p); + rde_param_i_symbol_save (p, s); + rde_param_i_error_nonterminal (p, m); + rde_param_i_ast_pop_rewind (p); + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_char (p, c, m); + } + SCOPE void + rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_range (p, s, e, m); + } + SCOPE void + rde_param_i_next_alnum (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_alnum (p); + } + SCOPE void + rde_param_i_next_alpha (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_alpha (p); + } + SCOPE void + rde_param_i_next_ascii (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_ascii (p); + } + SCOPE void + rde_param_i_next_control (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_control (p); + } + SCOPE void + rde_param_i_next_ddigit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_ddigit (p); + } + SCOPE void + rde_param_i_next_digit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_digit (p); + } + SCOPE void + rde_param_i_next_graph (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_graph (p); + } + SCOPE void + rde_param_i_next_lower (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_lower (p); + } + SCOPE void + rde_param_i_next_print (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_print (p); + } + SCOPE void + rde_param_i_next_punct (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_punct (p); + } + SCOPE void + rde_param_i_next_space (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_space (p); + } + SCOPE void + rde_param_i_next_upper (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_upper (p); + } + SCOPE void + rde_param_i_next_wordchar (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_wordchar (p); + } + SCOPE void + rde_param_i_next_xdigit (RDE_PARAM p, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + rde_param_i_test_xdigit (p); + } + SCOPE void + rde_param_i_notahead_start_d (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + } + SCOPE void + rde_param_i_notahead_exit_d (RDE_PARAM p) + { + if (p->ST) { + rde_param_i_ast_pop_rewind (p); + } else { + rde_stack_pop (p->mark, 1); + } + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + p->ST = !p->ST; + } + SCOPE void + rde_param_i_notahead_exit (RDE_PARAM p) + { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + p->ST = !p->ST; + } + SCOPE void + rde_param_i_state_push_2 (RDE_PARAM p) + { + + rde_stack_push (p->LS, (void*) p->CL); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + SCOPE void + rde_param_i_state_push_void (RDE_PARAM p) + { + rde_stack_push (p->LS, (void*) p->CL); + ER_CLEAR (p); + rde_stack_push (p->ES, p->ER); + + } + SCOPE void + rde_param_i_state_push_value (RDE_PARAM p) + { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + rde_stack_push (p->LS, (void*) p->CL); + ER_CLEAR (p); + rde_stack_push (p->ES, p->ER); + + } + SCOPE void + rde_param_i_state_merge_ok (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + p->ST = 1; + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_state_merge_void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + } + SCOPE void + rde_param_i_state_merge_value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (!p->ST) { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } + SCOPE int + rde_param_i_kleene_close (RDE_PARAM p) + { + int stop = !p->ST; + rde_param_i_error_pop_merge (p); + if (stop) { + p->ST = 1; + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + return stop; + } + SCOPE int + rde_param_i_kleene_abort (RDE_PARAM p) + { + int stop = !p->ST; + if (stop) { + p->CL = (long int) rde_stack_top (p->LS); + } + rde_stack_pop (p->LS, 1); + return stop; + } + SCOPE int + rde_param_i_seq_void2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_seq_void2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_seq_value2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + return 0; + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_pop (p->LS, 1); + return 1; + } + } + SCOPE int + rde_param_i_bra_void2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->LS, 1); + } else { + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_void2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->LS, 1); + } else { + rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_value2void (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_pop (p->mark, 1); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE int + rde_param_i_bra_value2value (RDE_PARAM p) + { + rde_param_i_error_pop_merge (p); + if (p->ST) { + rde_stack_pop (p->mark, 1); + rde_stack_pop (p->LS, 1); + } else { + long int trim = (long int) rde_stack_top (p->mark); + rde_stack_trim (p->ast, trim); + p->CL = (long int) rde_stack_top (p->LS); + rde_stack_push (p->ES, p->ER); + if (p->ER) { p->ER->refCount ++; } + } + return p->ST; + } + SCOPE void + rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) + { + int at = p->CL; + + while (*str) { + rde_param_i_input_next (p, m); + if (!p->ST) { + p->ER->loc = at+1; + p->CL = at; + return; + } + rde_param_i_test_char (p, str, m); + if (!p->ST) { + p->ER->loc = at+1; + p->CL = at; + return; + } + str = Tcl_UtfNext (str); + } + } + SCOPE void + rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) + { + rde_param_i_input_next (p, m); + if (!p->ST) return; + while (*class) { + p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; + if (p->ST) { + ER_CLEAR (p); + return; + } + class = Tcl_UtfNext (class); + } + error_set (p, m); + p->CL --; + } + + + /* + * Declaring the parse functions + */ + + static void ahead_3 (RDE_PARAM p); + static void sequence_6 (RDE_PARAM p); + static void sym_TEST (RDE_PARAM p); + + /* + * Precomputed table of strings (symbols, error messages, etc.). + */ + + static char const* p_string [17] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "t a", + /* 15 = */ "n TEST", + /* 16 = */ "TEST" + }; + + /* + * Grammar Start Expression + */ + + static void MAIN (RDE_PARAM p) { + sym_TEST (p); + return; + } + + /* + * value Symbol 'TEST' + */ + + static void sym_TEST (RDE_PARAM p) { + /* + * x + * & + * 'a' + * (IDENTIFIER) + */ + + if (rde_param_i_symbol_start (p, 16)) return ; + sequence_6 (p); + rde_param_i_symbol_done_leaf (p, 16, 15); + return; + } + + static void sequence_6 (RDE_PARAM p) { + /* + * x + * & + * 'a' + * (IDENTIFIER) + */ + + rde_param_i_state_push_void (p); + ahead_3 (p); + if (rde_param_i_seq_void2void(p)) return; + /* Undefined symbol 'IDENTIFIER' */; + rde_param_i_status_fail (p); + rde_param_i_state_merge_void (p); + return; + } + + static void ahead_3 (RDE_PARAM p) { + /* + * & + * 'a' + */ + + rde_param_i_loc_push (p); + rde_param_i_next_char (p, "a", 14); + rde_param_i_loc_pop_rewind (p); + return; + } + + /* -*- c -*- */ + + typedef struct PARSERg { + long int counter; + char buf [50]; + } PARSERg; + + static void + PARSERgRelease (ClientData cd, Tcl_Interp* interp) + { + ckfree((char*) cd); + } + + static const char* + PARSERnewName (Tcl_Interp* interp) + { +#define KEY "tcllib/parser/PACKAGE/TEA" + + Tcl_InterpDeleteProc* proc = PARSERgRelease; + PARSERg* parserg; + + parserg = Tcl_GetAssocData (interp, KEY, &proc); + if (parserg == NULL) { + parserg = (PARSERg*) ckalloc (sizeof (PARSERg)); + parserg->counter = 0; + + Tcl_SetAssocData (interp, KEY, proc, + (ClientData) parserg); + } + + parserg->counter ++; + sprintf (parserg->buf, "PARSER%ld", parserg->counter); + return parserg->buf; +#undef KEY + } + + static void + PARSERdeleteCmd (ClientData clientData) + { + /* + * Release the whole PARSER + * (Low-level engine only actually). + */ + rde_param_del ((RDE_PARAM) clientData); + } + + + /* * ** *** ***** ******** ************* + ** Functions implementing the object methods, and helper. + */ + + static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp); + + static int parser_PARSE (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + int mode; + Tcl_Channel chan; + + if (objc != 3) { + Tcl_WrongNumArgs (interp, 2, objv, "chan"); + return TCL_ERROR; + } + + chan = Tcl_GetChannel(interp, + Tcl_GetString (objv[2]), + &mode); + + if (!chan) { + return TCL_ERROR; + } + + rde_param_reset (p, chan); + MAIN (p) ; /* Entrypoint for the generated code. */ + return COMPLETE (p, interp); + } + + static int parser_PARSET (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + char* buf; + int len; + + if (objc != 3) { + Tcl_WrongNumArgs (interp, 2, objv, "text"); + return TCL_ERROR; + } + + buf = Tcl_GetStringFromObj (objv[2], &len); + + rde_param_reset (p, NULL); + rde_param_data (p, buf, len); + MAIN (p) ; /* Entrypoint for the generated code. */ + return COMPLETE (p, interp); + } + + /* See also rde_critcl/m.c, param_COMPLETE() */ + static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) + { + if (rde_param_query_st (p)) { + long int ac; + Tcl_Obj** av; + + rde_param_query_ast (p, &ac, &av); + + if (ac > 1) { + Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); + + memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); + lv [0] = Tcl_NewObj (); + lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); + lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); + + Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); + ckfree ((char*) lv); + + } else if (ac == 0) { + /* + * Match, but no AST. This is possible if the grammar + * consists of only the start expression. + */ + Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); + } else { + Tcl_SetObjResult (interp, av [0]); + } + + return TCL_OK; + } else { + Tcl_Obj* xv [1]; + const ERROR_STATE* er = rde_param_query_er (p); + Tcl_Obj* res = rde_param_query_er_tcl (p, er); + /* res = list (location, list(msg)) */ + + /* Stick the exception type-tag before the existing elements */ + xv [0] = Tcl_NewStringObj ("pt::rde",-1); + Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); + + Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); + Tcl_SetObjResult (interp, res); + return TCL_ERROR; + } + } + + + /* * ** *** ***** ******** ************* + ** Object command, method dispatch. + */ + static int parser_objcmd (ClientData cd, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) + { + RDE_PARAM p = (RDE_PARAM) cd; + int m, res; + + static CONST char* methods [] = { + "destroy", "parse", "parset", NULL + }; + enum methods { + M_DESTROY, M_PARSE, M_PARSET + }; + + if (objc < 2) { + Tcl_WrongNumArgs (interp, objc, objv, "option ?arg arg ...?"); + return TCL_ERROR; + } else if (Tcl_GetIndexFromObj (interp, objv [1], methods, "option", + 0, &m) != TCL_OK) { + return TCL_ERROR; + } + + /* Dispatch to methods. They check the #args in + * detail before performing the requested + * functionality + */ + + switch (m) { + case M_DESTROY: + if (objc != 2) { + Tcl_WrongNumArgs (interp, 2, objv, NULL); + return TCL_ERROR; + } + + Tcl_DeleteCommandFromToken(interp, (Tcl_Command) rde_param_query_clientdata (p)); + return TCL_OK; + + case M_PARSE: res = parser_PARSE (p, interp, objc, objv); break; + case M_PARSET: res = parser_PARSET (p, interp, objc, objv); break; + default: + /* Not coming to this place */ + ASSERT (0,"Reached unreachable location"); + } + + return res; + } + + /** * ** *** ***** ******** ************* + * Class command, i.e. object construction. + */ + static int ParserClassCmd (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const*objv) { + /* + * Syntax: No arguments beyond the name + */ + + RDE_PARAM parser; + CONST char* name; + Tcl_Obj* fqn; + Tcl_CmdInfo ci; + Tcl_Command c; + +#define USAGE "?name?" + + if ((objc != 2) && (objc != 1)) { + Tcl_WrongNumArgs (interp, 1, objv, USAGE); + return TCL_ERROR; + } + + if (objc < 2) { + name = PARSERnewName (interp); + } else { + name = Tcl_GetString (objv [1]); + } + + if (!Tcl_StringMatch (name, "::*")) { + /* Relative name. Prefix with current namespace */ + + Tcl_Eval (interp, "namespace current"); + fqn = Tcl_GetObjResult (interp); + fqn = Tcl_DuplicateObj (fqn); + Tcl_IncrRefCount (fqn); + + if (!Tcl_StringMatch (Tcl_GetString (fqn), "::")) { + Tcl_AppendToObj (fqn, "::", -1); + } + Tcl_AppendToObj (fqn, name, -1); + } else { + fqn = Tcl_NewStringObj (name, -1); + Tcl_IncrRefCount (fqn); + } + Tcl_ResetResult (interp); + + if (Tcl_GetCommandInfo (interp, + Tcl_GetString (fqn), + &ci)) { + Tcl_Obj* err; + + err = Tcl_NewObj (); + Tcl_AppendToObj (err, "command \"", -1); + Tcl_AppendObjToObj (err, fqn); + Tcl_AppendToObj (err, "\" already exists", -1); + + Tcl_DecrRefCount (fqn); + Tcl_SetObjResult (interp, err); + return TCL_ERROR; + } + + parser = rde_param_new (sizeof(p_string)/sizeof(char*), (char**) p_string); + c = Tcl_CreateObjCommand (interp, Tcl_GetString (fqn), + parser_objcmd, (ClientData) parser, + PARSERdeleteCmd); + rde_param_clientdata (parser, (ClientData) c); + Tcl_SetObjResult (interp, fqn); + Tcl_DecrRefCount (fqn); + return TCL_OK; + } + +int Package_Init(Tcl_Interp* interp) { + if (interp == 0) return TCL_ERROR; + + if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { + return TCL_ERROR; + } + + if (Tcl_CreateObjCommand(interp, "PARSER", ParserClassCmd , NULL, NULL) == NULL) { + Tcl_SetResult(interp, "Can't create constructor", NULL); + return TCL_ERROR; + } + + + Tcl_PkgProvide(interp, "PACKAGE", "0.1"); + + return TCL_OK; +} Index: modules/pt/tests/data/ok/peg_cparam/0_basic_arithmetic ================================================================== --- modules/pt/tests/data/ok/peg_cparam/0_basic_arithmetic +++ modules/pt/tests/data/ok/peg_cparam/0_basic_arithmetic @@ -30,32 +30,46 @@ /* * Precomputed table of strings (symbols, error messages, etc.). */ -static char const* <> [21] = { - /* 0 = */ "cl '-+'", - /* 1 = */ "n AddOp", - /* 2 = */ "AddOp", - /* 3 = */ "cl '0123456789'", - /* 4 = */ "n Digit", - /* 5 = */ "Digit", - /* 6 = */ "t \50", - /* 7 = */ "t \51", - /* 8 = */ "n Expression", - /* 9 = */ "Expression", - /* 10 = */ "n Factor", - /* 11 = */ "Factor", - /* 12 = */ "cl '*/'", - /* 13 = */ "n MulOp", - /* 14 = */ "MulOp", - /* 15 = */ "n Number", - /* 16 = */ "Number", - /* 17 = */ "n Sign", - /* 18 = */ "Sign", - /* 19 = */ "n Term", - /* 20 = */ "Term" +static char const* <> [35] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "cl -+", + /* 15 = */ "n AddOp", + /* 16 = */ "AddOp", + /* 17 = */ "cl 0123456789", + /* 18 = */ "n Digit", + /* 19 = */ "Digit", + /* 20 = */ "t (", + /* 21 = */ "t )", + /* 22 = */ "n Expression", + /* 23 = */ "Expression", + /* 24 = */ "n Factor", + /* 25 = */ "Factor", + /* 26 = */ "cl */", + /* 27 = */ "n MulOp", + /* 28 = */ "MulOp", + /* 29 = */ "n Number", + /* 30 = */ "Number", + /* 31 = */ "n Sign", + /* 32 = */ "Sign", + /* 33 = */ "n Term", + /* 34 = */ "Term" }; /* * Grammar Start Expression */ @@ -72,13 +86,13 @@ <> void <>sym_AddOp (<> <>) { <> /* * [-+] */ - if (rde_param_i_symbol_start (<>, 2)) return ; - rde_param_i_next_class (<>, "-+", 0); - rde_param_i_symbol_done_leaf (<>, 2, 1); + if (rde_param_i_symbol_start (<>, 16)) return ; + rde_param_i_next_class (<>, "-+", 14); + rde_param_i_symbol_done_leaf (<>, 16, 15); return; } /* * value Symbol 'Digit' @@ -87,13 +101,13 @@ <> void <>sym_Digit (<> <>) { <> /* * [0123456789] */ - if (rde_param_i_symbol_start (<>, 5)) return ; - rde_param_i_next_class (<>, "0123456789", 3); - rde_param_i_symbol_done_leaf (<>, 5, 4); + if (rde_param_i_symbol_start (<>, 19)) return ; + rde_param_i_next_class (<>, "0123456789", 17); + rde_param_i_symbol_done_leaf (<>, 19, 18); return; } /* * value Symbol 'Expression' @@ -112,13 +126,13 @@ * x * (MulOp) * (Factor) */ - if (rde_param_i_symbol_start_d (<>, 9)) return ; + if (rde_param_i_symbol_start_d (<>, 23)) return ; <> <>choice_20 (<>); - rde_param_i_symbol_done_d_reduce (<>, 9, 8); + rde_param_i_symbol_done_d_reduce (<>, 23, 22); return; } <> void <>choice_20 (<> <>) { <> /* @@ -150,15 +164,15 @@ * (Expression) * '\)' */ rde_param_i_state_push_void (<>); - rde_param_i_next_char (<>, "\50", 6); + rde_param_i_next_char (<>, "(", 20); if (rde_param_i_seq_void2value(<>)) return; <> <>sym_Expression (<>); if (rde_param_i_seq_value2value(<>)) return; - rde_param_i_next_char (<>, "\51", 7); + rde_param_i_next_char (<>, ")", 21); rde_param_i_state_merge_value (<>); return; } <> void <>sequence_18 (<> <>) { <> @@ -222,13 +236,13 @@ * x * (AddOp) * (Term) */ - if (rde_param_i_symbol_start_d (<>, 11)) return ; + if (rde_param_i_symbol_start_d (<>, 25)) return ; <> <>sequence_30 (<>); - rde_param_i_symbol_done_d_reduce (<>, 11, 10); + rde_param_i_symbol_done_d_reduce (<>, 25, 24); return; } <> void <>sequence_30 (<> <>) { <> /* @@ -286,13 +300,13 @@ <> void <>sym_MulOp (<> <>) { <> /* * [\u002a\u002f] */ - if (rde_param_i_symbol_start (<>, 14)) return ; - rde_param_i_next_class (<>, "*/", 12); - rde_param_i_symbol_done_leaf (<>, 14, 13); + if (rde_param_i_symbol_start (<>, 28)) return ; + rde_param_i_next_class (<>, "*/", 26); + rde_param_i_symbol_done_leaf (<>, 28, 27); return; } /* * value Symbol 'Number' @@ -305,13 +319,13 @@ * (Sign) * + * (Digit) */ - if (rde_param_i_symbol_start_d (<>, 16)) return ; + if (rde_param_i_symbol_start_d (<>, 30)) return ; <> <>sequence_41 (<>); - rde_param_i_symbol_done_d_reduce (<>, 16, 15); + rde_param_i_symbol_done_d_reduce (<>, 30, 29); return; } <> void <>sequence_41 (<> <>) { <> /* @@ -366,13 +380,13 @@ <> void <>sym_Sign (<> <>) { <> /* * [-+] */ - if (rde_param_i_symbol_start (<>, 18)) return ; - rde_param_i_next_class (<>, "-+", 0); - rde_param_i_symbol_done_leaf (<>, 18, 17); + if (rde_param_i_symbol_start (<>, 32)) return ; + rde_param_i_next_class (<>, "-+", 14); + rde_param_i_symbol_done_leaf (<>, 32, 31); return; } /* * value Symbol 'Term' @@ -381,13 +395,13 @@ <> void <>sym_Term (<> <>) { <> /* * (Number) */ - if (rde_param_i_symbol_start_d (<>, 20)) return ; + if (rde_param_i_symbol_start_d (<>, 34)) return ; <> <>sym_Number (<>); - rde_param_i_symbol_done_d_reduce (<>, 20, 19); + rde_param_i_symbol_done_d_reduce (<>, 34, 33); return; } /* */ Index: modules/pt/tests/data/ok/peg_cparam/10_notahead ================================================================== --- modules/pt/tests/data/ok/peg_cparam/10_notahead +++ modules/pt/tests/data/ok/peg_cparam/10_notahead @@ -14,14 +14,28 @@ /* * Precomputed table of strings (symbols, error messages, etc.). */ -static char const* <> [3] = { - /* 0 = */ "t a", - /* 1 = */ "n TEST", - /* 2 = */ "TEST" +static char const* <> [17] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "t a", + /* 15 = */ "n TEST", + /* 16 = */ "TEST" }; /* * Grammar Start Expression */ @@ -41,13 +55,13 @@ * ! * 'a' * (IDENTIFIER) */ - if (rde_param_i_symbol_start (<>, 2)) return ; + if (rde_param_i_symbol_start (<>, 16)) return ; <> <>sequence_6 (<>); - rde_param_i_symbol_done_leaf (<>, 2, 1); + rde_param_i_symbol_done_leaf (<>, 16, 15); return; } <> void <>sequence_6 (<> <>) { <> /* @@ -71,12 +85,12 @@ * ! * 'a' */ rde_param_i_loc_push (<>); - rde_param_i_next_char (<>, "a", 0); + rde_param_i_next_char (<>, "a", 14); rde_param_i_notahead_exit (<>); return; } /* */ Index: modules/pt/tests/data/ok/peg_cparam/11_epsilon ================================================================== --- modules/pt/tests/data/ok/peg_cparam/11_epsilon +++ modules/pt/tests/data/ok/peg_cparam/11_epsilon @@ -12,12 +12,26 @@ /* * Precomputed table of strings (symbols, error messages, etc.). */ -static char const* <> [1] = { - /* 0 = */ "t a" +static char const* <> [15] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "t a" }; /* * Grammar Start Expression */ @@ -33,14 +47,14 @@ * 'a' * */ rde_param_i_state_push_void (<>); - rde_param_i_next_char (<>, "a", 0); + rde_param_i_next_char (<>, "a", 14); if (rde_param_i_bra_void2void(<>)) return; rde_param_i_status_ok (<>); rde_param_i_state_merge_void (<>); return; } /* */ Index: modules/pt/tests/data/ok/peg_cparam/1_functions ================================================================== --- modules/pt/tests/data/ok/peg_cparam/1_functions +++ modules/pt/tests/data/ok/peg_cparam/1_functions @@ -15,19 +15,33 @@ /* * Precomputed table of strings (symbols, error messages, etc.). */ -static char const* <> [8] = { - /* 0 = */ "n Expression", - /* 1 = */ "Expression", - /* 2 = */ "n Function", - /* 3 = */ "Function", - /* 4 = */ "str 'sin\50'", - /* 5 = */ "t \51", - /* 6 = */ "n Sinus", - /* 7 = */ "Sinus" +static char const* <> [22] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "n Expression", + /* 15 = */ "Expression", + /* 16 = */ "n Function", + /* 17 = */ "Function", + /* 18 = */ "str sin(", + /* 19 = */ "t )", + /* 20 = */ "n Sinus", + /* 21 = */ "Sinus" }; /* * Grammar Start Expression */ @@ -44,13 +58,13 @@ <> void <>sym_Expression (<> <>) { <> /* * (Function) */ - if (rde_param_i_symbol_start_d (<>, 1)) return ; + if (rde_param_i_symbol_start_d (<>, 15)) return ; <> <>sym_Function (<>); - rde_param_i_symbol_done_d_reduce (<>, 1, 0); + rde_param_i_symbol_done_d_reduce (<>, 15, 14); return; } /* * value Symbol 'Function' @@ -59,13 +73,13 @@ <> void <>sym_Function (<> <>) { <> /* * (Sinus) */ - if (rde_param_i_symbol_start_d (<>, 3)) return ; + if (rde_param_i_symbol_start_d (<>, 17)) return ; <> <>sym_Sinus (<>); - rde_param_i_symbol_done_d_reduce (<>, 3, 2); + rde_param_i_symbol_done_d_reduce (<>, 17, 16); return; } /* * value Symbol 'Sinus' @@ -77,13 +91,13 @@ * "sin\(" * (Expression) * '\)' */ - if (rde_param_i_symbol_start_d (<>, 7)) return ; + if (rde_param_i_symbol_start_d (<>, 21)) return ; <> <>sequence_9 (<>); - rde_param_i_symbol_done_d_reduce (<>, 7, 6); + rde_param_i_symbol_done_d_reduce (<>, 21, 20); return; } <> void <>sequence_9 (<> <>) { <> /* @@ -92,16 +106,16 @@ * (Expression) * '\)' */ rde_param_i_state_push_void (<>); - rde_param_i_next_str (<>, "sin\50", 4); + rde_param_i_next_str (<>, "sin(", 18); if (rde_param_i_seq_void2value(<>)) return; <> <>sym_Expression (<>); if (rde_param_i_seq_value2value(<>)) return; - rde_param_i_next_char (<>, "\51", 5); + rde_param_i_next_char (<>, ")", 19); rde_param_i_state_merge_value (<>); return; } /* */ Index: modules/pt/tests/data/ok/peg_cparam/2_fun_arithmetic ================================================================== --- modules/pt/tests/data/ok/peg_cparam/2_fun_arithmetic +++ modules/pt/tests/data/ok/peg_cparam/2_fun_arithmetic @@ -33,37 +33,51 @@ /* * Precomputed table of strings (symbols, error messages, etc.). */ -static char const* <> [26] = { - /* 0 = */ "cl '-+'", - /* 1 = */ "n AddOp", - /* 2 = */ "AddOp", - /* 3 = */ "cl '0123456789'", - /* 4 = */ "n Digit", - /* 5 = */ "Digit", - /* 6 = */ "t \50", - /* 7 = */ "t \51", - /* 8 = */ "n Expression", - /* 9 = */ "Expression", - /* 10 = */ "n Factor", - /* 11 = */ "Factor", - /* 12 = */ "n Function", - /* 13 = */ "Function", - /* 14 = */ "cl '*/'", - /* 15 = */ "n MulOp", - /* 16 = */ "MulOp", - /* 17 = */ "n Number", - /* 18 = */ "Number", - /* 19 = */ "n Sign", - /* 20 = */ "Sign", - /* 21 = */ "str 'sin\50'", - /* 22 = */ "n Sinus", - /* 23 = */ "Sinus", - /* 24 = */ "n Term", - /* 25 = */ "Term" +static char const* <> [40] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "cl -+", + /* 15 = */ "n AddOp", + /* 16 = */ "AddOp", + /* 17 = */ "cl 0123456789", + /* 18 = */ "n Digit", + /* 19 = */ "Digit", + /* 20 = */ "t (", + /* 21 = */ "t )", + /* 22 = */ "n Expression", + /* 23 = */ "Expression", + /* 24 = */ "n Factor", + /* 25 = */ "Factor", + /* 26 = */ "n Function", + /* 27 = */ "Function", + /* 28 = */ "cl */", + /* 29 = */ "n MulOp", + /* 30 = */ "MulOp", + /* 31 = */ "n Number", + /* 32 = */ "Number", + /* 33 = */ "n Sign", + /* 34 = */ "Sign", + /* 35 = */ "str sin(", + /* 36 = */ "n Sinus", + /* 37 = */ "Sinus", + /* 38 = */ "n Term", + /* 39 = */ "Term" }; /* * Grammar Start Expression */ @@ -80,13 +94,13 @@ <> void <>sym_AddOp (<> <>) { <> /* * [-+] */ - if (rde_param_i_symbol_start (<>, 2)) return ; - rde_param_i_next_class (<>, "-+", 0); - rde_param_i_symbol_done_leaf (<>, 2, 1); + if (rde_param_i_symbol_start (<>, 16)) return ; + rde_param_i_next_class (<>, "-+", 14); + rde_param_i_symbol_done_leaf (<>, 16, 15); return; } /* * value Symbol 'Digit' @@ -95,13 +109,13 @@ <> void <>sym_Digit (<> <>) { <> /* * [0123456789] */ - if (rde_param_i_symbol_start (<>, 5)) return ; - rde_param_i_next_class (<>, "0123456789", 3); - rde_param_i_symbol_done_leaf (<>, 5, 4); + if (rde_param_i_symbol_start (<>, 19)) return ; + rde_param_i_next_class (<>, "0123456789", 17); + rde_param_i_symbol_done_leaf (<>, 19, 18); return; } /* * value Symbol 'Expression' @@ -121,13 +135,13 @@ * x * (MulOp) * (Factor) */ - if (rde_param_i_symbol_start_d (<>, 9)) return ; + if (rde_param_i_symbol_start_d (<>, 23)) return ; <> <>choice_21 (<>); - rde_param_i_symbol_done_d_reduce (<>, 9, 8); + rde_param_i_symbol_done_d_reduce (<>, 23, 22); return; } <> void <>choice_21 (<> <>) { <> /* @@ -162,15 +176,15 @@ * (Expression) * '\)' */ rde_param_i_state_push_void (<>); - rde_param_i_next_char (<>, "\50", 6); + rde_param_i_next_char (<>, "(", 20); if (rde_param_i_seq_void2value(<>)) return; <> <>sym_Expression (<>); if (rde_param_i_seq_value2value(<>)) return; - rde_param_i_next_char (<>, "\51", 7); + rde_param_i_next_char (<>, ")", 21); rde_param_i_state_merge_value (<>); return; } <> void <>sequence_19 (<> <>) { <> @@ -234,13 +248,13 @@ * x * (AddOp) * (Term) */ - if (rde_param_i_symbol_start_d (<>, 11)) return ; + if (rde_param_i_symbol_start_d (<>, 25)) return ; <> <>sequence_31 (<>); - rde_param_i_symbol_done_d_reduce (<>, 11, 10); + rde_param_i_symbol_done_d_reduce (<>, 25, 24); return; } <> void <>sequence_31 (<> <>) { <> /* @@ -298,13 +312,13 @@ <> void <>sym_Function (<> <>) { <> /* * (Sinus) */ - if (rde_param_i_symbol_start_d (<>, 13)) return ; + if (rde_param_i_symbol_start_d (<>, 27)) return ; <> <>sym_Sinus (<>); - rde_param_i_symbol_done_d_reduce (<>, 13, 12); + rde_param_i_symbol_done_d_reduce (<>, 27, 26); return; } /* * value Symbol 'MulOp' @@ -313,13 +327,13 @@ <> void <>sym_MulOp (<> <>) { <> /* * [\u002a\u002f] */ - if (rde_param_i_symbol_start (<>, 16)) return ; - rde_param_i_next_class (<>, "*/", 14); - rde_param_i_symbol_done_leaf (<>, 16, 15); + if (rde_param_i_symbol_start (<>, 30)) return ; + rde_param_i_next_class (<>, "*/", 28); + rde_param_i_symbol_done_leaf (<>, 30, 29); return; } /* * value Symbol 'Number' @@ -332,13 +346,13 @@ * (Sign) * + * (Digit) */ - if (rde_param_i_symbol_start_d (<>, 18)) return ; + if (rde_param_i_symbol_start_d (<>, 32)) return ; <> <>sequence_44 (<>); - rde_param_i_symbol_done_d_reduce (<>, 18, 17); + rde_param_i_symbol_done_d_reduce (<>, 32, 31); return; } <> void <>sequence_44 (<> <>) { <> /* @@ -393,13 +407,13 @@ <> void <>sym_Sign (<> <>) { <> /* * [-+] */ - if (rde_param_i_symbol_start (<>, 20)) return ; - rde_param_i_next_class (<>, "-+", 0); - rde_param_i_symbol_done_leaf (<>, 20, 19); + if (rde_param_i_symbol_start (<>, 34)) return ; + rde_param_i_next_class (<>, "-+", 14); + rde_param_i_symbol_done_leaf (<>, 34, 33); return; } /* * value Symbol 'Sinus' @@ -411,13 +425,13 @@ * "sin\(" * (Expression) * '\)' */ - if (rde_param_i_symbol_start_d (<>, 23)) return ; + if (rde_param_i_symbol_start_d (<>, 37)) return ; <> <>sequence_52 (<>); - rde_param_i_symbol_done_d_reduce (<>, 23, 22); + rde_param_i_symbol_done_d_reduce (<>, 37, 36); return; } <> void <>sequence_52 (<> <>) { <> /* @@ -426,15 +440,15 @@ * (Expression) * '\)' */ rde_param_i_state_push_void (<>); - rde_param_i_next_str (<>, "sin\50", 21); + rde_param_i_next_str (<>, "sin(", 35); if (rde_param_i_seq_void2value(<>)) return; <> <>sym_Expression (<>); if (rde_param_i_seq_value2value(<>)) return; - rde_param_i_next_char (<>, "\51", 7); + rde_param_i_next_char (<>, ")", 21); rde_param_i_state_merge_value (<>); return; } /* @@ -444,13 +458,13 @@ <> void <>sym_Term (<> <>) { <> /* * (Number) */ - if (rde_param_i_symbol_start_d (<>, 25)) return ; + if (rde_param_i_symbol_start_d (<>, 39)) return ; <> <>sym_Number (<>); - rde_param_i_symbol_done_d_reduce (<>, 25, 24); + rde_param_i_symbol_done_d_reduce (<>, 39, 38); return; } /* */ Index: modules/pt/tests/data/ok/peg_cparam/3_peg_itself ================================================================== --- modules/pt/tests/data/ok/peg_cparam/3_peg_itself +++ modules/pt/tests/data/ok/peg_cparam/3_peg_itself @@ -64,279 +64,286 @@ <> void <>sym_Definition (<> <>); <> void <>sequence_148 (<> <>); <> void <>sym_DIGIT (<> <>); <> void <>sequence_153 (<> <>); <> void <>sym_DOT (<> <>); -<> void <>sequence_158 (<> <>); -<> void <>sym_END (<> <>); -<> void <>notahead_162 (<> <>); +<> void <>notahead_157 (<> <>); <> void <>sym_EOF (<> <>); <> void <>sym_EOL (<> <>); -<> void <>sequence_170 (<> <>); -<> void <>kleene_172 (<> <>); -<> void <>sequence_174 (<> <>); +<> void <>sequence_165 (<> <>); +<> void <>kleene_167 (<> <>); +<> void <>sequence_169 (<> <>); <> void <>sym_Expression (<> <>); -<> void <>sequence_180 (<> <>); +<> void <>sequence_176 (<> <>); <> void <>sym_Final (<> <>); -<> void <>kleene_186 (<> <>); -<> void <>sequence_190 (<> <>); +<> void <>kleene_182 (<> <>); +<> void <>sequence_186 (<> <>); <> void <>sym_Grammar (<> <>); -<> void <>sequence_195 (<> <>); +<> void <>sequence_191 (<> <>); <> void <>sym_GRAPH (<> <>); -<> void <>sequence_201 (<> <>); +<> void <>sequence_197 (<> <>); <> void <>sym_Header (<> <>); +<> void <>choice_202 (<> <>); <> void <>choice_206 (<> <>); -<> void <>choice_210 (<> <>); -<> void <>kleene_212 (<> <>); -<> void <>sequence_214 (<> <>); +<> void <>kleene_208 (<> <>); +<> void <>sequence_210 (<> <>); <> void <>sym_Ident (<> <>); -<> void <>sequence_219 (<> <>); +<> void <>sequence_215 (<> <>); <> void <>sym_Identifier (<> <>); -<> void <>sequence_224 (<> <>); +<> void <>sequence_220 (<> <>); <> void <>sym_IS (<> <>); -<> void <>sequence_229 (<> <>); +<> void <>sequence_225 (<> <>); <> void <>sym_LEAF (<> <>); -<> void <>notahead_234 (<> <>); -<> void <>sequence_237 (<> <>); -<> void <>kleene_239 (<> <>); -<> void <>sequence_243 (<> <>); -<> void <>notahead_247 (<> <>); -<> void <>sequence_250 (<> <>); -<> void <>kleene_252 (<> <>); -<> void <>sequence_256 (<> <>); -<> void <>choice_258 (<> <>); +<> void <>notahead_230 (<> <>); +<> void <>sequence_233 (<> <>); +<> void <>kleene_235 (<> <>); +<> void <>sequence_239 (<> <>); +<> void <>notahead_243 (<> <>); +<> void <>sequence_246 (<> <>); +<> void <>kleene_248 (<> <>); +<> void <>sequence_252 (<> <>); +<> void <>choice_254 (<> <>); <> void <>sym_Literal (<> <>); -<> void <>sequence_263 (<> <>); +<> void <>sequence_259 (<> <>); <> void <>sym_LOWER (<> <>); -<> void <>sequence_268 (<> <>); +<> void <>sequence_264 (<> <>); <> void <>sym_NOT (<> <>); -<> void <>sequence_273 (<> <>); +<> void <>sequence_269 (<> <>); <> void <>sym_OPEN (<> <>); <> void <>sym_OPENB (<> <>); -<> void <>sequence_280 (<> <>); +<> void <>notahead_278 (<> <>); +<> void <>sequence_281 (<> <>); <> void <>sym_PEG (<> <>); -<> void <>sequence_285 (<> <>); +<> void <>sequence_286 (<> <>); <> void <>sym_PLUS (<> <>); -<> void <>choice_290 (<> <>); -<> void <>optional_292 (<> <>); -<> void <>sequence_295 (<> <>); +<> void <>choice_291 (<> <>); +<> void <>optional_293 (<> <>); +<> void <>sequence_296 (<> <>); <> void <>sym_Prefix (<> <>); -<> void <>sequence_316 (<> <>); -<> void <>choice_321 (<> <>); +<> void <>sequence_317 (<> <>); +<> void <>choice_322 (<> <>); <> void <>sym_Primary (<> <>); -<> void <>sequence_326 (<> <>); +<> void <>sequence_327 (<> <>); <> void <>sym_PRINTABLE (<> <>); -<> void <>sequence_331 (<> <>); +<> void <>sequence_332 (<> <>); <> void <>sym_PUNCT (<> <>); -<> void <>sequence_336 (<> <>); +<> void <>sequence_337 (<> <>); <> void <>sym_QUESTION (<> <>); -<> void <>sequence_342 (<> <>); -<> void <>choice_345 (<> <>); +<> void <>sequence_343 (<> <>); +<> void <>choice_346 (<> <>); <> void <>sym_Range (<> <>); -<> void <>sequence_350 (<> <>); +<> void <>sequence_351 (<> <>); <> void <>sym_SEMICOLON (<> <>); -<> void <>poskleene_354 (<> <>); +<> void <>poskleene_355 (<> <>); <> void <>sym_Sequence (<> <>); -<> void <>sequence_359 (<> <>); +<> void <>sequence_360 (<> <>); <> void <>sym_SLASH (<> <>); -<> void <>sequence_364 (<> <>); +<> void <>sequence_365 (<> <>); <> void <>sym_SPACE (<> <>); -<> void <>sequence_369 (<> <>); +<> void <>sequence_370 (<> <>); <> void <>sym_STAR (<> <>); <> void <>sym_StartExpr (<> <>); -<> void <>choice_381 (<> <>); -<> void <>optional_383 (<> <>); -<> void <>sequence_385 (<> <>); +<> void <>choice_382 (<> <>); +<> void <>optional_384 (<> <>); +<> void <>sequence_386 (<> <>); <> void <>sym_Suffix (<> <>); <> void <>sym_TO (<> <>); -<> void <>sequence_392 (<> <>); +<> void <>sequence_393 (<> <>); <> void <>sym_UPPER (<> <>); -<> void <>sequence_397 (<> <>); +<> void <>sequence_398 (<> <>); <> void <>sym_VOID (<> <>); -<> void <>choice_402 (<> <>); -<> void <>kleene_404 (<> <>); +<> void <>choice_403 (<> <>); +<> void <>kleene_405 (<> <>); <> void <>sym_WHITESPACE (<> <>); -<> void <>sequence_409 (<> <>); +<> void <>sequence_410 (<> <>); <> void <>sym_WORDCHAR (<> <>); -<> void <>sequence_414 (<> <>); +<> void <>sequence_415 (<> <>); <> void <>sym_XDIGIT (<> <>); /* * Precomputed table of strings (symbols, error messages, etc.). */ -static char const* <> [170] = { - /* 0 = */ "str ''", - /* 1 = */ "n ALNUM", - /* 2 = */ "ALNUM", - /* 3 = */ "str ''", - /* 4 = */ "n ALPHA", - /* 5 = */ "ALPHA", - /* 6 = */ "t &", - /* 7 = */ "n AND", - /* 8 = */ "AND", - /* 9 = */ "t '", - /* 10 = */ "n APOSTROPH", - /* 11 = */ "APOSTROPH", - /* 12 = */ "str ''", - /* 13 = */ "n ASCII", - /* 14 = */ "ASCII", - /* 15 = */ "n Attribute", - /* 16 = */ "Attribute", - /* 17 = */ "n Char", - /* 18 = */ "Char", - /* 19 = */ "t \134", - /* 20 = */ ".. 0 2", - /* 21 = */ ".. 0 7", - /* 22 = */ "n CharOctalFull", - /* 23 = */ "CharOctalFull", - /* 24 = */ "n CharOctalPart", - /* 25 = */ "CharOctalPart", - /* 26 = */ "cl 'nrt'\42\133\135\134'", - /* 27 = */ "n CharSpecial", - /* 28 = */ "CharSpecial", - /* 29 = */ "dot", - /* 30 = */ "n CharUnescaped", - /* 31 = */ "CharUnescaped", - /* 32 = */ "str '\134u'", - /* 33 = */ "xdigit", - /* 34 = */ "n CharUnicode", - /* 35 = */ "CharUnicode", - /* 36 = */ "n Class", - /* 37 = */ "Class", - /* 38 = */ "t \51", - /* 39 = */ "n CLOSE", - /* 40 = */ "CLOSE", - /* 41 = */ "t \135", - /* 42 = */ "n CLOSEB", - /* 43 = */ "CLOSEB", - /* 44 = */ "t :", - /* 45 = */ "n COLON", - /* 46 = */ "COLON", - /* 47 = */ "t #", - /* 48 = */ "n COMMENT", - /* 49 = */ "COMMENT", - /* 50 = */ "str ''", - /* 51 = */ "n CONTROL", - /* 52 = */ "CONTROL", - /* 53 = */ "t \42", - /* 54 = */ "n DAPOSTROPH", - /* 55 = */ "DAPOSTROPH", - /* 56 = */ "str ''", - /* 57 = */ "n DDIGIT", - /* 58 = */ "DDIGIT", - /* 59 = */ "n Definition", - /* 60 = */ "Definition", - /* 61 = */ "str ''", - /* 62 = */ "n DIGIT", - /* 63 = */ "DIGIT", - /* 64 = */ "t .", - /* 65 = */ "n DOT", - /* 66 = */ "DOT", - /* 67 = */ "str 'END'", - /* 68 = */ "n END", - /* 69 = */ "END", - /* 70 = */ "n EOF", - /* 71 = */ "EOF", - /* 72 = */ "cl '\n\r'", - /* 73 = */ "n EOL", - /* 74 = */ "EOL", - /* 75 = */ "n Expression", - /* 76 = */ "Expression", - /* 77 = */ "n Final", - /* 78 = */ "Final", - /* 79 = */ "n Grammar", - /* 80 = */ "Grammar", - /* 81 = */ "str ''", - /* 82 = */ "n GRAPH", - /* 83 = */ "GRAPH", - /* 84 = */ "n Header", - /* 85 = */ "Header", - /* 86 = */ "cl '_:'", - /* 87 = */ "alpha", - /* 88 = */ "alnum", - /* 89 = */ "n Ident", - /* 90 = */ "Ident", - /* 91 = */ "n Identifier", - /* 92 = */ "Identifier", - /* 93 = */ "str '<-'", - /* 94 = */ "n IS", - /* 95 = */ "IS", - /* 96 = */ "str 'leaf'", - /* 97 = */ "n LEAF", - /* 98 = */ "LEAF", - /* 99 = */ "n Literal", - /* 100 = */ "Literal", - /* 101 = */ "str ''", - /* 102 = */ "n LOWER", - /* 103 = */ "LOWER", - /* 104 = */ "t !", - /* 105 = */ "n NOT", - /* 106 = */ "NOT", - /* 107 = */ "t \50", - /* 108 = */ "n OPEN", - /* 109 = */ "OPEN", - /* 110 = */ "t \133", - /* 111 = */ "n OPENB", - /* 112 = */ "OPENB", - /* 113 = */ "str 'PEG'", - /* 114 = */ "n PEG", - /* 115 = */ "PEG", - /* 116 = */ "t +", - /* 117 = */ "n PLUS", - /* 118 = */ "PLUS", - /* 119 = */ "n Prefix", - /* 120 = */ "Prefix", - /* 121 = */ "n Primary", - /* 122 = */ "Primary", - /* 123 = */ "str ''", - /* 124 = */ "n PRINTABLE", - /* 125 = */ "PRINTABLE", - /* 126 = */ "str ''", - /* 127 = */ "n PUNCT", - /* 128 = */ "PUNCT", - /* 129 = */ "t ?", - /* 130 = */ "n QUESTION", - /* 131 = */ "QUESTION", - /* 132 = */ "n Range", - /* 133 = */ "Range", - /* 134 = */ "t \73", - /* 135 = */ "n SEMICOLON", - /* 136 = */ "SEMICOLON", - /* 137 = */ "n Sequence", - /* 138 = */ "Sequence", - /* 139 = */ "t /", - /* 140 = */ "n SLASH", - /* 141 = */ "SLASH", - /* 142 = */ "str ''", - /* 143 = */ "n SPACE", - /* 144 = */ "SPACE", - /* 145 = */ "t *", - /* 146 = */ "n STAR", - /* 147 = */ "STAR", - /* 148 = */ "n StartExpr", - /* 149 = */ "StartExpr", - /* 150 = */ "n Suffix", - /* 151 = */ "Suffix", - /* 152 = */ "t -", - /* 153 = */ "n TO", - /* 154 = */ "TO", - /* 155 = */ "str ''", - /* 156 = */ "n UPPER", - /* 157 = */ "UPPER", - /* 158 = */ "str 'void'", - /* 159 = */ "n VOID", - /* 160 = */ "VOID", - /* 161 = */ "space", - /* 162 = */ "n WHITESPACE", - /* 163 = */ "WHITESPACE", - /* 164 = */ "str ''", - /* 165 = */ "n WORDCHAR", - /* 166 = */ "WORDCHAR", - /* 167 = */ "str ''", - /* 168 = */ "n XDIGIT", - /* 169 = */ "XDIGIT" +static char const* <> [178] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "str ", + /* 15 = */ "n ALNUM", + /* 16 = */ "ALNUM", + /* 17 = */ "str ", + /* 18 = */ "n ALPHA", + /* 19 = */ "ALPHA", + /* 20 = */ "t &", + /* 21 = */ "n AND", + /* 22 = */ "AND", + /* 23 = */ "t '", + /* 24 = */ "n APOSTROPH", + /* 25 = */ "APOSTROPH", + /* 26 = */ "str ", + /* 27 = */ "n ASCII", + /* 28 = */ "ASCII", + /* 29 = */ "n Attribute", + /* 30 = */ "Attribute", + /* 31 = */ "n Char", + /* 32 = */ "Char", + /* 33 = */ "t \\\\", + /* 34 = */ ".. 0 2", + /* 35 = */ ".. 0 7", + /* 36 = */ "n CharOctalFull", + /* 37 = */ "CharOctalFull", + /* 38 = */ "n CharOctalPart", + /* 39 = */ "CharOctalPart", + /* 40 = */ "cl nrt'\\\"\\[\\]\\\\", + /* 41 = */ "n CharSpecial", + /* 42 = */ "CharSpecial", + /* 43 = */ "dot", + /* 44 = */ "n CharUnescaped", + /* 45 = */ "CharUnescaped", + /* 46 = */ "str \173\\u\175", + /* 47 = */ "n CharUnicode", + /* 48 = */ "CharUnicode", + /* 49 = */ "n Class", + /* 50 = */ "Class", + /* 51 = */ "t )", + /* 52 = */ "n CLOSE", + /* 53 = */ "CLOSE", + /* 54 = */ "t \\]", + /* 55 = */ "n CLOSEB", + /* 56 = */ "CLOSEB", + /* 57 = */ "t :", + /* 58 = */ "n COLON", + /* 59 = */ "COLON", + /* 60 = */ "t #", + /* 61 = */ "n COMMENT", + /* 62 = */ "COMMENT", + /* 63 = */ "str ", + /* 64 = */ "n CONTROL", + /* 65 = */ "CONTROL", + /* 66 = */ "t \173\"\175", + /* 67 = */ "n DAPOSTROPH", + /* 68 = */ "DAPOSTROPH", + /* 69 = */ "str ", + /* 70 = */ "n DDIGIT", + /* 71 = */ "DDIGIT", + /* 72 = */ "n Definition", + /* 73 = */ "Definition", + /* 74 = */ "str ", + /* 75 = */ "n DIGIT", + /* 76 = */ "DIGIT", + /* 77 = */ "t .", + /* 78 = */ "n DOT", + /* 79 = */ "DOT", + /* 80 = */ "n EOF", + /* 81 = */ "EOF", + /* 82 = */ "cl \173\n\r\175", + /* 83 = */ "n EOL", + /* 84 = */ "EOL", + /* 85 = */ "n Expression", + /* 86 = */ "Expression", + /* 87 = */ "str END", + /* 88 = */ "n Final", + /* 89 = */ "Final", + /* 90 = */ "n Grammar", + /* 91 = */ "Grammar", + /* 92 = */ "str ", + /* 93 = */ "n GRAPH", + /* 94 = */ "GRAPH", + /* 95 = */ "n Header", + /* 96 = */ "Header", + /* 97 = */ "cl _:", + /* 98 = */ "n Ident", + /* 99 = */ "Ident", + /* 100 = */ "n Identifier", + /* 101 = */ "Identifier", + /* 102 = */ "str <-", + /* 103 = */ "n IS", + /* 104 = */ "IS", + /* 105 = */ "str leaf", + /* 106 = */ "n LEAF", + /* 107 = */ "LEAF", + /* 108 = */ "n Literal", + /* 109 = */ "Literal", + /* 110 = */ "str ", + /* 111 = */ "n LOWER", + /* 112 = */ "LOWER", + /* 113 = */ "t !", + /* 114 = */ "n NOT", + /* 115 = */ "NOT", + /* 116 = */ "t (", + /* 117 = */ "n OPEN", + /* 118 = */ "OPEN", + /* 119 = */ "t \173[\175", + /* 120 = */ "n OPENB", + /* 121 = */ "OPENB", + /* 122 = */ "str PEG", + /* 123 = */ "n PEG", + /* 124 = */ "PEG", + /* 125 = */ "t +", + /* 126 = */ "n PLUS", + /* 127 = */ "PLUS", + /* 128 = */ "n Prefix", + /* 129 = */ "Prefix", + /* 130 = */ "n Primary", + /* 131 = */ "Primary", + /* 132 = */ "str ", + /* 133 = */ "n PRINTABLE", + /* 134 = */ "PRINTABLE", + /* 135 = */ "str ", + /* 136 = */ "n PUNCT", + /* 137 = */ "PUNCT", + /* 138 = */ "t ?", + /* 139 = */ "n QUESTION", + /* 140 = */ "QUESTION", + /* 141 = */ "n Range", + /* 142 = */ "Range", + /* 143 = */ "t \173;\175", + /* 144 = */ "n SEMICOLON", + /* 145 = */ "SEMICOLON", + /* 146 = */ "n Sequence", + /* 147 = */ "Sequence", + /* 148 = */ "t /", + /* 149 = */ "n SLASH", + /* 150 = */ "SLASH", + /* 151 = */ "str ", + /* 152 = */ "n SPACE", + /* 153 = */ "SPACE", + /* 154 = */ "t *", + /* 155 = */ "n STAR", + /* 156 = */ "STAR", + /* 157 = */ "n StartExpr", + /* 158 = */ "StartExpr", + /* 159 = */ "n Suffix", + /* 160 = */ "Suffix", + /* 161 = */ "t -", + /* 162 = */ "n TO", + /* 163 = */ "TO", + /* 164 = */ "str ", + /* 165 = */ "n UPPER", + /* 166 = */ "UPPER", + /* 167 = */ "str void", + /* 168 = */ "n VOID", + /* 169 = */ "VOID", + /* 170 = */ "n WHITESPACE", + /* 171 = */ "WHITESPACE", + /* 172 = */ "str ", + /* 173 = */ "n WORDCHAR", + /* 174 = */ "WORDCHAR", + /* 175 = */ "str ", + /* 176 = */ "n XDIGIT", + /* 177 = */ "XDIGIT" }; /* * Grammar Start Expression */ @@ -355,13 +362,13 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (<>, 2)) return ; + if (rde_param_i_symbol_start (<>, 16)) return ; <> <>sequence_4 (<>); - rde_param_i_symbol_done_leaf (<>, 2, 1); + rde_param_i_symbol_done_leaf (<>, 16, 15); return; } <> void <>sequence_4 (<> <>) { <> /* @@ -369,11 +376,11 @@ * "" * (WHITESPACE) */ rde_param_i_state_push_void (<>); - rde_param_i_next_str (<>, "", 0); + rde_param_i_next_str (<>, "", 14); if (rde_param_i_seq_void2void(<>)) return; <> <>sym_WHITESPACE (<>); rde_param_i_state_merge_void (<>); return; } @@ -387,13 +394,13 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (<>, 5)) return ; + if (rde_param_i_symbol_start (<>, 19)) return ; <> <>sequence_9 (<>); - rde_param_i_symbol_done_leaf (<>, 5, 4); + rde_param_i_symbol_done_leaf (<>, 19, 18); return; } <> void <>sequence_9 (<> <>) { <> /* @@ -401,11 +408,11 @@ * "" * (WHITESPACE) */ rde_param_i_state_push_void (<>); - rde_param_i_next_str (<>, "", 3); + rde_param_i_next_str (<>, "", 17); if (rde_param_i_seq_void2void(<>)) return; <> <>sym_WHITESPACE (<>); rde_param_i_state_merge_void (<>); return; } @@ -419,13 +426,13 @@ * x * '&' * (WHITESPACE) */ - if (rde_param_i_symbol_start (<>, 8)) return ; + if (rde_param_i_symbol_start (<>, 22)) return ; <> <>sequence_14 (<>); - rde_param_i_symbol_done_leaf (<>, 8, 7); + rde_param_i_symbol_done_leaf (<>, 22, 21); return; } <> void <>sequence_14 (<> <>) { <> /* @@ -433,11 +440,11 @@ * '&' * (WHITESPACE) */ rde_param_i_state_push_void (<>); - rde_param_i_next_char (<>, "&", 6); + rde_param_i_next_char (<>, "&", 20); if (rde_param_i_seq_void2void(<>)) return; <> <>sym_WHITESPACE (<>); rde_param_i_state_merge_void (<>); return; } @@ -449,13 +456,13 @@ <> void <>sym_APOSTROPH (<> <>) { <> /* * ''' */ - if (rde_param_i_symbol_void_start (<>, 11)) return ; - rde_param_i_next_char (<>, "'", 9); - rde_param_i_symbol_done_void (<>, 11, 10); + if (rde_param_i_symbol_void_start (<>, 25)) return ; + rde_param_i_next_char (<>, "'", 23); + rde_param_i_symbol_done_void (<>, 25, 24); return; } /* * leaf Symbol 'ASCII' @@ -466,13 +473,13 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (<>, 14)) return ; + if (rde_param_i_symbol_start (<>, 28)) return ; <> <>sequence_21 (<>); - rde_param_i_symbol_done_leaf (<>, 14, 13); + rde_param_i_symbol_done_leaf (<>, 28, 27); return; } <> void <>sequence_21 (<> <>) { <> /* @@ -480,11 +487,11 @@ * "" * (WHITESPACE) */ rde_param_i_state_push_void (<>); - rde_param_i_next_str (<>, "", 12); + rde_param_i_next_str (<>, "", 26); if (rde_param_i_seq_void2void(<>)) return; <> <>sym_WHITESPACE (<>); rde_param_i_state_merge_void (<>); return; } @@ -500,13 +507,13 @@ * (VOID) * (LEAF) * (COLON) */ - if (rde_param_i_symbol_start_d (<>, 16)) return ; + if (rde_param_i_symbol_start_d (<>, 30)) return ; <> <>sequence_29 (<>); - rde_param_i_symbol_done_d_reduce (<>, 16, 15); + rde_param_i_symbol_done_d_reduce (<>, 30, 29); return; } <> void <>sequence_29 (<> <>) { <> /* @@ -552,13 +559,13 @@ * (CharOctalPart) * (CharUnicode) * (CharUnescaped) */ - if (rde_param_i_symbol_start_d (<>, 18)) return ; + if (rde_param_i_symbol_start_d (<>, 32)) return ; <> <>choice_37 (<>); - rde_param_i_symbol_done_d_reduce (<>, 18, 17); + rde_param_i_symbol_done_d_reduce (<>, 32, 31); return; } <> void <>choice_37 (<> <>) { <> /* @@ -595,13 +602,13 @@ * range (0 .. 2) * range (0 .. 7) * range (0 .. 7) */ - if (rde_param_i_symbol_start (<>, 23)) return ; + if (rde_param_i_symbol_start (<>, 37)) return ; <> <>sequence_44 (<>); - rde_param_i_symbol_done_leaf (<>, 23, 22); + rde_param_i_symbol_done_leaf (<>, 37, 36); return; } <> void <>sequence_44 (<> <>) { <> /* @@ -611,17 +618,17 @@ * range (0 .. 7) * range (0 .. 7) */ rde_param_i_state_push_void (<>); - rde_param_i_next_char (<>, "\134", 19); + rde_param_i_next_char (<>, "\\", 33); + if (rde_param_i_seq_void2void(<>)) return; + rde_param_i_next_range (<>, "0", "2", 34); if (rde_param_i_seq_void2void(<>)) return; - rde_param_i_next_range (<>, "0", "2", 20); + rde_param_i_next_range (<>, "0", "7", 35); if (rde_param_i_seq_void2void(<>)) return; - rde_param_i_next_range (<>, "0", "7", 21); - if (rde_param_i_seq_void2void(<>)) return; - rde_param_i_next_range (<>, "0", "7", 21); + rde_param_i_next_range (<>, "0", "7", 35); rde_param_i_state_merge_void (<>); return; } /* @@ -635,13 +642,13 @@ * range (0 .. 7) * ? * range (0 .. 7) */ - if (rde_param_i_symbol_start (<>, 25)) return ; + if (rde_param_i_symbol_start (<>, 39)) return ; <> <>sequence_52 (<>); - rde_param_i_symbol_done_leaf (<>, 25, 24); + rde_param_i_symbol_done_leaf (<>, 39, 38); return; } <> void <>sequence_52 (<> <>) { <> /* @@ -651,13 +658,13 @@ * ? * range (0 .. 7) */ rde_param_i_state_push_void (<>); - rde_param_i_next_char (<>, "\134", 19); + rde_param_i_next_char (<>, "\\", 33); if (rde_param_i_seq_void2void(<>)) return; - rde_param_i_next_range (<>, "0", "7", 21); + rde_param_i_next_range (<>, "0", "7", 35); if (rde_param_i_seq_void2void(<>)) return; <> <>optional_50 (<>); rde_param_i_state_merge_void (<>); return; } @@ -667,11 +674,11 @@ * ? * range (0 .. 7) */ rde_param_i_state_push_2 (<>); - rde_param_i_next_range (<>, "0", "7", 21); + rde_param_i_next_range (<>, "0", "7", 35); rde_param_i_state_merge_ok (<>); return; } /* @@ -683,13 +690,13 @@ * x * '\' * [nrt'\"[]\] */ - if (rde_param_i_symbol_start (<>, 28)) return ; + if (rde_param_i_symbol_start (<>, 42)) return ; <> <>sequence_57 (<>); - rde_param_i_symbol_done_leaf (<>, 28, 27); + rde_param_i_symbol_done_leaf (<>, 42, 41); return; } <> void <>sequence_57 (<> <>) { <> /* @@ -697,13 +704,13 @@ * '\' * [nrt'\"[]\] */ rde_param_i_state_push_void (<>); - rde_param_i_next_char (<>, "\134", 19); + rde_param_i_next_char (<>, "\\", 33); if (rde_param_i_seq_void2void(<>)) return; - rde_param_i_next_class (<>, "nrt'\42\133\135\134", 26); + rde_param_i_next_class (<>, "nrt'\"[]\\", 40); rde_param_i_state_merge_void (<>); return; } /* @@ -716,13 +723,13 @@ * ! * '\' * */ - if (rde_param_i_symbol_start (<>, 31)) return ; + if (rde_param_i_symbol_start (<>, 45)) return ; <> <>sequence_64 (<>); - rde_param_i_symbol_done_leaf (<>, 31, 30); + rde_param_i_symbol_done_leaf (<>, 45, 44); return; } <> void <>sequence_64 (<> <>) { <> /* @@ -733,11 +740,11 @@ */ rde_param_i_state_push_void (<>); <> <>notahead_61 (<>); if (rde_param_i_seq_void2void(<>)) return; - rde_param_i_input_next (<>, 29); + rde_param_i_input_next (<>, 43); rde_param_i_state_merge_void (<>); return; } <> void <>notahead_61 (<> <>) { <> @@ -745,11 +752,11 @@ * ! * '\' */ rde_param_i_loc_push (<>); - rde_param_i_next_char (<>, "\134", 19); + rde_param_i_next_char (<>, "\\", 33); rde_param_i_notahead_exit (<>); return; } /* @@ -769,13 +776,13 @@ * * ? * */ - if (rde_param_i_symbol_start (<>, 35)) return ; + if (rde_param_i_symbol_start (<>, 48)) return ; <> <>sequence_82 (<>); - rde_param_i_symbol_done_leaf (<>, 35, 34); + rde_param_i_symbol_done_leaf (<>, 48, 47); return; } <> void <>sequence_82 (<> <>) { <> /* @@ -791,13 +798,13 @@ * ? * */ rde_param_i_state_push_void (<>); - rde_param_i_next_str (<>, "\134u", 32); + rde_param_i_next_str (<>, "\\u", 46); if (rde_param_i_seq_void2void(<>)) return; - rde_param_i_next_xdigit (<>, 33); + rde_param_i_next_xdigit (<>, 13); if (rde_param_i_seq_void2void(<>)) return; <> <>optional_80 (<>); rde_param_i_state_merge_void (<>); return; } @@ -830,11 +837,11 @@ * ? * */ rde_param_i_state_push_void (<>); - rde_param_i_next_xdigit (<>, 33); + rde_param_i_next_xdigit (<>, 13); if (rde_param_i_seq_void2void(<>)) return; <> <>optional_76 (<>); rde_param_i_state_merge_void (<>); return; } @@ -861,11 +868,11 @@ * ? * */ rde_param_i_state_push_void (<>); - rde_param_i_next_xdigit (<>, 33); + rde_param_i_next_xdigit (<>, 13); if (rde_param_i_seq_void2void(<>)) return; <> <>optional_72 (<>); rde_param_i_state_merge_void (<>); return; } @@ -875,11 +882,11 @@ * ? * */ rde_param_i_state_push_2 (<>); - rde_param_i_next_xdigit (<>, 33); + rde_param_i_next_xdigit (<>, 13); rde_param_i_state_merge_ok (<>); return; } /* @@ -897,13 +904,13 @@ * (Range) * (CLOSEB) * (WHITESPACE) */ - if (rde_param_i_symbol_start_d (<>, 37)) return ; + if (rde_param_i_symbol_start_d (<>, 50)) return ; <> <>sequence_96 (<>); - rde_param_i_symbol_done_d_reduce (<>, 37, 36); + rde_param_i_symbol_done_d_reduce (<>, 50, 49); return; } <> void <>sequence_96 (<> <>) { <> /* @@ -984,13 +991,13 @@ * x * '\)' * (WHITESPACE) */ - if (rde_param_i_symbol_void_start (<>, 40)) return ; + if (rde_param_i_symbol_void_start (<>, 53)) return ; <> <>sequence_101 (<>); - rde_param_i_symbol_done_void (<>, 40, 39); + rde_param_i_symbol_done_void (<>, 53, 52); return; } <> void <>sequence_101 (<> <>) { <> /* @@ -998,11 +1005,11 @@ * '\)' * (WHITESPACE) */ rde_param_i_state_push_void (<>); - rde_param_i_next_char (<>, "\51", 38); + rde_param_i_next_char (<>, ")", 51); if (rde_param_i_seq_void2void(<>)) return; <> <>sym_WHITESPACE (<>); rde_param_i_state_merge_void (<>); return; } @@ -1014,13 +1021,13 @@ <> void <>sym_CLOSEB (<> <>) { <> /* * ']' */ - if (rde_param_i_symbol_void_start (<>, 43)) return ; - rde_param_i_next_char (<>, "\135", 41); - rde_param_i_symbol_done_void (<>, 43, 42); + if (rde_param_i_symbol_void_start (<>, 56)) return ; + rde_param_i_next_char (<>, "]", 54); + rde_param_i_symbol_done_void (<>, 56, 55); return; } /* * void Symbol 'COLON' @@ -1031,13 +1038,13 @@ * x * ':' * (WHITESPACE) */ - if (rde_param_i_symbol_void_start (<>, 46)) return ; + if (rde_param_i_symbol_void_start (<>, 59)) return ; <> <>sequence_108 (<>); - rde_param_i_symbol_done_void (<>, 46, 45); + rde_param_i_symbol_done_void (<>, 59, 58); return; } <> void <>sequence_108 (<> <>) { <> /* @@ -1045,11 +1052,11 @@ * ':' * (WHITESPACE) */ rde_param_i_state_push_void (<>); - rde_param_i_next_char (<>, ":", 44); + rde_param_i_next_char (<>, ":", 57); if (rde_param_i_seq_void2void(<>)) return; <> <>sym_WHITESPACE (<>); rde_param_i_state_merge_void (<>); return; } @@ -1068,13 +1075,13 @@ * (EOL) * * (EOL) */ - if (rde_param_i_symbol_void_start (<>, 49)) return ; + if (rde_param_i_symbol_void_start (<>, 62)) return ; <> <>sequence_121 (<>); - rde_param_i_symbol_done_void (<>, 49, 48); + rde_param_i_symbol_done_void (<>, 62, 61); return; } <> void <>sequence_121 (<> <>) { <> /* @@ -1087,11 +1094,11 @@ * * (EOL) */ rde_param_i_state_push_void (<>); - rde_param_i_next_char (<>, "#", 47); + rde_param_i_next_char (<>, "#", 60); if (rde_param_i_seq_void2void(<>)) return; <> <>kleene_118 (<>); if (rde_param_i_seq_void2void(<>)) return; <> <>sym_EOL (<>); rde_param_i_state_merge_void (<>); @@ -1124,11 +1131,11 @@ */ rde_param_i_state_push_void (<>); <> <>notahead_113 (<>); if (rde_param_i_seq_void2void(<>)) return; - rde_param_i_input_next (<>, 29); + rde_param_i_input_next (<>, 43); rde_param_i_state_merge_void (<>); return; } <> void <>notahead_113 (<> <>) { <> @@ -1152,13 +1159,13 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (<>, 52)) return ; + if (rde_param_i_symbol_start (<>, 65)) return ; <> <>sequence_126 (<>); - rde_param_i_symbol_done_leaf (<>, 52, 51); + rde_param_i_symbol_done_leaf (<>, 65, 64); return; } <> void <>sequence_126 (<> <>) { <> /* @@ -1166,11 +1173,11 @@ * "" * (WHITESPACE) */ rde_param_i_state_push_void (<>); - rde_param_i_next_str (<>, "", 50); + rde_param_i_next_str (<>, "", 63); if (rde_param_i_seq_void2void(<>)) return; <> <>sym_WHITESPACE (<>); rde_param_i_state_merge_void (<>); return; } @@ -1182,13 +1189,13 @@ <> void <>sym_DAPOSTROPH (<> <>) { <> /* * '\"' */ - if (rde_param_i_symbol_void_start (<>, 55)) return ; - rde_param_i_next_char (<>, "\42", 53); - rde_param_i_symbol_done_void (<>, 55, 54); + if (rde_param_i_symbol_void_start (<>, 68)) return ; + rde_param_i_next_char (<>, "\"", 66); + rde_param_i_symbol_done_void (<>, 68, 67); return; } /* * leaf Symbol 'DDIGIT' @@ -1199,13 +1206,13 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (<>, 58)) return ; + if (rde_param_i_symbol_start (<>, 71)) return ; <> <>sequence_133 (<>); - rde_param_i_symbol_done_leaf (<>, 58, 57); + rde_param_i_symbol_done_leaf (<>, 71, 70); return; } <> void <>sequence_133 (<> <>) { <> /* @@ -1213,11 +1220,11 @@ * "" * (WHITESPACE) */ rde_param_i_state_push_void (<>); - rde_param_i_next_str (<>, "", 56); + rde_param_i_next_str (<>, "", 69); if (rde_param_i_seq_void2void(<>)) return; <> <>sym_WHITESPACE (<>); rde_param_i_state_merge_void (<>); return; } @@ -1235,13 +1242,13 @@ * (IS) * (Expression) * (SEMICOLON) */ - if (rde_param_i_symbol_start_d (<>, 60)) return ; + if (rde_param_i_symbol_start_d (<>, 73)) return ; <> <>sequence_143 (<>); - rde_param_i_symbol_done_d_reduce (<>, 60, 59); + rde_param_i_symbol_done_d_reduce (<>, 73, 72); return; } <> void <>sequence_143 (<> <>) { <> /* @@ -1289,13 +1296,13 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (<>, 63)) return ; + if (rde_param_i_symbol_start (<>, 76)) return ; <> <>sequence_148 (<>); - rde_param_i_symbol_done_leaf (<>, 63, 62); + rde_param_i_symbol_done_leaf (<>, 76, 75); return; } <> void <>sequence_148 (<> <>) { <> /* @@ -1303,11 +1310,11 @@ * "" * (WHITESPACE) */ rde_param_i_state_push_void (<>); - rde_param_i_next_str (<>, "", 61); + rde_param_i_next_str (<>, "", 74); if (rde_param_i_seq_void2void(<>)) return; <> <>sym_WHITESPACE (<>); rde_param_i_state_merge_void (<>); return; } @@ -1321,13 +1328,13 @@ * x * '.' * (WHITESPACE) */ - if (rde_param_i_symbol_start (<>, 66)) return ; + if (rde_param_i_symbol_start (<>, 79)) return ; <> <>sequence_153 (<>); - rde_param_i_symbol_done_leaf (<>, 66, 65); + rde_param_i_symbol_done_leaf (<>, 79, 78); return; } <> void <>sequence_153 (<> <>) { <> /* @@ -1335,43 +1342,11 @@ * '.' * (WHITESPACE) */ rde_param_i_state_push_void (<>); - rde_param_i_next_char (<>, ".", 64); - if (rde_param_i_seq_void2void(<>)) return; - <> <>sym_WHITESPACE (<>); - rde_param_i_state_merge_void (<>); - return; -} - -/* - * void Symbol 'END' - */ - -<> void <>sym_END (<> <>) { <> - /* - * x - * "END" - * (WHITESPACE) - */ - - if (rde_param_i_symbol_void_start (<>, 69)) return ; - <> <>sequence_158 (<>); - rde_param_i_symbol_done_void (<>, 69, 68); - return; -} - -<> void <>sequence_158 (<> <>) { <> - /* - * x - * "END" - * (WHITESPACE) - */ - - rde_param_i_state_push_void (<>); - rde_param_i_next_str (<>, "END", 67); + rde_param_i_next_char (<>, ".", 77); if (rde_param_i_seq_void2void(<>)) return; <> <>sym_WHITESPACE (<>); rde_param_i_state_merge_void (<>); return; } @@ -1384,24 +1359,24 @@ /* * ! * */ - if (rde_param_i_symbol_void_start (<>, 71)) return ; - <> <>notahead_162 (<>); - rde_param_i_symbol_done_void (<>, 71, 70); + if (rde_param_i_symbol_void_start (<>, 81)) return ; + <> <>notahead_157 (<>); + rde_param_i_symbol_done_void (<>, 81, 80); return; } -<> void <>notahead_162 (<> <>) { <> +<> void <>notahead_157 (<> <>) { <> /* * ! * */ rde_param_i_loc_push (<>); - rde_param_i_input_next (<>, 29); + rde_param_i_input_next (<>, 43); rde_param_i_notahead_exit (<>); return; } /* @@ -1411,13 +1386,13 @@ <> void <>sym_EOL (<> <>) { <> /* * [\n\r] */ - if (rde_param_i_symbol_void_start (<>, 74)) return ; - rde_param_i_next_class (<>, "\n\r", 72); - rde_param_i_symbol_done_void (<>, 74, 73); + if (rde_param_i_symbol_void_start (<>, 84)) return ; + rde_param_i_next_class (<>, "\n\r", 82); + rde_param_i_symbol_done_void (<>, 84, 83); return; } /* * value Symbol 'Expression' @@ -1431,17 +1406,17 @@ * x * (SLASH) * (Sequence) */ - if (rde_param_i_symbol_start_d (<>, 76)) return ; - <> <>sequence_174 (<>); - rde_param_i_symbol_done_d_reduce (<>, 76, 75); + if (rde_param_i_symbol_start_d (<>, 86)) return ; + <> <>sequence_169 (<>); + rde_param_i_symbol_done_d_reduce (<>, 86, 85); return; } -<> void <>sequence_174 (<> <>) { <> +<> void <>sequence_169 (<> <>) { <> /* * x * (Sequence) * * * x @@ -1450,32 +1425,32 @@ */ rde_param_i_state_push_value (<>); <> <>sym_Sequence (<>); if (rde_param_i_seq_value2value(<>)) return; - <> <>kleene_172 (<>); + <> <>kleene_167 (<>); rde_param_i_state_merge_value (<>); return; } -<> void <>kleene_172 (<> <>) { <> +<> void <>kleene_167 (<> <>) { <> /* * * * x * (SLASH) * (Sequence) */ while (1) { rde_param_i_state_push_2 (<>); - <> <>sequence_170 (<>); + <> <>sequence_165 (<>); if (rde_param_i_kleene_close(<>)) return; } return; } -<> void <>sequence_170 (<> <>) { <> +<> void <>sequence_165 (<> <>) { <> /* * x * (SLASH) * (Sequence) */ @@ -1493,31 +1468,35 @@ */ <> void <>sym_Final (<> <>) { <> /* * x - * (END) + * "END" + * (WHITESPACE) * (SEMICOLON) * (WHITESPACE) */ - if (rde_param_i_symbol_void_start (<>, 78)) return ; - <> <>sequence_180 (<>); - rde_param_i_symbol_done_void (<>, 78, 77); + if (rde_param_i_symbol_void_start (<>, 89)) return ; + <> <>sequence_176 (<>); + rde_param_i_symbol_done_void (<>, 89, 88); return; } -<> void <>sequence_180 (<> <>) { <> +<> void <>sequence_176 (<> <>) { <> /* * x - * (END) + * "END" + * (WHITESPACE) * (SEMICOLON) * (WHITESPACE) */ rde_param_i_state_push_void (<>); - <> <>sym_END (<>); + rde_param_i_next_str (<>, "END", 87); + if (rde_param_i_seq_void2void(<>)) return; + <> <>sym_WHITESPACE (<>); if (rde_param_i_seq_void2void(<>)) return; <> <>sym_SEMICOLON (<>); if (rde_param_i_seq_void2void(<>)) return; <> <>sym_WHITESPACE (<>); rde_param_i_state_merge_void (<>); @@ -1537,17 +1516,17 @@ * (Definition) * (Final) * (EOF) */ - if (rde_param_i_symbol_start_d (<>, 80)) return ; - <> <>sequence_190 (<>); - rde_param_i_symbol_done_d_reduce (<>, 80, 79); + if (rde_param_i_symbol_start_d (<>, 91)) return ; + <> <>sequence_186 (<>); + rde_param_i_symbol_done_d_reduce (<>, 91, 90); return; } -<> void <>sequence_190 (<> <>) { <> +<> void <>sequence_186 (<> <>) { <> /* * x * (WHITESPACE) * (Header) * * @@ -1559,20 +1538,20 @@ rde_param_i_state_push_void (<>); <> <>sym_WHITESPACE (<>); if (rde_param_i_seq_void2value(<>)) return; <> <>sym_Header (<>); if (rde_param_i_seq_value2value(<>)) return; - <> <>kleene_186 (<>); + <> <>kleene_182 (<>); if (rde_param_i_seq_value2value(<>)) return; <> <>sym_Final (<>); if (rde_param_i_seq_value2value(<>)) return; <> <>sym_EOF (<>); rde_param_i_state_merge_value (<>); return; } -<> void <>kleene_186 (<> <>) { <> +<> void <>kleene_182 (<> <>) { <> /* * * * (Definition) */ @@ -1593,25 +1572,25 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (<>, 83)) return ; - <> <>sequence_195 (<>); - rde_param_i_symbol_done_leaf (<>, 83, 82); + if (rde_param_i_symbol_start (<>, 94)) return ; + <> <>sequence_191 (<>); + rde_param_i_symbol_done_leaf (<>, 94, 93); return; } -<> void <>sequence_195 (<> <>) { <> +<> void <>sequence_191 (<> <>) { <> /* * x * "" * (WHITESPACE) */ rde_param_i_state_push_void (<>); - rde_param_i_next_str (<>, "", 81); + rde_param_i_next_str (<>, "", 92); if (rde_param_i_seq_void2void(<>)) return; <> <>sym_WHITESPACE (<>); rde_param_i_state_merge_void (<>); return; } @@ -1626,17 +1605,17 @@ * (PEG) * (Identifier) * (StartExpr) */ - if (rde_param_i_symbol_start_d (<>, 85)) return ; - <> <>sequence_201 (<>); - rde_param_i_symbol_done_d_reduce (<>, 85, 84); + if (rde_param_i_symbol_start_d (<>, 96)) return ; + <> <>sequence_197 (<>); + rde_param_i_symbol_done_d_reduce (<>, 96, 95); return; } -<> void <>sequence_201 (<> <>) { <> +<> void <>sequence_197 (<> <>) { <> /* * x * (PEG) * (Identifier) * (StartExpr) @@ -1666,17 +1645,17 @@ * / * [_:] * */ - if (rde_param_i_symbol_start (<>, 90)) return ; - <> <>sequence_214 (<>); - rde_param_i_symbol_done_leaf (<>, 90, 89); + if (rde_param_i_symbol_start (<>, 99)) return ; + <> <>sequence_210 (<>); + rde_param_i_symbol_done_leaf (<>, 99, 98); return; } -<> void <>sequence_214 (<> <>) { <> +<> void <>sequence_210 (<> <>) { <> /* * x * / * [_:] * @@ -1685,59 +1664,59 @@ * [_:] * */ rde_param_i_state_push_void (<>); - <> <>choice_206 (<>); + <> <>choice_202 (<>); if (rde_param_i_seq_void2void(<>)) return; - <> <>kleene_212 (<>); + <> <>kleene_208 (<>); rde_param_i_state_merge_void (<>); return; } -<> void <>choice_206 (<> <>) { <> +<> void <>choice_202 (<> <>) { <> /* * / * [_:] * */ rde_param_i_state_push_void (<>); - rde_param_i_next_class (<>, "_:", 86); + rde_param_i_next_class (<>, "_:", 97); if (rde_param_i_bra_void2void(<>)) return; - rde_param_i_next_alpha (<>, 87); + rde_param_i_next_alpha (<>, 1); rde_param_i_state_merge_void (<>); return; } -<> void <>kleene_212 (<> <>) { <> +<> void <>kleene_208 (<> <>) { <> /* * * * / * [_:] * */ while (1) { rde_param_i_state_push_2 (<>); - <> <>choice_210 (<>); + <> <>choice_206 (<>); if (rde_param_i_kleene_close(<>)) return; } return; } -<> void <>choice_210 (<> <>) { <> +<> void <>choice_206 (<> <>) { <> /* * / * [_:] * */ rde_param_i_state_push_void (<>); - rde_param_i_next_class (<>, "_:", 86); + rde_param_i_next_class (<>, "_:", 97); if (rde_param_i_bra_void2void(<>)) return; - rde_param_i_next_alnum (<>, 88); + rde_param_i_next_alnum (<>, 0); rde_param_i_state_merge_void (<>); return; } /* @@ -1749,17 +1728,17 @@ * x * (Ident) * (WHITESPACE) */ - if (rde_param_i_symbol_start_d (<>, 92)) return ; - <> <>sequence_219 (<>); - rde_param_i_symbol_done_d_reduce (<>, 92, 91); + if (rde_param_i_symbol_start_d (<>, 101)) return ; + <> <>sequence_215 (<>); + rde_param_i_symbol_done_d_reduce (<>, 101, 100); return; } -<> void <>sequence_219 (<> <>) { <> +<> void <>sequence_215 (<> <>) { <> /* * x * (Ident) * (WHITESPACE) */ @@ -1781,25 +1760,25 @@ * x * "<-" * (WHITESPACE) */ - if (rde_param_i_symbol_void_start (<>, 95)) return ; - <> <>sequence_224 (<>); - rde_param_i_symbol_done_void (<>, 95, 94); + if (rde_param_i_symbol_void_start (<>, 104)) return ; + <> <>sequence_220 (<>); + rde_param_i_symbol_done_void (<>, 104, 103); return; } -<> void <>sequence_224 (<> <>) { <> +<> void <>sequence_220 (<> <>) { <> /* * x * "<-" * (WHITESPACE) */ rde_param_i_state_push_void (<>); - rde_param_i_next_str (<>, "<-", 93); + rde_param_i_next_str (<>, "<-", 102); if (rde_param_i_seq_void2void(<>)) return; <> <>sym_WHITESPACE (<>); rde_param_i_state_merge_void (<>); return; } @@ -1813,25 +1792,25 @@ * x * "leaf" * (WHITESPACE) */ - if (rde_param_i_symbol_start (<>, 98)) return ; - <> <>sequence_229 (<>); - rde_param_i_symbol_done_leaf (<>, 98, 97); + if (rde_param_i_symbol_start (<>, 107)) return ; + <> <>sequence_225 (<>); + rde_param_i_symbol_done_leaf (<>, 107, 106); return; } -<> void <>sequence_229 (<> <>) { <> +<> void <>sequence_225 (<> <>) { <> /* * x * "leaf" * (WHITESPACE) */ rde_param_i_state_push_void (<>); - rde_param_i_next_str (<>, "leaf", 96); + rde_param_i_next_str (<>, "leaf", 105); if (rde_param_i_seq_void2void(<>)) return; <> <>sym_WHITESPACE (<>); rde_param_i_state_merge_void (<>); return; } @@ -1861,17 +1840,17 @@ * (Char) * (DAPOSTROPH) * (WHITESPACE) */ - if (rde_param_i_symbol_start_d (<>, 100)) return ; - <> <>choice_258 (<>); - rde_param_i_symbol_done_d_reduce (<>, 100, 99); + if (rde_param_i_symbol_start_d (<>, 109)) return ; + <> <>choice_254 (<>); + rde_param_i_symbol_done_d_reduce (<>, 109, 108); return; } -<> void <>choice_258 (<> <>) { <> +<> void <>choice_254 (<> <>) { <> /* * / * x * (APOSTROPH) * * @@ -1891,18 +1870,18 @@ * (DAPOSTROPH) * (WHITESPACE) */ rde_param_i_state_push_value (<>); - <> <>sequence_243 (<>); + <> <>sequence_239 (<>); if (rde_param_i_bra_value2value(<>)) return; - <> <>sequence_256 (<>); + <> <>sequence_252 (<>); rde_param_i_state_merge_value (<>); return; } -<> void <>sequence_243 (<> <>) { <> +<> void <>sequence_239 (<> <>) { <> /* * x * (APOSTROPH) * * * x @@ -1914,20 +1893,20 @@ */ rde_param_i_state_push_void (<>); <> <>sym_APOSTROPH (<>); if (rde_param_i_seq_void2value(<>)) return; - <> <>kleene_239 (<>); + <> <>kleene_235 (<>); if (rde_param_i_seq_value2value(<>)) return; <> <>sym_APOSTROPH (<>); if (rde_param_i_seq_value2value(<>)) return; <> <>sym_WHITESPACE (<>); rde_param_i_state_merge_value (<>); return; } -<> void <>kleene_239 (<> <>) { <> +<> void <>kleene_235 (<> <>) { <> /* * * * x * ! * (APOSTROPH) @@ -1934,33 +1913,33 @@ * (Char) */ while (1) { rde_param_i_state_push_2 (<>); - <> <>sequence_237 (<>); + <> <>sequence_233 (<>); if (rde_param_i_kleene_close(<>)) return; } return; } -<> void <>sequence_237 (<> <>) { <> +<> void <>sequence_233 (<> <>) { <> /* * x * ! * (APOSTROPH) * (Char) */ rde_param_i_state_push_void (<>); - <> <>notahead_234 (<>); + <> <>notahead_230 (<>); if (rde_param_i_seq_void2value(<>)) return; <> <>sym_Char (<>); rde_param_i_state_merge_value (<>); return; } -<> void <>notahead_234 (<> <>) { <> +<> void <>notahead_230 (<> <>) { <> /* * ! * (APOSTROPH) */ @@ -1968,11 +1947,11 @@ <> <>sym_APOSTROPH (<>); rde_param_i_notahead_exit (<>); return; } -<> void <>sequence_256 (<> <>) { <> +<> void <>sequence_252 (<> <>) { <> /* * x * (DAPOSTROPH) * * * x @@ -1984,20 +1963,20 @@ */ rde_param_i_state_push_void (<>); <> <>sym_DAPOSTROPH (<>); if (rde_param_i_seq_void2value(<>)) return; - <> <>kleene_252 (<>); + <> <>kleene_248 (<>); if (rde_param_i_seq_value2value(<>)) return; <> <>sym_DAPOSTROPH (<>); if (rde_param_i_seq_value2value(<>)) return; <> <>sym_WHITESPACE (<>); rde_param_i_state_merge_value (<>); return; } -<> void <>kleene_252 (<> <>) { <> +<> void <>kleene_248 (<> <>) { <> /* * * * x * ! * (DAPOSTROPH) @@ -2004,33 +1983,33 @@ * (Char) */ while (1) { rde_param_i_state_push_2 (<>); - <> <>sequence_250 (<>); + <> <>sequence_246 (<>); if (rde_param_i_kleene_close(<>)) return; } return; } -<> void <>sequence_250 (<> <>) { <> +<> void <>sequence_246 (<> <>) { <> /* * x * ! * (DAPOSTROPH) * (Char) */ rde_param_i_state_push_void (<>); - <> <>notahead_247 (<>); + <> <>notahead_243 (<>); if (rde_param_i_seq_void2value(<>)) return; <> <>sym_Char (<>); rde_param_i_state_merge_value (<>); return; } -<> void <>notahead_247 (<> <>) { <> +<> void <>notahead_243 (<> <>) { <> /* * ! * (DAPOSTROPH) */ @@ -2049,25 +2028,25 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (<>, 103)) return ; - <> <>sequence_263 (<>); - rde_param_i_symbol_done_leaf (<>, 103, 102); + if (rde_param_i_symbol_start (<>, 112)) return ; + <> <>sequence_259 (<>); + rde_param_i_symbol_done_leaf (<>, 112, 111); return; } -<> void <>sequence_263 (<> <>) { <> +<> void <>sequence_259 (<> <>) { <> /* * x * "" * (WHITESPACE) */ rde_param_i_state_push_void (<>); - rde_param_i_next_str (<>, "", 101); + rde_param_i_next_str (<>, "", 110); if (rde_param_i_seq_void2void(<>)) return; <> <>sym_WHITESPACE (<>); rde_param_i_state_merge_void (<>); return; } @@ -2081,25 +2060,25 @@ * x * '!' * (WHITESPACE) */ - if (rde_param_i_symbol_start (<>, 106)) return ; - <> <>sequence_268 (<>); - rde_param_i_symbol_done_leaf (<>, 106, 105); + if (rde_param_i_symbol_start (<>, 115)) return ; + <> <>sequence_264 (<>); + rde_param_i_symbol_done_leaf (<>, 115, 114); return; } -<> void <>sequence_268 (<> <>) { <> +<> void <>sequence_264 (<> <>) { <> /* * x * '!' * (WHITESPACE) */ rde_param_i_state_push_void (<>); - rde_param_i_next_char (<>, "!", 104); + rde_param_i_next_char (<>, "!", 113); if (rde_param_i_seq_void2void(<>)) return; <> <>sym_WHITESPACE (<>); rde_param_i_state_merge_void (<>); return; } @@ -2113,25 +2092,25 @@ * x * '\(' * (WHITESPACE) */ - if (rde_param_i_symbol_void_start (<>, 109)) return ; - <> <>sequence_273 (<>); - rde_param_i_symbol_done_void (<>, 109, 108); + if (rde_param_i_symbol_void_start (<>, 118)) return ; + <> <>sequence_269 (<>); + rde_param_i_symbol_done_void (<>, 118, 117); return; } -<> void <>sequence_273 (<> <>) { <> +<> void <>sequence_269 (<> <>) { <> /* * x * '\(' * (WHITESPACE) */ rde_param_i_state_push_void (<>); - rde_param_i_next_char (<>, "\50", 107); + rde_param_i_next_char (<>, "(", 116); if (rde_param_i_seq_void2void(<>)) return; <> <>sym_WHITESPACE (<>); rde_param_i_state_merge_void (<>); return; } @@ -2143,13 +2122,13 @@ <> void <>sym_OPENB (<> <>) { <> /* * '[' */ - if (rde_param_i_symbol_void_start (<>, 112)) return ; - rde_param_i_next_char (<>, "\133", 110); - rde_param_i_symbol_done_void (<>, 112, 111); + if (rde_param_i_symbol_void_start (<>, 121)) return ; + rde_param_i_next_char (<>, "[", 119); + rde_param_i_symbol_done_void (<>, 121, 120); return; } /* * void Symbol 'PEG' @@ -2157,33 +2136,57 @@ <> void <>sym_PEG (<> <>) { <> /* * x * "PEG" + * ! + * / + * [_:] + * * (WHITESPACE) */ - if (rde_param_i_symbol_void_start (<>, 115)) return ; - <> <>sequence_280 (<>); - rde_param_i_symbol_done_void (<>, 115, 114); + if (rde_param_i_symbol_void_start (<>, 124)) return ; + <> <>sequence_281 (<>); + rde_param_i_symbol_done_void (<>, 124, 123); return; } -<> void <>sequence_280 (<> <>) { <> +<> void <>sequence_281 (<> <>) { <> /* * x * "PEG" + * ! + * / + * [_:] + * * (WHITESPACE) */ rde_param_i_state_push_void (<>); - rde_param_i_next_str (<>, "PEG", 113); + rde_param_i_next_str (<>, "PEG", 122); + if (rde_param_i_seq_void2void(<>)) return; + <> <>notahead_278 (<>); if (rde_param_i_seq_void2void(<>)) return; <> <>sym_WHITESPACE (<>); rde_param_i_state_merge_void (<>); return; } + +<> void <>notahead_278 (<> <>) { <> + /* + * ! + * / + * [_:] + * + */ + + rde_param_i_loc_push (<>); + <> <>choice_206 (<>); + rde_param_i_notahead_exit (<>); + return; +} /* * leaf Symbol 'PLUS' */ @@ -2192,25 +2195,25 @@ * x * '+' * (WHITESPACE) */ - if (rde_param_i_symbol_start (<>, 118)) return ; - <> <>sequence_285 (<>); - rde_param_i_symbol_done_leaf (<>, 118, 117); + if (rde_param_i_symbol_start (<>, 127)) return ; + <> <>sequence_286 (<>); + rde_param_i_symbol_done_leaf (<>, 127, 126); return; } -<> void <>sequence_285 (<> <>) { <> +<> void <>sequence_286 (<> <>) { <> /* * x * '+' * (WHITESPACE) */ rde_param_i_state_push_void (<>); - rde_param_i_next_char (<>, "+", 116); + rde_param_i_next_char (<>, "+", 125); if (rde_param_i_seq_void2void(<>)) return; <> <>sym_WHITESPACE (<>); rde_param_i_state_merge_void (<>); return; } @@ -2227,17 +2230,17 @@ * (AND) * (NOT) * (Suffix) */ - if (rde_param_i_symbol_start_d (<>, 120)) return ; - <> <>sequence_295 (<>); - rde_param_i_symbol_done_d_reduce (<>, 120, 119); + if (rde_param_i_symbol_start_d (<>, 129)) return ; + <> <>sequence_296 (<>); + rde_param_i_symbol_done_d_reduce (<>, 129, 128); return; } -<> void <>sequence_295 (<> <>) { <> +<> void <>sequence_296 (<> <>) { <> /* * x * ? * / * (AND) @@ -2244,32 +2247,32 @@ * (NOT) * (Suffix) */ rde_param_i_state_push_value (<>); - <> <>optional_292 (<>); + <> <>optional_293 (<>); if (rde_param_i_seq_value2value(<>)) return; <> <>sym_Suffix (<>); rde_param_i_state_merge_value (<>); return; } -<> void <>optional_292 (<> <>) { <> +<> void <>optional_293 (<> <>) { <> /* * ? * / * (AND) * (NOT) */ rde_param_i_state_push_2 (<>); - <> <>choice_290 (<>); + <> <>choice_291 (<>); rde_param_i_state_merge_ok (<>); return; } -<> void <>choice_290 (<> <>) { <> +<> void <>choice_291 (<> <>) { <> /* * / * (AND) * (NOT) */ @@ -2311,17 +2314,17 @@ * (Literal) * (Class) * (DOT) */ - if (rde_param_i_symbol_start_d (<>, 122)) return ; - <> <>choice_321 (<>); - rde_param_i_symbol_done_d_reduce (<>, 122, 121); + if (rde_param_i_symbol_start_d (<>, 131)) return ; + <> <>choice_322 (<>); + rde_param_i_symbol_done_d_reduce (<>, 131, 130); return; } -<> void <>choice_321 (<> <>) { <> +<> void <>choice_322 (<> <>) { <> /* * / * (ALNUM) * (ALPHA) * (ASCII) @@ -2375,11 +2378,11 @@ if (rde_param_i_bra_value2value(<>)) return; <> <>sym_XDIGIT (<>); if (rde_param_i_bra_value2value(<>)) return; <> <>sym_Identifier (<>); if (rde_param_i_bra_value2value(<>)) return; - <> <>sequence_316 (<>); + <> <>sequence_317 (<>); if (rde_param_i_bra_value2value(<>)) return; <> <>sym_Literal (<>); if (rde_param_i_bra_value2value(<>)) return; <> <>sym_Class (<>); if (rde_param_i_bra_value2value(<>)) return; @@ -2386,11 +2389,11 @@ <> <>sym_DOT (<>); rde_param_i_state_merge_value (<>); return; } -<> void <>sequence_316 (<> <>) { <> +<> void <>sequence_317 (<> <>) { <> /* * x * (OPEN) * (Expression) * (CLOSE) @@ -2415,25 +2418,25 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (<>, 125)) return ; - <> <>sequence_326 (<>); - rde_param_i_symbol_done_leaf (<>, 125, 124); + if (rde_param_i_symbol_start (<>, 134)) return ; + <> <>sequence_327 (<>); + rde_param_i_symbol_done_leaf (<>, 134, 133); return; } -<> void <>sequence_326 (<> <>) { <> +<> void <>sequence_327 (<> <>) { <> /* * x * "" * (WHITESPACE) */ rde_param_i_state_push_void (<>); - rde_param_i_next_str (<>, "", 123); + rde_param_i_next_str (<>, "", 132); if (rde_param_i_seq_void2void(<>)) return; <> <>sym_WHITESPACE (<>); rde_param_i_state_merge_void (<>); return; } @@ -2447,25 +2450,25 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (<>, 128)) return ; - <> <>sequence_331 (<>); - rde_param_i_symbol_done_leaf (<>, 128, 127); + if (rde_param_i_symbol_start (<>, 137)) return ; + <> <>sequence_332 (<>); + rde_param_i_symbol_done_leaf (<>, 137, 136); return; } -<> void <>sequence_331 (<> <>) { <> +<> void <>sequence_332 (<> <>) { <> /* * x * "" * (WHITESPACE) */ rde_param_i_state_push_void (<>); - rde_param_i_next_str (<>, "", 126); + rde_param_i_next_str (<>, "", 135); if (rde_param_i_seq_void2void(<>)) return; <> <>sym_WHITESPACE (<>); rde_param_i_state_merge_void (<>); return; } @@ -2479,25 +2482,25 @@ * x * '?' * (WHITESPACE) */ - if (rde_param_i_symbol_start (<>, 131)) return ; - <> <>sequence_336 (<>); - rde_param_i_symbol_done_leaf (<>, 131, 130); + if (rde_param_i_symbol_start (<>, 140)) return ; + <> <>sequence_337 (<>); + rde_param_i_symbol_done_leaf (<>, 140, 139); return; } -<> void <>sequence_336 (<> <>) { <> +<> void <>sequence_337 (<> <>) { <> /* * x * '?' * (WHITESPACE) */ rde_param_i_state_push_void (<>); - rde_param_i_next_char (<>, "?", 129); + rde_param_i_next_char (<>, "?", 138); if (rde_param_i_seq_void2void(<>)) return; <> <>sym_WHITESPACE (<>); rde_param_i_state_merge_void (<>); return; } @@ -2514,17 +2517,17 @@ * (TO) * (Char) * (Char) */ - if (rde_param_i_symbol_start_d (<>, 133)) return ; - <> <>choice_345 (<>); - rde_param_i_symbol_done_d_reduce (<>, 133, 132); + if (rde_param_i_symbol_start_d (<>, 142)) return ; + <> <>choice_346 (<>); + rde_param_i_symbol_done_d_reduce (<>, 142, 141); return; } -<> void <>choice_345 (<> <>) { <> +<> void <>choice_346 (<> <>) { <> /* * / * x * (Char) * (TO) @@ -2531,18 +2534,18 @@ * (Char) * (Char) */ rde_param_i_state_push_value (<>); - <> <>sequence_342 (<>); + <> <>sequence_343 (<>); if (rde_param_i_bra_value2value(<>)) return; <> <>sym_Char (<>); rde_param_i_state_merge_value (<>); return; } -<> void <>sequence_342 (<> <>) { <> +<> void <>sequence_343 (<> <>) { <> /* * x * (Char) * (TO) * (Char) @@ -2567,25 +2570,25 @@ * x * ';' * (WHITESPACE) */ - if (rde_param_i_symbol_void_start (<>, 136)) return ; - <> <>sequence_350 (<>); - rde_param_i_symbol_done_void (<>, 136, 135); + if (rde_param_i_symbol_void_start (<>, 145)) return ; + <> <>sequence_351 (<>); + rde_param_i_symbol_done_void (<>, 145, 144); return; } -<> void <>sequence_350 (<> <>) { <> +<> void <>sequence_351 (<> <>) { <> /* * x * ';' * (WHITESPACE) */ rde_param_i_state_push_void (<>); - rde_param_i_next_char (<>, "\73", 134); + rde_param_i_next_char (<>, ";", 143); if (rde_param_i_seq_void2void(<>)) return; <> <>sym_WHITESPACE (<>); rde_param_i_state_merge_void (<>); return; } @@ -2598,17 +2601,17 @@ /* * + * (Prefix) */ - if (rde_param_i_symbol_start_d (<>, 138)) return ; - <> <>poskleene_354 (<>); - rde_param_i_symbol_done_d_reduce (<>, 138, 137); + if (rde_param_i_symbol_start_d (<>, 147)) return ; + <> <>poskleene_355 (<>); + rde_param_i_symbol_done_d_reduce (<>, 147, 146); return; } -<> void <>poskleene_354 (<> <>) { <> +<> void <>poskleene_355 (<> <>) { <> /* * + * (Prefix) */ @@ -2632,25 +2635,25 @@ * x * '/' * (WHITESPACE) */ - if (rde_param_i_symbol_void_start (<>, 141)) return ; - <> <>sequence_359 (<>); - rde_param_i_symbol_done_void (<>, 141, 140); + if (rde_param_i_symbol_void_start (<>, 150)) return ; + <> <>sequence_360 (<>); + rde_param_i_symbol_done_void (<>, 150, 149); return; } -<> void <>sequence_359 (<> <>) { <> +<> void <>sequence_360 (<> <>) { <> /* * x * '/' * (WHITESPACE) */ rde_param_i_state_push_void (<>); - rde_param_i_next_char (<>, "/", 139); + rde_param_i_next_char (<>, "/", 148); if (rde_param_i_seq_void2void(<>)) return; <> <>sym_WHITESPACE (<>); rde_param_i_state_merge_void (<>); return; } @@ -2664,25 +2667,25 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (<>, 144)) return ; - <> <>sequence_364 (<>); - rde_param_i_symbol_done_leaf (<>, 144, 143); + if (rde_param_i_symbol_start (<>, 153)) return ; + <> <>sequence_365 (<>); + rde_param_i_symbol_done_leaf (<>, 153, 152); return; } -<> void <>sequence_364 (<> <>) { <> +<> void <>sequence_365 (<> <>) { <> /* * x * "" * (WHITESPACE) */ rde_param_i_state_push_void (<>); - rde_param_i_next_str (<>, "", 142); + rde_param_i_next_str (<>, "", 151); if (rde_param_i_seq_void2void(<>)) return; <> <>sym_WHITESPACE (<>); rde_param_i_state_merge_void (<>); return; } @@ -2696,25 +2699,25 @@ * x * '*' * (WHITESPACE) */ - if (rde_param_i_symbol_start (<>, 147)) return ; - <> <>sequence_369 (<>); - rde_param_i_symbol_done_leaf (<>, 147, 146); + if (rde_param_i_symbol_start (<>, 156)) return ; + <> <>sequence_370 (<>); + rde_param_i_symbol_done_leaf (<>, 156, 155); return; } -<> void <>sequence_369 (<> <>) { <> +<> void <>sequence_370 (<> <>) { <> /* * x * '*' * (WHITESPACE) */ rde_param_i_state_push_void (<>); - rde_param_i_next_char (<>, "*", 145); + rde_param_i_next_char (<>, "*", 154); if (rde_param_i_seq_void2void(<>)) return; <> <>sym_WHITESPACE (<>); rde_param_i_state_merge_void (<>); return; } @@ -2729,13 +2732,13 @@ * (OPEN) * (Expression) * (CLOSE) */ - if (rde_param_i_symbol_start_d (<>, 149)) return ; - <> <>sequence_316 (<>); - rde_param_i_symbol_done_d_reduce (<>, 149, 148); + if (rde_param_i_symbol_start_d (<>, 158)) return ; + <> <>sequence_317 (<>); + rde_param_i_symbol_done_d_reduce (<>, 158, 157); return; } /* * value Symbol 'Suffix' @@ -2750,17 +2753,17 @@ * (QUESTION) * (STAR) * (PLUS) */ - if (rde_param_i_symbol_start_d (<>, 151)) return ; - <> <>sequence_385 (<>); - rde_param_i_symbol_done_d_reduce (<>, 151, 150); + if (rde_param_i_symbol_start_d (<>, 160)) return ; + <> <>sequence_386 (<>); + rde_param_i_symbol_done_d_reduce (<>, 160, 159); return; } -<> void <>sequence_385 (<> <>) { <> +<> void <>sequence_386 (<> <>) { <> /* * x * (Primary) * ? * / @@ -2770,31 +2773,31 @@ */ rde_param_i_state_push_value (<>); <> <>sym_Primary (<>); if (rde_param_i_seq_value2value(<>)) return; - <> <>optional_383 (<>); + <> <>optional_384 (<>); rde_param_i_state_merge_value (<>); return; } -<> void <>optional_383 (<> <>) { <> +<> void <>optional_384 (<> <>) { <> /* * ? * / * (QUESTION) * (STAR) * (PLUS) */ rde_param_i_state_push_2 (<>); - <> <>choice_381 (<>); + <> <>choice_382 (<>); rde_param_i_state_merge_ok (<>); return; } -<> void <>choice_381 (<> <>) { <> +<> void <>choice_382 (<> <>) { <> /* * / * (QUESTION) * (STAR) * (PLUS) @@ -2817,13 +2820,13 @@ <> void <>sym_TO (<> <>) { <> /* * '-' */ - if (rde_param_i_symbol_void_start (<>, 154)) return ; - rde_param_i_next_char (<>, "-", 152); - rde_param_i_symbol_done_void (<>, 154, 153); + if (rde_param_i_symbol_void_start (<>, 163)) return ; + rde_param_i_next_char (<>, "-", 161); + rde_param_i_symbol_done_void (<>, 163, 162); return; } /* * leaf Symbol 'UPPER' @@ -2834,25 +2837,25 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (<>, 157)) return ; - <> <>sequence_392 (<>); - rde_param_i_symbol_done_leaf (<>, 157, 156); + if (rde_param_i_symbol_start (<>, 166)) return ; + <> <>sequence_393 (<>); + rde_param_i_symbol_done_leaf (<>, 166, 165); return; } -<> void <>sequence_392 (<> <>) { <> +<> void <>sequence_393 (<> <>) { <> /* * x * "" * (WHITESPACE) */ rde_param_i_state_push_void (<>); - rde_param_i_next_str (<>, "", 155); + rde_param_i_next_str (<>, "", 164); if (rde_param_i_seq_void2void(<>)) return; <> <>sym_WHITESPACE (<>); rde_param_i_state_merge_void (<>); return; } @@ -2866,25 +2869,25 @@ * x * "void" * (WHITESPACE) */ - if (rde_param_i_symbol_start (<>, 160)) return ; - <> <>sequence_397 (<>); - rde_param_i_symbol_done_leaf (<>, 160, 159); + if (rde_param_i_symbol_start (<>, 169)) return ; + <> <>sequence_398 (<>); + rde_param_i_symbol_done_leaf (<>, 169, 168); return; } -<> void <>sequence_397 (<> <>) { <> +<> void <>sequence_398 (<> <>) { <> /* * x * "void" * (WHITESPACE) */ rde_param_i_state_push_void (<>); - rde_param_i_next_str (<>, "void", 158); + rde_param_i_next_str (<>, "void", 167); if (rde_param_i_seq_void2void(<>)) return; <> <>sym_WHITESPACE (<>); rde_param_i_state_merge_void (<>); return; } @@ -2899,41 +2902,41 @@ * / * * (COMMENT) */ - if (rde_param_i_symbol_void_start (<>, 163)) return ; - <> <>kleene_404 (<>); - rde_param_i_symbol_done_void (<>, 163, 162); + if (rde_param_i_symbol_void_start (<>, 171)) return ; + <> <>kleene_405 (<>); + rde_param_i_symbol_done_void (<>, 171, 170); return; } -<> void <>kleene_404 (<> <>) { <> +<> void <>kleene_405 (<> <>) { <> /* * * * / * * (COMMENT) */ while (1) { rde_param_i_state_push_2 (<>); - <> <>choice_402 (<>); + <> <>choice_403 (<>); if (rde_param_i_kleene_close(<>)) return; } return; } -<> void <>choice_402 (<> <>) { <> +<> void <>choice_403 (<> <>) { <> /* * / * * (COMMENT) */ rde_param_i_state_push_void (<>); - rde_param_i_next_space (<>, 161); + rde_param_i_next_space (<>, 10); if (rde_param_i_bra_void2void(<>)) return; <> <>sym_COMMENT (<>); rde_param_i_state_merge_void (<>); return; } @@ -2947,25 +2950,25 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (<>, 166)) return ; - <> <>sequence_409 (<>); - rde_param_i_symbol_done_leaf (<>, 166, 165); + if (rde_param_i_symbol_start (<>, 174)) return ; + <> <>sequence_410 (<>); + rde_param_i_symbol_done_leaf (<>, 174, 173); return; } -<> void <>sequence_409 (<> <>) { <> +<> void <>sequence_410 (<> <>) { <> /* * x * "" * (WHITESPACE) */ rde_param_i_state_push_void (<>); - rde_param_i_next_str (<>, "", 164); + rde_param_i_next_str (<>, "", 172); if (rde_param_i_seq_void2void(<>)) return; <> <>sym_WHITESPACE (<>); rde_param_i_state_merge_void (<>); return; } @@ -2979,28 +2982,28 @@ * x * "" * (WHITESPACE) */ - if (rde_param_i_symbol_start (<>, 169)) return ; - <> <>sequence_414 (<>); - rde_param_i_symbol_done_leaf (<>, 169, 168); + if (rde_param_i_symbol_start (<>, 177)) return ; + <> <>sequence_415 (<>); + rde_param_i_symbol_done_leaf (<>, 177, 176); return; } -<> void <>sequence_414 (<> <>) { <> +<> void <>sequence_415 (<> <>) { <> /* * x * "" * (WHITESPACE) */ rde_param_i_state_push_void (<>); - rde_param_i_next_str (<>, "", 167); + rde_param_i_next_str (<>, "", 175); if (rde_param_i_seq_void2void(<>)) return; <> <>sym_WHITESPACE (<>); rde_param_i_state_merge_void (<>); return; } /* */ Index: modules/pt/tests/data/ok/peg_cparam/4_choice ================================================================== --- modules/pt/tests/data/ok/peg_cparam/4_choice +++ modules/pt/tests/data/ok/peg_cparam/4_choice @@ -11,20 +11,34 @@ /* * Precomputed table of strings (symbols, error messages, etc.). */ -static char const* <> [1] = { - /* 0 = */ "cl 'abc'" +static char const* <> [15] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "cl abc" }; /* * Grammar Start Expression */ <> void <><
              > (<> <>) { <> - rde_param_i_next_class (<>, "abc", 0); + rde_param_i_next_class (<>, "abc", 14); return; } /* */ Index: modules/pt/tests/data/ok/peg_cparam/5_sequence ================================================================== --- modules/pt/tests/data/ok/peg_cparam/5_sequence +++ modules/pt/tests/data/ok/peg_cparam/5_sequence @@ -11,20 +11,34 @@ /* * Precomputed table of strings (symbols, error messages, etc.). */ -static char const* <> [1] = { - /* 0 = */ "str 'abc'" +static char const* <> [15] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "str abc" }; /* * Grammar Start Expression */ <> void <><
              > (<> <>) { <> - rde_param_i_next_str (<>, "abc", 0); + rde_param_i_next_str (<>, "abc", 14); return; } /* */ Index: modules/pt/tests/data/ok/peg_cparam/6_optional ================================================================== --- modules/pt/tests/data/ok/peg_cparam/6_optional +++ modules/pt/tests/data/ok/peg_cparam/6_optional @@ -12,12 +12,26 @@ /* * Precomputed table of strings (symbols, error messages, etc.). */ -static char const* <> [1] = { - /* 0 = */ "t a" +static char const* <> [15] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "t a" }; /* * Grammar Start Expression */ @@ -32,12 +46,12 @@ * ? * 'a' */ rde_param_i_state_push_2 (<>); - rde_param_i_next_char (<>, "a", 0); + rde_param_i_next_char (<>, "a", 14); rde_param_i_state_merge_ok (<>); return; } /* */ Index: modules/pt/tests/data/ok/peg_cparam/7_kleene ================================================================== --- modules/pt/tests/data/ok/peg_cparam/7_kleene +++ modules/pt/tests/data/ok/peg_cparam/7_kleene @@ -12,12 +12,26 @@ /* * Precomputed table of strings (symbols, error messages, etc.). */ -static char const* <> [1] = { - /* 0 = */ "t a" +static char const* <> [15] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "t a" }; /* * Grammar Start Expression */ @@ -33,13 +47,13 @@ * 'a' */ while (1) { rde_param_i_state_push_2 (<>); - rde_param_i_next_char (<>, "a", 0); + rde_param_i_next_char (<>, "a", 14); if (rde_param_i_kleene_close(<>)) return; } return; } /* */ Index: modules/pt/tests/data/ok/peg_cparam/8_pkleene ================================================================== --- modules/pt/tests/data/ok/peg_cparam/8_pkleene +++ modules/pt/tests/data/ok/peg_cparam/8_pkleene @@ -12,12 +12,26 @@ /* * Precomputed table of strings (symbols, error messages, etc.). */ -static char const* <> [1] = { - /* 0 = */ "t a" +static char const* <> [15] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "t a" }; /* * Grammar Start Expression */ @@ -32,17 +46,17 @@ * + * 'a' */ rde_param_i_loc_push (<>); - rde_param_i_next_char (<>, "a", 0); + rde_param_i_next_char (<>, "a", 14); if (rde_param_i_kleene_abort(<>)) return; while (1) { rde_param_i_state_push_2 (<>); - rde_param_i_next_char (<>, "a", 0); + rde_param_i_next_char (<>, "a", 14); if (rde_param_i_kleene_close(<>)) return; } return; } /* */ Index: modules/pt/tests/data/ok/peg_cparam/9_ahead ================================================================== --- modules/pt/tests/data/ok/peg_cparam/9_ahead +++ modules/pt/tests/data/ok/peg_cparam/9_ahead @@ -14,14 +14,28 @@ /* * Precomputed table of strings (symbols, error messages, etc.). */ -static char const* <> [3] = { - /* 0 = */ "t a", - /* 1 = */ "n TEST", - /* 2 = */ "TEST" +static char const* <> [17] = { + /* 0 = */ "alnum", + /* 1 = */ "alpha", + /* 2 = */ "ascii", + /* 3 = */ "control", + /* 4 = */ "ddigit", + /* 5 = */ "digit", + /* 6 = */ "graph", + /* 7 = */ "lower", + /* 8 = */ "print", + /* 9 = */ "punct", + /* 10 = */ "space", + /* 11 = */ "upper", + /* 12 = */ "wordchar", + /* 13 = */ "xdigit", + /* 14 = */ "t a", + /* 15 = */ "n TEST", + /* 16 = */ "TEST" }; /* * Grammar Start Expression */ @@ -41,13 +55,13 @@ * & * 'a' * (IDENTIFIER) */ - if (rde_param_i_symbol_start (<>, 2)) return ; + if (rde_param_i_symbol_start (<>, 16)) return ; <> <>sequence_6 (<>); - rde_param_i_symbol_done_leaf (<>, 2, 1); + rde_param_i_symbol_done_leaf (<>, 16, 15); return; } <> void <>sequence_6 (<> <>) { <> /* @@ -71,12 +85,12 @@ * & * 'a' */ rde_param_i_loc_push (<>); - rde_param_i_next_char (<>, "a", 0); + rde_param_i_next_char (<>, "a", 14); rde_param_i_loc_pop_rewind (<>); return; } /* */ Index: modules/pt/tests/data/ok/peg_json-indalign/3_peg_itself ================================================================== --- modules/pt/tests/data/ok/peg_json-indalign/3_peg_itself +++ modules/pt/tests/data/ok/peg_json-indalign/3_peg_itself @@ -91,14 +91,10 @@ }, "DOT" : { "is" : "x {t .} {n WHITESPACE}", "mode" : "leaf" }, - "END" : { - "is" : "x {t E} {t N} {t D} {n WHITESPACE}", - "mode" : "void" - }, "EOF" : { "is" : "! dot", "mode" : "void" }, "EOL" : { @@ -108,11 +104,11 @@ "Expression" : { "is" : "x {n Sequence} {* {x {n SLASH} {n Sequence}}}", "mode" : "value" }, "Final" : { - "is" : "x {n END} {n SEMICOLON} {n WHITESPACE}", + "is" : "x {t E} {t N} {t D} {n WHITESPACE} {n SEMICOLON} {n WHITESPACE}", "mode" : "void" }, "Grammar" : { "is" : "x {n WHITESPACE} {n Header} {* {n Definition}} {n Final} {n EOF}", "mode" : "value" @@ -160,11 +156,11 @@ "OPENB" : { "is" : "t {[}", "mode" : "void" }, "PEG" : { - "is" : "x {t P} {t E} {t G} {n WHITESPACE}", + "is" : "x {t P} {t E} {t G} {! {/ {t _} {t :} alnum}} {n WHITESPACE}", "mode" : "void" }, "PLUS" : { "is" : "x {t +} {n WHITESPACE}", "mode" : "leaf" Index: modules/pt/tests/data/ok/peg_json-indented/3_peg_itself ================================================================== --- modules/pt/tests/data/ok/peg_json-indented/3_peg_itself +++ modules/pt/tests/data/ok/peg_json-indented/3_peg_itself @@ -91,14 +91,10 @@ }, "DOT" : { "is" : "x {t .} {n WHITESPACE}", "mode" : "leaf" }, - "END" : { - "is" : "x {t E} {t N} {t D} {n WHITESPACE}", - "mode" : "void" - }, "EOF" : { "is" : "! dot", "mode" : "void" }, "EOL" : { @@ -108,11 +104,11 @@ "Expression" : { "is" : "x {n Sequence} {* {x {n SLASH} {n Sequence}}}", "mode" : "value" }, "Final" : { - "is" : "x {n END} {n SEMICOLON} {n WHITESPACE}", + "is" : "x {t E} {t N} {t D} {n WHITESPACE} {n SEMICOLON} {n WHITESPACE}", "mode" : "void" }, "Grammar" : { "is" : "x {n WHITESPACE} {n Header} {* {n Definition}} {n Final} {n EOF}", "mode" : "value" @@ -160,11 +156,11 @@ "OPENB" : { "is" : "t {[}", "mode" : "void" }, "PEG" : { - "is" : "x {t P} {t E} {t G} {n WHITESPACE}", + "is" : "x {t P} {t E} {t G} {! {/ {t _} {t :} alnum}} {n WHITESPACE}", "mode" : "void" }, "PLUS" : { "is" : "x {t +} {n WHITESPACE}", "mode" : "leaf" Index: modules/pt/tests/data/ok/peg_json-ultracompact/3_peg_itself ================================================================== --- modules/pt/tests/data/ok/peg_json-ultracompact/3_peg_itself +++ modules/pt/tests/data/ok/peg_json-ultracompact/3_peg_itself @@ -1,1 +1,1 @@ -{"pt::grammar::peg":{"rules":{"ALNUM":{"is":"x {t <} {t a} {t l} {t n} {t u} {t m} {t >} {n WHITESPACE}","mode":"leaf"},"ALPHA":{"is":"x {t <} {t a} {t l} {t p} {t h} {t a} {t >} {n WHITESPACE}","mode":"leaf"},"AND":{"is":"x {t &} {n WHITESPACE}","mode":"leaf"},"APOSTROPH":{"is":"t '","mode":"void"},"ASCII":{"is":"x {t <} {t a} {t s} {t c} {t i} {t i} {t >} {n WHITESPACE}","mode":"leaf"},"Attribute":{"is":"x {/ {n VOID} {n LEAF}} {n COLON}","mode":"value"},"Char":{"is":"/ {n CharSpecial} {n CharOctalFull} {n CharOctalPart} {n CharUnicode} {n CharUnescaped}","mode":"value"},"CharOctalFull":{"is":"x {t \\\\} {.. 0 2} {.. 0 7} {.. 0 7}","mode":"leaf"},"CharOctalPart":{"is":"x {t \\\\} {.. 0 7} {? {.. 0 7}}","mode":"leaf"},"CharSpecial":{"is":"x {t \\\\} {/ {t n} {t r} {t t} {t '} {t {\"}} {t {[}} {t \\]} {t \\\\}}","mode":"leaf"},"CharUnescaped":{"is":"x {! {t \\\\}} dot","mode":"leaf"},"CharUnicode":{"is":"x {t \\\\} {t u} xdigit {? {x xdigit {? {x xdigit {? xdigit}}}}}","mode":"leaf"},"Class":{"is":"x {n OPENB} {* {x {! {n CLOSEB}} {n Range}}} {n CLOSEB} {n WHITESPACE}","mode":"value"},"CLOSE":{"is":"x {t )} {n WHITESPACE}","mode":"void"},"CLOSEB":{"is":"t \\]","mode":"void"},"COLON":{"is":"x {t :} {n WHITESPACE}","mode":"void"},"COMMENT":{"is":"x {t #} {* {x {! {n EOL}} dot}} {n EOL}","mode":"void"},"CONTROL":{"is":"x {t <} {t c} {t o} {t n} {t t} {t r} {t o} {t l} {t >} {n WHITESPACE}","mode":"leaf"},"DAPOSTROPH":{"is":"t {\"}","mode":"void"},"DDIGIT":{"is":"x {t <} {t d} {t d} {t i} {t g} {t i} {t t} {t >} {n WHITESPACE}","mode":"leaf"},"Definition":{"is":"x {? {n Attribute}} {n Identifier} {n IS} {n Expression} {n SEMICOLON}","mode":"value"},"DIGIT":{"is":"x {t <} {t d} {t i} {t g} {t i} {t t} {t >} {n WHITESPACE}","mode":"leaf"},"DOT":{"is":"x {t .} {n WHITESPACE}","mode":"leaf"},"END":{"is":"x {t E} {t N} {t D} {n WHITESPACE}","mode":"void"},"EOF":{"is":"! dot","mode":"void"},"EOL":{"is":"/ {t {\n}} {t {\r}}","mode":"void"},"Expression":{"is":"x {n Sequence} {* {x {n SLASH} {n Sequence}}}","mode":"value"},"Final":{"is":"x {n END} {n SEMICOLON} {n WHITESPACE}","mode":"void"},"Grammar":{"is":"x {n WHITESPACE} {n Header} {* {n Definition}} {n Final} {n EOF}","mode":"value"},"GRAPH":{"is":"x {t <} {t g} {t r} {t a} {t p} {t h} {t >} {n WHITESPACE}","mode":"leaf"},"Header":{"is":"x {n PEG} {n Identifier} {n StartExpr}","mode":"value"},"Ident":{"is":"x {/ {t _} {t :} alpha} {* {/ {t _} {t :} alnum}}","mode":"leaf"},"Identifier":{"is":"x {n Ident} {n WHITESPACE}","mode":"value"},"IS":{"is":"x {t <} {t -} {n WHITESPACE}","mode":"void"},"LEAF":{"is":"x {t l} {t e} {t a} {t f} {n WHITESPACE}","mode":"leaf"},"Literal":{"is":"/ {x {n APOSTROPH} {* {x {! {n APOSTROPH}} {n Char}}} {n APOSTROPH} {n WHITESPACE}} {x {n DAPOSTROPH} {* {x {! {n DAPOSTROPH}} {n Char}}} {n DAPOSTROPH} {n WHITESPACE}}","mode":"value"},"LOWER":{"is":"x {t <} {t l} {t o} {t w} {t e} {t r} {t >} {n WHITESPACE}","mode":"leaf"},"NOT":{"is":"x {t !} {n WHITESPACE}","mode":"leaf"},"OPEN":{"is":"x {t (} {n WHITESPACE}","mode":"void"},"OPENB":{"is":"t {[}","mode":"void"},"PEG":{"is":"x {t P} {t E} {t G} {n WHITESPACE}","mode":"void"},"PLUS":{"is":"x {t +} {n WHITESPACE}","mode":"leaf"},"Prefix":{"is":"x {? {/ {n AND} {n NOT}}} {n Suffix}","mode":"value"},"Primary":{"is":"/ {n ALNUM} {n ALPHA} {n ASCII} {n CONTROL} {n DDIGIT} {n DIGIT} {n GRAPH} {n LOWER} {n PRINTABLE} {n PUNCT} {n SPACE} {n UPPER} {n WORDCHAR} {n XDIGIT} {n Identifier} {x {n OPEN} {n Expression} {n CLOSE}} {n Literal} {n Class} {n DOT}","mode":"value"},"PRINTABLE":{"is":"x {t <} {t p} {t r} {t i} {t n} {t t} {t >} {n WHITESPACE}","mode":"leaf"},"PUNCT":{"is":"x {t <} {t p} {t u} {t n} {t c} {t t} {t >} {n WHITESPACE}","mode":"leaf"},"QUESTION":{"is":"x {t ?} {n WHITESPACE}","mode":"leaf"},"Range":{"is":"/ {x {n Char} {n TO} {n Char}} {n Char}","mode":"value"},"SEMICOLON":{"is":"x {t {;}} {n WHITESPACE}","mode":"void"},"Sequence":{"is":"+ {n Prefix}","mode":"value"},"SLASH":{"is":"x {t /} {n WHITESPACE}","mode":"void"},"SPACE":{"is":"x {t <} {t s} {t p} {t a} {t c} {t e} {t >} {n WHITESPACE}","mode":"leaf"},"STAR":{"is":"x {t *} {n WHITESPACE}","mode":"leaf"},"StartExpr":{"is":"x {n OPEN} {n Expression} {n CLOSE}","mode":"value"},"Suffix":{"is":"x {n Primary} {? {/ {n QUESTION} {n STAR} {n PLUS}}}","mode":"value"},"TO":{"is":"t -","mode":"void"},"UPPER":{"is":"x {t <} {t u} {t p} {t p} {t e} {t r} {t >} {n WHITESPACE}","mode":"leaf"},"VOID":{"is":"x {t v} {t o} {t i} {t d} {n WHITESPACE}","mode":"leaf"},"WHITESPACE":{"is":"* {/ space {n COMMENT}}","mode":"void"},"WORDCHAR":{"is":"x {t <} {t w} {t o} {t r} {t d} {t c} {t h} {t a} {t r} {t >} {n WHITESPACE}","mode":"leaf"},"XDIGIT":{"is":"x {t <} {t x} {t d} {t i} {t g} {t i} {t t} {t >} {n WHITESPACE}","mode":"leaf"}},"start":"n Grammar"}} +{"pt::grammar::peg":{"rules":{"ALNUM":{"is":"x {t <} {t a} {t l} {t n} {t u} {t m} {t >} {n WHITESPACE}","mode":"leaf"},"ALPHA":{"is":"x {t <} {t a} {t l} {t p} {t h} {t a} {t >} {n WHITESPACE}","mode":"leaf"},"AND":{"is":"x {t &} {n WHITESPACE}","mode":"leaf"},"APOSTROPH":{"is":"t '","mode":"void"},"ASCII":{"is":"x {t <} {t a} {t s} {t c} {t i} {t i} {t >} {n WHITESPACE}","mode":"leaf"},"Attribute":{"is":"x {/ {n VOID} {n LEAF}} {n COLON}","mode":"value"},"Char":{"is":"/ {n CharSpecial} {n CharOctalFull} {n CharOctalPart} {n CharUnicode} {n CharUnescaped}","mode":"value"},"CharOctalFull":{"is":"x {t \\\\} {.. 0 2} {.. 0 7} {.. 0 7}","mode":"leaf"},"CharOctalPart":{"is":"x {t \\\\} {.. 0 7} {? {.. 0 7}}","mode":"leaf"},"CharSpecial":{"is":"x {t \\\\} {/ {t n} {t r} {t t} {t '} {t {\"}} {t {[}} {t \\]} {t \\\\}}","mode":"leaf"},"CharUnescaped":{"is":"x {! {t \\\\}} dot","mode":"leaf"},"CharUnicode":{"is":"x {t \\\\} {t u} xdigit {? {x xdigit {? {x xdigit {? xdigit}}}}}","mode":"leaf"},"Class":{"is":"x {n OPENB} {* {x {! {n CLOSEB}} {n Range}}} {n CLOSEB} {n WHITESPACE}","mode":"value"},"CLOSE":{"is":"x {t )} {n WHITESPACE}","mode":"void"},"CLOSEB":{"is":"t \\]","mode":"void"},"COLON":{"is":"x {t :} {n WHITESPACE}","mode":"void"},"COMMENT":{"is":"x {t #} {* {x {! {n EOL}} dot}} {n EOL}","mode":"void"},"CONTROL":{"is":"x {t <} {t c} {t o} {t n} {t t} {t r} {t o} {t l} {t >} {n WHITESPACE}","mode":"leaf"},"DAPOSTROPH":{"is":"t {\"}","mode":"void"},"DDIGIT":{"is":"x {t <} {t d} {t d} {t i} {t g} {t i} {t t} {t >} {n WHITESPACE}","mode":"leaf"},"Definition":{"is":"x {? {n Attribute}} {n Identifier} {n IS} {n Expression} {n SEMICOLON}","mode":"value"},"DIGIT":{"is":"x {t <} {t d} {t i} {t g} {t i} {t t} {t >} {n WHITESPACE}","mode":"leaf"},"DOT":{"is":"x {t .} {n WHITESPACE}","mode":"leaf"},"EOF":{"is":"! dot","mode":"void"},"EOL":{"is":"/ {t {\n}} {t {\r}}","mode":"void"},"Expression":{"is":"x {n Sequence} {* {x {n SLASH} {n Sequence}}}","mode":"value"},"Final":{"is":"x {t E} {t N} {t D} {n WHITESPACE} {n SEMICOLON} {n WHITESPACE}","mode":"void"},"Grammar":{"is":"x {n WHITESPACE} {n Header} {* {n Definition}} {n Final} {n EOF}","mode":"value"},"GRAPH":{"is":"x {t <} {t g} {t r} {t a} {t p} {t h} {t >} {n WHITESPACE}","mode":"leaf"},"Header":{"is":"x {n PEG} {n Identifier} {n StartExpr}","mode":"value"},"Ident":{"is":"x {/ {t _} {t :} alpha} {* {/ {t _} {t :} alnum}}","mode":"leaf"},"Identifier":{"is":"x {n Ident} {n WHITESPACE}","mode":"value"},"IS":{"is":"x {t <} {t -} {n WHITESPACE}","mode":"void"},"LEAF":{"is":"x {t l} {t e} {t a} {t f} {n WHITESPACE}","mode":"leaf"},"Literal":{"is":"/ {x {n APOSTROPH} {* {x {! {n APOSTROPH}} {n Char}}} {n APOSTROPH} {n WHITESPACE}} {x {n DAPOSTROPH} {* {x {! {n DAPOSTROPH}} {n Char}}} {n DAPOSTROPH} {n WHITESPACE}}","mode":"value"},"LOWER":{"is":"x {t <} {t l} {t o} {t w} {t e} {t r} {t >} {n WHITESPACE}","mode":"leaf"},"NOT":{"is":"x {t !} {n WHITESPACE}","mode":"leaf"},"OPEN":{"is":"x {t (} {n WHITESPACE}","mode":"void"},"OPENB":{"is":"t {[}","mode":"void"},"PEG":{"is":"x {t P} {t E} {t G} {! {/ {t _} {t :} alnum}} {n WHITESPACE}","mode":"void"},"PLUS":{"is":"x {t +} {n WHITESPACE}","mode":"leaf"},"Prefix":{"is":"x {? {/ {n AND} {n NOT}}} {n Suffix}","mode":"value"},"Primary":{"is":"/ {n ALNUM} {n ALPHA} {n ASCII} {n CONTROL} {n DDIGIT} {n DIGIT} {n GRAPH} {n LOWER} {n PRINTABLE} {n PUNCT} {n SPACE} {n UPPER} {n WORDCHAR} {n XDIGIT} {n Identifier} {x {n OPEN} {n Expression} {n CLOSE}} {n Literal} {n Class} {n DOT}","mode":"value"},"PRINTABLE":{"is":"x {t <} {t p} {t r} {t i} {t n} {t t} {t >} {n WHITESPACE}","mode":"leaf"},"PUNCT":{"is":"x {t <} {t p} {t u} {t n} {t c} {t t} {t >} {n WHITESPACE}","mode":"leaf"},"QUESTION":{"is":"x {t ?} {n WHITESPACE}","mode":"leaf"},"Range":{"is":"/ {x {n Char} {n TO} {n Char}} {n Char}","mode":"value"},"SEMICOLON":{"is":"x {t {;}} {n WHITESPACE}","mode":"void"},"Sequence":{"is":"+ {n Prefix}","mode":"value"},"SLASH":{"is":"x {t /} {n WHITESPACE}","mode":"void"},"SPACE":{"is":"x {t <} {t s} {t p} {t a} {t c} {t e} {t >} {n WHITESPACE}","mode":"leaf"},"STAR":{"is":"x {t *} {n WHITESPACE}","mode":"leaf"},"StartExpr":{"is":"x {n OPEN} {n Expression} {n CLOSE}","mode":"value"},"Suffix":{"is":"x {n Primary} {? {/ {n QUESTION} {n STAR} {n PLUS}}}","mode":"value"},"TO":{"is":"t -","mode":"void"},"UPPER":{"is":"x {t <} {t u} {t p} {t p} {t e} {t r} {t >} {n WHITESPACE}","mode":"leaf"},"VOID":{"is":"x {t v} {t o} {t i} {t d} {n WHITESPACE}","mode":"leaf"},"WHITESPACE":{"is":"* {/ space {n COMMENT}}","mode":"void"},"WORDCHAR":{"is":"x {t <} {t w} {t o} {t r} {t d} {t c} {t h} {t a} {t r} {t >} {n WHITESPACE}","mode":"leaf"},"XDIGIT":{"is":"x {t <} {t x} {t d} {t i} {t g} {t i} {t t} {t >} {n WHITESPACE}","mode":"leaf"}},"start":"n Grammar"}} Index: modules/pt/tests/data/ok/peg_param-compact/3_peg_itself ================================================================== --- modules/pt/tests/data/ok/peg_param-compact/3_peg_itself +++ modules/pt/tests/data/ok/peg_param-compact/3_peg_itself @@ -748,12 +748,12 @@ return char_85: # '\' - input_next "t \\" - ok! test_char "\\" + input_next "t \" + ok! test_char "\" return range_87: # range (0 .. 2) @@ -1020,12 +1020,12 @@ return char_114: # '\"' - input_next "t \"" - ok! test_char "\"" + input_next "t "" + ok! test_char """ return char_116: # '[' @@ -2241,95 +2241,10 @@ input_next "t ." ok! test_char "." return # -# void Symbol 'END' -# - -sym_END: -# x -# 'E' -# 'N' -# 'D' -# (WHITESPACE) - - symbol_restore END - found! return - loc_push - - call sequence_289 - - value_clear - symbol_save END - error_nonterminal END - loc_pop_discard - return - -sequence_289: -# x -# 'E' -# 'N' -# 'D' -# (WHITESPACE) - - loc_push - error_clear - - error_push - - call char_282 - - error_pop_merge - fail! jump failed_290 - error_push - - call char_284 - - error_pop_merge - fail! jump failed_290 - error_push - - call char_286 - - error_pop_merge - fail! jump failed_290 - error_push - - call sym_WHITESPACE - - error_pop_merge - fail! jump failed_290 - - loc_pop_discard - return - -failed_290: - loc_pop_rewind - return - -char_282: -# 'E' - - input_next "t E" - ok! test_char "E" - return - -char_284: -# 'N' - - input_next "t N" - ok! test_char "N" - return - -char_286: -# 'D' - - input_next "t D" - ok! test_char "D" - return -# # void Symbol 'EOF' # sym_EOF: # ! @@ -2337,19 +2252,19 @@ symbol_restore EOF found! return loc_push - call notahead_294 + call notahead_283 value_clear symbol_save EOF error_nonterminal EOF loc_pop_discard return -notahead_294: +notahead_283: # ! # loc_push @@ -2369,62 +2284,62 @@ symbol_restore EOL found! return loc_push - call choice_302 + call choice_291 value_clear symbol_save EOL error_nonterminal EOL loc_pop_discard return -choice_302: +choice_291: # / # '\n' # '\r' error_clear loc_push error_push - call char_297 + call char_286 error_pop_merge - ok! jump oknoast_301 + ok! jump oknoast_290 loc_pop_rewind loc_push error_push - call char_299 + call char_288 error_pop_merge - ok! jump oknoast_301 + ok! jump oknoast_290 loc_pop_rewind status_fail return -oknoast_301: +oknoast_290: loc_pop_discard return -char_297: +char_286: # '\n' - input_next "t \\n" - ok! test_char "\\n" + input_next "t " + ok! test_char "" return -char_299: +char_288: # '\r' - input_next "t \\r" - ok! test_char "\\r" + input_next "t " + ok! test_char "" return # # value Symbol 'Expression' # @@ -2435,28 +2350,28 @@ # x # (SLASH) # (Sequence) symbol_restore Expression - found! jump found_318 + found! jump found_307 loc_push ast_push - call sequence_315 + call sequence_304 fail! value_clear ok! value_reduce Expression symbol_save Expression error_nonterminal Expression ast_pop_rewind loc_pop_discard -found_318: +found_307: ok! ast_value_push return -sequence_315: +sequence_304: # x # (Sequence) # * # x # (SLASH) @@ -2469,49 +2384,49 @@ error_push call sym_Sequence error_pop_merge - fail! jump failed_316 + fail! jump failed_305 error_push - call kleene_312 + call kleene_301 error_pop_merge - fail! jump failed_316 + fail! jump failed_305 ast_pop_discard loc_pop_discard return -failed_316: +failed_305: ast_pop_rewind loc_pop_rewind return -kleene_312: +kleene_301: # * # x # (SLASH) # (Sequence) loc_push error_push - call sequence_308 + call sequence_297 error_pop_merge - fail! jump failed_313 + fail! jump failed_302 loc_pop_discard - jump kleene_312 + jump kleene_301 -failed_313: +failed_302: loc_pop_rewind status_ok return -sequence_308: +sequence_297: # x # (SLASH) # (Sequence) loc_push @@ -2520,85 +2435,130 @@ error_push call sym_SLASH error_pop_merge - fail! jump failednoast_310 + fail! jump failednoast_299 ast_push error_push call sym_Sequence error_pop_merge - fail! jump failed_309 + fail! jump failed_298 ast_pop_discard loc_pop_discard return -failed_309: +failed_298: ast_pop_rewind -failednoast_310: +failednoast_299: loc_pop_rewind return # # void Symbol 'Final' # sym_Final: # x -# (END) +# 'E' +# 'N' +# 'D' +# (WHITESPACE) # (SEMICOLON) # (WHITESPACE) symbol_restore Final found! return loc_push - call sequence_323 + call sequence_318 value_clear symbol_save Final error_nonterminal Final loc_pop_discard return -sequence_323: +sequence_318: # x -# (END) +# 'E' +# 'N' +# 'D' +# (WHITESPACE) # (SEMICOLON) # (WHITESPACE) loc_push error_clear error_push - call sym_END + call char_309 error_pop_merge - fail! jump failed_324 + fail! jump failed_319 + error_push + + call char_311 + + error_pop_merge + fail! jump failed_319 + error_push + + call char_313 + + error_pop_merge + fail! jump failed_319 + error_push + + call sym_WHITESPACE + + error_pop_merge + fail! jump failed_319 error_push call sym_SEMICOLON error_pop_merge - fail! jump failed_324 + fail! jump failed_319 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_324 + fail! jump failed_319 loc_pop_discard return -failed_324: +failed_319: loc_pop_rewind return + +char_309: +# 'E' + + input_next "t E" + ok! test_char "E" + return + +char_311: +# 'N' + + input_next "t N" + ok! test_char "N" + return + +char_313: +# 'D' + + input_next "t D" + ok! test_char "D" + return # # value Symbol 'Grammar' # sym_Grammar: @@ -2609,28 +2569,28 @@ # (Definition) # (Final) # (EOF) symbol_restore Grammar - found! jump found_339 + found! jump found_334 loc_push ast_push - call sequence_335 + call sequence_330 fail! value_clear ok! value_reduce Grammar symbol_save Grammar error_nonterminal Grammar ast_pop_rewind loc_pop_discard -found_339: +found_334: ok! ast_value_push return -sequence_335: +sequence_330: # x # (WHITESPACE) # (Header) # * # (Definition) @@ -2643,63 +2603,63 @@ error_push call sym_WHITESPACE error_pop_merge - fail! jump failednoast_337 + fail! jump failednoast_332 ast_push error_push call sym_Header error_pop_merge - fail! jump failed_336 + fail! jump failed_331 error_push - call kleene_330 + call kleene_325 error_pop_merge - fail! jump failed_336 + fail! jump failed_331 error_push call sym_Final error_pop_merge - fail! jump failed_336 + fail! jump failed_331 error_push call sym_EOF error_pop_merge - fail! jump failed_336 + fail! jump failed_331 ast_pop_discard loc_pop_discard return -failed_336: +failed_331: ast_pop_rewind -failednoast_337: +failednoast_332: loc_pop_rewind return -kleene_330: +kleene_325: # * # (Definition) loc_push error_push call sym_Definition error_pop_merge - fail! jump failed_331 + fail! jump failed_326 loc_pop_discard - jump kleene_330 + jump kleene_325 -failed_331: +failed_326: loc_pop_rewind status_ok return # # leaf Symbol 'GRAPH' @@ -2715,26 +2675,26 @@ # 'h' # '>' # (WHITESPACE) symbol_restore GRAPH - found! jump found_352 + found! jump found_347 loc_push - call sequence_349 + call sequence_344 fail! value_clear ok! value_leaf GRAPH symbol_save GRAPH error_nonterminal GRAPH loc_pop_discard -found_352: +found_347: ok! ast_value_push return -sequence_349: +sequence_344: # x # '<' # 'g' # 'r' # 'a' @@ -2749,58 +2709,58 @@ error_push call char_2 error_pop_merge - fail! jump failed_350 + fail! jump failed_345 error_push call char_238 error_pop_merge - fail! jump failed_350 + fail! jump failed_345 error_push call char_109 error_pop_merge - fail! jump failed_350 + fail! jump failed_345 error_push call char_4 error_pop_merge - fail! jump failed_350 + fail! jump failed_345 error_push call char_25 error_pop_merge - fail! jump failed_350 + fail! jump failed_345 error_push call char_27 error_pop_merge - fail! jump failed_350 + fail! jump failed_345 error_push call char_14 error_pop_merge - fail! jump failed_350 + fail! jump failed_345 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_350 + fail! jump failed_345 loc_pop_discard return -failed_350: +failed_345: loc_pop_rewind return # # value Symbol 'Header' # @@ -2810,28 +2770,28 @@ # (PEG) # (Identifier) # (StartExpr) symbol_restore Header - found! jump found_361 + found! jump found_356 loc_push ast_push - call sequence_357 + call sequence_352 fail! value_clear ok! value_reduce Header symbol_save Header error_nonterminal Header ast_pop_rewind loc_pop_discard -found_361: +found_356: ok! ast_value_push return -sequence_357: +sequence_352: # x # (PEG) # (Identifier) # (StartExpr) @@ -2841,33 +2801,33 @@ error_push call sym_PEG error_pop_merge - fail! jump failednoast_359 + fail! jump failednoast_354 ast_push error_push call sym_Identifier error_pop_merge - fail! jump failed_358 + fail! jump failed_353 error_push call sym_StartExpr error_pop_merge - fail! jump failed_358 + fail! jump failed_353 ast_pop_discard loc_pop_discard return -failed_358: +failed_353: ast_pop_rewind -failednoast_359: +failednoast_354: loc_pop_rewind return # # leaf Symbol 'Ident' # @@ -2883,26 +2843,26 @@ # '_' # ':' # symbol_restore Ident - found! jump found_384 + found! jump found_379 loc_push - call sequence_381 + call sequence_376 fail! value_clear ok! value_leaf Ident symbol_save Ident error_nonterminal Ident loc_pop_discard -found_384: +found_379: ok! ast_value_push return -sequence_381: +sequence_376: # x # / # '_' # ':' # @@ -2915,29 +2875,29 @@ loc_push error_clear error_push - call choice_369 + call choice_364 error_pop_merge - fail! jump failed_382 + fail! jump failed_377 error_push - call kleene_378 + call kleene_373 error_pop_merge - fail! jump failed_382 + fail! jump failed_377 loc_pop_discard return -failed_382: +failed_377: loc_pop_rewind return -choice_369: +choice_364: # / # '_' # ':' # @@ -2944,78 +2904,78 @@ error_clear loc_push error_push - call char_363 + call char_358 error_pop_merge - ok! jump oknoast_368 + ok! jump oknoast_363 loc_pop_rewind loc_push error_push call char_191 error_pop_merge - ok! jump oknoast_368 + ok! jump oknoast_363 loc_pop_rewind loc_push error_push - call alpha_366 + call alpha_361 error_pop_merge - ok! jump oknoast_368 + ok! jump oknoast_363 loc_pop_rewind status_fail return -oknoast_368: +oknoast_363: loc_pop_discard return -char_363: +char_358: # '_' input_next "t _" ok! test_char "_" return -alpha_366: +alpha_361: # input_next "alpha" ok! test_alpha return -kleene_378: +kleene_373: # * # / # '_' # ':' # loc_push error_push - call choice_376 + call choice_371 error_pop_merge - fail! jump failed_379 + fail! jump failed_374 loc_pop_discard - jump kleene_378 + jump kleene_373 -failed_379: +failed_374: loc_pop_rewind status_ok return -choice_376: +choice_371: # / # '_' # ':' # @@ -3022,42 +2982,42 @@ error_clear loc_push error_push - call char_363 + call char_358 error_pop_merge - ok! jump oknoast_375 + ok! jump oknoast_370 loc_pop_rewind loc_push error_push call char_191 error_pop_merge - ok! jump oknoast_375 + ok! jump oknoast_370 loc_pop_rewind loc_push error_push - call alnum_373 + call alnum_368 error_pop_merge - ok! jump oknoast_375 + ok! jump oknoast_370 loc_pop_rewind status_fail return -oknoast_375: +oknoast_370: loc_pop_discard return -alnum_373: +alnum_368: # input_next "alnum" ok! test_alnum return @@ -3069,28 +3029,28 @@ # x # (Ident) # (WHITESPACE) symbol_restore Identifier - found! jump found_391 + found! jump found_386 loc_push ast_push - call sequence_388 + call sequence_383 fail! value_clear ok! value_reduce Identifier symbol_save Identifier error_nonterminal Identifier ast_pop_rewind loc_pop_discard -found_391: +found_386: ok! ast_value_push return -sequence_388: +sequence_383: # x # (Ident) # (WHITESPACE) ast_push @@ -3100,23 +3060,23 @@ error_push call sym_Ident error_pop_merge - fail! jump failed_389 + fail! jump failed_384 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_389 + fail! jump failed_384 ast_pop_discard loc_pop_discard return -failed_389: +failed_384: ast_pop_rewind loc_pop_rewind return # # void Symbol 'IS' @@ -3130,19 +3090,19 @@ symbol_restore IS found! return loc_push - call sequence_397 + call sequence_392 value_clear symbol_save IS error_nonterminal IS loc_pop_discard return -sequence_397: +sequence_392: # x # '<' # '-' # (WHITESPACE) @@ -3152,32 +3112,32 @@ error_push call char_2 error_pop_merge - fail! jump failed_398 + fail! jump failed_393 error_push - call char_394 + call char_389 error_pop_merge - fail! jump failed_398 + fail! jump failed_393 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_398 + fail! jump failed_393 loc_pop_discard return -failed_398: +failed_393: loc_pop_rewind return -char_394: +char_389: # '-' input_next "t -" ok! test_char "-" return @@ -3192,26 +3152,26 @@ # 'a' # 'f' # (WHITESPACE) symbol_restore LEAF - found! jump found_411 + found! jump found_406 loc_push - call sequence_408 + call sequence_403 fail! value_clear ok! value_leaf LEAF symbol_save LEAF error_nonterminal LEAF loc_pop_discard -found_411: +found_406: ok! ast_value_push return -sequence_408: +sequence_403: # x # 'l' # 'e' # 'a' # 'f' @@ -3223,51 +3183,51 @@ error_push call char_6 error_pop_merge - fail! jump failed_409 + fail! jump failed_404 error_push - call char_402 + call char_397 error_pop_merge - fail! jump failed_409 + fail! jump failed_404 error_push call char_4 error_pop_merge - fail! jump failed_409 + fail! jump failed_404 error_push - call char_405 + call char_400 error_pop_merge - fail! jump failed_409 + fail! jump failed_404 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_409 + fail! jump failed_404 loc_pop_discard return -failed_409: +failed_404: loc_pop_rewind return -char_402: +char_397: # 'e' input_next "t e" ok! test_char "e" return -char_405: +char_400: # 'f' input_next "t f" ok! test_char "f" return @@ -3295,28 +3255,28 @@ # (Char) # (DAPOSTROPH) # (WHITESPACE) symbol_restore Literal - found! jump found_452 + found! jump found_447 loc_push ast_push - call choice_450 + call choice_445 fail! value_clear ok! value_reduce Literal symbol_save Literal error_nonterminal Literal ast_pop_rewind loc_pop_discard -found_452: +found_447: ok! ast_value_push return -choice_450: +choice_445: # / # x # (APOSTROPH) # * # x @@ -3339,37 +3299,37 @@ ast_push loc_push error_push - call sequence_427 + call sequence_422 error_pop_merge - ok! jump ok_449 + ok! jump ok_444 ast_pop_rewind loc_pop_rewind ast_push loc_push error_push - call sequence_445 + call sequence_440 error_pop_merge - ok! jump ok_449 + ok! jump ok_444 ast_pop_rewind loc_pop_rewind status_fail return -ok_449: +ok_444: ast_pop_discard loc_pop_discard return -sequence_427: +sequence_422: # x # (APOSTROPH) # * # x # ! @@ -3384,65 +3344,65 @@ error_push call sym_APOSTROPH error_pop_merge - fail! jump failednoast_429 + fail! jump failednoast_424 ast_push error_push - call kleene_422 + call kleene_417 error_pop_merge - fail! jump failed_428 + fail! jump failed_423 error_push call sym_APOSTROPH error_pop_merge - fail! jump failed_428 + fail! jump failed_423 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_428 + fail! jump failed_423 ast_pop_discard loc_pop_discard return -failed_428: +failed_423: ast_pop_rewind -failednoast_429: +failednoast_424: loc_pop_rewind return -kleene_422: +kleene_417: # * # x # ! # (APOSTROPH) # (Char) loc_push error_push - call sequence_418 + call sequence_413 error_pop_merge - fail! jump failed_423 + fail! jump failed_418 loc_pop_discard - jump kleene_422 + jump kleene_417 -failed_423: +failed_418: loc_pop_rewind status_ok return -sequence_418: +sequence_413: # x # ! # (APOSTROPH) # (Char) @@ -3449,34 +3409,34 @@ loc_push error_clear error_push - call notahead_415 + call notahead_410 error_pop_merge - fail! jump failednoast_420 + fail! jump failednoast_415 ast_push error_push call sym_Char error_pop_merge - fail! jump failed_419 + fail! jump failed_414 ast_pop_discard loc_pop_discard return -failed_419: +failed_414: ast_pop_rewind -failednoast_420: +failednoast_415: loc_pop_rewind return -notahead_415: +notahead_410: # ! # (APOSTROPH) loc_push @@ -3484,11 +3444,11 @@ loc_pop_rewind status_negate return -sequence_445: +sequence_440: # x # (DAPOSTROPH) # * # x # ! @@ -3503,65 +3463,65 @@ error_push call sym_DAPOSTROPH error_pop_merge - fail! jump failednoast_447 + fail! jump failednoast_442 ast_push error_push - call kleene_440 + call kleene_435 error_pop_merge - fail! jump failed_446 + fail! jump failed_441 error_push call sym_DAPOSTROPH error_pop_merge - fail! jump failed_446 + fail! jump failed_441 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_446 + fail! jump failed_441 ast_pop_discard loc_pop_discard return -failed_446: +failed_441: ast_pop_rewind -failednoast_447: +failednoast_442: loc_pop_rewind return -kleene_440: +kleene_435: # * # x # ! # (DAPOSTROPH) # (Char) loc_push error_push - call sequence_436 + call sequence_431 error_pop_merge - fail! jump failed_441 + fail! jump failed_436 loc_pop_discard - jump kleene_440 + jump kleene_435 -failed_441: +failed_436: loc_pop_rewind status_ok return -sequence_436: +sequence_431: # x # ! # (DAPOSTROPH) # (Char) @@ -3568,34 +3528,34 @@ loc_push error_clear error_push - call notahead_433 + call notahead_428 error_pop_merge - fail! jump failednoast_438 + fail! jump failednoast_433 ast_push error_push call sym_Char error_pop_merge - fail! jump failed_437 + fail! jump failed_432 ast_pop_discard loc_pop_discard return -failed_437: +failed_432: ast_pop_rewind -failednoast_438: +failednoast_433: loc_pop_rewind return -notahead_433: +notahead_428: # ! # (DAPOSTROPH) loc_push @@ -3618,26 +3578,26 @@ # 'r' # '>' # (WHITESPACE) symbol_restore LOWER - found! jump found_466 + found! jump found_461 loc_push - call sequence_463 + call sequence_458 fail! value_clear ok! value_leaf LOWER symbol_save LOWER error_nonterminal LOWER loc_pop_discard -found_466: +found_461: ok! ast_value_push return -sequence_463: +sequence_458: # x # '<' # 'l' # 'o' # 'w' @@ -3652,62 +3612,62 @@ error_push call char_2 error_pop_merge - fail! jump failed_464 + fail! jump failed_459 error_push call char_6 error_pop_merge - fail! jump failed_464 + fail! jump failed_459 error_push call char_217 error_pop_merge - fail! jump failed_464 + fail! jump failed_459 error_push - call char_457 + call char_452 error_pop_merge - fail! jump failed_464 + fail! jump failed_459 error_push - call char_402 + call char_397 error_pop_merge - fail! jump failed_464 + fail! jump failed_459 error_push call char_109 error_pop_merge - fail! jump failed_464 + fail! jump failed_459 error_push call char_14 error_pop_merge - fail! jump failed_464 + fail! jump failed_459 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_464 + fail! jump failed_459 loc_pop_discard return -failed_464: +failed_459: loc_pop_rewind return -char_457: +char_452: # 'w' input_next "t w" ok! test_char "w" return @@ -3719,54 +3679,54 @@ # x # '!' # (WHITESPACE) symbol_restore NOT - found! jump found_474 + found! jump found_469 loc_push - call sequence_471 + call sequence_466 fail! value_clear ok! value_leaf NOT symbol_save NOT error_nonterminal NOT loc_pop_discard -found_474: +found_469: ok! ast_value_push return -sequence_471: +sequence_466: # x # '!' # (WHITESPACE) loc_push error_clear error_push - call char_468 + call char_463 error_pop_merge - fail! jump failed_472 + fail! jump failed_467 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_472 + fail! jump failed_467 loc_pop_discard return -failed_472: +failed_467: loc_pop_rewind return -char_468: +char_463: # '!' input_next "t !" ok! test_char "!" return @@ -3781,47 +3741,47 @@ symbol_restore OPEN found! return loc_push - call sequence_479 + call sequence_474 value_clear symbol_save OPEN error_nonterminal OPEN loc_pop_discard return -sequence_479: +sequence_474: # x # '\(' # (WHITESPACE) loc_push error_clear error_push - call char_476 + call char_471 error_pop_merge - fail! jump failed_480 + fail! jump failed_475 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_480 + fail! jump failed_475 loc_pop_discard return -failed_480: +failed_475: loc_pop_rewind return -char_476: +char_471: # '\(' input_next "t (" ok! test_char "(" return @@ -3850,79 +3810,110 @@ sym_PEG: # x # 'P' # 'E' # 'G' +# ! +# / +# '_' +# ':' +# # (WHITESPACE) symbol_restore PEG found! return loc_push - call sequence_491 + call sequence_493 value_clear symbol_save PEG error_nonterminal PEG loc_pop_discard return -sequence_491: +sequence_493: # x # 'P' # 'E' # 'G' +# ! +# / +# '_' +# ':' +# # (WHITESPACE) loc_push error_clear error_push - call char_485 - - error_pop_merge - fail! jump failed_492 - error_push - - call char_282 - - error_pop_merge - fail! jump failed_492 - error_push - - call char_488 - - error_pop_merge - fail! jump failed_492 + call char_480 + + error_pop_merge + fail! jump failed_494 + error_push + + call char_309 + + error_pop_merge + fail! jump failed_494 + error_push + + call char_483 + + error_pop_merge + fail! jump failed_494 + error_push + + call notahead_490 + + error_pop_merge + fail! jump failed_494 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_492 + fail! jump failed_494 loc_pop_discard return -failed_492: +failed_494: loc_pop_rewind return -char_485: +char_480: # 'P' input_next "t P" ok! test_char "P" return -char_488: +char_483: # 'G' input_next "t G" ok! test_char "G" return + +notahead_490: +# ! +# / +# '_' +# ':' +# + + loc_push + + call choice_371 + + loc_pop_rewind + status_negate + return # # leaf Symbol 'PLUS' # sym_PLUS: @@ -3929,54 +3920,54 @@ # x # '+' # (WHITESPACE) symbol_restore PLUS - found! jump found_501 + found! jump found_503 loc_push - call sequence_498 + call sequence_500 fail! value_clear ok! value_leaf PLUS symbol_save PLUS error_nonterminal PLUS loc_pop_discard -found_501: +found_503: ok! ast_value_push return -sequence_498: +sequence_500: # x # '+' # (WHITESPACE) loc_push error_clear error_push - call char_495 + call char_497 error_pop_merge - fail! jump failed_499 + fail! jump failed_501 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_499 + fail! jump failed_501 loc_pop_discard return -failed_499: +failed_501: loc_pop_rewind return -char_495: +char_497: # '+' input_next "t +" ok! test_char "+" return @@ -3991,28 +3982,28 @@ # (AND) # (NOT) # (Suffix) symbol_restore Prefix - found! jump found_514 + found! jump found_516 loc_push ast_push - call sequence_511 + call sequence_513 fail! value_clear ok! value_reduce Prefix symbol_save Prefix error_nonterminal Prefix ast_pop_rewind loc_pop_discard -found_514: +found_516: ok! ast_value_push return -sequence_511: +sequence_513: # x # ? # / # (AND) # (NOT) @@ -4022,48 +4013,48 @@ loc_push error_clear error_push - call optional_508 + call optional_510 error_pop_merge - fail! jump failed_512 + fail! jump failed_514 error_push call sym_Suffix error_pop_merge - fail! jump failed_512 + fail! jump failed_514 ast_pop_discard loc_pop_discard return -failed_512: +failed_514: ast_pop_rewind loc_pop_rewind return -optional_508: +optional_510: # ? # / # (AND) # (NOT) loc_push error_push - call choice_506 + call choice_508 error_pop_merge fail! loc_pop_rewind ok! loc_pop_discard status_ok return -choice_506: +choice_508: # / # (AND) # (NOT) error_clear @@ -4073,11 +4064,11 @@ error_push call sym_AND error_pop_merge - ok! jump ok_505 + ok! jump ok_507 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4084,18 +4075,18 @@ error_push call sym_NOT error_pop_merge - ok! jump ok_505 + ok! jump ok_507 ast_pop_rewind loc_pop_rewind status_fail return -ok_505: +ok_507: ast_pop_discard loc_pop_discard return # # value Symbol 'Primary' @@ -4125,28 +4116,28 @@ # (Literal) # (Class) # (DOT) symbol_restore Primary - found! jump found_544 + found! jump found_546 loc_push ast_push - call choice_542 + call choice_544 fail! value_clear ok! value_reduce Primary symbol_save Primary error_nonterminal Primary ast_pop_rewind loc_pop_discard -found_544: +found_546: ok! ast_value_push return -choice_542: +choice_544: # / # (ALNUM) # (ALPHA) # (ASCII) # (CONTROL) @@ -4176,11 +4167,11 @@ error_push call sym_ALNUM error_pop_merge - ok! jump ok_541 + ok! jump ok_543 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4187,11 +4178,11 @@ error_push call sym_ALPHA error_pop_merge - ok! jump ok_541 + ok! jump ok_543 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4198,11 +4189,11 @@ error_push call sym_ASCII error_pop_merge - ok! jump ok_541 + ok! jump ok_543 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4209,11 +4200,11 @@ error_push call sym_CONTROL error_pop_merge - ok! jump ok_541 + ok! jump ok_543 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4220,11 +4211,11 @@ error_push call sym_DDIGIT error_pop_merge - ok! jump ok_541 + ok! jump ok_543 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4231,11 +4222,11 @@ error_push call sym_DIGIT error_pop_merge - ok! jump ok_541 + ok! jump ok_543 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4242,11 +4233,11 @@ error_push call sym_GRAPH error_pop_merge - ok! jump ok_541 + ok! jump ok_543 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4253,11 +4244,11 @@ error_push call sym_LOWER error_pop_merge - ok! jump ok_541 + ok! jump ok_543 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4264,11 +4255,11 @@ error_push call sym_PRINTABLE error_pop_merge - ok! jump ok_541 + ok! jump ok_543 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4275,11 +4266,11 @@ error_push call sym_PUNCT error_pop_merge - ok! jump ok_541 + ok! jump ok_543 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4286,11 +4277,11 @@ error_push call sym_SPACE error_pop_merge - ok! jump ok_541 + ok! jump ok_543 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4297,11 +4288,11 @@ error_push call sym_UPPER error_pop_merge - ok! jump ok_541 + ok! jump ok_543 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4308,11 +4299,11 @@ error_push call sym_WORDCHAR error_pop_merge - ok! jump ok_541 + ok! jump ok_543 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4319,11 +4310,11 @@ error_push call sym_XDIGIT error_pop_merge - ok! jump ok_541 + ok! jump ok_543 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4330,22 +4321,22 @@ error_push call sym_Identifier error_pop_merge - ok! jump ok_541 + ok! jump ok_543 ast_pop_rewind loc_pop_rewind ast_push loc_push error_push - call sequence_534 + call sequence_536 error_pop_merge - ok! jump ok_541 + ok! jump ok_543 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4352,11 +4343,11 @@ error_push call sym_Literal error_pop_merge - ok! jump ok_541 + ok! jump ok_543 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4363,11 +4354,11 @@ error_push call sym_Class error_pop_merge - ok! jump ok_541 + ok! jump ok_543 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4374,23 +4365,23 @@ error_push call sym_DOT error_pop_merge - ok! jump ok_541 + ok! jump ok_543 ast_pop_rewind loc_pop_rewind status_fail return -ok_541: +ok_543: ast_pop_discard loc_pop_discard return -sequence_534: +sequence_536: # x # (OPEN) # (Expression) # (CLOSE) @@ -4400,33 +4391,33 @@ error_push call sym_OPEN error_pop_merge - fail! jump failednoast_536 + fail! jump failednoast_538 ast_push error_push call sym_Expression error_pop_merge - fail! jump failed_535 + fail! jump failed_537 error_push call sym_CLOSE error_pop_merge - fail! jump failed_535 + fail! jump failed_537 ast_pop_discard loc_pop_discard return -failed_535: +failed_537: ast_pop_rewind -failednoast_536: +failednoast_538: loc_pop_rewind return # # leaf Symbol 'PRINTABLE' # @@ -4441,26 +4432,26 @@ # 't' # '>' # (WHITESPACE) symbol_restore PRINTABLE - found! jump found_557 + found! jump found_559 loc_push - call sequence_554 + call sequence_556 fail! value_clear ok! value_leaf PRINTABLE symbol_save PRINTABLE error_nonterminal PRINTABLE loc_pop_discard -found_557: +found_559: ok! ast_value_push return -sequence_554: +sequence_556: # x # '<' # 'p' # 'r' # 'i' @@ -4475,58 +4466,58 @@ error_push call char_2 error_pop_merge - fail! jump failed_555 + fail! jump failed_557 error_push call char_25 error_pop_merge - fail! jump failed_555 + fail! jump failed_557 error_push call char_109 error_pop_merge - fail! jump failed_555 + fail! jump failed_557 error_push call char_54 error_pop_merge - fail! jump failed_555 + fail! jump failed_557 error_push call char_8 error_pop_merge - fail! jump failed_555 + fail! jump failed_557 error_push call char_111 error_pop_merge - fail! jump failed_555 + fail! jump failed_557 error_push call char_14 error_pop_merge - fail! jump failed_555 + fail! jump failed_557 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_555 + fail! jump failed_557 loc_pop_discard return -failed_555: +failed_557: loc_pop_rewind return # # leaf Symbol 'PUNCT' # @@ -4541,26 +4532,26 @@ # 't' # '>' # (WHITESPACE) symbol_restore PUNCT - found! jump found_570 + found! jump found_572 loc_push - call sequence_567 + call sequence_569 fail! value_clear ok! value_leaf PUNCT symbol_save PUNCT error_nonterminal PUNCT loc_pop_discard -found_570: +found_572: ok! ast_value_push return -sequence_567: +sequence_569: # x # '<' # 'p' # 'u' # 'n' @@ -4575,58 +4566,58 @@ error_push call char_2 error_pop_merge - fail! jump failed_568 + fail! jump failed_570 error_push call char_25 error_pop_merge - fail! jump failed_568 + fail! jump failed_570 error_push call char_10 error_pop_merge - fail! jump failed_568 + fail! jump failed_570 error_push call char_8 error_pop_merge - fail! jump failed_568 + fail! jump failed_570 error_push call char_52 error_pop_merge - fail! jump failed_568 + fail! jump failed_570 error_push call char_111 error_pop_merge - fail! jump failed_568 + fail! jump failed_570 error_push call char_14 error_pop_merge - fail! jump failed_568 + fail! jump failed_570 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_568 + fail! jump failed_570 loc_pop_discard return -failed_568: +failed_570: loc_pop_rewind return # # leaf Symbol 'QUESTION' # @@ -4635,54 +4626,54 @@ # x # '?' # (WHITESPACE) symbol_restore QUESTION - found! jump found_578 + found! jump found_580 loc_push - call sequence_575 + call sequence_577 fail! value_clear ok! value_leaf QUESTION symbol_save QUESTION error_nonterminal QUESTION loc_pop_discard -found_578: +found_580: ok! ast_value_push return -sequence_575: +sequence_577: # x # '?' # (WHITESPACE) loc_push error_clear error_push - call char_572 + call char_574 error_pop_merge - fail! jump failed_576 + fail! jump failed_578 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_576 + fail! jump failed_578 loc_pop_discard return -failed_576: +failed_578: loc_pop_rewind return -char_572: +char_574: # '?' input_next "t ?" ok! test_char "?" return @@ -4697,28 +4688,28 @@ # (TO) # (Char) # (Char) symbol_restore Range - found! jump found_590 + found! jump found_592 loc_push ast_push - call choice_588 + call choice_590 fail! value_clear ok! value_reduce Range symbol_save Range error_nonterminal Range ast_pop_rewind loc_pop_discard -found_590: +found_592: ok! ast_value_push return -choice_588: +choice_590: # / # x # (Char) # (TO) # (Char) @@ -4728,14 +4719,14 @@ ast_push loc_push error_push - call sequence_583 + call sequence_585 error_pop_merge - ok! jump ok_587 + ok! jump ok_589 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4742,23 +4733,23 @@ error_push call sym_Char error_pop_merge - ok! jump ok_587 + ok! jump ok_589 ast_pop_rewind loc_pop_rewind status_fail return -ok_587: +ok_589: ast_pop_discard loc_pop_discard return -sequence_583: +sequence_585: # x # (Char) # (TO) # (Char) @@ -4769,29 +4760,29 @@ error_push call sym_Char error_pop_merge - fail! jump failed_584 + fail! jump failed_586 error_push call sym_TO error_pop_merge - fail! jump failed_584 + fail! jump failed_586 error_push call sym_Char error_pop_merge - fail! jump failed_584 + fail! jump failed_586 ast_pop_discard loc_pop_discard return -failed_584: +failed_586: ast_pop_rewind loc_pop_rewind return # # void Symbol 'SEMICOLON' @@ -4804,47 +4795,47 @@ symbol_restore SEMICOLON found! return loc_push - call sequence_595 + call sequence_597 value_clear symbol_save SEMICOLON error_nonterminal SEMICOLON loc_pop_discard return -sequence_595: +sequence_597: # x # ';' # (WHITESPACE) loc_push error_clear error_push - call char_592 + call char_594 error_pop_merge - fail! jump failed_596 + fail! jump failed_598 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_596 + fail! jump failed_598 loc_pop_discard return -failed_596: +failed_598: loc_pop_rewind return -char_592: +char_594: # ';' input_next "t ;" ok! test_char ";" return @@ -4855,49 +4846,49 @@ sym_Sequence: # + # (Prefix) symbol_restore Sequence - found! jump found_604 + found! jump found_606 loc_push ast_push - call poskleene_600 + call poskleene_602 fail! value_clear ok! value_reduce Sequence symbol_save Sequence error_nonterminal Sequence ast_pop_rewind loc_pop_discard -found_604: +found_606: ok! ast_value_push return -poskleene_600: +poskleene_602: # + # (Prefix) loc_push call sym_Prefix - fail! jump failed_601 + fail! jump failed_603 -loop_602: +loop_604: loc_pop_discard loc_push error_push call sym_Prefix error_pop_merge - ok! jump loop_602 + ok! jump loop_604 status_ok -failed_601: +failed_603: loc_pop_rewind return # # void Symbol 'SLASH' # @@ -4909,47 +4900,47 @@ symbol_restore SLASH found! return loc_push - call sequence_609 + call sequence_611 value_clear symbol_save SLASH error_nonterminal SLASH loc_pop_discard return -sequence_609: +sequence_611: # x # '/' # (WHITESPACE) loc_push error_clear error_push - call char_606 + call char_608 error_pop_merge - fail! jump failed_610 + fail! jump failed_612 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_610 + fail! jump failed_612 loc_pop_discard return -failed_610: +failed_612: loc_pop_rewind return -char_606: +char_608: # '/' input_next "t /" ok! test_char "/" return @@ -4967,26 +4958,26 @@ # 'e' # '>' # (WHITESPACE) symbol_restore SPACE - found! jump found_624 + found! jump found_626 loc_push - call sequence_621 + call sequence_623 fail! value_clear ok! value_leaf SPACE symbol_save SPACE error_nonterminal SPACE loc_pop_discard -found_624: +found_626: ok! ast_value_push return -sequence_621: +sequence_623: # x # '<' # 's' # 'p' # 'a' @@ -5001,58 +4992,58 @@ error_push call char_2 error_pop_merge - fail! jump failed_622 + fail! jump failed_624 error_push call char_50 error_pop_merge - fail! jump failed_622 + fail! jump failed_624 error_push call char_25 error_pop_merge - fail! jump failed_622 + fail! jump failed_624 error_push call char_4 error_pop_merge - fail! jump failed_622 + fail! jump failed_624 error_push call char_52 error_pop_merge - fail! jump failed_622 + fail! jump failed_624 error_push - call char_402 + call char_397 error_pop_merge - fail! jump failed_622 + fail! jump failed_624 error_push call char_14 error_pop_merge - fail! jump failed_622 + fail! jump failed_624 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_622 + fail! jump failed_624 loc_pop_discard return -failed_622: +failed_624: loc_pop_rewind return # # leaf Symbol 'STAR' # @@ -5061,54 +5052,54 @@ # x # '*' # (WHITESPACE) symbol_restore STAR - found! jump found_632 + found! jump found_634 loc_push - call sequence_629 + call sequence_631 fail! value_clear ok! value_leaf STAR symbol_save STAR error_nonterminal STAR loc_pop_discard -found_632: +found_634: ok! ast_value_push return -sequence_629: +sequence_631: # x # '*' # (WHITESPACE) loc_push error_clear error_push - call char_626 + call char_628 error_pop_merge - fail! jump failed_630 + fail! jump failed_632 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_630 + fail! jump failed_632 loc_pop_discard return -failed_630: +failed_632: loc_pop_rewind return -char_626: +char_628: # '*' input_next "t *" ok! test_char "*" return @@ -5121,24 +5112,24 @@ # (OPEN) # (Expression) # (CLOSE) symbol_restore StartExpr - found! jump found_638 + found! jump found_640 loc_push ast_push - call sequence_534 + call sequence_536 fail! value_clear ok! value_reduce StartExpr symbol_save StartExpr error_nonterminal StartExpr ast_pop_rewind loc_pop_discard -found_638: +found_640: ok! ast_value_push return # # value Symbol 'Suffix' # @@ -5151,28 +5142,28 @@ # (QUESTION) # (STAR) # (PLUS) symbol_restore Suffix - found! jump found_652 + found! jump found_654 loc_push ast_push - call sequence_649 + call sequence_651 fail! value_clear ok! value_reduce Suffix symbol_save Suffix error_nonterminal Suffix ast_pop_rewind loc_pop_discard -found_652: +found_654: ok! ast_value_push return -sequence_649: +sequence_651: # x # (Primary) # ? # / # (QUESTION) @@ -5186,46 +5177,46 @@ error_push call sym_Primary error_pop_merge - fail! jump failed_650 + fail! jump failed_652 error_push - call optional_647 + call optional_649 error_pop_merge - fail! jump failed_650 + fail! jump failed_652 ast_pop_discard loc_pop_discard return -failed_650: +failed_652: ast_pop_rewind loc_pop_rewind return -optional_647: +optional_649: # ? # / # (QUESTION) # (STAR) # (PLUS) loc_push error_push - call choice_645 + call choice_647 error_pop_merge fail! loc_pop_rewind ok! loc_pop_discard status_ok return -choice_645: +choice_647: # / # (QUESTION) # (STAR) # (PLUS) @@ -5236,11 +5227,11 @@ error_push call sym_QUESTION error_pop_merge - ok! jump ok_644 + ok! jump ok_646 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -5247,11 +5238,11 @@ error_push call sym_STAR error_pop_merge - ok! jump ok_644 + ok! jump ok_646 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -5258,18 +5249,18 @@ error_push call sym_PLUS error_pop_merge - ok! jump ok_644 + ok! jump ok_646 ast_pop_rewind loc_pop_rewind status_fail return -ok_644: +ok_646: ast_pop_discard loc_pop_discard return # # void Symbol 'TO' @@ -5280,11 +5271,11 @@ symbol_restore TO found! return loc_push - call char_394 + call char_389 value_clear symbol_save TO error_nonterminal TO loc_pop_discard @@ -5303,26 +5294,26 @@ # 'r' # '>' # (WHITESPACE) symbol_restore UPPER - found! jump found_667 + found! jump found_669 loc_push - call sequence_664 + call sequence_666 fail! value_clear ok! value_leaf UPPER symbol_save UPPER error_nonterminal UPPER loc_pop_discard -found_667: +found_669: ok! ast_value_push return -sequence_664: +sequence_666: # x # '<' # 'u' # 'p' # 'p' @@ -5337,58 +5328,58 @@ error_push call char_2 error_pop_merge - fail! jump failed_665 + fail! jump failed_667 error_push call char_10 error_pop_merge - fail! jump failed_665 + fail! jump failed_667 error_push call char_25 error_pop_merge - fail! jump failed_665 + fail! jump failed_667 error_push call char_25 error_pop_merge - fail! jump failed_665 + fail! jump failed_667 error_push - call char_402 + call char_397 error_pop_merge - fail! jump failed_665 + fail! jump failed_667 error_push call char_109 error_pop_merge - fail! jump failed_665 + fail! jump failed_667 error_push call char_14 error_pop_merge - fail! jump failed_665 + fail! jump failed_667 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_665 + fail! jump failed_667 loc_pop_discard return -failed_665: +failed_667: loc_pop_rewind return # # leaf Symbol 'VOID' # @@ -5400,26 +5391,26 @@ # 'i' # 'd' # (WHITESPACE) symbol_restore VOID - found! jump found_678 + found! jump found_680 loc_push - call sequence_675 + call sequence_677 fail! value_clear ok! value_leaf VOID symbol_save VOID error_nonterminal VOID loc_pop_discard -found_678: +found_680: ok! ast_value_push return -sequence_675: +sequence_677: # x # 'v' # 'o' # 'i' # 'd' @@ -5428,47 +5419,47 @@ loc_push error_clear error_push - call char_669 + call char_671 error_pop_merge - fail! jump failed_676 + fail! jump failed_678 error_push call char_217 error_pop_merge - fail! jump failed_676 + fail! jump failed_678 error_push call char_54 error_pop_merge - fail! jump failed_676 + fail! jump failed_678 error_push call char_234 error_pop_merge - fail! jump failed_676 + fail! jump failed_678 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_676 + fail! jump failed_678 loc_pop_discard return -failed_676: +failed_678: loc_pop_rewind return -char_669: +char_671: # 'v' input_next "t v" ok! test_char "v" return @@ -5484,72 +5475,72 @@ symbol_restore WHITESPACE found! return loc_push - call kleene_686 + call kleene_688 value_clear symbol_save WHITESPACE error_nonterminal WHITESPACE loc_pop_discard return -kleene_686: +kleene_688: # * # / # # (COMMENT) loc_push error_push - call choice_684 + call choice_686 error_pop_merge - fail! jump failed_687 + fail! jump failed_689 loc_pop_discard - jump kleene_686 + jump kleene_688 -failed_687: +failed_689: loc_pop_rewind status_ok return -choice_684: +choice_686: # / # # (COMMENT) error_clear loc_push error_push - call space_680 + call space_682 error_pop_merge - ok! jump oknoast_683 + ok! jump oknoast_685 loc_pop_rewind loc_push error_push call sym_COMMENT error_pop_merge - ok! jump oknoast_683 + ok! jump oknoast_685 loc_pop_rewind status_fail return -oknoast_683: +oknoast_685: loc_pop_discard return -space_680: +space_682: # input_next "space" ok! test_space return @@ -5570,26 +5561,26 @@ # 'r' # '>' # (WHITESPACE) symbol_restore WORDCHAR - found! jump found_704 + found! jump found_706 loc_push - call sequence_701 + call sequence_703 fail! value_clear ok! value_leaf WORDCHAR symbol_save WORDCHAR error_nonterminal WORDCHAR loc_pop_discard -found_704: +found_706: ok! ast_value_push return -sequence_701: +sequence_703: # x # '<' # 'w' # 'o' # 'r' @@ -5607,76 +5598,76 @@ error_push call char_2 error_pop_merge - fail! jump failed_702 + fail! jump failed_704 error_push - call char_457 + call char_452 error_pop_merge - fail! jump failed_702 + fail! jump failed_704 error_push call char_217 error_pop_merge - fail! jump failed_702 + fail! jump failed_704 error_push call char_109 error_pop_merge - fail! jump failed_702 + fail! jump failed_704 error_push call char_234 error_pop_merge - fail! jump failed_702 + fail! jump failed_704 error_push call char_52 error_pop_merge - fail! jump failed_702 + fail! jump failed_704 error_push call char_27 error_pop_merge - fail! jump failed_702 + fail! jump failed_704 error_push call char_4 error_pop_merge - fail! jump failed_702 + fail! jump failed_704 error_push call char_109 error_pop_merge - fail! jump failed_702 + fail! jump failed_704 error_push call char_14 error_pop_merge - fail! jump failed_702 + fail! jump failed_704 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_702 + fail! jump failed_704 loc_pop_discard return -failed_702: +failed_704: loc_pop_rewind return # # leaf Symbol 'XDIGIT' # @@ -5692,26 +5683,26 @@ # 't' # '>' # (WHITESPACE) symbol_restore XDIGIT - found! jump found_719 + found! jump found_721 loc_push - call sequence_716 + call sequence_718 fail! value_clear ok! value_leaf XDIGIT symbol_save XDIGIT error_nonterminal XDIGIT loc_pop_discard -found_719: +found_721: ok! ast_value_push return -sequence_716: +sequence_718: # x # '<' # 'x' # 'd' # 'i' @@ -5727,71 +5718,71 @@ error_push call char_2 error_pop_merge - fail! jump failed_717 - error_push - - call char_707 - - error_pop_merge - fail! jump failed_717 - error_push - - call char_234 - - error_pop_merge - fail! jump failed_717 - error_push - - call char_54 - - error_pop_merge - fail! jump failed_717 - error_push - - call char_238 - - error_pop_merge - fail! jump failed_717 - error_push - - call char_54 - - error_pop_merge - fail! jump failed_717 - error_push - - call char_111 - - error_pop_merge - fail! jump failed_717 - error_push - - call char_14 - - error_pop_merge - fail! jump failed_717 - error_push - - call sym_WHITESPACE - - error_pop_merge - fail! jump failed_717 - - loc_pop_discard - return - -failed_717: - loc_pop_rewind - return - -char_707: + fail! jump failed_719 + error_push + + call char_709 + + error_pop_merge + fail! jump failed_719 + error_push + + call char_234 + + error_pop_merge + fail! jump failed_719 + error_push + + call char_54 + + error_pop_merge + fail! jump failed_719 + error_push + + call char_238 + + error_pop_merge + fail! jump failed_719 + error_push + + call char_54 + + error_pop_merge + fail! jump failed_719 + error_push + + call char_111 + + error_pop_merge + fail! jump failed_719 + error_push + + call char_14 + + error_pop_merge + fail! jump failed_719 + error_push + + call sym_WHITESPACE + + error_pop_merge + fail! jump failed_719 + + loc_pop_discard + return + +failed_719: + loc_pop_rewind + return + +char_709: # 'x' input_next "t x" ok! test_char "x" return # # Index: modules/pt/tests/data/ok/peg_param-inlined/3_peg_itself ================================================================== --- modules/pt/tests/data/ok/peg_param-inlined/3_peg_itself +++ modules/pt/tests/data/ok/peg_param-inlined/3_peg_itself @@ -640,12 +640,12 @@ loc_push error_clear error_push - input_next "t \\" - ok! test_char "\\" + input_next "t \" + ok! test_char "\" error_pop_merge fail! jump failed_76 error_push @@ -712,12 +712,12 @@ loc_push error_clear error_push - input_next "t \\" - ok! test_char "\\" + input_next "t \" + ok! test_char "\" error_pop_merge fail! jump failed_86 error_push @@ -804,12 +804,12 @@ loc_push error_clear error_push - input_next "t \\" - ok! test_char "\\" + input_next "t \" + ok! test_char "\" error_pop_merge fail! jump failed_103 error_push @@ -879,12 +879,12 @@ loc_pop_rewind loc_push error_push - input_next "t \"" - ok! test_char "\"" + input_next "t "" + ok! test_char """ error_pop_merge ok! jump oknoast_99 loc_pop_rewind @@ -909,12 +909,12 @@ loc_pop_rewind loc_push error_push - input_next "t \\" - ok! test_char "\\" + input_next "t \" + ok! test_char "\" error_pop_merge ok! jump oknoast_99 loc_pop_rewind @@ -983,12 +983,12 @@ # ! # '\' loc_push - input_next "t \\" - ok! test_char "\\" + input_next "t \" + ok! test_char "\" loc_pop_rewind status_negate return # @@ -1042,12 +1042,12 @@ loc_push error_clear error_push - input_next "t \\" - ok! test_char "\\" + input_next "t \" + ok! test_char "\" error_pop_merge fail! jump failed_135 error_push @@ -1724,12 +1724,12 @@ symbol_restore DAPOSTROPH found! return loc_push - input_next "t \"" - ok! test_char "\"" + input_next "t "" + ok! test_char """ value_clear symbol_save DAPOSTROPH error_nonterminal DAPOSTROPH loc_pop_discard @@ -2107,77 +2107,10 @@ failed_248: loc_pop_rewind return # -# void Symbol 'END' -# - -sym_END: -# x -# 'E' -# 'N' -# 'D' -# (WHITESPACE) - - symbol_restore END - found! return - loc_push - - call sequence_256 - - value_clear - symbol_save END - error_nonterminal END - loc_pop_discard - return - -sequence_256: -# x -# 'E' -# 'N' -# 'D' -# (WHITESPACE) - - loc_push - error_clear - - error_push - - input_next "t E" - ok! test_char "E" - - error_pop_merge - fail! jump failed_257 - error_push - - input_next "t N" - ok! test_char "N" - - error_pop_merge - fail! jump failed_257 - error_push - - input_next "t D" - ok! test_char "D" - - error_pop_merge - fail! jump failed_257 - error_push - - call sym_WHITESPACE - - error_pop_merge - fail! jump failed_257 - - loc_pop_discard - return - -failed_257: - loc_pop_rewind - return -# # void Symbol 'EOF' # sym_EOF: # ! @@ -2185,19 +2118,19 @@ symbol_restore EOF found! return loc_push - call notahead_261 + call notahead_253 value_clear symbol_save EOF error_nonterminal EOF loc_pop_discard return -notahead_261: +notahead_253: # ! # loc_push @@ -2217,49 +2150,49 @@ symbol_restore EOL found! return loc_push - call choice_267 + call choice_259 value_clear symbol_save EOL error_nonterminal EOL loc_pop_discard return -choice_267: +choice_259: # / # '\n' # '\r' error_clear loc_push error_push - input_next "t \\n" - ok! test_char "\\n" + input_next "t " + ok! test_char "" error_pop_merge - ok! jump oknoast_266 + ok! jump oknoast_258 loc_pop_rewind loc_push error_push - input_next "t \\r" - ok! test_char "\\r" + input_next "t " + ok! test_char "" error_pop_merge - ok! jump oknoast_266 + ok! jump oknoast_258 loc_pop_rewind status_fail return -oknoast_266: +oknoast_258: loc_pop_discard return # # value Symbol 'Expression' # @@ -2271,28 +2204,28 @@ # x # (SLASH) # (Sequence) symbol_restore Expression - found! jump found_283 + found! jump found_275 loc_push ast_push - call sequence_280 + call sequence_272 fail! value_clear ok! value_reduce Expression symbol_save Expression error_nonterminal Expression ast_pop_rewind loc_pop_discard -found_283: +found_275: ok! ast_value_push return -sequence_280: +sequence_272: # x # (Sequence) # * # x # (SLASH) @@ -2305,49 +2238,49 @@ error_push call sym_Sequence error_pop_merge - fail! jump failed_281 + fail! jump failed_273 error_push - call kleene_277 + call kleene_269 error_pop_merge - fail! jump failed_281 + fail! jump failed_273 ast_pop_discard loc_pop_discard return -failed_281: +failed_273: ast_pop_rewind loc_pop_rewind return -kleene_277: +kleene_269: # * # x # (SLASH) # (Sequence) loc_push error_push - call sequence_273 + call sequence_265 error_pop_merge - fail! jump failed_278 + fail! jump failed_270 loc_pop_discard - jump kleene_277 + jump kleene_269 -failed_278: +failed_270: loc_pop_rewind status_ok return -sequence_273: +sequence_265: # x # (SLASH) # (Sequence) loc_push @@ -2356,83 +2289,110 @@ error_push call sym_SLASH error_pop_merge - fail! jump failednoast_275 + fail! jump failednoast_267 ast_push error_push call sym_Sequence error_pop_merge - fail! jump failed_274 + fail! jump failed_266 ast_pop_discard loc_pop_discard return -failed_274: +failed_266: ast_pop_rewind -failednoast_275: +failednoast_267: loc_pop_rewind return # # void Symbol 'Final' # sym_Final: # x -# (END) +# 'E' +# 'N' +# 'D' +# (WHITESPACE) # (SEMICOLON) # (WHITESPACE) symbol_restore Final found! return loc_push - call sequence_288 + call sequence_283 value_clear symbol_save Final error_nonterminal Final loc_pop_discard return -sequence_288: +sequence_283: # x -# (END) +# 'E' +# 'N' +# 'D' +# (WHITESPACE) # (SEMICOLON) # (WHITESPACE) loc_push error_clear error_push - call sym_END + input_next "t E" + ok! test_char "E" error_pop_merge - fail! jump failed_289 + fail! jump failed_284 + error_push + + input_next "t N" + ok! test_char "N" + + error_pop_merge + fail! jump failed_284 + error_push + + input_next "t D" + ok! test_char "D" + + error_pop_merge + fail! jump failed_284 + error_push + + call sym_WHITESPACE + + error_pop_merge + fail! jump failed_284 error_push call sym_SEMICOLON error_pop_merge - fail! jump failed_289 + fail! jump failed_284 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_289 + fail! jump failed_284 loc_pop_discard return -failed_289: +failed_284: loc_pop_rewind return # # value Symbol 'Grammar' # @@ -2445,28 +2405,28 @@ # (Definition) # (Final) # (EOF) symbol_restore Grammar - found! jump found_304 + found! jump found_299 loc_push ast_push - call sequence_300 + call sequence_295 fail! value_clear ok! value_reduce Grammar symbol_save Grammar error_nonterminal Grammar ast_pop_rewind loc_pop_discard -found_304: +found_299: ok! ast_value_push return -sequence_300: +sequence_295: # x # (WHITESPACE) # (Header) # * # (Definition) @@ -2479,63 +2439,63 @@ error_push call sym_WHITESPACE error_pop_merge - fail! jump failednoast_302 + fail! jump failednoast_297 ast_push error_push call sym_Header error_pop_merge - fail! jump failed_301 + fail! jump failed_296 error_push - call kleene_295 + call kleene_290 error_pop_merge - fail! jump failed_301 + fail! jump failed_296 error_push call sym_Final error_pop_merge - fail! jump failed_301 + fail! jump failed_296 error_push call sym_EOF error_pop_merge - fail! jump failed_301 + fail! jump failed_296 ast_pop_discard loc_pop_discard return -failed_301: +failed_296: ast_pop_rewind -failednoast_302: +failednoast_297: loc_pop_rewind return -kleene_295: +kleene_290: # * # (Definition) loc_push error_push call sym_Definition error_pop_merge - fail! jump failed_296 + fail! jump failed_291 loc_pop_discard - jump kleene_295 + jump kleene_290 -failed_296: +failed_291: loc_pop_rewind status_ok return # # leaf Symbol 'GRAPH' @@ -2551,26 +2511,26 @@ # 'h' # '>' # (WHITESPACE) symbol_restore GRAPH - found! jump found_317 + found! jump found_312 loc_push - call sequence_314 + call sequence_309 fail! value_clear ok! value_leaf GRAPH symbol_save GRAPH error_nonterminal GRAPH loc_pop_discard -found_317: +found_312: ok! ast_value_push return -sequence_314: +sequence_309: # x # '<' # 'g' # 'r' # 'a' @@ -2586,64 +2546,64 @@ input_next "t <" ok! test_char "<" error_pop_merge - fail! jump failed_315 + fail! jump failed_310 error_push input_next "t g" ok! test_char "g" error_pop_merge - fail! jump failed_315 + fail! jump failed_310 error_push input_next "t r" ok! test_char "r" error_pop_merge - fail! jump failed_315 + fail! jump failed_310 error_push input_next "t a" ok! test_char "a" error_pop_merge - fail! jump failed_315 + fail! jump failed_310 error_push input_next "t p" ok! test_char "p" error_pop_merge - fail! jump failed_315 + fail! jump failed_310 error_push input_next "t h" ok! test_char "h" error_pop_merge - fail! jump failed_315 + fail! jump failed_310 error_push input_next "t >" ok! test_char ">" error_pop_merge - fail! jump failed_315 + fail! jump failed_310 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_315 + fail! jump failed_310 loc_pop_discard return -failed_315: +failed_310: loc_pop_rewind return # # value Symbol 'Header' # @@ -2653,28 +2613,28 @@ # (PEG) # (Identifier) # (StartExpr) symbol_restore Header - found! jump found_326 + found! jump found_321 loc_push ast_push - call sequence_322 + call sequence_317 fail! value_clear ok! value_reduce Header symbol_save Header error_nonterminal Header ast_pop_rewind loc_pop_discard -found_326: +found_321: ok! ast_value_push return -sequence_322: +sequence_317: # x # (PEG) # (Identifier) # (StartExpr) @@ -2684,33 +2644,33 @@ error_push call sym_PEG error_pop_merge - fail! jump failednoast_324 + fail! jump failednoast_319 ast_push error_push call sym_Identifier error_pop_merge - fail! jump failed_323 + fail! jump failed_318 error_push call sym_StartExpr error_pop_merge - fail! jump failed_323 + fail! jump failed_318 ast_pop_discard loc_pop_discard return -failed_323: +failed_318: ast_pop_rewind -failednoast_324: +failednoast_319: loc_pop_rewind return # # leaf Symbol 'Ident' # @@ -2726,26 +2686,26 @@ # '_' # ':' # symbol_restore Ident - found! jump found_346 + found! jump found_341 loc_push - call sequence_343 + call sequence_338 fail! value_clear ok! value_leaf Ident symbol_save Ident error_nonterminal Ident loc_pop_discard -found_346: +found_341: ok! ast_value_push return -sequence_343: +sequence_338: # x # / # '_' # ':' # @@ -2758,29 +2718,29 @@ loc_push error_clear error_push - call choice_332 + call choice_327 error_pop_merge - fail! jump failed_344 + fail! jump failed_339 error_push - call kleene_340 + call kleene_335 error_pop_merge - fail! jump failed_344 + fail! jump failed_339 loc_pop_discard return -failed_344: +failed_339: loc_pop_rewind return -choice_332: +choice_327: # / # '_' # ':' # @@ -2791,63 +2751,63 @@ input_next "t _" ok! test_char "_" error_pop_merge - ok! jump oknoast_331 + ok! jump oknoast_326 loc_pop_rewind loc_push error_push input_next "t :" ok! test_char ":" error_pop_merge - ok! jump oknoast_331 + ok! jump oknoast_326 loc_pop_rewind loc_push error_push input_next "alpha" ok! test_alpha error_pop_merge - ok! jump oknoast_331 + ok! jump oknoast_326 loc_pop_rewind status_fail return -oknoast_331: +oknoast_326: loc_pop_discard return -kleene_340: +kleene_335: # * # / # '_' # ':' # loc_push error_push - call choice_338 + call choice_333 error_pop_merge - fail! jump failed_341 + fail! jump failed_336 loc_pop_discard - jump kleene_340 + jump kleene_335 -failed_341: +failed_336: loc_pop_rewind status_ok return -choice_338: +choice_333: # / # '_' # ':' # @@ -2858,37 +2818,37 @@ input_next "t _" ok! test_char "_" error_pop_merge - ok! jump oknoast_337 + ok! jump oknoast_332 loc_pop_rewind loc_push error_push input_next "t :" ok! test_char ":" error_pop_merge - ok! jump oknoast_337 + ok! jump oknoast_332 loc_pop_rewind loc_push error_push input_next "alnum" ok! test_alnum error_pop_merge - ok! jump oknoast_337 + ok! jump oknoast_332 loc_pop_rewind status_fail return -oknoast_337: +oknoast_332: loc_pop_discard return # # value Symbol 'Identifier' # @@ -2897,28 +2857,28 @@ # x # (Ident) # (WHITESPACE) symbol_restore Identifier - found! jump found_353 + found! jump found_348 loc_push ast_push - call sequence_350 + call sequence_345 fail! value_clear ok! value_reduce Identifier symbol_save Identifier error_nonterminal Identifier ast_pop_rewind loc_pop_discard -found_353: +found_348: ok! ast_value_push return -sequence_350: +sequence_345: # x # (Ident) # (WHITESPACE) ast_push @@ -2928,23 +2888,23 @@ error_push call sym_Ident error_pop_merge - fail! jump failed_351 + fail! jump failed_346 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_351 + fail! jump failed_346 ast_pop_discard loc_pop_discard return -failed_351: +failed_346: ast_pop_rewind loc_pop_rewind return # # void Symbol 'IS' @@ -2958,19 +2918,19 @@ symbol_restore IS found! return loc_push - call sequence_358 + call sequence_353 value_clear symbol_save IS error_nonterminal IS loc_pop_discard return -sequence_358: +sequence_353: # x # '<' # '-' # (WHITESPACE) @@ -2981,29 +2941,29 @@ input_next "t <" ok! test_char "<" error_pop_merge - fail! jump failed_359 + fail! jump failed_354 error_push input_next "t -" ok! test_char "-" error_pop_merge - fail! jump failed_359 + fail! jump failed_354 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_359 + fail! jump failed_354 loc_pop_discard return -failed_359: +failed_354: loc_pop_rewind return # # leaf Symbol 'LEAF' # @@ -3015,26 +2975,26 @@ # 'a' # 'f' # (WHITESPACE) symbol_restore LEAF - found! jump found_370 + found! jump found_365 loc_push - call sequence_367 + call sequence_362 fail! value_clear ok! value_leaf LEAF symbol_save LEAF error_nonterminal LEAF loc_pop_discard -found_370: +found_365: ok! ast_value_push return -sequence_367: +sequence_362: # x # 'l' # 'e' # 'a' # 'f' @@ -3047,43 +3007,43 @@ input_next "t l" ok! test_char "l" error_pop_merge - fail! jump failed_368 + fail! jump failed_363 error_push input_next "t e" ok! test_char "e" error_pop_merge - fail! jump failed_368 + fail! jump failed_363 error_push input_next "t a" ok! test_char "a" error_pop_merge - fail! jump failed_368 + fail! jump failed_363 error_push input_next "t f" ok! test_char "f" error_pop_merge - fail! jump failed_368 + fail! jump failed_363 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_368 + fail! jump failed_363 loc_pop_discard return -failed_368: +failed_363: loc_pop_rewind return # # value Symbol 'Literal' # @@ -3108,28 +3068,28 @@ # (Char) # (DAPOSTROPH) # (WHITESPACE) symbol_restore Literal - found! jump found_411 + found! jump found_406 loc_push ast_push - call choice_409 + call choice_404 fail! value_clear ok! value_reduce Literal symbol_save Literal error_nonterminal Literal ast_pop_rewind loc_pop_discard -found_411: +found_406: ok! ast_value_push return -choice_409: +choice_404: # / # x # (APOSTROPH) # * # x @@ -3152,37 +3112,37 @@ ast_push loc_push error_push - call sequence_386 + call sequence_381 error_pop_merge - ok! jump ok_408 + ok! jump ok_403 ast_pop_rewind loc_pop_rewind ast_push loc_push error_push - call sequence_404 + call sequence_399 error_pop_merge - ok! jump ok_408 + ok! jump ok_403 ast_pop_rewind loc_pop_rewind status_fail return -ok_408: +ok_403: ast_pop_discard loc_pop_discard return -sequence_386: +sequence_381: # x # (APOSTROPH) # * # x # ! @@ -3197,65 +3157,65 @@ error_push call sym_APOSTROPH error_pop_merge - fail! jump failednoast_388 + fail! jump failednoast_383 ast_push error_push - call kleene_381 + call kleene_376 error_pop_merge - fail! jump failed_387 + fail! jump failed_382 error_push call sym_APOSTROPH error_pop_merge - fail! jump failed_387 + fail! jump failed_382 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_387 + fail! jump failed_382 ast_pop_discard loc_pop_discard return -failed_387: +failed_382: ast_pop_rewind -failednoast_388: +failednoast_383: loc_pop_rewind return -kleene_381: +kleene_376: # * # x # ! # (APOSTROPH) # (Char) loc_push error_push - call sequence_377 + call sequence_372 error_pop_merge - fail! jump failed_382 + fail! jump failed_377 loc_pop_discard - jump kleene_381 + jump kleene_376 -failed_382: +failed_377: loc_pop_rewind status_ok return -sequence_377: +sequence_372: # x # ! # (APOSTROPH) # (Char) @@ -3262,34 +3222,34 @@ loc_push error_clear error_push - call notahead_374 + call notahead_369 error_pop_merge - fail! jump failednoast_379 + fail! jump failednoast_374 ast_push error_push call sym_Char error_pop_merge - fail! jump failed_378 + fail! jump failed_373 ast_pop_discard loc_pop_discard return -failed_378: +failed_373: ast_pop_rewind -failednoast_379: +failednoast_374: loc_pop_rewind return -notahead_374: +notahead_369: # ! # (APOSTROPH) loc_push @@ -3297,11 +3257,11 @@ loc_pop_rewind status_negate return -sequence_404: +sequence_399: # x # (DAPOSTROPH) # * # x # ! @@ -3316,65 +3276,65 @@ error_push call sym_DAPOSTROPH error_pop_merge - fail! jump failednoast_406 + fail! jump failednoast_401 ast_push error_push - call kleene_399 + call kleene_394 error_pop_merge - fail! jump failed_405 + fail! jump failed_400 error_push call sym_DAPOSTROPH error_pop_merge - fail! jump failed_405 + fail! jump failed_400 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_405 + fail! jump failed_400 ast_pop_discard loc_pop_discard return -failed_405: +failed_400: ast_pop_rewind -failednoast_406: +failednoast_401: loc_pop_rewind return -kleene_399: +kleene_394: # * # x # ! # (DAPOSTROPH) # (Char) loc_push error_push - call sequence_395 + call sequence_390 error_pop_merge - fail! jump failed_400 + fail! jump failed_395 loc_pop_discard - jump kleene_399 + jump kleene_394 -failed_400: +failed_395: loc_pop_rewind status_ok return -sequence_395: +sequence_390: # x # ! # (DAPOSTROPH) # (Char) @@ -3381,34 +3341,34 @@ loc_push error_clear error_push - call notahead_392 + call notahead_387 error_pop_merge - fail! jump failednoast_397 + fail! jump failednoast_392 ast_push error_push call sym_Char error_pop_merge - fail! jump failed_396 + fail! jump failed_391 ast_pop_discard loc_pop_discard return -failed_396: +failed_391: ast_pop_rewind -failednoast_397: +failednoast_392: loc_pop_rewind return -notahead_392: +notahead_387: # ! # (DAPOSTROPH) loc_push @@ -3431,26 +3391,26 @@ # 'r' # '>' # (WHITESPACE) symbol_restore LOWER - found! jump found_424 + found! jump found_419 loc_push - call sequence_421 + call sequence_416 fail! value_clear ok! value_leaf LOWER symbol_save LOWER error_nonterminal LOWER loc_pop_discard -found_424: +found_419: ok! ast_value_push return -sequence_421: +sequence_416: # x # '<' # 'l' # 'o' # 'w' @@ -3466,64 +3426,64 @@ input_next "t <" ok! test_char "<" error_pop_merge - fail! jump failed_422 + fail! jump failed_417 error_push input_next "t l" ok! test_char "l" error_pop_merge - fail! jump failed_422 + fail! jump failed_417 error_push input_next "t o" ok! test_char "o" error_pop_merge - fail! jump failed_422 + fail! jump failed_417 error_push input_next "t w" ok! test_char "w" error_pop_merge - fail! jump failed_422 + fail! jump failed_417 error_push input_next "t e" ok! test_char "e" error_pop_merge - fail! jump failed_422 + fail! jump failed_417 error_push input_next "t r" ok! test_char "r" error_pop_merge - fail! jump failed_422 + fail! jump failed_417 error_push input_next "t >" ok! test_char ">" error_pop_merge - fail! jump failed_422 + fail! jump failed_417 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_422 + fail! jump failed_417 loc_pop_discard return -failed_422: +failed_417: loc_pop_rewind return # # leaf Symbol 'NOT' # @@ -3532,26 +3492,26 @@ # x # '!' # (WHITESPACE) symbol_restore NOT - found! jump found_431 + found! jump found_426 loc_push - call sequence_428 + call sequence_423 fail! value_clear ok! value_leaf NOT symbol_save NOT error_nonterminal NOT loc_pop_discard -found_431: +found_426: ok! ast_value_push return -sequence_428: +sequence_423: # x # '!' # (WHITESPACE) loc_push @@ -3561,22 +3521,22 @@ input_next "t !" ok! test_char "!" error_pop_merge - fail! jump failed_429 + fail! jump failed_424 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_429 + fail! jump failed_424 loc_pop_discard return -failed_429: +failed_424: loc_pop_rewind return # # void Symbol 'OPEN' # @@ -3588,19 +3548,19 @@ symbol_restore OPEN found! return loc_push - call sequence_435 + call sequence_430 value_clear symbol_save OPEN error_nonterminal OPEN loc_pop_discard return -sequence_435: +sequence_430: # x # '\(' # (WHITESPACE) loc_push @@ -3610,22 +3570,22 @@ input_next "t (" ok! test_char "(" error_pop_merge - fail! jump failed_436 + fail! jump failed_431 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_436 + fail! jump failed_431 loc_pop_discard return -failed_436: +failed_431: loc_pop_rewind return # # void Symbol 'OPENB' # @@ -3652,29 +3612,39 @@ sym_PEG: # x # 'P' # 'E' # 'G' +# ! +# / +# '_' +# ':' +# # (WHITESPACE) symbol_restore PEG found! return loc_push - call sequence_445 + call sequence_448 value_clear symbol_save PEG error_nonterminal PEG loc_pop_discard return -sequence_445: +sequence_448: # x # 'P' # 'E' # 'G' +# ! +# / +# '_' +# ':' +# # (WHITESPACE) loc_push error_clear @@ -3682,37 +3652,103 @@ input_next "t P" ok! test_char "P" error_pop_merge - fail! jump failed_446 + fail! jump failed_449 error_push input_next "t E" ok! test_char "E" error_pop_merge - fail! jump failed_446 + fail! jump failed_449 error_push input_next "t G" ok! test_char "G" error_pop_merge - fail! jump failed_446 + fail! jump failed_449 + error_push + + call notahead_445 + + error_pop_merge + fail! jump failed_449 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_446 + fail! jump failed_449 loc_pop_discard return -failed_446: +failed_449: + loc_pop_rewind + return + +notahead_445: +# ! +# / +# '_' +# ':' +# + + loc_push + + call choice_443 + + loc_pop_rewind + status_negate + return + +choice_443: +# / +# '_' +# ':' +# + + error_clear + + loc_push + error_push + + input_next "t _" + ok! test_char "_" + + error_pop_merge + ok! jump oknoast_442 + + loc_pop_rewind + loc_push + error_push + + input_next "t :" + ok! test_char ":" + + error_pop_merge + ok! jump oknoast_442 + + loc_pop_rewind + loc_push + error_push + + input_next "alnum" + ok! test_alnum + + error_pop_merge + ok! jump oknoast_442 + loc_pop_rewind + status_fail + return + +oknoast_442: + loc_pop_discard return # # leaf Symbol 'PLUS' # @@ -3720,26 +3756,26 @@ # x # '+' # (WHITESPACE) symbol_restore PLUS - found! jump found_454 + found! jump found_457 loc_push - call sequence_451 + call sequence_454 fail! value_clear ok! value_leaf PLUS symbol_save PLUS error_nonterminal PLUS loc_pop_discard -found_454: +found_457: ok! ast_value_push return -sequence_451: +sequence_454: # x # '+' # (WHITESPACE) loc_push @@ -3749,22 +3785,22 @@ input_next "t +" ok! test_char "+" error_pop_merge - fail! jump failed_452 + fail! jump failed_455 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_452 + fail! jump failed_455 loc_pop_discard return -failed_452: +failed_455: loc_pop_rewind return # # value Symbol 'Prefix' # @@ -3776,28 +3812,28 @@ # (AND) # (NOT) # (Suffix) symbol_restore Prefix - found! jump found_467 + found! jump found_470 loc_push ast_push - call sequence_464 + call sequence_467 fail! value_clear ok! value_reduce Prefix symbol_save Prefix error_nonterminal Prefix ast_pop_rewind loc_pop_discard -found_467: +found_470: ok! ast_value_push return -sequence_464: +sequence_467: # x # ? # / # (AND) # (NOT) @@ -3807,48 +3843,48 @@ loc_push error_clear error_push - call optional_461 + call optional_464 error_pop_merge - fail! jump failed_465 + fail! jump failed_468 error_push call sym_Suffix error_pop_merge - fail! jump failed_465 + fail! jump failed_468 ast_pop_discard loc_pop_discard return -failed_465: +failed_468: ast_pop_rewind loc_pop_rewind return -optional_461: +optional_464: # ? # / # (AND) # (NOT) loc_push error_push - call choice_459 + call choice_462 error_pop_merge fail! loc_pop_rewind ok! loc_pop_discard status_ok return -choice_459: +choice_462: # / # (AND) # (NOT) error_clear @@ -3858,11 +3894,11 @@ error_push call sym_AND error_pop_merge - ok! jump ok_458 + ok! jump ok_461 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -3869,18 +3905,18 @@ error_push call sym_NOT error_pop_merge - ok! jump ok_458 + ok! jump ok_461 ast_pop_rewind loc_pop_rewind status_fail return -ok_458: +ok_461: ast_pop_discard loc_pop_discard return # # value Symbol 'Primary' @@ -3910,28 +3946,28 @@ # (Literal) # (Class) # (DOT) symbol_restore Primary - found! jump found_497 + found! jump found_500 loc_push ast_push - call choice_495 + call choice_498 fail! value_clear ok! value_reduce Primary symbol_save Primary error_nonterminal Primary ast_pop_rewind loc_pop_discard -found_497: +found_500: ok! ast_value_push return -choice_495: +choice_498: # / # (ALNUM) # (ALPHA) # (ASCII) # (CONTROL) @@ -3961,11 +3997,11 @@ error_push call sym_ALNUM error_pop_merge - ok! jump ok_494 + ok! jump ok_497 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -3972,11 +4008,11 @@ error_push call sym_ALPHA error_pop_merge - ok! jump ok_494 + ok! jump ok_497 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -3983,11 +4019,11 @@ error_push call sym_ASCII error_pop_merge - ok! jump ok_494 + ok! jump ok_497 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -3994,11 +4030,11 @@ error_push call sym_CONTROL error_pop_merge - ok! jump ok_494 + ok! jump ok_497 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4005,11 +4041,11 @@ error_push call sym_DDIGIT error_pop_merge - ok! jump ok_494 + ok! jump ok_497 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4016,11 +4052,11 @@ error_push call sym_DIGIT error_pop_merge - ok! jump ok_494 + ok! jump ok_497 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4027,11 +4063,11 @@ error_push call sym_GRAPH error_pop_merge - ok! jump ok_494 + ok! jump ok_497 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4038,11 +4074,11 @@ error_push call sym_LOWER error_pop_merge - ok! jump ok_494 + ok! jump ok_497 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4049,11 +4085,11 @@ error_push call sym_PRINTABLE error_pop_merge - ok! jump ok_494 + ok! jump ok_497 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4060,11 +4096,11 @@ error_push call sym_PUNCT error_pop_merge - ok! jump ok_494 + ok! jump ok_497 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4071,11 +4107,11 @@ error_push call sym_SPACE error_pop_merge - ok! jump ok_494 + ok! jump ok_497 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4082,11 +4118,11 @@ error_push call sym_UPPER error_pop_merge - ok! jump ok_494 + ok! jump ok_497 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4093,11 +4129,11 @@ error_push call sym_WORDCHAR error_pop_merge - ok! jump ok_494 + ok! jump ok_497 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4104,11 +4140,11 @@ error_push call sym_XDIGIT error_pop_merge - ok! jump ok_494 + ok! jump ok_497 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4115,22 +4151,22 @@ error_push call sym_Identifier error_pop_merge - ok! jump ok_494 + ok! jump ok_497 ast_pop_rewind loc_pop_rewind ast_push loc_push error_push - call sequence_487 + call sequence_490 error_pop_merge - ok! jump ok_494 + ok! jump ok_497 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4137,11 +4173,11 @@ error_push call sym_Literal error_pop_merge - ok! jump ok_494 + ok! jump ok_497 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4148,11 +4184,11 @@ error_push call sym_Class error_pop_merge - ok! jump ok_494 + ok! jump ok_497 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4159,23 +4195,23 @@ error_push call sym_DOT error_pop_merge - ok! jump ok_494 + ok! jump ok_497 ast_pop_rewind loc_pop_rewind status_fail return -ok_494: +ok_497: ast_pop_discard loc_pop_discard return -sequence_487: +sequence_490: # x # (OPEN) # (Expression) # (CLOSE) @@ -4185,33 +4221,33 @@ error_push call sym_OPEN error_pop_merge - fail! jump failednoast_489 + fail! jump failednoast_492 ast_push error_push call sym_Expression error_pop_merge - fail! jump failed_488 + fail! jump failed_491 error_push call sym_CLOSE error_pop_merge - fail! jump failed_488 + fail! jump failed_491 ast_pop_discard loc_pop_discard return -failed_488: +failed_491: ast_pop_rewind -failednoast_489: +failednoast_492: loc_pop_rewind return # # leaf Symbol 'PRINTABLE' # @@ -4226,26 +4262,26 @@ # 't' # '>' # (WHITESPACE) symbol_restore PRINTABLE - found! jump found_510 + found! jump found_513 loc_push - call sequence_507 + call sequence_510 fail! value_clear ok! value_leaf PRINTABLE symbol_save PRINTABLE error_nonterminal PRINTABLE loc_pop_discard -found_510: +found_513: ok! ast_value_push return -sequence_507: +sequence_510: # x # '<' # 'p' # 'r' # 'i' @@ -4261,64 +4297,64 @@ input_next "t <" ok! test_char "<" error_pop_merge - fail! jump failed_508 + fail! jump failed_511 error_push input_next "t p" ok! test_char "p" error_pop_merge - fail! jump failed_508 + fail! jump failed_511 error_push input_next "t r" ok! test_char "r" error_pop_merge - fail! jump failed_508 + fail! jump failed_511 error_push input_next "t i" ok! test_char "i" error_pop_merge - fail! jump failed_508 + fail! jump failed_511 error_push input_next "t n" ok! test_char "n" error_pop_merge - fail! jump failed_508 + fail! jump failed_511 error_push input_next "t t" ok! test_char "t" error_pop_merge - fail! jump failed_508 + fail! jump failed_511 error_push input_next "t >" ok! test_char ">" error_pop_merge - fail! jump failed_508 + fail! jump failed_511 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_508 + fail! jump failed_511 loc_pop_discard return -failed_508: +failed_511: loc_pop_rewind return # # leaf Symbol 'PUNCT' # @@ -4333,26 +4369,26 @@ # 't' # '>' # (WHITESPACE) symbol_restore PUNCT - found! jump found_523 + found! jump found_526 loc_push - call sequence_520 + call sequence_523 fail! value_clear ok! value_leaf PUNCT symbol_save PUNCT error_nonterminal PUNCT loc_pop_discard -found_523: +found_526: ok! ast_value_push return -sequence_520: +sequence_523: # x # '<' # 'p' # 'u' # 'n' @@ -4368,64 +4404,64 @@ input_next "t <" ok! test_char "<" error_pop_merge - fail! jump failed_521 + fail! jump failed_524 error_push input_next "t p" ok! test_char "p" error_pop_merge - fail! jump failed_521 + fail! jump failed_524 error_push input_next "t u" ok! test_char "u" error_pop_merge - fail! jump failed_521 + fail! jump failed_524 error_push input_next "t n" ok! test_char "n" error_pop_merge - fail! jump failed_521 + fail! jump failed_524 error_push input_next "t c" ok! test_char "c" error_pop_merge - fail! jump failed_521 + fail! jump failed_524 error_push input_next "t t" ok! test_char "t" error_pop_merge - fail! jump failed_521 + fail! jump failed_524 error_push input_next "t >" ok! test_char ">" error_pop_merge - fail! jump failed_521 + fail! jump failed_524 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_521 + fail! jump failed_524 loc_pop_discard return -failed_521: +failed_524: loc_pop_rewind return # # leaf Symbol 'QUESTION' # @@ -4434,26 +4470,26 @@ # x # '?' # (WHITESPACE) symbol_restore QUESTION - found! jump found_530 + found! jump found_533 loc_push - call sequence_527 + call sequence_530 fail! value_clear ok! value_leaf QUESTION symbol_save QUESTION error_nonterminal QUESTION loc_pop_discard -found_530: +found_533: ok! ast_value_push return -sequence_527: +sequence_530: # x # '?' # (WHITESPACE) loc_push @@ -4463,22 +4499,22 @@ input_next "t ?" ok! test_char "?" error_pop_merge - fail! jump failed_528 + fail! jump failed_531 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_528 + fail! jump failed_531 loc_pop_discard return -failed_528: +failed_531: loc_pop_rewind return # # value Symbol 'Range' # @@ -4490,28 +4526,28 @@ # (TO) # (Char) # (Char) symbol_restore Range - found! jump found_542 + found! jump found_545 loc_push ast_push - call choice_540 + call choice_543 fail! value_clear ok! value_reduce Range symbol_save Range error_nonterminal Range ast_pop_rewind loc_pop_discard -found_542: +found_545: ok! ast_value_push return -choice_540: +choice_543: # / # x # (Char) # (TO) # (Char) @@ -4521,14 +4557,14 @@ ast_push loc_push error_push - call sequence_535 + call sequence_538 error_pop_merge - ok! jump ok_539 + ok! jump ok_542 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4535,23 +4571,23 @@ error_push call sym_Char error_pop_merge - ok! jump ok_539 + ok! jump ok_542 ast_pop_rewind loc_pop_rewind status_fail return -ok_539: +ok_542: ast_pop_discard loc_pop_discard return -sequence_535: +sequence_538: # x # (Char) # (TO) # (Char) @@ -4562,29 +4598,29 @@ error_push call sym_Char error_pop_merge - fail! jump failed_536 + fail! jump failed_539 error_push call sym_TO error_pop_merge - fail! jump failed_536 + fail! jump failed_539 error_push call sym_Char error_pop_merge - fail! jump failed_536 + fail! jump failed_539 ast_pop_discard loc_pop_discard return -failed_536: +failed_539: ast_pop_rewind loc_pop_rewind return # # void Symbol 'SEMICOLON' @@ -4597,19 +4633,19 @@ symbol_restore SEMICOLON found! return loc_push - call sequence_546 + call sequence_549 value_clear symbol_save SEMICOLON error_nonterminal SEMICOLON loc_pop_discard return -sequence_546: +sequence_549: # x # ';' # (WHITESPACE) loc_push @@ -4619,22 +4655,22 @@ input_next "t ;" ok! test_char ";" error_pop_merge - fail! jump failed_547 + fail! jump failed_550 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_547 + fail! jump failed_550 loc_pop_discard return -failed_547: +failed_550: loc_pop_rewind return # # value Symbol 'Sequence' # @@ -4642,49 +4678,49 @@ sym_Sequence: # + # (Prefix) symbol_restore Sequence - found! jump found_555 + found! jump found_558 loc_push ast_push - call poskleene_551 + call poskleene_554 fail! value_clear ok! value_reduce Sequence symbol_save Sequence error_nonterminal Sequence ast_pop_rewind loc_pop_discard -found_555: +found_558: ok! ast_value_push return -poskleene_551: +poskleene_554: # + # (Prefix) loc_push call sym_Prefix - fail! jump failed_552 + fail! jump failed_555 -loop_553: +loop_556: loc_pop_discard loc_push error_push call sym_Prefix error_pop_merge - ok! jump loop_553 + ok! jump loop_556 status_ok -failed_552: +failed_555: loc_pop_rewind return # # void Symbol 'SLASH' # @@ -4696,19 +4732,19 @@ symbol_restore SLASH found! return loc_push - call sequence_559 + call sequence_562 value_clear symbol_save SLASH error_nonterminal SLASH loc_pop_discard return -sequence_559: +sequence_562: # x # '/' # (WHITESPACE) loc_push @@ -4718,22 +4754,22 @@ input_next "t /" ok! test_char "/" error_pop_merge - fail! jump failed_560 + fail! jump failed_563 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_560 + fail! jump failed_563 loc_pop_discard return -failed_560: +failed_563: loc_pop_rewind return # # leaf Symbol 'SPACE' # @@ -4748,26 +4784,26 @@ # 'e' # '>' # (WHITESPACE) symbol_restore SPACE - found! jump found_574 + found! jump found_577 loc_push - call sequence_571 + call sequence_574 fail! value_clear ok! value_leaf SPACE symbol_save SPACE error_nonterminal SPACE loc_pop_discard -found_574: +found_577: ok! ast_value_push return -sequence_571: +sequence_574: # x # '<' # 's' # 'p' # 'a' @@ -4783,64 +4819,64 @@ input_next "t <" ok! test_char "<" error_pop_merge - fail! jump failed_572 + fail! jump failed_575 error_push input_next "t s" ok! test_char "s" error_pop_merge - fail! jump failed_572 + fail! jump failed_575 error_push input_next "t p" ok! test_char "p" error_pop_merge - fail! jump failed_572 + fail! jump failed_575 error_push input_next "t a" ok! test_char "a" error_pop_merge - fail! jump failed_572 + fail! jump failed_575 error_push input_next "t c" ok! test_char "c" error_pop_merge - fail! jump failed_572 + fail! jump failed_575 error_push input_next "t e" ok! test_char "e" error_pop_merge - fail! jump failed_572 + fail! jump failed_575 error_push input_next "t >" ok! test_char ">" error_pop_merge - fail! jump failed_572 + fail! jump failed_575 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_572 + fail! jump failed_575 loc_pop_discard return -failed_572: +failed_575: loc_pop_rewind return # # leaf Symbol 'STAR' # @@ -4849,26 +4885,26 @@ # x # '*' # (WHITESPACE) symbol_restore STAR - found! jump found_581 + found! jump found_584 loc_push - call sequence_578 + call sequence_581 fail! value_clear ok! value_leaf STAR symbol_save STAR error_nonterminal STAR loc_pop_discard -found_581: +found_584: ok! ast_value_push return -sequence_578: +sequence_581: # x # '*' # (WHITESPACE) loc_push @@ -4878,22 +4914,22 @@ input_next "t *" ok! test_char "*" error_pop_merge - fail! jump failed_579 + fail! jump failed_582 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_579 + fail! jump failed_582 loc_pop_discard return -failed_579: +failed_582: loc_pop_rewind return # # value Symbol 'StartExpr' # @@ -4903,28 +4939,28 @@ # (OPEN) # (Expression) # (CLOSE) symbol_restore StartExpr - found! jump found_590 + found! jump found_593 loc_push ast_push - call sequence_586 + call sequence_589 fail! value_clear ok! value_reduce StartExpr symbol_save StartExpr error_nonterminal StartExpr ast_pop_rewind loc_pop_discard -found_590: +found_593: ok! ast_value_push return -sequence_586: +sequence_589: # x # (OPEN) # (Expression) # (CLOSE) @@ -4934,33 +4970,33 @@ error_push call sym_OPEN error_pop_merge - fail! jump failednoast_588 + fail! jump failednoast_591 ast_push error_push call sym_Expression error_pop_merge - fail! jump failed_587 + fail! jump failed_590 error_push call sym_CLOSE error_pop_merge - fail! jump failed_587 + fail! jump failed_590 ast_pop_discard loc_pop_discard return -failed_587: +failed_590: ast_pop_rewind -failednoast_588: +failednoast_591: loc_pop_rewind return # # value Symbol 'Suffix' # @@ -4973,28 +5009,28 @@ # (QUESTION) # (STAR) # (PLUS) symbol_restore Suffix - found! jump found_604 + found! jump found_607 loc_push ast_push - call sequence_601 + call sequence_604 fail! value_clear ok! value_reduce Suffix symbol_save Suffix error_nonterminal Suffix ast_pop_rewind loc_pop_discard -found_604: +found_607: ok! ast_value_push return -sequence_601: +sequence_604: # x # (Primary) # ? # / # (QUESTION) @@ -5008,46 +5044,46 @@ error_push call sym_Primary error_pop_merge - fail! jump failed_602 + fail! jump failed_605 error_push - call optional_599 + call optional_602 error_pop_merge - fail! jump failed_602 + fail! jump failed_605 ast_pop_discard loc_pop_discard return -failed_602: +failed_605: ast_pop_rewind loc_pop_rewind return -optional_599: +optional_602: # ? # / # (QUESTION) # (STAR) # (PLUS) loc_push error_push - call choice_597 + call choice_600 error_pop_merge fail! loc_pop_rewind ok! loc_pop_discard status_ok return -choice_597: +choice_600: # / # (QUESTION) # (STAR) # (PLUS) @@ -5058,11 +5094,11 @@ error_push call sym_QUESTION error_pop_merge - ok! jump ok_596 + ok! jump ok_599 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -5069,11 +5105,11 @@ error_push call sym_STAR error_pop_merge - ok! jump ok_596 + ok! jump ok_599 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -5080,18 +5116,18 @@ error_push call sym_PLUS error_pop_merge - ok! jump ok_596 + ok! jump ok_599 ast_pop_rewind loc_pop_rewind status_fail return -ok_596: +ok_599: ast_pop_discard loc_pop_discard return # # void Symbol 'TO' @@ -5126,26 +5162,26 @@ # 'r' # '>' # (WHITESPACE) symbol_restore UPPER - found! jump found_619 + found! jump found_622 loc_push - call sequence_616 + call sequence_619 fail! value_clear ok! value_leaf UPPER symbol_save UPPER error_nonterminal UPPER loc_pop_discard -found_619: +found_622: ok! ast_value_push return -sequence_616: +sequence_619: # x # '<' # 'u' # 'p' # 'p' @@ -5161,64 +5197,64 @@ input_next "t <" ok! test_char "<" error_pop_merge - fail! jump failed_617 + fail! jump failed_620 error_push input_next "t u" ok! test_char "u" error_pop_merge - fail! jump failed_617 + fail! jump failed_620 error_push input_next "t p" ok! test_char "p" error_pop_merge - fail! jump failed_617 + fail! jump failed_620 error_push input_next "t p" ok! test_char "p" error_pop_merge - fail! jump failed_617 + fail! jump failed_620 error_push input_next "t e" ok! test_char "e" error_pop_merge - fail! jump failed_617 + fail! jump failed_620 error_push input_next "t r" ok! test_char "r" error_pop_merge - fail! jump failed_617 + fail! jump failed_620 error_push input_next "t >" ok! test_char ">" error_pop_merge - fail! jump failed_617 + fail! jump failed_620 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_617 + fail! jump failed_620 loc_pop_discard return -failed_617: +failed_620: loc_pop_rewind return # # leaf Symbol 'VOID' # @@ -5230,26 +5266,26 @@ # 'i' # 'd' # (WHITESPACE) symbol_restore VOID - found! jump found_629 + found! jump found_632 loc_push - call sequence_626 + call sequence_629 fail! value_clear ok! value_leaf VOID symbol_save VOID error_nonterminal VOID loc_pop_discard -found_629: +found_632: ok! ast_value_push return -sequence_626: +sequence_629: # x # 'v' # 'o' # 'i' # 'd' @@ -5262,43 +5298,43 @@ input_next "t v" ok! test_char "v" error_pop_merge - fail! jump failed_627 + fail! jump failed_630 error_push input_next "t o" ok! test_char "o" error_pop_merge - fail! jump failed_627 + fail! jump failed_630 error_push input_next "t i" ok! test_char "i" error_pop_merge - fail! jump failed_627 + fail! jump failed_630 error_push input_next "t d" ok! test_char "d" error_pop_merge - fail! jump failed_627 + fail! jump failed_630 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_627 + fail! jump failed_630 loc_pop_discard return -failed_627: +failed_630: loc_pop_rewind return # # void Symbol 'WHITESPACE' # @@ -5311,40 +5347,40 @@ symbol_restore WHITESPACE found! return loc_push - call kleene_636 + call kleene_639 value_clear symbol_save WHITESPACE error_nonterminal WHITESPACE loc_pop_discard return -kleene_636: +kleene_639: # * # / # # (COMMENT) loc_push error_push - call choice_634 + call choice_637 error_pop_merge - fail! jump failed_637 + fail! jump failed_640 loc_pop_discard - jump kleene_636 + jump kleene_639 -failed_637: +failed_640: loc_pop_rewind status_ok return -choice_634: +choice_637: # / # # (COMMENT) error_clear @@ -5354,26 +5390,26 @@ input_next "space" ok! test_space error_pop_merge - ok! jump oknoast_633 + ok! jump oknoast_636 loc_pop_rewind loc_push error_push call sym_COMMENT error_pop_merge - ok! jump oknoast_633 + ok! jump oknoast_636 loc_pop_rewind status_fail return -oknoast_633: +oknoast_636: loc_pop_discard return # # leaf Symbol 'WORDCHAR' # @@ -5391,26 +5427,26 @@ # 'r' # '>' # (WHITESPACE) symbol_restore WORDCHAR - found! jump found_654 + found! jump found_657 loc_push - call sequence_651 + call sequence_654 fail! value_clear ok! value_leaf WORDCHAR symbol_save WORDCHAR error_nonterminal WORDCHAR loc_pop_discard -found_654: +found_657: ok! ast_value_push return -sequence_651: +sequence_654: # x # '<' # 'w' # 'o' # 'r' @@ -5429,85 +5465,85 @@ input_next "t <" ok! test_char "<" error_pop_merge - fail! jump failed_652 + fail! jump failed_655 error_push input_next "t w" ok! test_char "w" error_pop_merge - fail! jump failed_652 + fail! jump failed_655 error_push input_next "t o" ok! test_char "o" error_pop_merge - fail! jump failed_652 + fail! jump failed_655 error_push input_next "t r" ok! test_char "r" error_pop_merge - fail! jump failed_652 + fail! jump failed_655 error_push input_next "t d" ok! test_char "d" error_pop_merge - fail! jump failed_652 + fail! jump failed_655 error_push input_next "t c" ok! test_char "c" error_pop_merge - fail! jump failed_652 + fail! jump failed_655 error_push input_next "t h" ok! test_char "h" error_pop_merge - fail! jump failed_652 + fail! jump failed_655 error_push input_next "t a" ok! test_char "a" error_pop_merge - fail! jump failed_652 + fail! jump failed_655 error_push input_next "t r" ok! test_char "r" error_pop_merge - fail! jump failed_652 + fail! jump failed_655 error_push input_next "t >" ok! test_char ">" error_pop_merge - fail! jump failed_652 + fail! jump failed_655 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_652 + fail! jump failed_655 loc_pop_discard return -failed_652: +failed_655: loc_pop_rewind return # # leaf Symbol 'XDIGIT' # @@ -5523,26 +5559,26 @@ # 't' # '>' # (WHITESPACE) symbol_restore XDIGIT - found! jump found_668 + found! jump found_671 loc_push - call sequence_665 + call sequence_668 fail! value_clear ok! value_leaf XDIGIT symbol_save XDIGIT error_nonterminal XDIGIT loc_pop_discard -found_668: +found_671: ok! ast_value_push return -sequence_665: +sequence_668: # x # '<' # 'x' # 'd' # 'i' @@ -5559,71 +5595,71 @@ input_next "t <" ok! test_char "<" error_pop_merge - fail! jump failed_666 + fail! jump failed_669 error_push input_next "t x" ok! test_char "x" error_pop_merge - fail! jump failed_666 + fail! jump failed_669 error_push input_next "t d" ok! test_char "d" error_pop_merge - fail! jump failed_666 + fail! jump failed_669 error_push input_next "t i" ok! test_char "i" error_pop_merge - fail! jump failed_666 + fail! jump failed_669 error_push input_next "t g" ok! test_char "g" error_pop_merge - fail! jump failed_666 + fail! jump failed_669 error_push input_next "t i" ok! test_char "i" error_pop_merge - fail! jump failed_666 + fail! jump failed_669 error_push input_next "t t" ok! test_char "t" error_pop_merge - fail! jump failed_666 + fail! jump failed_669 error_push input_next "t >" ok! test_char ">" error_pop_merge - fail! jump failed_666 + fail! jump failed_669 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_666 + fail! jump failed_669 loc_pop_discard return -failed_666: +failed_669: loc_pop_rewind return # # Index: modules/pt/tests/data/ok/peg_param-unopt/3_peg_itself ================================================================== --- modules/pt/tests/data/ok/peg_param-unopt/3_peg_itself +++ modules/pt/tests/data/ok/peg_param-unopt/3_peg_itself @@ -811,12 +811,12 @@ return char_94: # '\' - input_next "t \\" - ok! test_char "\\" + input_next "t \" + ok! test_char "\" return range_96: # range (0 .. 2) @@ -901,12 +901,12 @@ return char_107: # '\' - input_next "t \\" - ok! test_char "\\" + input_next "t \" + ok! test_char "\" return range_109: # range (0 .. 7) @@ -1005,12 +1005,12 @@ return char_120: # '\' - input_next "t \\" - ok! test_char "\\" + input_next "t \" + ok! test_char "\" return choice_139: # / # 'n' @@ -1132,12 +1132,12 @@ return char_130: # '\"' - input_next "t \"" - ok! test_char "\"" + input_next "t "" + ok! test_char """ return char_132: # '[' @@ -1153,12 +1153,12 @@ return char_136: # '\' - input_next "t \\" - ok! test_char "\\" + input_next "t \" + ok! test_char "\" return # # leaf Symbol 'CharUnescaped' # @@ -1226,12 +1226,12 @@ return char_146: # '\' - input_next "t \\" - ok! test_char "\\" + input_next "t \" + ok! test_char "\" return # # leaf Symbol 'CharUnicode' # @@ -1315,12 +1315,12 @@ return char_156: # '\' - input_next "t \\" - ok! test_char "\\" + input_next "t \" + ok! test_char "\" return char_158: # 'u' @@ -2089,12 +2089,12 @@ return char_263: # '\"' - input_next "t \"" - ok! test_char "\"" + input_next "t "" + ok! test_char """ return # # leaf Symbol 'DDIGIT' # @@ -2563,95 +2563,10 @@ input_next "t ." ok! test_char "." return # -# void Symbol 'END' -# - -sym_END: -# x -# 'E' -# 'N' -# 'D' -# (WHITESPACE) - - symbol_restore END - found! return - loc_push - - call sequence_335 - - value_clear - symbol_save END - error_nonterminal END - loc_pop_discard - return - -sequence_335: -# x -# 'E' -# 'N' -# 'D' -# (WHITESPACE) - - loc_push - error_clear - - error_push - - call char_328 - - error_pop_merge - fail! jump failed_336 - error_push - - call char_330 - - error_pop_merge - fail! jump failed_336 - error_push - - call char_332 - - error_pop_merge - fail! jump failed_336 - error_push - - call sym_WHITESPACE - - error_pop_merge - fail! jump failed_336 - - loc_pop_discard - return - -failed_336: - loc_pop_rewind - return - -char_328: -# 'E' - - input_next "t E" - ok! test_char "E" - return - -char_330: -# 'N' - - input_next "t N" - ok! test_char "N" - return - -char_332: -# 'D' - - input_next "t D" - ok! test_char "D" - return -# # void Symbol 'EOF' # sym_EOF: # ! @@ -2659,19 +2574,19 @@ symbol_restore EOF found! return loc_push - call notahead_340 + call notahead_329 value_clear symbol_save EOF error_nonterminal EOF loc_pop_discard return -notahead_340: +notahead_329: # ! # loc_push @@ -2691,62 +2606,62 @@ symbol_restore EOL found! return loc_push - call choice_348 + call choice_337 value_clear symbol_save EOL error_nonterminal EOL loc_pop_discard return -choice_348: +choice_337: # / # '\n' # '\r' error_clear loc_push error_push - call char_343 + call char_332 error_pop_merge - ok! jump oknoast_347 + ok! jump oknoast_336 loc_pop_rewind loc_push error_push - call char_345 + call char_334 error_pop_merge - ok! jump oknoast_347 + ok! jump oknoast_336 loc_pop_rewind status_fail return -oknoast_347: +oknoast_336: loc_pop_discard return -char_343: +char_332: # '\n' - input_next "t \\n" - ok! test_char "\\n" + input_next "t " + ok! test_char "" return -char_345: +char_334: # '\r' - input_next "t \\r" - ok! test_char "\\r" + input_next "t " + ok! test_char "" return # # value Symbol 'Expression' # @@ -2757,28 +2672,28 @@ # x # (SLASH) # (Sequence) symbol_restore Expression - found! jump found_364 + found! jump found_353 loc_push ast_push - call sequence_361 + call sequence_350 fail! value_clear ok! value_reduce Expression symbol_save Expression error_nonterminal Expression ast_pop_rewind loc_pop_discard -found_364: +found_353: ok! ast_value_push return -sequence_361: +sequence_350: # x # (Sequence) # * # x # (SLASH) @@ -2791,49 +2706,49 @@ error_push call sym_Sequence error_pop_merge - fail! jump failed_362 + fail! jump failed_351 error_push - call kleene_358 + call kleene_347 error_pop_merge - fail! jump failed_362 + fail! jump failed_351 ast_pop_discard loc_pop_discard return -failed_362: +failed_351: ast_pop_rewind loc_pop_rewind return -kleene_358: +kleene_347: # * # x # (SLASH) # (Sequence) loc_push error_push - call sequence_354 + call sequence_343 error_pop_merge - fail! jump failed_359 + fail! jump failed_348 loc_pop_discard - jump kleene_358 + jump kleene_347 -failed_359: +failed_348: loc_pop_rewind status_ok return -sequence_354: +sequence_343: # x # (SLASH) # (Sequence) loc_push @@ -2842,85 +2757,130 @@ error_push call sym_SLASH error_pop_merge - fail! jump failednoast_356 + fail! jump failednoast_345 ast_push error_push call sym_Sequence error_pop_merge - fail! jump failed_355 + fail! jump failed_344 ast_pop_discard loc_pop_discard return -failed_355: +failed_344: ast_pop_rewind -failednoast_356: +failednoast_345: loc_pop_rewind return # # void Symbol 'Final' # sym_Final: # x -# (END) +# 'E' +# 'N' +# 'D' +# (WHITESPACE) # (SEMICOLON) # (WHITESPACE) symbol_restore Final found! return loc_push - call sequence_369 + call sequence_364 value_clear symbol_save Final error_nonterminal Final loc_pop_discard return -sequence_369: +sequence_364: # x -# (END) +# 'E' +# 'N' +# 'D' +# (WHITESPACE) # (SEMICOLON) # (WHITESPACE) loc_push error_clear error_push - call sym_END + call char_355 error_pop_merge - fail! jump failed_370 + fail! jump failed_365 + error_push + + call char_357 + + error_pop_merge + fail! jump failed_365 + error_push + + call char_359 + + error_pop_merge + fail! jump failed_365 + error_push + + call sym_WHITESPACE + + error_pop_merge + fail! jump failed_365 error_push call sym_SEMICOLON error_pop_merge - fail! jump failed_370 + fail! jump failed_365 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_370 + fail! jump failed_365 loc_pop_discard return -failed_370: +failed_365: loc_pop_rewind return + +char_355: +# 'E' + + input_next "t E" + ok! test_char "E" + return + +char_357: +# 'N' + + input_next "t N" + ok! test_char "N" + return + +char_359: +# 'D' + + input_next "t D" + ok! test_char "D" + return # # value Symbol 'Grammar' # sym_Grammar: @@ -2931,28 +2891,28 @@ # (Definition) # (Final) # (EOF) symbol_restore Grammar - found! jump found_385 + found! jump found_380 loc_push ast_push - call sequence_381 + call sequence_376 fail! value_clear ok! value_reduce Grammar symbol_save Grammar error_nonterminal Grammar ast_pop_rewind loc_pop_discard -found_385: +found_380: ok! ast_value_push return -sequence_381: +sequence_376: # x # (WHITESPACE) # (Header) # * # (Definition) @@ -2965,63 +2925,63 @@ error_push call sym_WHITESPACE error_pop_merge - fail! jump failednoast_383 + fail! jump failednoast_378 ast_push error_push call sym_Header error_pop_merge - fail! jump failed_382 + fail! jump failed_377 error_push - call kleene_376 + call kleene_371 error_pop_merge - fail! jump failed_382 + fail! jump failed_377 error_push call sym_Final error_pop_merge - fail! jump failed_382 + fail! jump failed_377 error_push call sym_EOF error_pop_merge - fail! jump failed_382 + fail! jump failed_377 ast_pop_discard loc_pop_discard return -failed_382: +failed_377: ast_pop_rewind -failednoast_383: +failednoast_378: loc_pop_rewind return -kleene_376: +kleene_371: # * # (Definition) loc_push error_push call sym_Definition error_pop_merge - fail! jump failed_377 + fail! jump failed_372 loc_pop_discard - jump kleene_376 + jump kleene_371 -failed_377: +failed_372: loc_pop_rewind status_ok return # # leaf Symbol 'GRAPH' @@ -3037,26 +2997,26 @@ # 'h' # '>' # (WHITESPACE) symbol_restore GRAPH - found! jump found_405 + found! jump found_400 loc_push - call sequence_402 + call sequence_397 fail! value_clear ok! value_leaf GRAPH symbol_save GRAPH error_nonterminal GRAPH loc_pop_discard -found_405: +found_400: ok! ast_value_push return -sequence_402: +sequence_397: # x # '<' # 'g' # 'r' # 'a' @@ -3068,107 +3028,107 @@ loc_push error_clear error_push - call char_387 - - error_pop_merge - fail! jump failed_403 - error_push - - call char_389 - - error_pop_merge - fail! jump failed_403 - error_push - - call char_391 - - error_pop_merge - fail! jump failed_403 - error_push - - call char_393 - - error_pop_merge - fail! jump failed_403 - error_push - - call char_395 - - error_pop_merge - fail! jump failed_403 - error_push - - call char_397 - - error_pop_merge - fail! jump failed_403 - error_push - - call char_399 - - error_pop_merge - fail! jump failed_403 + call char_382 + + error_pop_merge + fail! jump failed_398 + error_push + + call char_384 + + error_pop_merge + fail! jump failed_398 + error_push + + call char_386 + + error_pop_merge + fail! jump failed_398 + error_push + + call char_388 + + error_pop_merge + fail! jump failed_398 + error_push + + call char_390 + + error_pop_merge + fail! jump failed_398 + error_push + + call char_392 + + error_pop_merge + fail! jump failed_398 + error_push + + call char_394 + + error_pop_merge + fail! jump failed_398 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_403 + fail! jump failed_398 loc_pop_discard return -failed_403: +failed_398: loc_pop_rewind return -char_387: +char_382: # '<' input_next "t <" ok! test_char "<" return -char_389: +char_384: # 'g' input_next "t g" ok! test_char "g" return -char_391: +char_386: # 'r' input_next "t r" ok! test_char "r" return -char_393: +char_388: # 'a' input_next "t a" ok! test_char "a" return -char_395: +char_390: # 'p' input_next "t p" ok! test_char "p" return -char_397: +char_392: # 'h' input_next "t h" ok! test_char "h" return -char_399: +char_394: # '>' input_next "t >" ok! test_char ">" return @@ -3181,28 +3141,28 @@ # (PEG) # (Identifier) # (StartExpr) symbol_restore Header - found! jump found_414 + found! jump found_409 loc_push ast_push - call sequence_410 + call sequence_405 fail! value_clear ok! value_reduce Header symbol_save Header error_nonterminal Header ast_pop_rewind loc_pop_discard -found_414: +found_409: ok! ast_value_push return -sequence_410: +sequence_405: # x # (PEG) # (Identifier) # (StartExpr) @@ -3212,33 +3172,33 @@ error_push call sym_PEG error_pop_merge - fail! jump failednoast_412 + fail! jump failednoast_407 ast_push error_push call sym_Identifier error_pop_merge - fail! jump failed_411 + fail! jump failed_406 error_push call sym_StartExpr error_pop_merge - fail! jump failed_411 + fail! jump failed_406 ast_pop_discard loc_pop_discard return -failed_411: +failed_406: ast_pop_rewind -failednoast_412: +failednoast_407: loc_pop_rewind return # # leaf Symbol 'Ident' # @@ -3254,26 +3214,26 @@ # '_' # ':' # symbol_restore Ident - found! jump found_440 + found! jump found_435 loc_push - call sequence_437 + call sequence_432 fail! value_clear ok! value_leaf Ident symbol_save Ident error_nonterminal Ident loc_pop_discard -found_440: +found_435: ok! ast_value_push return -sequence_437: +sequence_432: # x # / # '_' # ':' # @@ -3286,29 +3246,29 @@ loc_push error_clear error_push - call choice_423 + call choice_418 error_pop_merge - fail! jump failed_438 + fail! jump failed_433 error_push - call kleene_434 + call kleene_429 error_pop_merge - fail! jump failed_438 + fail! jump failed_433 loc_pop_discard return -failed_438: +failed_433: loc_pop_rewind return -choice_423: +choice_418: # / # '_' # ':' # @@ -3315,85 +3275,85 @@ error_clear loc_push error_push - call char_416 + call char_411 error_pop_merge - ok! jump oknoast_422 + ok! jump oknoast_417 loc_pop_rewind loc_push error_push - call char_418 + call char_413 error_pop_merge - ok! jump oknoast_422 + ok! jump oknoast_417 loc_pop_rewind loc_push error_push - call alpha_420 + call alpha_415 error_pop_merge - ok! jump oknoast_422 + ok! jump oknoast_417 loc_pop_rewind status_fail return -oknoast_422: +oknoast_417: loc_pop_discard return -char_416: +char_411: # '_' input_next "t _" ok! test_char "_" return -char_418: +char_413: # ':' input_next "t :" ok! test_char ":" return -alpha_420: +alpha_415: # input_next "alpha" ok! test_alpha return -kleene_434: +kleene_429: # * # / # '_' # ':' # loc_push error_push - call choice_432 + call choice_427 error_pop_merge - fail! jump failed_435 + fail! jump failed_430 loc_pop_discard - jump kleene_434 + jump kleene_429 -failed_435: +failed_430: loc_pop_rewind status_ok return -choice_432: +choice_427: # / # '_' # ':' # @@ -3400,56 +3360,56 @@ error_clear loc_push error_push - call char_425 + call char_420 error_pop_merge - ok! jump oknoast_431 + ok! jump oknoast_426 loc_pop_rewind loc_push error_push - call char_427 + call char_422 error_pop_merge - ok! jump oknoast_431 + ok! jump oknoast_426 loc_pop_rewind loc_push error_push - call alnum_429 + call alnum_424 error_pop_merge - ok! jump oknoast_431 + ok! jump oknoast_426 loc_pop_rewind status_fail return -oknoast_431: +oknoast_426: loc_pop_discard return -char_425: +char_420: # '_' input_next "t _" ok! test_char "_" return -char_427: +char_422: # ':' input_next "t :" ok! test_char ":" return -alnum_429: +alnum_424: # input_next "alnum" ok! test_alnum return @@ -3461,28 +3421,28 @@ # x # (Ident) # (WHITESPACE) symbol_restore Identifier - found! jump found_447 + found! jump found_442 loc_push ast_push - call sequence_444 + call sequence_439 fail! value_clear ok! value_reduce Identifier symbol_save Identifier error_nonterminal Identifier ast_pop_rewind loc_pop_discard -found_447: +found_442: ok! ast_value_push return -sequence_444: +sequence_439: # x # (Ident) # (WHITESPACE) ast_push @@ -3492,23 +3452,23 @@ error_push call sym_Ident error_pop_merge - fail! jump failed_445 + fail! jump failed_440 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_445 + fail! jump failed_440 ast_pop_discard loc_pop_discard return -failed_445: +failed_440: ast_pop_rewind loc_pop_rewind return # # void Symbol 'IS' @@ -3522,19 +3482,19 @@ symbol_restore IS found! return loc_push - call sequence_454 + call sequence_449 value_clear symbol_save IS error_nonterminal IS loc_pop_discard return -sequence_454: +sequence_449: # x # '<' # '-' # (WHITESPACE) @@ -3541,42 +3501,42 @@ loc_push error_clear error_push - call char_449 + call char_444 error_pop_merge - fail! jump failed_455 + fail! jump failed_450 error_push - call char_451 + call char_446 error_pop_merge - fail! jump failed_455 + fail! jump failed_450 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_455 + fail! jump failed_450 loc_pop_discard return -failed_455: +failed_450: loc_pop_rewind return -char_449: +char_444: # '<' input_next "t <" ok! test_char "<" return -char_451: +char_446: # '-' input_next "t -" ok! test_char "-" return @@ -3591,26 +3551,26 @@ # 'a' # 'f' # (WHITESPACE) symbol_restore LEAF - found! jump found_470 + found! jump found_465 loc_push - call sequence_467 + call sequence_462 fail! value_clear ok! value_leaf LEAF symbol_save LEAF error_nonterminal LEAF loc_pop_discard -found_470: +found_465: ok! ast_value_push return -sequence_467: +sequence_462: # x # 'l' # 'e' # 'a' # 'f' @@ -3619,68 +3579,68 @@ loc_push error_clear error_push - call char_458 - - error_pop_merge - fail! jump failed_468 - error_push - - call char_460 - - error_pop_merge - fail! jump failed_468 - error_push - - call char_462 - - error_pop_merge - fail! jump failed_468 - error_push - - call char_464 - - error_pop_merge - fail! jump failed_468 + call char_453 + + error_pop_merge + fail! jump failed_463 + error_push + + call char_455 + + error_pop_merge + fail! jump failed_463 + error_push + + call char_457 + + error_pop_merge + fail! jump failed_463 + error_push + + call char_459 + + error_pop_merge + fail! jump failed_463 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_468 + fail! jump failed_463 loc_pop_discard return -failed_468: +failed_463: loc_pop_rewind return -char_458: +char_453: # 'l' input_next "t l" ok! test_char "l" return -char_460: +char_455: # 'e' input_next "t e" ok! test_char "e" return -char_462: +char_457: # 'a' input_next "t a" ok! test_char "a" return -char_464: +char_459: # 'f' input_next "t f" ok! test_char "f" return @@ -3708,28 +3668,28 @@ # (Char) # (DAPOSTROPH) # (WHITESPACE) symbol_restore Literal - found! jump found_511 + found! jump found_506 loc_push ast_push - call choice_509 + call choice_504 fail! value_clear ok! value_reduce Literal symbol_save Literal error_nonterminal Literal ast_pop_rewind loc_pop_discard -found_511: +found_506: ok! ast_value_push return -choice_509: +choice_504: # / # x # (APOSTROPH) # * # x @@ -3752,37 +3712,37 @@ ast_push loc_push error_push - call sequence_486 + call sequence_481 error_pop_merge - ok! jump ok_508 + ok! jump ok_503 ast_pop_rewind loc_pop_rewind ast_push loc_push error_push - call sequence_504 + call sequence_499 error_pop_merge - ok! jump ok_508 + ok! jump ok_503 ast_pop_rewind loc_pop_rewind status_fail return -ok_508: +ok_503: ast_pop_discard loc_pop_discard return -sequence_486: +sequence_481: # x # (APOSTROPH) # * # x # ! @@ -3797,65 +3757,65 @@ error_push call sym_APOSTROPH error_pop_merge - fail! jump failednoast_488 + fail! jump failednoast_483 ast_push error_push - call kleene_481 + call kleene_476 error_pop_merge - fail! jump failed_487 + fail! jump failed_482 error_push call sym_APOSTROPH error_pop_merge - fail! jump failed_487 + fail! jump failed_482 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_487 + fail! jump failed_482 ast_pop_discard loc_pop_discard return -failed_487: +failed_482: ast_pop_rewind -failednoast_488: +failednoast_483: loc_pop_rewind return -kleene_481: +kleene_476: # * # x # ! # (APOSTROPH) # (Char) loc_push error_push - call sequence_477 + call sequence_472 error_pop_merge - fail! jump failed_482 + fail! jump failed_477 loc_pop_discard - jump kleene_481 + jump kleene_476 -failed_482: +failed_477: loc_pop_rewind status_ok return -sequence_477: +sequence_472: # x # ! # (APOSTROPH) # (Char) @@ -3862,34 +3822,34 @@ loc_push error_clear error_push - call notahead_474 + call notahead_469 error_pop_merge - fail! jump failednoast_479 + fail! jump failednoast_474 ast_push error_push call sym_Char error_pop_merge - fail! jump failed_478 + fail! jump failed_473 ast_pop_discard loc_pop_discard return -failed_478: +failed_473: ast_pop_rewind -failednoast_479: +failednoast_474: loc_pop_rewind return -notahead_474: +notahead_469: # ! # (APOSTROPH) loc_push @@ -3897,11 +3857,11 @@ loc_pop_rewind status_negate return -sequence_504: +sequence_499: # x # (DAPOSTROPH) # * # x # ! @@ -3916,65 +3876,65 @@ error_push call sym_DAPOSTROPH error_pop_merge - fail! jump failednoast_506 + fail! jump failednoast_501 ast_push error_push - call kleene_499 + call kleene_494 error_pop_merge - fail! jump failed_505 + fail! jump failed_500 error_push call sym_DAPOSTROPH error_pop_merge - fail! jump failed_505 + fail! jump failed_500 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_505 + fail! jump failed_500 ast_pop_discard loc_pop_discard return -failed_505: +failed_500: ast_pop_rewind -failednoast_506: +failednoast_501: loc_pop_rewind return -kleene_499: +kleene_494: # * # x # ! # (DAPOSTROPH) # (Char) loc_push error_push - call sequence_495 + call sequence_490 error_pop_merge - fail! jump failed_500 + fail! jump failed_495 loc_pop_discard - jump kleene_499 + jump kleene_494 -failed_500: +failed_495: loc_pop_rewind status_ok return -sequence_495: +sequence_490: # x # ! # (DAPOSTROPH) # (Char) @@ -3981,34 +3941,34 @@ loc_push error_clear error_push - call notahead_492 + call notahead_487 error_pop_merge - fail! jump failednoast_497 + fail! jump failednoast_492 ast_push error_push call sym_Char error_pop_merge - fail! jump failed_496 + fail! jump failed_491 ast_pop_discard loc_pop_discard return -failed_496: +failed_491: ast_pop_rewind -failednoast_497: +failednoast_492: loc_pop_rewind return -notahead_492: +notahead_487: # ! # (DAPOSTROPH) loc_push @@ -4031,26 +3991,26 @@ # 'r' # '>' # (WHITESPACE) symbol_restore LOWER - found! jump found_531 + found! jump found_526 loc_push - call sequence_528 + call sequence_523 fail! value_clear ok! value_leaf LOWER symbol_save LOWER error_nonterminal LOWER loc_pop_discard -found_531: +found_526: ok! ast_value_push return -sequence_528: +sequence_523: # x # '<' # 'l' # 'o' # 'w' @@ -4062,107 +4022,107 @@ loc_push error_clear error_push - call char_513 - - error_pop_merge - fail! jump failed_529 - error_push - - call char_515 - - error_pop_merge - fail! jump failed_529 - error_push - - call char_517 - - error_pop_merge - fail! jump failed_529 - error_push - - call char_519 - - error_pop_merge - fail! jump failed_529 - error_push - - call char_521 - - error_pop_merge - fail! jump failed_529 - error_push - - call char_523 - - error_pop_merge - fail! jump failed_529 - error_push - - call char_525 - - error_pop_merge - fail! jump failed_529 + call char_508 + + error_pop_merge + fail! jump failed_524 + error_push + + call char_510 + + error_pop_merge + fail! jump failed_524 + error_push + + call char_512 + + error_pop_merge + fail! jump failed_524 + error_push + + call char_514 + + error_pop_merge + fail! jump failed_524 + error_push + + call char_516 + + error_pop_merge + fail! jump failed_524 + error_push + + call char_518 + + error_pop_merge + fail! jump failed_524 + error_push + + call char_520 + + error_pop_merge + fail! jump failed_524 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_529 + fail! jump failed_524 loc_pop_discard return -failed_529: +failed_524: loc_pop_rewind return -char_513: +char_508: # '<' input_next "t <" ok! test_char "<" return -char_515: +char_510: # 'l' input_next "t l" ok! test_char "l" return -char_517: +char_512: # 'o' input_next "t o" ok! test_char "o" return -char_519: +char_514: # 'w' input_next "t w" ok! test_char "w" return -char_521: +char_516: # 'e' input_next "t e" ok! test_char "e" return -char_523: +char_518: # 'r' input_next "t r" ok! test_char "r" return -char_525: +char_520: # '>' input_next "t >" ok! test_char ">" return @@ -4174,54 +4134,54 @@ # x # '!' # (WHITESPACE) symbol_restore NOT - found! jump found_539 + found! jump found_534 loc_push - call sequence_536 + call sequence_531 fail! value_clear ok! value_leaf NOT symbol_save NOT error_nonterminal NOT loc_pop_discard -found_539: +found_534: ok! ast_value_push return -sequence_536: +sequence_531: # x # '!' # (WHITESPACE) loc_push error_clear error_push - call char_533 + call char_528 error_pop_merge - fail! jump failed_537 + fail! jump failed_532 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_537 + fail! jump failed_532 loc_pop_discard return -failed_537: +failed_532: loc_pop_rewind return -char_533: +char_528: # '!' input_next "t !" ok! test_char "!" return @@ -4236,47 +4196,47 @@ symbol_restore OPEN found! return loc_push - call sequence_544 + call sequence_539 value_clear symbol_save OPEN error_nonterminal OPEN loc_pop_discard return -sequence_544: +sequence_539: # x # '\(' # (WHITESPACE) loc_push error_clear error_push - call char_541 + call char_536 error_pop_merge - fail! jump failed_545 + fail! jump failed_540 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_545 + fail! jump failed_540 loc_pop_discard return -failed_545: +failed_540: loc_pop_rewind return -char_541: +char_536: # '\(' input_next "t (" ok! test_char "(" return @@ -4289,19 +4249,19 @@ symbol_restore OPENB found! return loc_push - call char_548 + call char_543 value_clear symbol_save OPENB error_nonterminal OPENB loc_pop_discard return -char_548: +char_543: # '[' input_next "t [" ok! test_char "[" return @@ -4312,86 +4272,180 @@ sym_PEG: # x # 'P' # 'E' # 'G' +# ! +# / +# '_' +# ':' +# # (WHITESPACE) symbol_restore PEG found! return loc_push - call sequence_558 + call sequence_564 value_clear symbol_save PEG error_nonterminal PEG loc_pop_discard return -sequence_558: +sequence_564: # x # 'P' # 'E' # 'G' +# ! +# / +# '_' +# ':' +# # (WHITESPACE) loc_push error_clear error_push - call char_551 - - error_pop_merge - fail! jump failed_559 - error_push - - call char_553 - - error_pop_merge - fail! jump failed_559 - error_push - - call char_555 - - error_pop_merge - fail! jump failed_559 + call char_546 + + error_pop_merge + fail! jump failed_565 + error_push + + call char_548 + + error_pop_merge + fail! jump failed_565 + error_push + + call char_550 + + error_pop_merge + fail! jump failed_565 + error_push + + call notahead_561 + + error_pop_merge + fail! jump failed_565 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_559 + fail! jump failed_565 loc_pop_discard return -failed_559: +failed_565: loc_pop_rewind return -char_551: +char_546: # 'P' input_next "t P" ok! test_char "P" return -char_553: +char_548: # 'E' input_next "t E" ok! test_char "E" return -char_555: +char_550: # 'G' input_next "t G" ok! test_char "G" return + +notahead_561: +# ! +# / +# '_' +# ':' +# + + loc_push + + call choice_559 + + loc_pop_rewind + status_negate + return + +choice_559: +# / +# '_' +# ':' +# + + error_clear + + loc_push + error_push + + call char_552 + + error_pop_merge + ok! jump oknoast_558 + + loc_pop_rewind + loc_push + error_push + + call char_554 + + error_pop_merge + ok! jump oknoast_558 + + loc_pop_rewind + loc_push + error_push + + call alnum_556 + + error_pop_merge + ok! jump oknoast_558 + + loc_pop_rewind + status_fail + return + +oknoast_558: + loc_pop_discard + return + +char_552: +# '_' + + input_next "t _" + ok! test_char "_" + return + +char_554: +# ':' + + input_next "t :" + ok! test_char ":" + return + +alnum_556: +# + + input_next "alnum" + ok! test_alnum + return # # leaf Symbol 'PLUS' # sym_PLUS: @@ -4398,54 +4452,54 @@ # x # '+' # (WHITESPACE) symbol_restore PLUS - found! jump found_568 + found! jump found_574 loc_push - call sequence_565 + call sequence_571 fail! value_clear ok! value_leaf PLUS symbol_save PLUS error_nonterminal PLUS loc_pop_discard -found_568: +found_574: ok! ast_value_push return -sequence_565: +sequence_571: # x # '+' # (WHITESPACE) loc_push error_clear error_push - call char_562 + call char_568 error_pop_merge - fail! jump failed_566 + fail! jump failed_572 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_566 + fail! jump failed_572 loc_pop_discard return -failed_566: +failed_572: loc_pop_rewind return -char_562: +char_568: # '+' input_next "t +" ok! test_char "+" return @@ -4460,28 +4514,28 @@ # (AND) # (NOT) # (Suffix) symbol_restore Prefix - found! jump found_581 + found! jump found_587 loc_push ast_push - call sequence_578 + call sequence_584 fail! value_clear ok! value_reduce Prefix symbol_save Prefix error_nonterminal Prefix ast_pop_rewind loc_pop_discard -found_581: +found_587: ok! ast_value_push return -sequence_578: +sequence_584: # x # ? # / # (AND) # (NOT) @@ -4491,48 +4545,48 @@ loc_push error_clear error_push - call optional_575 + call optional_581 error_pop_merge - fail! jump failed_579 + fail! jump failed_585 error_push call sym_Suffix error_pop_merge - fail! jump failed_579 + fail! jump failed_585 ast_pop_discard loc_pop_discard return -failed_579: +failed_585: ast_pop_rewind loc_pop_rewind return -optional_575: +optional_581: # ? # / # (AND) # (NOT) loc_push error_push - call choice_573 + call choice_579 error_pop_merge fail! loc_pop_rewind ok! loc_pop_discard status_ok return -choice_573: +choice_579: # / # (AND) # (NOT) error_clear @@ -4542,11 +4596,11 @@ error_push call sym_AND error_pop_merge - ok! jump ok_572 + ok! jump ok_578 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4553,18 +4607,18 @@ error_push call sym_NOT error_pop_merge - ok! jump ok_572 + ok! jump ok_578 ast_pop_rewind loc_pop_rewind status_fail return -ok_572: +ok_578: ast_pop_discard loc_pop_discard return # # value Symbol 'Primary' @@ -4594,28 +4648,28 @@ # (Literal) # (Class) # (DOT) symbol_restore Primary - found! jump found_611 + found! jump found_617 loc_push ast_push - call choice_609 + call choice_615 fail! value_clear ok! value_reduce Primary symbol_save Primary error_nonterminal Primary ast_pop_rewind loc_pop_discard -found_611: +found_617: ok! ast_value_push return -choice_609: +choice_615: # / # (ALNUM) # (ALPHA) # (ASCII) # (CONTROL) @@ -4645,11 +4699,11 @@ error_push call sym_ALNUM error_pop_merge - ok! jump ok_608 + ok! jump ok_614 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4656,11 +4710,11 @@ error_push call sym_ALPHA error_pop_merge - ok! jump ok_608 + ok! jump ok_614 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4667,11 +4721,11 @@ error_push call sym_ASCII error_pop_merge - ok! jump ok_608 + ok! jump ok_614 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4678,11 +4732,11 @@ error_push call sym_CONTROL error_pop_merge - ok! jump ok_608 + ok! jump ok_614 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4689,11 +4743,11 @@ error_push call sym_DDIGIT error_pop_merge - ok! jump ok_608 + ok! jump ok_614 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4700,11 +4754,11 @@ error_push call sym_DIGIT error_pop_merge - ok! jump ok_608 + ok! jump ok_614 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4711,11 +4765,11 @@ error_push call sym_GRAPH error_pop_merge - ok! jump ok_608 + ok! jump ok_614 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4722,11 +4776,11 @@ error_push call sym_LOWER error_pop_merge - ok! jump ok_608 + ok! jump ok_614 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4733,11 +4787,11 @@ error_push call sym_PRINTABLE error_pop_merge - ok! jump ok_608 + ok! jump ok_614 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4744,11 +4798,11 @@ error_push call sym_PUNCT error_pop_merge - ok! jump ok_608 + ok! jump ok_614 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4755,11 +4809,11 @@ error_push call sym_SPACE error_pop_merge - ok! jump ok_608 + ok! jump ok_614 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4766,11 +4820,11 @@ error_push call sym_UPPER error_pop_merge - ok! jump ok_608 + ok! jump ok_614 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4777,11 +4831,11 @@ error_push call sym_WORDCHAR error_pop_merge - ok! jump ok_608 + ok! jump ok_614 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4788,11 +4842,11 @@ error_push call sym_XDIGIT error_pop_merge - ok! jump ok_608 + ok! jump ok_614 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4799,22 +4853,22 @@ error_push call sym_Identifier error_pop_merge - ok! jump ok_608 + ok! jump ok_614 ast_pop_rewind loc_pop_rewind ast_push loc_push error_push - call sequence_601 + call sequence_607 error_pop_merge - ok! jump ok_608 + ok! jump ok_614 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4821,11 +4875,11 @@ error_push call sym_Literal error_pop_merge - ok! jump ok_608 + ok! jump ok_614 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4832,11 +4886,11 @@ error_push call sym_Class error_pop_merge - ok! jump ok_608 + ok! jump ok_614 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4843,23 +4897,23 @@ error_push call sym_DOT error_pop_merge - ok! jump ok_608 + ok! jump ok_614 ast_pop_rewind loc_pop_rewind status_fail return -ok_608: +ok_614: ast_pop_discard loc_pop_discard return -sequence_601: +sequence_607: # x # (OPEN) # (Expression) # (CLOSE) @@ -4869,33 +4923,33 @@ error_push call sym_OPEN error_pop_merge - fail! jump failednoast_603 + fail! jump failednoast_609 ast_push error_push call sym_Expression error_pop_merge - fail! jump failed_602 + fail! jump failed_608 error_push call sym_CLOSE error_pop_merge - fail! jump failed_602 + fail! jump failed_608 ast_pop_discard loc_pop_discard return -failed_602: +failed_608: ast_pop_rewind -failednoast_603: +failednoast_609: loc_pop_rewind return # # leaf Symbol 'PRINTABLE' # @@ -4910,26 +4964,26 @@ # 't' # '>' # (WHITESPACE) symbol_restore PRINTABLE - found! jump found_631 + found! jump found_637 loc_push - call sequence_628 + call sequence_634 fail! value_clear ok! value_leaf PRINTABLE symbol_save PRINTABLE error_nonterminal PRINTABLE loc_pop_discard -found_631: +found_637: ok! ast_value_push return -sequence_628: +sequence_634: # x # '<' # 'p' # 'r' # 'i' @@ -4941,107 +4995,107 @@ loc_push error_clear error_push - call char_613 - - error_pop_merge - fail! jump failed_629 - error_push - - call char_615 - - error_pop_merge - fail! jump failed_629 - error_push - - call char_617 - - error_pop_merge - fail! jump failed_629 - error_push - call char_619 error_pop_merge - fail! jump failed_629 + fail! jump failed_635 error_push call char_621 error_pop_merge - fail! jump failed_629 + fail! jump failed_635 error_push call char_623 error_pop_merge - fail! jump failed_629 + fail! jump failed_635 error_push call char_625 error_pop_merge - fail! jump failed_629 + fail! jump failed_635 + error_push + + call char_627 + + error_pop_merge + fail! jump failed_635 + error_push + + call char_629 + + error_pop_merge + fail! jump failed_635 + error_push + + call char_631 + + error_pop_merge + fail! jump failed_635 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_629 + fail! jump failed_635 loc_pop_discard return -failed_629: +failed_635: loc_pop_rewind return -char_613: +char_619: # '<' input_next "t <" ok! test_char "<" return -char_615: +char_621: # 'p' input_next "t p" ok! test_char "p" return -char_617: +char_623: # 'r' input_next "t r" ok! test_char "r" return -char_619: +char_625: # 'i' input_next "t i" ok! test_char "i" return -char_621: +char_627: # 'n' input_next "t n" ok! test_char "n" return -char_623: +char_629: # 't' input_next "t t" ok! test_char "t" return -char_625: +char_631: # '>' input_next "t >" ok! test_char ">" return @@ -5059,26 +5113,26 @@ # 't' # '>' # (WHITESPACE) symbol_restore PUNCT - found! jump found_651 + found! jump found_657 loc_push - call sequence_648 + call sequence_654 fail! value_clear ok! value_leaf PUNCT symbol_save PUNCT error_nonterminal PUNCT loc_pop_discard -found_651: +found_657: ok! ast_value_push return -sequence_648: +sequence_654: # x # '<' # 'p' # 'u' # 'n' @@ -5090,107 +5144,107 @@ loc_push error_clear error_push - call char_633 - - error_pop_merge - fail! jump failed_649 - error_push - - call char_635 - - error_pop_merge - fail! jump failed_649 - error_push - - call char_637 - - error_pop_merge - fail! jump failed_649 - error_push - call char_639 error_pop_merge - fail! jump failed_649 + fail! jump failed_655 error_push call char_641 error_pop_merge - fail! jump failed_649 + fail! jump failed_655 error_push call char_643 error_pop_merge - fail! jump failed_649 + fail! jump failed_655 error_push call char_645 error_pop_merge - fail! jump failed_649 + fail! jump failed_655 + error_push + + call char_647 + + error_pop_merge + fail! jump failed_655 + error_push + + call char_649 + + error_pop_merge + fail! jump failed_655 + error_push + + call char_651 + + error_pop_merge + fail! jump failed_655 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_649 + fail! jump failed_655 loc_pop_discard return -failed_649: +failed_655: loc_pop_rewind return -char_633: +char_639: # '<' input_next "t <" ok! test_char "<" return -char_635: +char_641: # 'p' input_next "t p" ok! test_char "p" return -char_637: +char_643: # 'u' input_next "t u" ok! test_char "u" return -char_639: +char_645: # 'n' input_next "t n" ok! test_char "n" return -char_641: +char_647: # 'c' input_next "t c" ok! test_char "c" return -char_643: +char_649: # 't' input_next "t t" ok! test_char "t" return -char_645: +char_651: # '>' input_next "t >" ok! test_char ">" return @@ -5202,54 +5256,54 @@ # x # '?' # (WHITESPACE) symbol_restore QUESTION - found! jump found_659 + found! jump found_665 loc_push - call sequence_656 + call sequence_662 fail! value_clear ok! value_leaf QUESTION symbol_save QUESTION error_nonterminal QUESTION loc_pop_discard -found_659: +found_665: ok! ast_value_push return -sequence_656: +sequence_662: # x # '?' # (WHITESPACE) loc_push error_clear error_push - call char_653 + call char_659 error_pop_merge - fail! jump failed_657 + fail! jump failed_663 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_657 + fail! jump failed_663 loc_pop_discard return -failed_657: +failed_663: loc_pop_rewind return -char_653: +char_659: # '?' input_next "t ?" ok! test_char "?" return @@ -5264,28 +5318,28 @@ # (TO) # (Char) # (Char) symbol_restore Range - found! jump found_671 + found! jump found_677 loc_push ast_push - call choice_669 + call choice_675 fail! value_clear ok! value_reduce Range symbol_save Range error_nonterminal Range ast_pop_rewind loc_pop_discard -found_671: +found_677: ok! ast_value_push return -choice_669: +choice_675: # / # x # (Char) # (TO) # (Char) @@ -5295,14 +5349,14 @@ ast_push loc_push error_push - call sequence_664 + call sequence_670 error_pop_merge - ok! jump ok_668 + ok! jump ok_674 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -5309,23 +5363,23 @@ error_push call sym_Char error_pop_merge - ok! jump ok_668 + ok! jump ok_674 ast_pop_rewind loc_pop_rewind status_fail return -ok_668: +ok_674: ast_pop_discard loc_pop_discard return -sequence_664: +sequence_670: # x # (Char) # (TO) # (Char) @@ -5336,29 +5390,29 @@ error_push call sym_Char error_pop_merge - fail! jump failed_665 + fail! jump failed_671 error_push call sym_TO error_pop_merge - fail! jump failed_665 + fail! jump failed_671 error_push call sym_Char error_pop_merge - fail! jump failed_665 + fail! jump failed_671 ast_pop_discard loc_pop_discard return -failed_665: +failed_671: ast_pop_rewind loc_pop_rewind return # # void Symbol 'SEMICOLON' @@ -5371,47 +5425,47 @@ symbol_restore SEMICOLON found! return loc_push - call sequence_676 + call sequence_682 value_clear symbol_save SEMICOLON error_nonterminal SEMICOLON loc_pop_discard return -sequence_676: +sequence_682: # x # ';' # (WHITESPACE) loc_push error_clear error_push - call char_673 + call char_679 error_pop_merge - fail! jump failed_677 + fail! jump failed_683 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_677 + fail! jump failed_683 loc_pop_discard return -failed_677: +failed_683: loc_pop_rewind return -char_673: +char_679: # ';' input_next "t ;" ok! test_char ";" return @@ -5422,49 +5476,49 @@ sym_Sequence: # + # (Prefix) symbol_restore Sequence - found! jump found_685 + found! jump found_691 loc_push ast_push - call poskleene_681 + call poskleene_687 fail! value_clear ok! value_reduce Sequence symbol_save Sequence error_nonterminal Sequence ast_pop_rewind loc_pop_discard -found_685: +found_691: ok! ast_value_push return -poskleene_681: +poskleene_687: # + # (Prefix) loc_push call sym_Prefix - fail! jump failed_682 + fail! jump failed_688 -loop_683: +loop_689: loc_pop_discard loc_push error_push call sym_Prefix error_pop_merge - ok! jump loop_683 + ok! jump loop_689 status_ok -failed_682: +failed_688: loc_pop_rewind return # # void Symbol 'SLASH' # @@ -5476,47 +5530,47 @@ symbol_restore SLASH found! return loc_push - call sequence_690 + call sequence_696 value_clear symbol_save SLASH error_nonterminal SLASH loc_pop_discard return -sequence_690: +sequence_696: # x # '/' # (WHITESPACE) loc_push error_clear error_push - call char_687 + call char_693 error_pop_merge - fail! jump failed_691 + fail! jump failed_697 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_691 + fail! jump failed_697 loc_pop_discard return -failed_691: +failed_697: loc_pop_rewind return -char_687: +char_693: # '/' input_next "t /" ok! test_char "/" return @@ -5534,26 +5588,26 @@ # 'e' # '>' # (WHITESPACE) symbol_restore SPACE - found! jump found_712 + found! jump found_718 loc_push - call sequence_709 + call sequence_715 fail! value_clear ok! value_leaf SPACE symbol_save SPACE error_nonterminal SPACE loc_pop_discard -found_712: +found_718: ok! ast_value_push return -sequence_709: +sequence_715: # x # '<' # 's' # 'p' # 'a' @@ -5565,107 +5619,107 @@ loc_push error_clear error_push - call char_694 - - error_pop_merge - fail! jump failed_710 - error_push - - call char_696 - - error_pop_merge - fail! jump failed_710 - error_push - - call char_698 - - error_pop_merge - fail! jump failed_710 - error_push - call char_700 error_pop_merge - fail! jump failed_710 + fail! jump failed_716 error_push call char_702 error_pop_merge - fail! jump failed_710 + fail! jump failed_716 error_push call char_704 error_pop_merge - fail! jump failed_710 + fail! jump failed_716 error_push call char_706 error_pop_merge - fail! jump failed_710 + fail! jump failed_716 + error_push + + call char_708 + + error_pop_merge + fail! jump failed_716 + error_push + + call char_710 + + error_pop_merge + fail! jump failed_716 + error_push + + call char_712 + + error_pop_merge + fail! jump failed_716 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_710 + fail! jump failed_716 loc_pop_discard return -failed_710: +failed_716: loc_pop_rewind return -char_694: +char_700: # '<' input_next "t <" ok! test_char "<" return -char_696: +char_702: # 's' input_next "t s" ok! test_char "s" return -char_698: +char_704: # 'p' input_next "t p" ok! test_char "p" return -char_700: +char_706: # 'a' input_next "t a" ok! test_char "a" return -char_702: +char_708: # 'c' input_next "t c" ok! test_char "c" return -char_704: +char_710: # 'e' input_next "t e" ok! test_char "e" return -char_706: +char_712: # '>' input_next "t >" ok! test_char ">" return @@ -5677,54 +5731,54 @@ # x # '*' # (WHITESPACE) symbol_restore STAR - found! jump found_720 + found! jump found_726 loc_push - call sequence_717 + call sequence_723 fail! value_clear ok! value_leaf STAR symbol_save STAR error_nonterminal STAR loc_pop_discard -found_720: +found_726: ok! ast_value_push return -sequence_717: +sequence_723: # x # '*' # (WHITESPACE) loc_push error_clear error_push - call char_714 + call char_720 error_pop_merge - fail! jump failed_718 + fail! jump failed_724 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_718 + fail! jump failed_724 loc_pop_discard return -failed_718: +failed_724: loc_pop_rewind return -char_714: +char_720: # '*' input_next "t *" ok! test_char "*" return @@ -5737,28 +5791,28 @@ # (OPEN) # (Expression) # (CLOSE) symbol_restore StartExpr - found! jump found_729 + found! jump found_735 loc_push ast_push - call sequence_725 + call sequence_731 fail! value_clear ok! value_reduce StartExpr symbol_save StartExpr error_nonterminal StartExpr ast_pop_rewind loc_pop_discard -found_729: +found_735: ok! ast_value_push return -sequence_725: +sequence_731: # x # (OPEN) # (Expression) # (CLOSE) @@ -5768,33 +5822,33 @@ error_push call sym_OPEN error_pop_merge - fail! jump failednoast_727 + fail! jump failednoast_733 ast_push error_push call sym_Expression error_pop_merge - fail! jump failed_726 + fail! jump failed_732 error_push call sym_CLOSE error_pop_merge - fail! jump failed_726 + fail! jump failed_732 ast_pop_discard loc_pop_discard return -failed_726: +failed_732: ast_pop_rewind -failednoast_727: +failednoast_733: loc_pop_rewind return # # value Symbol 'Suffix' # @@ -5807,28 +5861,28 @@ # (QUESTION) # (STAR) # (PLUS) symbol_restore Suffix - found! jump found_743 + found! jump found_749 loc_push ast_push - call sequence_740 + call sequence_746 fail! value_clear ok! value_reduce Suffix symbol_save Suffix error_nonterminal Suffix ast_pop_rewind loc_pop_discard -found_743: +found_749: ok! ast_value_push return -sequence_740: +sequence_746: # x # (Primary) # ? # / # (QUESTION) @@ -5842,46 +5896,46 @@ error_push call sym_Primary error_pop_merge - fail! jump failed_741 + fail! jump failed_747 error_push - call optional_738 + call optional_744 error_pop_merge - fail! jump failed_741 + fail! jump failed_747 ast_pop_discard loc_pop_discard return -failed_741: +failed_747: ast_pop_rewind loc_pop_rewind return -optional_738: +optional_744: # ? # / # (QUESTION) # (STAR) # (PLUS) loc_push error_push - call choice_736 + call choice_742 error_pop_merge fail! loc_pop_rewind ok! loc_pop_discard status_ok return -choice_736: +choice_742: # / # (QUESTION) # (STAR) # (PLUS) @@ -5892,11 +5946,11 @@ error_push call sym_QUESTION error_pop_merge - ok! jump ok_735 + ok! jump ok_741 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -5903,11 +5957,11 @@ error_push call sym_STAR error_pop_merge - ok! jump ok_735 + ok! jump ok_741 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -5914,18 +5968,18 @@ error_push call sym_PLUS error_pop_merge - ok! jump ok_735 + ok! jump ok_741 ast_pop_rewind loc_pop_rewind status_fail return -ok_735: +ok_741: ast_pop_discard loc_pop_discard return # # void Symbol 'TO' @@ -5936,19 +5990,19 @@ symbol_restore TO found! return loc_push - call char_745 + call char_751 value_clear symbol_save TO error_nonterminal TO loc_pop_discard return -char_745: +char_751: # '-' input_next "t -" ok! test_char "-" return @@ -5966,26 +6020,26 @@ # 'r' # '>' # (WHITESPACE) symbol_restore UPPER - found! jump found_766 + found! jump found_772 loc_push - call sequence_763 + call sequence_769 fail! value_clear ok! value_leaf UPPER symbol_save UPPER error_nonterminal UPPER loc_pop_discard -found_766: +found_772: ok! ast_value_push return -sequence_763: +sequence_769: # x # '<' # 'u' # 'p' # 'p' @@ -5997,107 +6051,107 @@ loc_push error_clear error_push - call char_748 - - error_pop_merge - fail! jump failed_764 - error_push - - call char_750 - - error_pop_merge - fail! jump failed_764 - error_push - - call char_752 - - error_pop_merge - fail! jump failed_764 - error_push - call char_754 error_pop_merge - fail! jump failed_764 + fail! jump failed_770 error_push call char_756 error_pop_merge - fail! jump failed_764 + fail! jump failed_770 error_push call char_758 error_pop_merge - fail! jump failed_764 + fail! jump failed_770 error_push call char_760 error_pop_merge - fail! jump failed_764 + fail! jump failed_770 + error_push + + call char_762 + + error_pop_merge + fail! jump failed_770 + error_push + + call char_764 + + error_pop_merge + fail! jump failed_770 + error_push + + call char_766 + + error_pop_merge + fail! jump failed_770 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_764 + fail! jump failed_770 loc_pop_discard return -failed_764: +failed_770: loc_pop_rewind return -char_748: +char_754: # '<' input_next "t <" ok! test_char "<" return -char_750: +char_756: # 'u' input_next "t u" ok! test_char "u" return -char_752: +char_758: # 'p' input_next "t p" ok! test_char "p" return -char_754: +char_760: # 'p' input_next "t p" ok! test_char "p" return -char_756: +char_762: # 'e' input_next "t e" ok! test_char "e" return -char_758: +char_764: # 'r' input_next "t r" ok! test_char "r" return -char_760: +char_766: # '>' input_next "t >" ok! test_char ">" return @@ -6112,26 +6166,26 @@ # 'i' # 'd' # (WHITESPACE) symbol_restore VOID - found! jump found_780 + found! jump found_786 loc_push - call sequence_777 + call sequence_783 fail! value_clear ok! value_leaf VOID symbol_save VOID error_nonterminal VOID loc_pop_discard -found_780: +found_786: ok! ast_value_push return -sequence_777: +sequence_783: # x # 'v' # 'o' # 'i' # 'd' @@ -6140,68 +6194,68 @@ loc_push error_clear error_push - call char_768 - - error_pop_merge - fail! jump failed_778 - error_push - - call char_770 - - error_pop_merge - fail! jump failed_778 - error_push - - call char_772 - - error_pop_merge - fail! jump failed_778 - error_push - call char_774 error_pop_merge - fail! jump failed_778 + fail! jump failed_784 + error_push + + call char_776 + + error_pop_merge + fail! jump failed_784 + error_push + + call char_778 + + error_pop_merge + fail! jump failed_784 + error_push + + call char_780 + + error_pop_merge + fail! jump failed_784 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_778 + fail! jump failed_784 loc_pop_discard return -failed_778: +failed_784: loc_pop_rewind return -char_768: +char_774: # 'v' input_next "t v" ok! test_char "v" return -char_770: +char_776: # 'o' input_next "t o" ok! test_char "o" return -char_772: +char_778: # 'i' input_next "t i" ok! test_char "i" return -char_774: +char_780: # 'd' input_next "t d" ok! test_char "d" return @@ -6217,72 +6271,72 @@ symbol_restore WHITESPACE found! return loc_push - call kleene_788 + call kleene_794 value_clear symbol_save WHITESPACE error_nonterminal WHITESPACE loc_pop_discard return -kleene_788: +kleene_794: # * # / # # (COMMENT) loc_push error_push - call choice_786 + call choice_792 error_pop_merge - fail! jump failed_789 + fail! jump failed_795 loc_pop_discard - jump kleene_788 + jump kleene_794 -failed_789: +failed_795: loc_pop_rewind status_ok return -choice_786: +choice_792: # / # # (COMMENT) error_clear loc_push error_push - call space_782 + call space_788 error_pop_merge - ok! jump oknoast_785 + ok! jump oknoast_791 loc_pop_rewind loc_push error_push call sym_COMMENT error_pop_merge - ok! jump oknoast_785 + ok! jump oknoast_791 loc_pop_rewind status_fail return -oknoast_785: +oknoast_791: loc_pop_discard return -space_782: +space_788: # input_next "space" ok! test_space return @@ -6303,26 +6357,26 @@ # 'r' # '>' # (WHITESPACE) symbol_restore WORDCHAR - found! jump found_816 + found! jump found_822 loc_push - call sequence_813 + call sequence_819 fail! value_clear ok! value_leaf WORDCHAR symbol_save WORDCHAR error_nonterminal WORDCHAR loc_pop_discard -found_816: +found_822: ok! ast_value_push return -sequence_813: +sequence_819: # x # '<' # 'w' # 'o' # 'r' @@ -6337,146 +6391,146 @@ loc_push error_clear error_push - call char_792 - - error_pop_merge - fail! jump failed_814 - error_push - - call char_794 - - error_pop_merge - fail! jump failed_814 - error_push - - call char_796 - - error_pop_merge - fail! jump failed_814 - error_push - call char_798 error_pop_merge - fail! jump failed_814 + fail! jump failed_820 error_push call char_800 error_pop_merge - fail! jump failed_814 + fail! jump failed_820 error_push call char_802 error_pop_merge - fail! jump failed_814 + fail! jump failed_820 error_push call char_804 error_pop_merge - fail! jump failed_814 + fail! jump failed_820 error_push call char_806 error_pop_merge - fail! jump failed_814 + fail! jump failed_820 error_push call char_808 error_pop_merge - fail! jump failed_814 + fail! jump failed_820 error_push call char_810 error_pop_merge - fail! jump failed_814 + fail! jump failed_820 + error_push + + call char_812 + + error_pop_merge + fail! jump failed_820 + error_push + + call char_814 + + error_pop_merge + fail! jump failed_820 + error_push + + call char_816 + + error_pop_merge + fail! jump failed_820 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_814 + fail! jump failed_820 loc_pop_discard return -failed_814: +failed_820: loc_pop_rewind return -char_792: +char_798: # '<' input_next "t <" ok! test_char "<" return -char_794: +char_800: # 'w' input_next "t w" ok! test_char "w" return -char_796: +char_802: # 'o' input_next "t o" ok! test_char "o" return -char_798: +char_804: # 'r' input_next "t r" ok! test_char "r" return -char_800: +char_806: # 'd' input_next "t d" ok! test_char "d" return -char_802: +char_808: # 'c' input_next "t c" ok! test_char "c" return -char_804: +char_810: # 'h' input_next "t h" ok! test_char "h" return -char_806: +char_812: # 'a' input_next "t a" ok! test_char "a" return -char_808: +char_814: # 'r' input_next "t r" ok! test_char "r" return -char_810: +char_816: # '>' input_next "t >" ok! test_char ">" return @@ -6495,26 +6549,26 @@ # 't' # '>' # (WHITESPACE) symbol_restore XDIGIT - found! jump found_838 + found! jump found_844 loc_push - call sequence_835 + call sequence_841 fail! value_clear ok! value_leaf XDIGIT symbol_save XDIGIT error_nonterminal XDIGIT loc_pop_discard -found_838: +found_844: ok! ast_value_push return -sequence_835: +sequence_841: # x # '<' # 'x' # 'd' # 'i' @@ -6527,123 +6581,123 @@ loc_push error_clear error_push - call char_818 - - error_pop_merge - fail! jump failed_836 - error_push - - call char_820 - - error_pop_merge - fail! jump failed_836 - error_push - - call char_822 - - error_pop_merge - fail! jump failed_836 - error_push - call char_824 error_pop_merge - fail! jump failed_836 + fail! jump failed_842 error_push call char_826 error_pop_merge - fail! jump failed_836 + fail! jump failed_842 error_push call char_828 error_pop_merge - fail! jump failed_836 + fail! jump failed_842 error_push call char_830 error_pop_merge - fail! jump failed_836 + fail! jump failed_842 error_push call char_832 error_pop_merge - fail! jump failed_836 + fail! jump failed_842 + error_push + + call char_834 + + error_pop_merge + fail! jump failed_842 + error_push + + call char_836 + + error_pop_merge + fail! jump failed_842 + error_push + + call char_838 + + error_pop_merge + fail! jump failed_842 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_836 + fail! jump failed_842 loc_pop_discard return -failed_836: +failed_842: loc_pop_rewind return -char_818: +char_824: # '<' input_next "t <" ok! test_char "<" return -char_820: +char_826: # 'x' input_next "t x" ok! test_char "x" return -char_822: +char_828: # 'd' input_next "t d" ok! test_char "d" return -char_824: +char_830: # 'i' input_next "t i" ok! test_char "i" return -char_826: +char_832: # 'g' input_next "t g" ok! test_char "g" return -char_828: +char_834: # 'i' input_next "t i" ok! test_char "i" return -char_830: +char_836: # 't' input_next "t t" ok! test_char "t" return -char_832: +char_838: # '>' input_next "t >" ok! test_char ">" return # # Index: modules/pt/tests/data/ok/peg_param/3_peg_itself ================================================================== --- modules/pt/tests/data/ok/peg_param/3_peg_itself +++ modules/pt/tests/data/ok/peg_param/3_peg_itself @@ -640,12 +640,12 @@ loc_push error_clear error_push - input_next "t \\" - ok! test_char "\\" + input_next "t \" + ok! test_char "\" error_pop_merge fail! jump failed_76 error_push @@ -712,12 +712,12 @@ loc_push error_clear error_push - input_next "t \\" - ok! test_char "\\" + input_next "t \" + ok! test_char "\" error_pop_merge fail! jump failed_86 error_push @@ -804,12 +804,12 @@ loc_push error_clear error_push - input_next "t \\" - ok! test_char "\\" + input_next "t \" + ok! test_char "\" error_pop_merge fail! jump failed_103 error_push @@ -879,12 +879,12 @@ loc_pop_rewind loc_push error_push - input_next "t \"" - ok! test_char "\"" + input_next "t "" + ok! test_char """ error_pop_merge ok! jump oknoast_99 loc_pop_rewind @@ -909,12 +909,12 @@ loc_pop_rewind loc_push error_push - input_next "t \\" - ok! test_char "\\" + input_next "t \" + ok! test_char "\" error_pop_merge ok! jump oknoast_99 loc_pop_rewind @@ -983,12 +983,12 @@ # ! # '\' loc_push - input_next "t \\" - ok! test_char "\\" + input_next "t \" + ok! test_char "\" loc_pop_rewind status_negate return # @@ -1042,12 +1042,12 @@ loc_push error_clear error_push - input_next "t \\" - ok! test_char "\\" + input_next "t \" + ok! test_char "\" error_pop_merge fail! jump failed_135 error_push @@ -1724,12 +1724,12 @@ symbol_restore DAPOSTROPH found! return loc_push - input_next "t \"" - ok! test_char "\"" + input_next "t "" + ok! test_char """ value_clear symbol_save DAPOSTROPH error_nonterminal DAPOSTROPH loc_pop_discard @@ -2107,77 +2107,10 @@ failed_248: loc_pop_rewind return # -# void Symbol 'END' -# - -sym_END: -# x -# 'E' -# 'N' -# 'D' -# (WHITESPACE) - - symbol_restore END - found! return - loc_push - - call sequence_256 - - value_clear - symbol_save END - error_nonterminal END - loc_pop_discard - return - -sequence_256: -# x -# 'E' -# 'N' -# 'D' -# (WHITESPACE) - - loc_push - error_clear - - error_push - - input_next "t E" - ok! test_char "E" - - error_pop_merge - fail! jump failed_257 - error_push - - input_next "t N" - ok! test_char "N" - - error_pop_merge - fail! jump failed_257 - error_push - - input_next "t D" - ok! test_char "D" - - error_pop_merge - fail! jump failed_257 - error_push - - call sym_WHITESPACE - - error_pop_merge - fail! jump failed_257 - - loc_pop_discard - return - -failed_257: - loc_pop_rewind - return -# # void Symbol 'EOF' # sym_EOF: # ! @@ -2185,19 +2118,19 @@ symbol_restore EOF found! return loc_push - call notahead_261 + call notahead_253 value_clear symbol_save EOF error_nonterminal EOF loc_pop_discard return -notahead_261: +notahead_253: # ! # loc_push @@ -2217,49 +2150,49 @@ symbol_restore EOL found! return loc_push - call choice_267 + call choice_259 value_clear symbol_save EOL error_nonterminal EOL loc_pop_discard return -choice_267: +choice_259: # / # '\n' # '\r' error_clear loc_push error_push - input_next "t \\n" - ok! test_char "\\n" + input_next "t " + ok! test_char "" error_pop_merge - ok! jump oknoast_266 + ok! jump oknoast_258 loc_pop_rewind loc_push error_push - input_next "t \\r" - ok! test_char "\\r" + input_next "t " + ok! test_char "" error_pop_merge - ok! jump oknoast_266 + ok! jump oknoast_258 loc_pop_rewind status_fail return -oknoast_266: +oknoast_258: loc_pop_discard return # # value Symbol 'Expression' # @@ -2271,28 +2204,28 @@ # x # (SLASH) # (Sequence) symbol_restore Expression - found! jump found_283 + found! jump found_275 loc_push ast_push - call sequence_280 + call sequence_272 fail! value_clear ok! value_reduce Expression symbol_save Expression error_nonterminal Expression ast_pop_rewind loc_pop_discard -found_283: +found_275: ok! ast_value_push return -sequence_280: +sequence_272: # x # (Sequence) # * # x # (SLASH) @@ -2305,49 +2238,49 @@ error_push call sym_Sequence error_pop_merge - fail! jump failed_281 + fail! jump failed_273 error_push - call kleene_277 + call kleene_269 error_pop_merge - fail! jump failed_281 + fail! jump failed_273 ast_pop_discard loc_pop_discard return -failed_281: +failed_273: ast_pop_rewind loc_pop_rewind return -kleene_277: +kleene_269: # * # x # (SLASH) # (Sequence) loc_push error_push - call sequence_273 + call sequence_265 error_pop_merge - fail! jump failed_278 + fail! jump failed_270 loc_pop_discard - jump kleene_277 + jump kleene_269 -failed_278: +failed_270: loc_pop_rewind status_ok return -sequence_273: +sequence_265: # x # (SLASH) # (Sequence) loc_push @@ -2356,83 +2289,110 @@ error_push call sym_SLASH error_pop_merge - fail! jump failednoast_275 + fail! jump failednoast_267 ast_push error_push call sym_Sequence error_pop_merge - fail! jump failed_274 + fail! jump failed_266 ast_pop_discard loc_pop_discard return -failed_274: +failed_266: ast_pop_rewind -failednoast_275: +failednoast_267: loc_pop_rewind return # # void Symbol 'Final' # sym_Final: # x -# (END) +# 'E' +# 'N' +# 'D' +# (WHITESPACE) # (SEMICOLON) # (WHITESPACE) symbol_restore Final found! return loc_push - call sequence_288 + call sequence_283 value_clear symbol_save Final error_nonterminal Final loc_pop_discard return -sequence_288: +sequence_283: # x -# (END) +# 'E' +# 'N' +# 'D' +# (WHITESPACE) # (SEMICOLON) # (WHITESPACE) loc_push error_clear error_push - call sym_END + input_next "t E" + ok! test_char "E" error_pop_merge - fail! jump failed_289 + fail! jump failed_284 + error_push + + input_next "t N" + ok! test_char "N" + + error_pop_merge + fail! jump failed_284 + error_push + + input_next "t D" + ok! test_char "D" + + error_pop_merge + fail! jump failed_284 + error_push + + call sym_WHITESPACE + + error_pop_merge + fail! jump failed_284 error_push call sym_SEMICOLON error_pop_merge - fail! jump failed_289 + fail! jump failed_284 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_289 + fail! jump failed_284 loc_pop_discard return -failed_289: +failed_284: loc_pop_rewind return # # value Symbol 'Grammar' # @@ -2445,28 +2405,28 @@ # (Definition) # (Final) # (EOF) symbol_restore Grammar - found! jump found_304 + found! jump found_299 loc_push ast_push - call sequence_300 + call sequence_295 fail! value_clear ok! value_reduce Grammar symbol_save Grammar error_nonterminal Grammar ast_pop_rewind loc_pop_discard -found_304: +found_299: ok! ast_value_push return -sequence_300: +sequence_295: # x # (WHITESPACE) # (Header) # * # (Definition) @@ -2479,63 +2439,63 @@ error_push call sym_WHITESPACE error_pop_merge - fail! jump failednoast_302 + fail! jump failednoast_297 ast_push error_push call sym_Header error_pop_merge - fail! jump failed_301 + fail! jump failed_296 error_push - call kleene_295 + call kleene_290 error_pop_merge - fail! jump failed_301 + fail! jump failed_296 error_push call sym_Final error_pop_merge - fail! jump failed_301 + fail! jump failed_296 error_push call sym_EOF error_pop_merge - fail! jump failed_301 + fail! jump failed_296 ast_pop_discard loc_pop_discard return -failed_301: +failed_296: ast_pop_rewind -failednoast_302: +failednoast_297: loc_pop_rewind return -kleene_295: +kleene_290: # * # (Definition) loc_push error_push call sym_Definition error_pop_merge - fail! jump failed_296 + fail! jump failed_291 loc_pop_discard - jump kleene_295 + jump kleene_290 -failed_296: +failed_291: loc_pop_rewind status_ok return # # leaf Symbol 'GRAPH' @@ -2551,26 +2511,26 @@ # 'h' # '>' # (WHITESPACE) symbol_restore GRAPH - found! jump found_317 + found! jump found_312 loc_push - call sequence_314 + call sequence_309 fail! value_clear ok! value_leaf GRAPH symbol_save GRAPH error_nonterminal GRAPH loc_pop_discard -found_317: +found_312: ok! ast_value_push return -sequence_314: +sequence_309: # x # '<' # 'g' # 'r' # 'a' @@ -2586,64 +2546,64 @@ input_next "t <" ok! test_char "<" error_pop_merge - fail! jump failed_315 + fail! jump failed_310 error_push input_next "t g" ok! test_char "g" error_pop_merge - fail! jump failed_315 + fail! jump failed_310 error_push input_next "t r" ok! test_char "r" error_pop_merge - fail! jump failed_315 + fail! jump failed_310 error_push input_next "t a" ok! test_char "a" error_pop_merge - fail! jump failed_315 + fail! jump failed_310 error_push input_next "t p" ok! test_char "p" error_pop_merge - fail! jump failed_315 + fail! jump failed_310 error_push input_next "t h" ok! test_char "h" error_pop_merge - fail! jump failed_315 + fail! jump failed_310 error_push input_next "t >" ok! test_char ">" error_pop_merge - fail! jump failed_315 + fail! jump failed_310 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_315 + fail! jump failed_310 loc_pop_discard return -failed_315: +failed_310: loc_pop_rewind return # # value Symbol 'Header' # @@ -2653,28 +2613,28 @@ # (PEG) # (Identifier) # (StartExpr) symbol_restore Header - found! jump found_326 + found! jump found_321 loc_push ast_push - call sequence_322 + call sequence_317 fail! value_clear ok! value_reduce Header symbol_save Header error_nonterminal Header ast_pop_rewind loc_pop_discard -found_326: +found_321: ok! ast_value_push return -sequence_322: +sequence_317: # x # (PEG) # (Identifier) # (StartExpr) @@ -2684,33 +2644,33 @@ error_push call sym_PEG error_pop_merge - fail! jump failednoast_324 + fail! jump failednoast_319 ast_push error_push call sym_Identifier error_pop_merge - fail! jump failed_323 + fail! jump failed_318 error_push call sym_StartExpr error_pop_merge - fail! jump failed_323 + fail! jump failed_318 ast_pop_discard loc_pop_discard return -failed_323: +failed_318: ast_pop_rewind -failednoast_324: +failednoast_319: loc_pop_rewind return # # leaf Symbol 'Ident' # @@ -2726,26 +2686,26 @@ # '_' # ':' # symbol_restore Ident - found! jump found_346 + found! jump found_341 loc_push - call sequence_343 + call sequence_338 fail! value_clear ok! value_leaf Ident symbol_save Ident error_nonterminal Ident loc_pop_discard -found_346: +found_341: ok! ast_value_push return -sequence_343: +sequence_338: # x # / # '_' # ':' # @@ -2758,29 +2718,29 @@ loc_push error_clear error_push - call choice_332 + call choice_327 error_pop_merge - fail! jump failed_344 + fail! jump failed_339 error_push - call kleene_340 + call kleene_335 error_pop_merge - fail! jump failed_344 + fail! jump failed_339 loc_pop_discard return -failed_344: +failed_339: loc_pop_rewind return -choice_332: +choice_327: # / # '_' # ':' # @@ -2791,63 +2751,63 @@ input_next "t _" ok! test_char "_" error_pop_merge - ok! jump oknoast_331 + ok! jump oknoast_326 loc_pop_rewind loc_push error_push input_next "t :" ok! test_char ":" error_pop_merge - ok! jump oknoast_331 + ok! jump oknoast_326 loc_pop_rewind loc_push error_push input_next "alpha" ok! test_alpha error_pop_merge - ok! jump oknoast_331 + ok! jump oknoast_326 loc_pop_rewind status_fail return -oknoast_331: +oknoast_326: loc_pop_discard return -kleene_340: +kleene_335: # * # / # '_' # ':' # loc_push error_push - call choice_338 + call choice_333 error_pop_merge - fail! jump failed_341 + fail! jump failed_336 loc_pop_discard - jump kleene_340 + jump kleene_335 -failed_341: +failed_336: loc_pop_rewind status_ok return -choice_338: +choice_333: # / # '_' # ':' # @@ -2858,37 +2818,37 @@ input_next "t _" ok! test_char "_" error_pop_merge - ok! jump oknoast_337 + ok! jump oknoast_332 loc_pop_rewind loc_push error_push input_next "t :" ok! test_char ":" error_pop_merge - ok! jump oknoast_337 + ok! jump oknoast_332 loc_pop_rewind loc_push error_push input_next "alnum" ok! test_alnum error_pop_merge - ok! jump oknoast_337 + ok! jump oknoast_332 loc_pop_rewind status_fail return -oknoast_337: +oknoast_332: loc_pop_discard return # # value Symbol 'Identifier' # @@ -2897,28 +2857,28 @@ # x # (Ident) # (WHITESPACE) symbol_restore Identifier - found! jump found_353 + found! jump found_348 loc_push ast_push - call sequence_350 + call sequence_345 fail! value_clear ok! value_reduce Identifier symbol_save Identifier error_nonterminal Identifier ast_pop_rewind loc_pop_discard -found_353: +found_348: ok! ast_value_push return -sequence_350: +sequence_345: # x # (Ident) # (WHITESPACE) ast_push @@ -2928,23 +2888,23 @@ error_push call sym_Ident error_pop_merge - fail! jump failed_351 + fail! jump failed_346 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_351 + fail! jump failed_346 ast_pop_discard loc_pop_discard return -failed_351: +failed_346: ast_pop_rewind loc_pop_rewind return # # void Symbol 'IS' @@ -2958,19 +2918,19 @@ symbol_restore IS found! return loc_push - call sequence_358 + call sequence_353 value_clear symbol_save IS error_nonterminal IS loc_pop_discard return -sequence_358: +sequence_353: # x # '<' # '-' # (WHITESPACE) @@ -2981,29 +2941,29 @@ input_next "t <" ok! test_char "<" error_pop_merge - fail! jump failed_359 + fail! jump failed_354 error_push input_next "t -" ok! test_char "-" error_pop_merge - fail! jump failed_359 + fail! jump failed_354 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_359 + fail! jump failed_354 loc_pop_discard return -failed_359: +failed_354: loc_pop_rewind return # # leaf Symbol 'LEAF' # @@ -3015,26 +2975,26 @@ # 'a' # 'f' # (WHITESPACE) symbol_restore LEAF - found! jump found_370 + found! jump found_365 loc_push - call sequence_367 + call sequence_362 fail! value_clear ok! value_leaf LEAF symbol_save LEAF error_nonterminal LEAF loc_pop_discard -found_370: +found_365: ok! ast_value_push return -sequence_367: +sequence_362: # x # 'l' # 'e' # 'a' # 'f' @@ -3047,43 +3007,43 @@ input_next "t l" ok! test_char "l" error_pop_merge - fail! jump failed_368 + fail! jump failed_363 error_push input_next "t e" ok! test_char "e" error_pop_merge - fail! jump failed_368 + fail! jump failed_363 error_push input_next "t a" ok! test_char "a" error_pop_merge - fail! jump failed_368 + fail! jump failed_363 error_push input_next "t f" ok! test_char "f" error_pop_merge - fail! jump failed_368 + fail! jump failed_363 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_368 + fail! jump failed_363 loc_pop_discard return -failed_368: +failed_363: loc_pop_rewind return # # value Symbol 'Literal' # @@ -3108,28 +3068,28 @@ # (Char) # (DAPOSTROPH) # (WHITESPACE) symbol_restore Literal - found! jump found_411 + found! jump found_406 loc_push ast_push - call choice_409 + call choice_404 fail! value_clear ok! value_reduce Literal symbol_save Literal error_nonterminal Literal ast_pop_rewind loc_pop_discard -found_411: +found_406: ok! ast_value_push return -choice_409: +choice_404: # / # x # (APOSTROPH) # * # x @@ -3152,37 +3112,37 @@ ast_push loc_push error_push - call sequence_386 + call sequence_381 error_pop_merge - ok! jump ok_408 + ok! jump ok_403 ast_pop_rewind loc_pop_rewind ast_push loc_push error_push - call sequence_404 + call sequence_399 error_pop_merge - ok! jump ok_408 + ok! jump ok_403 ast_pop_rewind loc_pop_rewind status_fail return -ok_408: +ok_403: ast_pop_discard loc_pop_discard return -sequence_386: +sequence_381: # x # (APOSTROPH) # * # x # ! @@ -3197,65 +3157,65 @@ error_push call sym_APOSTROPH error_pop_merge - fail! jump failednoast_388 + fail! jump failednoast_383 ast_push error_push - call kleene_381 + call kleene_376 error_pop_merge - fail! jump failed_387 + fail! jump failed_382 error_push call sym_APOSTROPH error_pop_merge - fail! jump failed_387 + fail! jump failed_382 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_387 + fail! jump failed_382 ast_pop_discard loc_pop_discard return -failed_387: +failed_382: ast_pop_rewind -failednoast_388: +failednoast_383: loc_pop_rewind return -kleene_381: +kleene_376: # * # x # ! # (APOSTROPH) # (Char) loc_push error_push - call sequence_377 + call sequence_372 error_pop_merge - fail! jump failed_382 + fail! jump failed_377 loc_pop_discard - jump kleene_381 + jump kleene_376 -failed_382: +failed_377: loc_pop_rewind status_ok return -sequence_377: +sequence_372: # x # ! # (APOSTROPH) # (Char) @@ -3262,34 +3222,34 @@ loc_push error_clear error_push - call notahead_374 + call notahead_369 error_pop_merge - fail! jump failednoast_379 + fail! jump failednoast_374 ast_push error_push call sym_Char error_pop_merge - fail! jump failed_378 + fail! jump failed_373 ast_pop_discard loc_pop_discard return -failed_378: +failed_373: ast_pop_rewind -failednoast_379: +failednoast_374: loc_pop_rewind return -notahead_374: +notahead_369: # ! # (APOSTROPH) loc_push @@ -3297,11 +3257,11 @@ loc_pop_rewind status_negate return -sequence_404: +sequence_399: # x # (DAPOSTROPH) # * # x # ! @@ -3316,65 +3276,65 @@ error_push call sym_DAPOSTROPH error_pop_merge - fail! jump failednoast_406 + fail! jump failednoast_401 ast_push error_push - call kleene_399 + call kleene_394 error_pop_merge - fail! jump failed_405 + fail! jump failed_400 error_push call sym_DAPOSTROPH error_pop_merge - fail! jump failed_405 + fail! jump failed_400 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_405 + fail! jump failed_400 ast_pop_discard loc_pop_discard return -failed_405: +failed_400: ast_pop_rewind -failednoast_406: +failednoast_401: loc_pop_rewind return -kleene_399: +kleene_394: # * # x # ! # (DAPOSTROPH) # (Char) loc_push error_push - call sequence_395 + call sequence_390 error_pop_merge - fail! jump failed_400 + fail! jump failed_395 loc_pop_discard - jump kleene_399 + jump kleene_394 -failed_400: +failed_395: loc_pop_rewind status_ok return -sequence_395: +sequence_390: # x # ! # (DAPOSTROPH) # (Char) @@ -3381,34 +3341,34 @@ loc_push error_clear error_push - call notahead_392 + call notahead_387 error_pop_merge - fail! jump failednoast_397 + fail! jump failednoast_392 ast_push error_push call sym_Char error_pop_merge - fail! jump failed_396 + fail! jump failed_391 ast_pop_discard loc_pop_discard return -failed_396: +failed_391: ast_pop_rewind -failednoast_397: +failednoast_392: loc_pop_rewind return -notahead_392: +notahead_387: # ! # (DAPOSTROPH) loc_push @@ -3431,26 +3391,26 @@ # 'r' # '>' # (WHITESPACE) symbol_restore LOWER - found! jump found_424 + found! jump found_419 loc_push - call sequence_421 + call sequence_416 fail! value_clear ok! value_leaf LOWER symbol_save LOWER error_nonterminal LOWER loc_pop_discard -found_424: +found_419: ok! ast_value_push return -sequence_421: +sequence_416: # x # '<' # 'l' # 'o' # 'w' @@ -3466,64 +3426,64 @@ input_next "t <" ok! test_char "<" error_pop_merge - fail! jump failed_422 + fail! jump failed_417 error_push input_next "t l" ok! test_char "l" error_pop_merge - fail! jump failed_422 + fail! jump failed_417 error_push input_next "t o" ok! test_char "o" error_pop_merge - fail! jump failed_422 + fail! jump failed_417 error_push input_next "t w" ok! test_char "w" error_pop_merge - fail! jump failed_422 + fail! jump failed_417 error_push input_next "t e" ok! test_char "e" error_pop_merge - fail! jump failed_422 + fail! jump failed_417 error_push input_next "t r" ok! test_char "r" error_pop_merge - fail! jump failed_422 + fail! jump failed_417 error_push input_next "t >" ok! test_char ">" error_pop_merge - fail! jump failed_422 + fail! jump failed_417 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_422 + fail! jump failed_417 loc_pop_discard return -failed_422: +failed_417: loc_pop_rewind return # # leaf Symbol 'NOT' # @@ -3532,26 +3492,26 @@ # x # '!' # (WHITESPACE) symbol_restore NOT - found! jump found_431 + found! jump found_426 loc_push - call sequence_428 + call sequence_423 fail! value_clear ok! value_leaf NOT symbol_save NOT error_nonterminal NOT loc_pop_discard -found_431: +found_426: ok! ast_value_push return -sequence_428: +sequence_423: # x # '!' # (WHITESPACE) loc_push @@ -3561,22 +3521,22 @@ input_next "t !" ok! test_char "!" error_pop_merge - fail! jump failed_429 + fail! jump failed_424 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_429 + fail! jump failed_424 loc_pop_discard return -failed_429: +failed_424: loc_pop_rewind return # # void Symbol 'OPEN' # @@ -3588,19 +3548,19 @@ symbol_restore OPEN found! return loc_push - call sequence_435 + call sequence_430 value_clear symbol_save OPEN error_nonterminal OPEN loc_pop_discard return -sequence_435: +sequence_430: # x # '\(' # (WHITESPACE) loc_push @@ -3610,22 +3570,22 @@ input_next "t (" ok! test_char "(" error_pop_merge - fail! jump failed_436 + fail! jump failed_431 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_436 + fail! jump failed_431 loc_pop_discard return -failed_436: +failed_431: loc_pop_rewind return # # void Symbol 'OPENB' # @@ -3652,29 +3612,39 @@ sym_PEG: # x # 'P' # 'E' # 'G' +# ! +# / +# '_' +# ':' +# # (WHITESPACE) symbol_restore PEG found! return loc_push - call sequence_445 + call sequence_447 value_clear symbol_save PEG error_nonterminal PEG loc_pop_discard return -sequence_445: +sequence_447: # x # 'P' # 'E' # 'G' +# ! +# / +# '_' +# ':' +# # (WHITESPACE) loc_push error_clear @@ -3682,37 +3652,58 @@ input_next "t P" ok! test_char "P" error_pop_merge - fail! jump failed_446 + fail! jump failed_448 error_push input_next "t E" ok! test_char "E" error_pop_merge - fail! jump failed_446 + fail! jump failed_448 error_push input_next "t G" ok! test_char "G" error_pop_merge - fail! jump failed_446 + fail! jump failed_448 + error_push + + call notahead_444 + + error_pop_merge + fail! jump failed_448 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_446 + fail! jump failed_448 loc_pop_discard return -failed_446: +failed_448: + loc_pop_rewind + return + +notahead_444: +# ! +# / +# '_' +# ':' +# + + loc_push + + call choice_333 + loc_pop_rewind + status_negate return # # leaf Symbol 'PLUS' # @@ -3720,26 +3711,26 @@ # x # '+' # (WHITESPACE) symbol_restore PLUS - found! jump found_454 + found! jump found_456 loc_push - call sequence_451 + call sequence_453 fail! value_clear ok! value_leaf PLUS symbol_save PLUS error_nonterminal PLUS loc_pop_discard -found_454: +found_456: ok! ast_value_push return -sequence_451: +sequence_453: # x # '+' # (WHITESPACE) loc_push @@ -3749,22 +3740,22 @@ input_next "t +" ok! test_char "+" error_pop_merge - fail! jump failed_452 + fail! jump failed_454 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_452 + fail! jump failed_454 loc_pop_discard return -failed_452: +failed_454: loc_pop_rewind return # # value Symbol 'Prefix' # @@ -3776,28 +3767,28 @@ # (AND) # (NOT) # (Suffix) symbol_restore Prefix - found! jump found_467 + found! jump found_469 loc_push ast_push - call sequence_464 + call sequence_466 fail! value_clear ok! value_reduce Prefix symbol_save Prefix error_nonterminal Prefix ast_pop_rewind loc_pop_discard -found_467: +found_469: ok! ast_value_push return -sequence_464: +sequence_466: # x # ? # / # (AND) # (NOT) @@ -3807,48 +3798,48 @@ loc_push error_clear error_push - call optional_461 + call optional_463 error_pop_merge - fail! jump failed_465 + fail! jump failed_467 error_push call sym_Suffix error_pop_merge - fail! jump failed_465 + fail! jump failed_467 ast_pop_discard loc_pop_discard return -failed_465: +failed_467: ast_pop_rewind loc_pop_rewind return -optional_461: +optional_463: # ? # / # (AND) # (NOT) loc_push error_push - call choice_459 + call choice_461 error_pop_merge fail! loc_pop_rewind ok! loc_pop_discard status_ok return -choice_459: +choice_461: # / # (AND) # (NOT) error_clear @@ -3858,11 +3849,11 @@ error_push call sym_AND error_pop_merge - ok! jump ok_458 + ok! jump ok_460 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -3869,18 +3860,18 @@ error_push call sym_NOT error_pop_merge - ok! jump ok_458 + ok! jump ok_460 ast_pop_rewind loc_pop_rewind status_fail return -ok_458: +ok_460: ast_pop_discard loc_pop_discard return # # value Symbol 'Primary' @@ -3910,28 +3901,28 @@ # (Literal) # (Class) # (DOT) symbol_restore Primary - found! jump found_497 + found! jump found_499 loc_push ast_push - call choice_495 + call choice_497 fail! value_clear ok! value_reduce Primary symbol_save Primary error_nonterminal Primary ast_pop_rewind loc_pop_discard -found_497: +found_499: ok! ast_value_push return -choice_495: +choice_497: # / # (ALNUM) # (ALPHA) # (ASCII) # (CONTROL) @@ -3961,11 +3952,11 @@ error_push call sym_ALNUM error_pop_merge - ok! jump ok_494 + ok! jump ok_496 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -3972,11 +3963,11 @@ error_push call sym_ALPHA error_pop_merge - ok! jump ok_494 + ok! jump ok_496 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -3983,11 +3974,11 @@ error_push call sym_ASCII error_pop_merge - ok! jump ok_494 + ok! jump ok_496 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -3994,11 +3985,11 @@ error_push call sym_CONTROL error_pop_merge - ok! jump ok_494 + ok! jump ok_496 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4005,11 +3996,11 @@ error_push call sym_DDIGIT error_pop_merge - ok! jump ok_494 + ok! jump ok_496 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4016,11 +4007,11 @@ error_push call sym_DIGIT error_pop_merge - ok! jump ok_494 + ok! jump ok_496 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4027,11 +4018,11 @@ error_push call sym_GRAPH error_pop_merge - ok! jump ok_494 + ok! jump ok_496 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4038,11 +4029,11 @@ error_push call sym_LOWER error_pop_merge - ok! jump ok_494 + ok! jump ok_496 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4049,11 +4040,11 @@ error_push call sym_PRINTABLE error_pop_merge - ok! jump ok_494 + ok! jump ok_496 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4060,11 +4051,11 @@ error_push call sym_PUNCT error_pop_merge - ok! jump ok_494 + ok! jump ok_496 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4071,11 +4062,11 @@ error_push call sym_SPACE error_pop_merge - ok! jump ok_494 + ok! jump ok_496 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4082,11 +4073,11 @@ error_push call sym_UPPER error_pop_merge - ok! jump ok_494 + ok! jump ok_496 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4093,11 +4084,11 @@ error_push call sym_WORDCHAR error_pop_merge - ok! jump ok_494 + ok! jump ok_496 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4104,11 +4095,11 @@ error_push call sym_XDIGIT error_pop_merge - ok! jump ok_494 + ok! jump ok_496 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4115,22 +4106,22 @@ error_push call sym_Identifier error_pop_merge - ok! jump ok_494 + ok! jump ok_496 ast_pop_rewind loc_pop_rewind ast_push loc_push error_push - call sequence_487 + call sequence_489 error_pop_merge - ok! jump ok_494 + ok! jump ok_496 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4137,11 +4128,11 @@ error_push call sym_Literal error_pop_merge - ok! jump ok_494 + ok! jump ok_496 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4148,11 +4139,11 @@ error_push call sym_Class error_pop_merge - ok! jump ok_494 + ok! jump ok_496 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4159,23 +4150,23 @@ error_push call sym_DOT error_pop_merge - ok! jump ok_494 + ok! jump ok_496 ast_pop_rewind loc_pop_rewind status_fail return -ok_494: +ok_496: ast_pop_discard loc_pop_discard return -sequence_487: +sequence_489: # x # (OPEN) # (Expression) # (CLOSE) @@ -4185,33 +4176,33 @@ error_push call sym_OPEN error_pop_merge - fail! jump failednoast_489 + fail! jump failednoast_491 ast_push error_push call sym_Expression error_pop_merge - fail! jump failed_488 + fail! jump failed_490 error_push call sym_CLOSE error_pop_merge - fail! jump failed_488 + fail! jump failed_490 ast_pop_discard loc_pop_discard return -failed_488: +failed_490: ast_pop_rewind -failednoast_489: +failednoast_491: loc_pop_rewind return # # leaf Symbol 'PRINTABLE' # @@ -4226,26 +4217,26 @@ # 't' # '>' # (WHITESPACE) symbol_restore PRINTABLE - found! jump found_510 + found! jump found_512 loc_push - call sequence_507 + call sequence_509 fail! value_clear ok! value_leaf PRINTABLE symbol_save PRINTABLE error_nonterminal PRINTABLE loc_pop_discard -found_510: +found_512: ok! ast_value_push return -sequence_507: +sequence_509: # x # '<' # 'p' # 'r' # 'i' @@ -4261,64 +4252,64 @@ input_next "t <" ok! test_char "<" error_pop_merge - fail! jump failed_508 + fail! jump failed_510 error_push input_next "t p" ok! test_char "p" error_pop_merge - fail! jump failed_508 + fail! jump failed_510 error_push input_next "t r" ok! test_char "r" error_pop_merge - fail! jump failed_508 + fail! jump failed_510 error_push input_next "t i" ok! test_char "i" error_pop_merge - fail! jump failed_508 + fail! jump failed_510 error_push input_next "t n" ok! test_char "n" error_pop_merge - fail! jump failed_508 + fail! jump failed_510 error_push input_next "t t" ok! test_char "t" error_pop_merge - fail! jump failed_508 + fail! jump failed_510 error_push input_next "t >" ok! test_char ">" error_pop_merge - fail! jump failed_508 + fail! jump failed_510 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_508 + fail! jump failed_510 loc_pop_discard return -failed_508: +failed_510: loc_pop_rewind return # # leaf Symbol 'PUNCT' # @@ -4333,26 +4324,26 @@ # 't' # '>' # (WHITESPACE) symbol_restore PUNCT - found! jump found_523 + found! jump found_525 loc_push - call sequence_520 + call sequence_522 fail! value_clear ok! value_leaf PUNCT symbol_save PUNCT error_nonterminal PUNCT loc_pop_discard -found_523: +found_525: ok! ast_value_push return -sequence_520: +sequence_522: # x # '<' # 'p' # 'u' # 'n' @@ -4368,64 +4359,64 @@ input_next "t <" ok! test_char "<" error_pop_merge - fail! jump failed_521 + fail! jump failed_523 error_push input_next "t p" ok! test_char "p" error_pop_merge - fail! jump failed_521 + fail! jump failed_523 error_push input_next "t u" ok! test_char "u" error_pop_merge - fail! jump failed_521 + fail! jump failed_523 error_push input_next "t n" ok! test_char "n" error_pop_merge - fail! jump failed_521 + fail! jump failed_523 error_push input_next "t c" ok! test_char "c" error_pop_merge - fail! jump failed_521 + fail! jump failed_523 error_push input_next "t t" ok! test_char "t" error_pop_merge - fail! jump failed_521 + fail! jump failed_523 error_push input_next "t >" ok! test_char ">" error_pop_merge - fail! jump failed_521 + fail! jump failed_523 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_521 + fail! jump failed_523 loc_pop_discard return -failed_521: +failed_523: loc_pop_rewind return # # leaf Symbol 'QUESTION' # @@ -4434,26 +4425,26 @@ # x # '?' # (WHITESPACE) symbol_restore QUESTION - found! jump found_530 + found! jump found_532 loc_push - call sequence_527 + call sequence_529 fail! value_clear ok! value_leaf QUESTION symbol_save QUESTION error_nonterminal QUESTION loc_pop_discard -found_530: +found_532: ok! ast_value_push return -sequence_527: +sequence_529: # x # '?' # (WHITESPACE) loc_push @@ -4463,22 +4454,22 @@ input_next "t ?" ok! test_char "?" error_pop_merge - fail! jump failed_528 + fail! jump failed_530 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_528 + fail! jump failed_530 loc_pop_discard return -failed_528: +failed_530: loc_pop_rewind return # # value Symbol 'Range' # @@ -4490,28 +4481,28 @@ # (TO) # (Char) # (Char) symbol_restore Range - found! jump found_542 + found! jump found_544 loc_push ast_push - call choice_540 + call choice_542 fail! value_clear ok! value_reduce Range symbol_save Range error_nonterminal Range ast_pop_rewind loc_pop_discard -found_542: +found_544: ok! ast_value_push return -choice_540: +choice_542: # / # x # (Char) # (TO) # (Char) @@ -4521,14 +4512,14 @@ ast_push loc_push error_push - call sequence_535 + call sequence_537 error_pop_merge - ok! jump ok_539 + ok! jump ok_541 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -4535,23 +4526,23 @@ error_push call sym_Char error_pop_merge - ok! jump ok_539 + ok! jump ok_541 ast_pop_rewind loc_pop_rewind status_fail return -ok_539: +ok_541: ast_pop_discard loc_pop_discard return -sequence_535: +sequence_537: # x # (Char) # (TO) # (Char) @@ -4562,29 +4553,29 @@ error_push call sym_Char error_pop_merge - fail! jump failed_536 + fail! jump failed_538 error_push call sym_TO error_pop_merge - fail! jump failed_536 + fail! jump failed_538 error_push call sym_Char error_pop_merge - fail! jump failed_536 + fail! jump failed_538 ast_pop_discard loc_pop_discard return -failed_536: +failed_538: ast_pop_rewind loc_pop_rewind return # # void Symbol 'SEMICOLON' @@ -4597,19 +4588,19 @@ symbol_restore SEMICOLON found! return loc_push - call sequence_546 + call sequence_548 value_clear symbol_save SEMICOLON error_nonterminal SEMICOLON loc_pop_discard return -sequence_546: +sequence_548: # x # ';' # (WHITESPACE) loc_push @@ -4619,22 +4610,22 @@ input_next "t ;" ok! test_char ";" error_pop_merge - fail! jump failed_547 + fail! jump failed_549 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_547 + fail! jump failed_549 loc_pop_discard return -failed_547: +failed_549: loc_pop_rewind return # # value Symbol 'Sequence' # @@ -4642,49 +4633,49 @@ sym_Sequence: # + # (Prefix) symbol_restore Sequence - found! jump found_555 + found! jump found_557 loc_push ast_push - call poskleene_551 + call poskleene_553 fail! value_clear ok! value_reduce Sequence symbol_save Sequence error_nonterminal Sequence ast_pop_rewind loc_pop_discard -found_555: +found_557: ok! ast_value_push return -poskleene_551: +poskleene_553: # + # (Prefix) loc_push call sym_Prefix - fail! jump failed_552 + fail! jump failed_554 -loop_553: +loop_555: loc_pop_discard loc_push error_push call sym_Prefix error_pop_merge - ok! jump loop_553 + ok! jump loop_555 status_ok -failed_552: +failed_554: loc_pop_rewind return # # void Symbol 'SLASH' # @@ -4696,19 +4687,19 @@ symbol_restore SLASH found! return loc_push - call sequence_559 + call sequence_561 value_clear symbol_save SLASH error_nonterminal SLASH loc_pop_discard return -sequence_559: +sequence_561: # x # '/' # (WHITESPACE) loc_push @@ -4718,22 +4709,22 @@ input_next "t /" ok! test_char "/" error_pop_merge - fail! jump failed_560 + fail! jump failed_562 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_560 + fail! jump failed_562 loc_pop_discard return -failed_560: +failed_562: loc_pop_rewind return # # leaf Symbol 'SPACE' # @@ -4748,26 +4739,26 @@ # 'e' # '>' # (WHITESPACE) symbol_restore SPACE - found! jump found_574 + found! jump found_576 loc_push - call sequence_571 + call sequence_573 fail! value_clear ok! value_leaf SPACE symbol_save SPACE error_nonterminal SPACE loc_pop_discard -found_574: +found_576: ok! ast_value_push return -sequence_571: +sequence_573: # x # '<' # 's' # 'p' # 'a' @@ -4783,64 +4774,64 @@ input_next "t <" ok! test_char "<" error_pop_merge - fail! jump failed_572 + fail! jump failed_574 error_push input_next "t s" ok! test_char "s" error_pop_merge - fail! jump failed_572 + fail! jump failed_574 error_push input_next "t p" ok! test_char "p" error_pop_merge - fail! jump failed_572 + fail! jump failed_574 error_push input_next "t a" ok! test_char "a" error_pop_merge - fail! jump failed_572 + fail! jump failed_574 error_push input_next "t c" ok! test_char "c" error_pop_merge - fail! jump failed_572 + fail! jump failed_574 error_push input_next "t e" ok! test_char "e" error_pop_merge - fail! jump failed_572 + fail! jump failed_574 error_push input_next "t >" ok! test_char ">" error_pop_merge - fail! jump failed_572 + fail! jump failed_574 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_572 + fail! jump failed_574 loc_pop_discard return -failed_572: +failed_574: loc_pop_rewind return # # leaf Symbol 'STAR' # @@ -4849,26 +4840,26 @@ # x # '*' # (WHITESPACE) symbol_restore STAR - found! jump found_581 + found! jump found_583 loc_push - call sequence_578 + call sequence_580 fail! value_clear ok! value_leaf STAR symbol_save STAR error_nonterminal STAR loc_pop_discard -found_581: +found_583: ok! ast_value_push return -sequence_578: +sequence_580: # x # '*' # (WHITESPACE) loc_push @@ -4878,22 +4869,22 @@ input_next "t *" ok! test_char "*" error_pop_merge - fail! jump failed_579 + fail! jump failed_581 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_579 + fail! jump failed_581 loc_pop_discard return -failed_579: +failed_581: loc_pop_rewind return # # value Symbol 'StartExpr' # @@ -4903,24 +4894,24 @@ # (OPEN) # (Expression) # (CLOSE) symbol_restore StartExpr - found! jump found_587 + found! jump found_589 loc_push ast_push - call sequence_487 + call sequence_489 fail! value_clear ok! value_reduce StartExpr symbol_save StartExpr error_nonterminal StartExpr ast_pop_rewind loc_pop_discard -found_587: +found_589: ok! ast_value_push return # # value Symbol 'Suffix' # @@ -4933,28 +4924,28 @@ # (QUESTION) # (STAR) # (PLUS) symbol_restore Suffix - found! jump found_601 + found! jump found_603 loc_push ast_push - call sequence_598 + call sequence_600 fail! value_clear ok! value_reduce Suffix symbol_save Suffix error_nonterminal Suffix ast_pop_rewind loc_pop_discard -found_601: +found_603: ok! ast_value_push return -sequence_598: +sequence_600: # x # (Primary) # ? # / # (QUESTION) @@ -4968,46 +4959,46 @@ error_push call sym_Primary error_pop_merge - fail! jump failed_599 + fail! jump failed_601 error_push - call optional_596 + call optional_598 error_pop_merge - fail! jump failed_599 + fail! jump failed_601 ast_pop_discard loc_pop_discard return -failed_599: +failed_601: ast_pop_rewind loc_pop_rewind return -optional_596: +optional_598: # ? # / # (QUESTION) # (STAR) # (PLUS) loc_push error_push - call choice_594 + call choice_596 error_pop_merge fail! loc_pop_rewind ok! loc_pop_discard status_ok return -choice_594: +choice_596: # / # (QUESTION) # (STAR) # (PLUS) @@ -5018,11 +5009,11 @@ error_push call sym_QUESTION error_pop_merge - ok! jump ok_593 + ok! jump ok_595 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -5029,11 +5020,11 @@ error_push call sym_STAR error_pop_merge - ok! jump ok_593 + ok! jump ok_595 ast_pop_rewind loc_pop_rewind ast_push loc_push @@ -5040,18 +5031,18 @@ error_push call sym_PLUS error_pop_merge - ok! jump ok_593 + ok! jump ok_595 ast_pop_rewind loc_pop_rewind status_fail return -ok_593: +ok_595: ast_pop_discard loc_pop_discard return # # void Symbol 'TO' @@ -5086,26 +5077,26 @@ # 'r' # '>' # (WHITESPACE) symbol_restore UPPER - found! jump found_616 + found! jump found_618 loc_push - call sequence_613 + call sequence_615 fail! value_clear ok! value_leaf UPPER symbol_save UPPER error_nonterminal UPPER loc_pop_discard -found_616: +found_618: ok! ast_value_push return -sequence_613: +sequence_615: # x # '<' # 'u' # 'p' # 'p' @@ -5121,64 +5112,64 @@ input_next "t <" ok! test_char "<" error_pop_merge - fail! jump failed_614 + fail! jump failed_616 error_push input_next "t u" ok! test_char "u" error_pop_merge - fail! jump failed_614 + fail! jump failed_616 error_push input_next "t p" ok! test_char "p" error_pop_merge - fail! jump failed_614 + fail! jump failed_616 error_push input_next "t p" ok! test_char "p" error_pop_merge - fail! jump failed_614 + fail! jump failed_616 error_push input_next "t e" ok! test_char "e" error_pop_merge - fail! jump failed_614 + fail! jump failed_616 error_push input_next "t r" ok! test_char "r" error_pop_merge - fail! jump failed_614 + fail! jump failed_616 error_push input_next "t >" ok! test_char ">" error_pop_merge - fail! jump failed_614 + fail! jump failed_616 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_614 + fail! jump failed_616 loc_pop_discard return -failed_614: +failed_616: loc_pop_rewind return # # leaf Symbol 'VOID' # @@ -5190,26 +5181,26 @@ # 'i' # 'd' # (WHITESPACE) symbol_restore VOID - found! jump found_626 + found! jump found_628 loc_push - call sequence_623 + call sequence_625 fail! value_clear ok! value_leaf VOID symbol_save VOID error_nonterminal VOID loc_pop_discard -found_626: +found_628: ok! ast_value_push return -sequence_623: +sequence_625: # x # 'v' # 'o' # 'i' # 'd' @@ -5222,43 +5213,43 @@ input_next "t v" ok! test_char "v" error_pop_merge - fail! jump failed_624 + fail! jump failed_626 error_push input_next "t o" ok! test_char "o" error_pop_merge - fail! jump failed_624 + fail! jump failed_626 error_push input_next "t i" ok! test_char "i" error_pop_merge - fail! jump failed_624 + fail! jump failed_626 error_push input_next "t d" ok! test_char "d" error_pop_merge - fail! jump failed_624 + fail! jump failed_626 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_624 + fail! jump failed_626 loc_pop_discard return -failed_624: +failed_626: loc_pop_rewind return # # void Symbol 'WHITESPACE' # @@ -5271,40 +5262,40 @@ symbol_restore WHITESPACE found! return loc_push - call kleene_633 + call kleene_635 value_clear symbol_save WHITESPACE error_nonterminal WHITESPACE loc_pop_discard return -kleene_633: +kleene_635: # * # / # # (COMMENT) loc_push error_push - call choice_631 + call choice_633 error_pop_merge - fail! jump failed_634 + fail! jump failed_636 loc_pop_discard - jump kleene_633 + jump kleene_635 -failed_634: +failed_636: loc_pop_rewind status_ok return -choice_631: +choice_633: # / # # (COMMENT) error_clear @@ -5314,26 +5305,26 @@ input_next "space" ok! test_space error_pop_merge - ok! jump oknoast_630 + ok! jump oknoast_632 loc_pop_rewind loc_push error_push call sym_COMMENT error_pop_merge - ok! jump oknoast_630 + ok! jump oknoast_632 loc_pop_rewind status_fail return -oknoast_630: +oknoast_632: loc_pop_discard return # # leaf Symbol 'WORDCHAR' # @@ -5351,26 +5342,26 @@ # 'r' # '>' # (WHITESPACE) symbol_restore WORDCHAR - found! jump found_651 + found! jump found_653 loc_push - call sequence_648 + call sequence_650 fail! value_clear ok! value_leaf WORDCHAR symbol_save WORDCHAR error_nonterminal WORDCHAR loc_pop_discard -found_651: +found_653: ok! ast_value_push return -sequence_648: +sequence_650: # x # '<' # 'w' # 'o' # 'r' @@ -5389,85 +5380,85 @@ input_next "t <" ok! test_char "<" error_pop_merge - fail! jump failed_649 + fail! jump failed_651 error_push input_next "t w" ok! test_char "w" error_pop_merge - fail! jump failed_649 + fail! jump failed_651 error_push input_next "t o" ok! test_char "o" error_pop_merge - fail! jump failed_649 + fail! jump failed_651 error_push input_next "t r" ok! test_char "r" error_pop_merge - fail! jump failed_649 + fail! jump failed_651 error_push input_next "t d" ok! test_char "d" error_pop_merge - fail! jump failed_649 + fail! jump failed_651 error_push input_next "t c" ok! test_char "c" error_pop_merge - fail! jump failed_649 + fail! jump failed_651 error_push input_next "t h" ok! test_char "h" error_pop_merge - fail! jump failed_649 + fail! jump failed_651 error_push input_next "t a" ok! test_char "a" error_pop_merge - fail! jump failed_649 + fail! jump failed_651 error_push input_next "t r" ok! test_char "r" error_pop_merge - fail! jump failed_649 + fail! jump failed_651 error_push input_next "t >" ok! test_char ">" error_pop_merge - fail! jump failed_649 + fail! jump failed_651 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_649 + fail! jump failed_651 loc_pop_discard return -failed_649: +failed_651: loc_pop_rewind return # # leaf Symbol 'XDIGIT' # @@ -5483,26 +5474,26 @@ # 't' # '>' # (WHITESPACE) symbol_restore XDIGIT - found! jump found_665 + found! jump found_667 loc_push - call sequence_662 + call sequence_664 fail! value_clear ok! value_leaf XDIGIT symbol_save XDIGIT error_nonterminal XDIGIT loc_pop_discard -found_665: +found_667: ok! ast_value_push return -sequence_662: +sequence_664: # x # '<' # 'x' # 'd' # 'i' @@ -5519,71 +5510,71 @@ input_next "t <" ok! test_char "<" error_pop_merge - fail! jump failed_663 + fail! jump failed_665 error_push input_next "t x" ok! test_char "x" error_pop_merge - fail! jump failed_663 + fail! jump failed_665 error_push input_next "t d" ok! test_char "d" error_pop_merge - fail! jump failed_663 + fail! jump failed_665 error_push input_next "t i" ok! test_char "i" error_pop_merge - fail! jump failed_663 + fail! jump failed_665 error_push input_next "t g" ok! test_char "g" error_pop_merge - fail! jump failed_663 + fail! jump failed_665 error_push input_next "t i" ok! test_char "i" error_pop_merge - fail! jump failed_663 + fail! jump failed_665 error_push input_next "t t" ok! test_char "t" error_pop_merge - fail! jump failed_663 + fail! jump failed_665 error_push input_next "t >" ok! test_char ">" error_pop_merge - fail! jump failed_663 + fail! jump failed_665 error_push call sym_WHITESPACE error_pop_merge - fail! jump failed_663 + fail! jump failed_665 loc_pop_discard return -failed_663: +failed_665: loc_pop_rewind return # # Index: modules/pt/tests/data/ok/peg_peg-ast-fused/3_peg_itself ================================================================== --- modules/pt/tests/data/ok/peg_peg-ast-fused/3_peg_itself +++ modules/pt/tests/data/ok/peg_peg-ast-fused/3_peg_itself @@ -1,6 +1,6 @@ - :: 0 3043 + :: 0 3032
              :: 0 27 :: 4 16 :: 4 15 :: 17 27 :: 18 24 @@ -642,1046 +642,1055 @@ :: 1112 1122 :: 1112 1122 :: 1112 1122 :: 1112 1122 :: 1112 1121 - :: 1125 1166 + :: 1125 1152 :: 1125 1130 :: 1125 1128 :: 1131 1144 :: 1131 1133 - :: 1148 1164 - :: 1148 1164 - :: 1148 1153 - :: 1148 1153 - :: 1148 1153 - :: 1148 1153 - :: 1149 1149 - :: 1149 1149 - :: 1150 1150 - :: 1150 1150 - :: 1151 1151 - :: 1151 1151 - :: 1154 1164 - :: 1154 1164 - :: 1154 1164 - :: 1154 1164 - :: 1154 1163 - :: 1167 1194 - :: 1167 1172 - :: 1167 1170 - :: 1173 1186 - :: 1173 1175 - :: 1190 1192 - :: 1190 1192 - :: 1190 1192 - :: 1190 1190 - :: 1191 1192 - :: 1191 1192 - :: 1191 1192 - :: 1195 1232 - :: 1195 1200 - :: 1195 1198 - :: 1201 1214 - :: 1201 1203 - :: 1218 1224 - :: 1218 1224 - :: 1218 1224 - :: 1218 1224 - :: 1218 1224 - :: 1218 1224 - :: 1219 1220 - :: 1219 1220 - :: 1219 1220 - :: 1221 1222 - :: 1221 1222 - :: 1221 1222 - :: 1233 1278 - :: 1233 1246 - :: 1233 1242 - :: 1250 1276 - :: 1250 1276 - :: 1250 1258 - :: 1250 1258 - :: 1250 1258 - :: 1250 1258 - :: 1250 1257 - :: 1259 1276 - :: 1259 1276 - :: 1259 1274 - :: 1260 1273 - :: 1260 1273 - :: 1260 1265 - :: 1260 1265 - :: 1260 1265 - :: 1260 1265 - :: 1260 1264 - :: 1266 1273 - :: 1266 1273 - :: 1266 1273 - :: 1266 1273 - :: 1266 1273 - :: 1275 1276 - :: 1279 1334 - :: 1279 1284 - :: 1279 1282 - :: 1285 1298 - :: 1285 1289 - :: 1302 1326 - :: 1302 1326 - :: 1302 1305 - :: 1302 1305 - :: 1302 1305 - :: 1302 1305 - :: 1302 1304 - :: 1306 1315 - :: 1306 1315 - :: 1306 1315 - :: 1306 1315 - :: 1306 1314 - :: 1316 1326 - :: 1316 1326 - :: 1316 1326 - :: 1316 1326 - :: 1316 1325 - :: 1335 1393 - :: 1335 1348 - :: 1335 1341 - :: 1352 1391 - :: 1352 1391 - :: 1352 1362 - :: 1352 1362 - :: 1352 1362 - :: 1352 1362 - :: 1352 1361 - :: 1363 1369 - :: 1363 1369 - :: 1363 1369 - :: 1363 1369 - :: 1363 1368 - :: 1370 1381 - :: 1370 1381 - :: 1370 1379 - :: 1370 1379 - :: 1370 1379 - :: 1380 1381 - :: 1382 1387 - :: 1382 1387 - :: 1382 1387 - :: 1382 1387 - :: 1382 1386 - :: 1388 1391 - :: 1388 1391 - :: 1388 1391 - :: 1388 1391 - :: 1388 1390 - :: 1394 1445 - :: 1394 1399 - :: 1394 1397 - :: 1400 1413 - :: 1400 1404 - :: 1417 1437 - :: 1417 1437 - :: 1417 1426 - :: 1417 1426 - :: 1417 1426 - :: 1417 1426 - :: 1418 1418 - :: 1418 1418 - :: 1419 1419 - :: 1419 1419 - :: 1420 1420 - :: 1420 1420 - :: 1421 1421 - :: 1421 1421 - :: 1422 1422 - :: 1422 1422 - :: 1423 1423 - :: 1423 1423 - :: 1424 1424 - :: 1424 1424 - :: 1427 1437 - :: 1427 1437 - :: 1427 1437 - :: 1427 1437 - :: 1427 1436 - :: 1446 1489 - :: 1446 1459 - :: 1446 1451 - :: 1463 1487 - :: 1463 1487 - :: 1463 1466 - :: 1463 1466 - :: 1463 1466 - :: 1463 1466 - :: 1463 1465 - :: 1467 1477 - :: 1467 1477 - :: 1467 1477 - :: 1467 1477 - :: 1467 1476 - :: 1478 1487 - :: 1478 1487 - :: 1478 1487 - :: 1478 1487 - :: 1478 1486 - :: 1490 1555 - :: 1490 1495 - :: 1490 1493 - :: 1496 1509 - :: 1496 1500 - :: 1513 1547 - :: 1513 1547 - :: 1513 1529 - :: 1513 1529 - :: 1513 1529 - :: 1514 1527 - :: 1514 1518 - :: 1514 1518 - :: 1514 1518 - :: 1514 1518 - :: 1514 1518 - :: 1515 1515 - :: 1515 1515 - :: 1515 1515 - :: 1516 1516 - :: 1516 1516 - :: 1516 1516 - :: 1521 1527 - :: 1521 1527 - :: 1521 1527 - :: 1521 1527 - :: 1521 1527 - :: 1530 1547 - :: 1530 1547 - :: 1530 1545 - :: 1531 1544 - :: 1531 1535 - :: 1531 1535 - :: 1531 1535 - :: 1531 1535 - :: 1531 1535 - :: 1532 1532 - :: 1532 1532 - :: 1532 1532 - :: 1533 1533 - :: 1533 1533 - :: 1533 1533 - :: 1538 1544 - :: 1538 1544 - :: 1538 1544 - :: 1538 1544 - :: 1538 1544 - :: 1546 1547 - :: 1556 1591 - :: 1556 1569 - :: 1556 1565 - :: 1573 1589 - :: 1573 1589 - :: 1573 1578 - :: 1573 1578 - :: 1573 1578 - :: 1573 1578 - :: 1573 1577 - :: 1579 1589 - :: 1579 1589 - :: 1579 1589 - :: 1579 1589 - :: 1579 1588 - :: 1592 1632 - :: 1592 1597 - :: 1592 1595 - :: 1598 1611 - :: 1598 1599 - :: 1615 1630 - :: 1615 1630 - :: 1615 1619 - :: 1615 1619 - :: 1615 1619 - :: 1615 1619 - :: 1616 1616 - :: 1616 1616 - :: 1617 1617 - :: 1617 1617 - :: 1620 1630 - :: 1620 1630 - :: 1620 1630 - :: 1620 1630 - :: 1620 1629 - :: 1633 1681 - :: 1633 1638 - :: 1633 1636 - :: 1639 1652 - :: 1639 1642 - :: 1656 1673 - :: 1656 1673 - :: 1656 1662 - :: 1656 1662 - :: 1656 1662 - :: 1656 1662 - :: 1657 1657 - :: 1657 1657 - :: 1658 1658 - :: 1658 1658 - :: 1659 1659 - :: 1659 1659 - :: 1660 1660 - :: 1660 1660 - :: 1663 1673 - :: 1663 1673 - :: 1663 1673 - :: 1663 1673 - :: 1663 1672 - :: 1682 1805 - :: 1682 1695 - :: 1682 1688 - :: 1699 1803 - :: 1699 1748 + :: 1148 1150 + :: 1148 1150 + :: 1148 1150 + :: 1148 1148 + :: 1149 1150 + :: 1149 1150 + :: 1149 1150 + :: 1153 1190 + :: 1153 1158 + :: 1153 1156 + :: 1159 1172 + :: 1159 1161 + :: 1176 1182 + :: 1176 1182 + :: 1176 1182 + :: 1176 1182 + :: 1176 1182 + :: 1176 1182 + :: 1177 1178 + :: 1177 1178 + :: 1177 1178 + :: 1179 1180 + :: 1179 1180 + :: 1179 1180 + :: 1191 1236 + :: 1191 1204 + :: 1191 1200 + :: 1208 1234 + :: 1208 1234 + :: 1208 1216 + :: 1208 1216 + :: 1208 1216 + :: 1208 1216 + :: 1208 1215 + :: 1217 1234 + :: 1217 1234 + :: 1217 1232 + :: 1218 1231 + :: 1218 1231 + :: 1218 1223 + :: 1218 1223 + :: 1218 1223 + :: 1218 1223 + :: 1218 1222 + :: 1224 1231 + :: 1224 1231 + :: 1224 1231 + :: 1224 1231 + :: 1224 1231 + :: 1233 1234 + :: 1237 1305 + :: 1237 1242 + :: 1237 1240 + :: 1243 1256 + :: 1243 1247 + :: 1260 1297 + :: 1260 1297 + :: 1260 1265 + :: 1260 1265 + :: 1260 1265 + :: 1260 1265 + :: 1261 1261 + :: 1261 1261 + :: 1262 1262 + :: 1262 1262 + :: 1263 1263 + :: 1263 1263 + :: 1266 1276 + :: 1266 1276 + :: 1266 1276 + :: 1266 1276 + :: 1266 1275 + :: 1277 1286 + :: 1277 1286 + :: 1277 1286 + :: 1277 1286 + :: 1277 1285 + :: 1287 1297 + :: 1287 1297 + :: 1287 1297 + :: 1287 1297 + :: 1287 1296 + :: 1306 1364 + :: 1306 1319 + :: 1306 1312 + :: 1323 1362 + :: 1323 1362 + :: 1323 1333 + :: 1323 1333 + :: 1323 1333 + :: 1323 1333 + :: 1323 1332 + :: 1334 1340 + :: 1334 1340 + :: 1334 1340 + :: 1334 1340 + :: 1334 1339 + :: 1341 1352 + :: 1341 1352 + :: 1341 1350 + :: 1341 1350 + :: 1341 1350 + :: 1351 1352 + :: 1353 1358 + :: 1353 1358 + :: 1353 1358 + :: 1353 1358 + :: 1353 1357 + :: 1359 1362 + :: 1359 1362 + :: 1359 1362 + :: 1359 1362 + :: 1359 1361 + :: 1365 1416 + :: 1365 1370 + :: 1365 1368 + :: 1371 1384 + :: 1371 1375 + :: 1388 1408 + :: 1388 1408 + :: 1388 1397 + :: 1388 1397 + :: 1388 1397 + :: 1388 1397 + :: 1389 1389 + :: 1389 1389 + :: 1390 1390 + :: 1390 1390 + :: 1391 1391 + :: 1391 1391 + :: 1392 1392 + :: 1392 1392 + :: 1393 1393 + :: 1393 1393 + :: 1394 1394 + :: 1394 1394 + :: 1395 1395 + :: 1395 1395 + :: 1398 1408 + :: 1398 1408 + :: 1398 1408 + :: 1398 1408 + :: 1398 1407 + :: 1417 1460 + :: 1417 1430 + :: 1417 1422 + :: 1434 1458 + :: 1434 1458 + :: 1434 1437 + :: 1434 1437 + :: 1434 1437 + :: 1434 1437 + :: 1434 1436 + :: 1438 1448 + :: 1438 1448 + :: 1438 1448 + :: 1438 1448 + :: 1438 1447 + :: 1449 1458 + :: 1449 1458 + :: 1449 1458 + :: 1449 1458 + :: 1449 1457 + :: 1461 1526 + :: 1461 1466 + :: 1461 1464 + :: 1467 1480 + :: 1467 1471 + :: 1484 1518 + :: 1484 1518 + :: 1484 1500 + :: 1484 1500 + :: 1484 1500 + :: 1485 1498 + :: 1485 1489 + :: 1485 1489 + :: 1485 1489 + :: 1485 1489 + :: 1485 1489 + :: 1486 1486 + :: 1486 1486 + :: 1486 1486 + :: 1487 1487 + :: 1487 1487 + :: 1487 1487 + :: 1492 1498 + :: 1492 1498 + :: 1492 1498 + :: 1492 1498 + :: 1492 1498 + :: 1501 1518 + :: 1501 1518 + :: 1501 1516 + :: 1502 1515 + :: 1502 1506 + :: 1502 1506 + :: 1502 1506 + :: 1502 1506 + :: 1502 1506 + :: 1503 1503 + :: 1503 1503 + :: 1503 1503 + :: 1504 1504 + :: 1504 1504 + :: 1504 1504 + :: 1509 1515 + :: 1509 1515 + :: 1509 1515 + :: 1509 1515 + :: 1509 1515 + :: 1517 1518 + :: 1527 1562 + :: 1527 1540 + :: 1527 1536 + :: 1544 1560 + :: 1544 1560 + :: 1544 1549 + :: 1544 1549 + :: 1544 1549 + :: 1544 1549 + :: 1544 1548 + :: 1550 1560 + :: 1550 1560 + :: 1550 1560 + :: 1550 1560 + :: 1550 1559 + :: 1563 1603 + :: 1563 1568 + :: 1563 1566 + :: 1569 1582 + :: 1569 1570 + :: 1586 1601 + :: 1586 1601 + :: 1586 1590 + :: 1586 1590 + :: 1586 1590 + :: 1586 1590 + :: 1587 1587 + :: 1587 1587 + :: 1588 1588 + :: 1588 1588 + :: 1591 1601 + :: 1591 1601 + :: 1591 1601 + :: 1591 1601 + :: 1591 1600 + :: 1604 1652 + :: 1604 1609 + :: 1604 1607 + :: 1610 1623 + :: 1610 1613 + :: 1627 1644 + :: 1627 1644 + :: 1627 1633 + :: 1627 1633 + :: 1627 1633 + :: 1627 1633 + :: 1628 1628 + :: 1628 1628 + :: 1629 1629 + :: 1629 1629 + :: 1630 1630 + :: 1630 1630 + :: 1631 1631 + :: 1631 1631 + :: 1634 1644 + :: 1634 1644 + :: 1634 1644 + :: 1634 1644 + :: 1634 1643 + :: 1653 1776 + :: 1653 1666 + :: 1653 1659 + :: 1670 1774 + :: 1670 1719 + :: 1670 1679 + :: 1670 1679 + :: 1670 1679 + :: 1670 1679 + :: 1670 1678 + :: 1680 1698 + :: 1680 1698 + :: 1680 1696 + :: 1681 1695 + :: 1681 1695 + :: 1681 1691 + :: 1681 1681 + :: 1682 1691 + :: 1682 1691 + :: 1682 1691 + :: 1682 1690 + :: 1692 1695 + :: 1692 1695 + :: 1692 1695 + :: 1692 1695 + :: 1692 1695 + :: 1697 1698 :: 1699 1708 :: 1699 1708 :: 1699 1708 :: 1699 1708 :: 1699 1707 - :: 1709 1727 - :: 1709 1727 - :: 1709 1725 - :: 1710 1724 - :: 1710 1724 - :: 1710 1720 - :: 1710 1710 - :: 1711 1720 - :: 1711 1720 - :: 1711 1720 - :: 1711 1719 - :: 1721 1724 - :: 1721 1724 - :: 1721 1724 - :: 1721 1724 - :: 1721 1724 - :: 1726 1727 - :: 1728 1737 - :: 1728 1737 - :: 1728 1737 - :: 1728 1737 - :: 1728 1736 - :: 1738 1748 - :: 1738 1748 - :: 1738 1748 - :: 1738 1748 - :: 1738 1747 - :: 1751 1803 - :: 1751 1761 - :: 1751 1761 - :: 1751 1761 - :: 1751 1761 - :: 1751 1760 - :: 1762 1781 - :: 1762 1781 - :: 1762 1779 - :: 1763 1778 - :: 1763 1778 - :: 1763 1774 - :: 1763 1763 - :: 1764 1774 - :: 1764 1774 - :: 1764 1774 - :: 1764 1773 - :: 1775 1778 - :: 1775 1778 - :: 1775 1778 - :: 1775 1778 - :: 1775 1778 - :: 1780 1781 - :: 1782 1792 - :: 1782 1792 - :: 1782 1792 - :: 1782 1792 - :: 1782 1791 - :: 1793 1803 - :: 1793 1803 - :: 1793 1803 - :: 1793 1803 - :: 1793 1802 - :: 1806 1851 - :: 1806 1811 - :: 1806 1809 - :: 1812 1825 - :: 1812 1816 - :: 1829 1849 - :: 1829 1849 - :: 1829 1838 - :: 1829 1838 - :: 1829 1838 - :: 1829 1838 - :: 1830 1830 - :: 1830 1830 - :: 1831 1831 - :: 1831 1831 - :: 1832 1832 - :: 1832 1832 - :: 1833 1833 - :: 1833 1833 - :: 1834 1834 - :: 1834 1834 - :: 1835 1835 - :: 1835 1835 - :: 1836 1836 - :: 1836 1836 - :: 1839 1849 - :: 1839 1849 - :: 1839 1849 - :: 1839 1849 - :: 1839 1848 - :: 1852 1891 - :: 1852 1857 - :: 1852 1855 - :: 1858 1871 - :: 1858 1860 - :: 1875 1889 - :: 1875 1889 - :: 1875 1878 - :: 1875 1878 - :: 1875 1878 - :: 1875 1878 - :: 1876 1876 - :: 1876 1876 - :: 1879 1889 - :: 1879 1889 - :: 1879 1889 - :: 1879 1889 - :: 1879 1888 - :: 1892 1931 - :: 1892 1897 - :: 1892 1895 - :: 1898 1911 - :: 1898 1901 - :: 1915 1929 - :: 1915 1929 - :: 1915 1918 - :: 1915 1918 - :: 1915 1918 - :: 1915 1918 - :: 1916 1916 - :: 1916 1916 - :: 1919 1929 - :: 1919 1929 - :: 1919 1929 - :: 1919 1929 - :: 1919 1928 - :: 1932 1961 - :: 1932 1937 - :: 1932 1935 - :: 1938 1951 - :: 1938 1942 - :: 1955 1959 - :: 1955 1959 - :: 1955 1959 - :: 1955 1959 - :: 1955 1959 - :: 1955 1959 - :: 1956 1957 - :: 1956 1957 - :: 1962 2003 - :: 1962 1967 - :: 1962 1965 - :: 1968 1981 - :: 1968 1970 - :: 1985 2001 - :: 1985 2001 - :: 1985 1990 - :: 1985 1990 - :: 1985 1990 - :: 1985 1990 - :: 1986 1986 - :: 1986 1986 - :: 1987 1987 - :: 1987 1987 - :: 1988 1988 - :: 1988 1988 - :: 1991 2001 - :: 1991 2001 - :: 1991 2001 - :: 1991 2001 - :: 1991 2000 - :: 2004 2049 - :: 2004 2009 - :: 2004 2007 - :: 2010 2023 - :: 2010 2013 - :: 2027 2041 - :: 2027 2041 - :: 2027 2030 - :: 2027 2030 - :: 2027 2030 - :: 2027 2030 - :: 2028 2028 - :: 2028 2028 - :: 2031 2041 - :: 2031 2041 - :: 2031 2041 - :: 2031 2041 - :: 2031 2040 - :: 2050 2094 - :: 2050 2063 - :: 2050 2055 - :: 2067 2086 - :: 2067 2086 - :: 2067 2079 - :: 2067 2079 - :: 2067 2077 - :: 2068 2076 - :: 2068 2071 - :: 2068 2071 - :: 2068 2071 - :: 2068 2071 - :: 2068 2071 - :: 2068 2070 - :: 2074 2076 - :: 2074 2076 - :: 2074 2076 - :: 2074 2076 - :: 2074 2076 - :: 2074 2076 - :: 2078 2079 - :: 2080 2086 - :: 2080 2086 - :: 2080 2086 - :: 2080 2086 - :: 2080 2085 - :: 2095 2295 - :: 2095 2108 - :: 2095 2101 - :: 2112 2293 - :: 2112 2117 - :: 2112 2117 - :: 2112 2117 - :: 2112 2117 - :: 2112 2117 - :: 2112 2116 - :: 2120 2125 - :: 2120 2125 - :: 2120 2125 - :: 2120 2125 - :: 2120 2125 - :: 2120 2124 - :: 2128 2133 - :: 2128 2133 - :: 2128 2133 - :: 2128 2133 - :: 2128 2133 - :: 2128 2132 - :: 2136 2143 - :: 2136 2143 - :: 2136 2143 - :: 2136 2143 - :: 2136 2143 - :: 2136 2142 - :: 2146 2152 - :: 2146 2152 - :: 2146 2152 - :: 2146 2152 - :: 2146 2152 - :: 2146 2151 - :: 2155 2160 - :: 2155 2160 - :: 2155 2160 - :: 2155 2160 - :: 2155 2160 - :: 2155 2159 - :: 2163 2168 - :: 2163 2168 - :: 2163 2168 - :: 2163 2168 - :: 2163 2168 - :: 2163 2167 - :: 2171 2176 - :: 2171 2176 - :: 2171 2176 - :: 2171 2176 - :: 2171 2176 - :: 2171 2175 - :: 2179 2188 - :: 2179 2188 - :: 2179 2188 - :: 2179 2188 - :: 2179 2188 - :: 2179 2187 - :: 2191 2196 - :: 2191 2196 - :: 2191 2196 - :: 2191 2196 - :: 2191 2196 - :: 2191 2195 - :: 2199 2204 - :: 2199 2204 - :: 2199 2204 - :: 2199 2204 - :: 2199 2204 - :: 2199 2203 - :: 2207 2212 - :: 2207 2212 - :: 2207 2212 - :: 2207 2212 - :: 2207 2212 - :: 2207 2211 - :: 2215 2223 - :: 2215 2223 - :: 2215 2223 - :: 2215 2223 - :: 2215 2223 - :: 2215 2222 - :: 2226 2232 - :: 2226 2232 - :: 2226 2232 - :: 2226 2232 - :: 2226 2232 - :: 2226 2231 - :: 2235 2245 - :: 2235 2245 - :: 2235 2245 - :: 2235 2245 - :: 2235 2245 - :: 2235 2244 - :: 2248 2269 - :: 2248 2252 - :: 2248 2252 - :: 2248 2252 - :: 2248 2252 - :: 2248 2251 - :: 2253 2263 - :: 2253 2263 - :: 2253 2263 - :: 2253 2263 - :: 2253 2262 - :: 2264 2269 - :: 2264 2269 - :: 2264 2269 - :: 2264 2269 - :: 2264 2268 - :: 2272 2279 - :: 2272 2279 - :: 2272 2279 - :: 2272 2279 - :: 2272 2279 - :: 2272 2278 - :: 2282 2287 - :: 2282 2287 - :: 2282 2287 - :: 2282 2287 - :: 2282 2287 - :: 2282 2286 - :: 2290 2293 - :: 2290 2293 - :: 2290 2293 - :: 2290 2293 - :: 2290 2293 - :: 2290 2292 - :: 2296 2341 - :: 2296 2301 - :: 2296 2299 - :: 2302 2315 - :: 2302 2310 - :: 2319 2339 - :: 2319 2339 - :: 2319 2328 - :: 2319 2328 - :: 2319 2328 - :: 2319 2328 - :: 2320 2320 - :: 2320 2320 - :: 2321 2321 - :: 2321 2321 - :: 2322 2322 - :: 2322 2322 - :: 2323 2323 - :: 2323 2323 - :: 2324 2324 - :: 2324 2324 - :: 2325 2325 - :: 2325 2325 - :: 2326 2326 - :: 2326 2326 - :: 2329 2339 - :: 2329 2339 - :: 2329 2339 - :: 2329 2339 - :: 2329 2338 - :: 2342 2387 - :: 2342 2347 - :: 2342 2345 - :: 2348 2361 - :: 2348 2352 - :: 2365 2385 - :: 2365 2385 - :: 2365 2374 - :: 2365 2374 - :: 2365 2374 - :: 2365 2374 - :: 2366 2366 - :: 2366 2366 - :: 2367 2367 - :: 2367 2367 - :: 2368 2368 - :: 2368 2368 - :: 2369 2369 - :: 2369 2369 - :: 2370 2370 - :: 2370 2370 - :: 2371 2371 - :: 2371 2371 - :: 2372 2372 - :: 2372 2372 - :: 2375 2385 - :: 2375 2385 - :: 2375 2385 - :: 2375 2385 - :: 2375 2384 - :: 2388 2433 - :: 2388 2393 - :: 2388 2391 - :: 2394 2407 - :: 2394 2401 - :: 2411 2425 - :: 2411 2425 - :: 2411 2414 - :: 2411 2414 - :: 2411 2414 - :: 2411 2414 - :: 2412 2412 - :: 2412 2412 - :: 2415 2425 - :: 2415 2425 - :: 2415 2425 - :: 2415 2425 - :: 2415 2424 - :: 2434 2472 - :: 2434 2447 - :: 2434 2438 - :: 2451 2470 - :: 2451 2463 - :: 2451 2455 - :: 2451 2455 - :: 2451 2455 - :: 2451 2455 - :: 2451 2454 - :: 2456 2458 - :: 2456 2458 - :: 2456 2458 - :: 2456 2458 - :: 2456 2457 - :: 2459 2463 - :: 2459 2463 - :: 2459 2463 - :: 2459 2463 - :: 2459 2462 - :: 2466 2470 - :: 2466 2470 - :: 2466 2470 - :: 2466 2470 - :: 2466 2470 - :: 2466 2469 - :: 2473 2518 - :: 2473 2478 - :: 2473 2476 - :: 2479 2492 - :: 2479 2487 - :: 2496 2510 - :: 2496 2510 - :: 2496 2499 - :: 2496 2499 - :: 2496 2499 - :: 2496 2499 - :: 2497 2497 - :: 2497 2497 - :: 2500 2510 - :: 2500 2510 - :: 2500 2510 - :: 2500 2510 - :: 2500 2509 - :: 2519 2545 - :: 2519 2532 - :: 2519 2526 - :: 2536 2543 - :: 2536 2543 - :: 2536 2543 - :: 2536 2543 - :: 2536 2541 - :: 2536 2541 - :: 2536 2541 - :: 2542 2543 - :: 2546 2585 - :: 2546 2551 - :: 2546 2549 - :: 2552 2565 - :: 2552 2556 - :: 2569 2583 - :: 2569 2583 - :: 2569 2572 - :: 2569 2572 - :: 2569 2572 - :: 2569 2572 - :: 2570 2570 - :: 2570 2570 - :: 2573 2583 - :: 2573 2583 - :: 2573 2583 - :: 2573 2583 - :: 2573 2582 - :: 2586 2631 - :: 2586 2591 - :: 2586 2589 - :: 2592 2605 - :: 2592 2596 - :: 2609 2629 - :: 2609 2629 - :: 2609 2618 - :: 2609 2618 - :: 2609 2618 - :: 2609 2618 - :: 2610 2610 - :: 2610 2610 - :: 2611 2611 - :: 2611 2611 - :: 2612 2612 - :: 2612 2612 - :: 2613 2613 - :: 2613 2613 - :: 2614 2614 - :: 2614 2614 - :: 2615 2615 - :: 2615 2615 - :: 2616 2616 - :: 2616 2616 - :: 2619 2629 - :: 2619 2629 - :: 2619 2629 - :: 2619 2629 - :: 2619 2628 - :: 2632 2677 - :: 2632 2637 - :: 2632 2635 - :: 2638 2651 - :: 2638 2641 - :: 2655 2669 - :: 2655 2669 - :: 2655 2658 - :: 2655 2658 - :: 2655 2658 - :: 2655 2658 - :: 2656 2656 - :: 2656 2656 - :: 2659 2669 - :: 2659 2669 - :: 2659 2669 - :: 2659 2669 - :: 2659 2668 - :: 2678 2724 - :: 2678 2691 - :: 2678 2686 - :: 2695 2716 - :: 2695 2716 - :: 2695 2699 - :: 2695 2699 - :: 2695 2699 - :: 2695 2699 - :: 2695 2698 - :: 2700 2710 - :: 2700 2710 - :: 2700 2710 - :: 2700 2710 - :: 2700 2709 - :: 2711 2716 - :: 2711 2716 - :: 2711 2716 - :: 2711 2716 - :: 2711 2715 - :: 2725 2777 - :: 2725 2738 - :: 2725 2730 - :: 2742 2775 - :: 2742 2775 - :: 2742 2749 - :: 2742 2749 - :: 2742 2749 - :: 2742 2749 - :: 2742 2748 - :: 2750 2775 - :: 2750 2775 - :: 2750 2773 - :: 2751 2772 - :: 2751 2759 - :: 2751 2759 - :: 2751 2759 - :: 2751 2759 - :: 2751 2759 - :: 2751 2758 - :: 2762 2766 - :: 2762 2766 - :: 2762 2766 - :: 2762 2766 - :: 2762 2766 - :: 2762 2765 - :: 2769 2772 - :: 2769 2772 - :: 2769 2772 - :: 2769 2772 - :: 2769 2772 - :: 2769 2772 - :: 2774 2775 - :: 2778 2806 - :: 2778 2783 - :: 2778 2781 - :: 2784 2797 - :: 2784 2785 - :: 2801 2804 - :: 2801 2804 - :: 2801 2804 - :: 2801 2804 - :: 2801 2804 - :: 2801 2804 - :: 2802 2802 - :: 2802 2802 - :: 2807 2852 - :: 2807 2812 - :: 2807 2810 - :: 2813 2826 - :: 2813 2817 - :: 2830 2850 - :: 2830 2850 - :: 2830 2839 - :: 2830 2839 - :: 2830 2839 - :: 2830 2839 - :: 2831 2831 - :: 2831 2831 - :: 2832 2832 - :: 2832 2832 - :: 2833 2833 - :: 2833 2833 - :: 2834 2834 - :: 2834 2834 - :: 2835 2835 - :: 2835 2835 - :: 2836 2836 - :: 2836 2836 - :: 2837 2837 - :: 2837 2837 - :: 2840 2850 - :: 2840 2850 - :: 2840 2850 - :: 2840 2850 - :: 2840 2849 - :: 2853 2895 - :: 2853 2858 - :: 2853 2856 - :: 2859 2872 - :: 2859 2862 - :: 2876 2893 - :: 2876 2893 - :: 2876 2882 - :: 2876 2882 - :: 2876 2882 - :: 2876 2882 - :: 2877 2877 - :: 2877 2877 - :: 2878 2878 - :: 2878 2878 - :: 2879 2879 - :: 2879 2879 - :: 2880 2880 - :: 2880 2880 - :: 2883 2893 - :: 2883 2893 - :: 2883 2893 - :: 2883 2893 - :: 2883 2892 - :: 2896 2941 - :: 2896 2901 - :: 2896 2899 - :: 2902 2915 - :: 2902 2911 - :: 2919 2939 - :: 2919 2939 - :: 2919 2939 - :: 2919 2939 - :: 2919 2937 - :: 2920 2936 - :: 2920 2927 - :: 2920 2927 - :: 2920 2927 - :: 2920 2927 - :: 2920 2927 - :: 2930 2936 - :: 2930 2936 - :: 2930 2936 - :: 2930 2936 - :: 2930 2936 - :: 2930 2936 - :: 2938 2939 - :: 2942 2990 - :: 2942 2947 - :: 2942 2945 - :: 2948 2961 - :: 2948 2955 - :: 2965 2988 - :: 2965 2988 - :: 2965 2977 - :: 2965 2977 - :: 2965 2977 - :: 2965 2977 - :: 2966 2966 - :: 2966 2966 - :: 2967 2967 - :: 2967 2967 - :: 2968 2968 - :: 2968 2968 - :: 2969 2969 - :: 2969 2969 - :: 2970 2970 - :: 2970 2970 - :: 2971 2971 - :: 2971 2971 - :: 2972 2972 - :: 2972 2972 - :: 2973 2973 - :: 2973 2973 - :: 2974 2974 - :: 2974 2974 - :: 2975 2975 - :: 2975 2975 - :: 2978 2988 - :: 2978 2988 - :: 2978 2988 - :: 2978 2988 - :: 2978 2987 - :: 2991 3038 - :: 2991 2996 - :: 2991 2994 - :: 2997 3010 - :: 2997 3002 - :: 3014 3035 - :: 3014 3035 + :: 1709 1719 + :: 1709 1719 + :: 1709 1719 + :: 1709 1719 + :: 1709 1718 + :: 1722 1774 + :: 1722 1732 + :: 1722 1732 + :: 1722 1732 + :: 1722 1732 + :: 1722 1731 + :: 1733 1752 + :: 1733 1752 + :: 1733 1750 + :: 1734 1749 + :: 1734 1749 + :: 1734 1745 + :: 1734 1734 + :: 1735 1745 + :: 1735 1745 + :: 1735 1745 + :: 1735 1744 + :: 1746 1749 + :: 1746 1749 + :: 1746 1749 + :: 1746 1749 + :: 1746 1749 + :: 1751 1752 + :: 1753 1763 + :: 1753 1763 + :: 1753 1763 + :: 1753 1763 + :: 1753 1762 + :: 1764 1774 + :: 1764 1774 + :: 1764 1774 + :: 1764 1774 + :: 1764 1773 + :: 1777 1822 + :: 1777 1782 + :: 1777 1780 + :: 1783 1796 + :: 1783 1787 + :: 1800 1820 + :: 1800 1820 + :: 1800 1809 + :: 1800 1809 + :: 1800 1809 + :: 1800 1809 + :: 1801 1801 + :: 1801 1801 + :: 1802 1802 + :: 1802 1802 + :: 1803 1803 + :: 1803 1803 + :: 1804 1804 + :: 1804 1804 + :: 1805 1805 + :: 1805 1805 + :: 1806 1806 + :: 1806 1806 + :: 1807 1807 + :: 1807 1807 + :: 1810 1820 + :: 1810 1820 + :: 1810 1820 + :: 1810 1820 + :: 1810 1819 + :: 1823 1862 + :: 1823 1828 + :: 1823 1826 + :: 1829 1842 + :: 1829 1831 + :: 1846 1860 + :: 1846 1860 + :: 1846 1849 + :: 1846 1849 + :: 1846 1849 + :: 1846 1849 + :: 1847 1847 + :: 1847 1847 + :: 1850 1860 + :: 1850 1860 + :: 1850 1860 + :: 1850 1860 + :: 1850 1859 + :: 1863 1902 + :: 1863 1868 + :: 1863 1866 + :: 1869 1882 + :: 1869 1872 + :: 1886 1900 + :: 1886 1900 + :: 1886 1889 + :: 1886 1889 + :: 1886 1889 + :: 1886 1889 + :: 1887 1887 + :: 1887 1887 + :: 1890 1900 + :: 1890 1900 + :: 1890 1900 + :: 1890 1900 + :: 1890 1899 + :: 1903 1932 + :: 1903 1908 + :: 1903 1906 + :: 1909 1922 + :: 1909 1913 + :: 1926 1930 + :: 1926 1930 + :: 1926 1930 + :: 1926 1930 + :: 1926 1930 + :: 1926 1930 + :: 1927 1928 + :: 1927 1928 + :: 1933 1992 + :: 1933 1938 + :: 1933 1936 + :: 1939 1952 + :: 1939 1941 + :: 1956 1990 + :: 1956 1990 + :: 1956 1961 + :: 1956 1961 + :: 1956 1961 + :: 1956 1961 + :: 1957 1957 + :: 1957 1957 + :: 1958 1958 + :: 1958 1958 + :: 1959 1959 + :: 1959 1959 + :: 1962 1979 + :: 1962 1962 + :: 1963 1979 + :: 1963 1979 + :: 1964 1977 + :: 1964 1968 + :: 1964 1968 + :: 1964 1968 + :: 1964 1968 + :: 1964 1968 + :: 1965 1965 + :: 1965 1965 + :: 1965 1965 + :: 1966 1966 + :: 1966 1966 + :: 1966 1966 + :: 1971 1977 + :: 1971 1977 + :: 1971 1977 + :: 1971 1977 + :: 1971 1977 + :: 1980 1990 + :: 1980 1990 + :: 1980 1990 + :: 1980 1990 + :: 1980 1989 + :: 1993 2038 + :: 1993 1998 + :: 1993 1996 + :: 1999 2012 + :: 1999 2002 + :: 2016 2030 + :: 2016 2030 + :: 2016 2019 + :: 2016 2019 + :: 2016 2019 + :: 2016 2019 + :: 2017 2017 + :: 2017 2017 + :: 2020 2030 + :: 2020 2030 + :: 2020 2030 + :: 2020 2030 + :: 2020 2029 + :: 2039 2083 + :: 2039 2052 + :: 2039 2044 + :: 2056 2075 + :: 2056 2075 + :: 2056 2068 + :: 2056 2068 + :: 2056 2066 + :: 2057 2065 + :: 2057 2060 + :: 2057 2060 + :: 2057 2060 + :: 2057 2060 + :: 2057 2060 + :: 2057 2059 + :: 2063 2065 + :: 2063 2065 + :: 2063 2065 + :: 2063 2065 + :: 2063 2065 + :: 2063 2065 + :: 2067 2068 + :: 2069 2075 + :: 2069 2075 + :: 2069 2075 + :: 2069 2075 + :: 2069 2074 + :: 2084 2284 + :: 2084 2097 + :: 2084 2090 + :: 2101 2282 + :: 2101 2106 + :: 2101 2106 + :: 2101 2106 + :: 2101 2106 + :: 2101 2106 + :: 2101 2105 + :: 2109 2114 + :: 2109 2114 + :: 2109 2114 + :: 2109 2114 + :: 2109 2114 + :: 2109 2113 + :: 2117 2122 + :: 2117 2122 + :: 2117 2122 + :: 2117 2122 + :: 2117 2122 + :: 2117 2121 + :: 2125 2132 + :: 2125 2132 + :: 2125 2132 + :: 2125 2132 + :: 2125 2132 + :: 2125 2131 + :: 2135 2141 + :: 2135 2141 + :: 2135 2141 + :: 2135 2141 + :: 2135 2141 + :: 2135 2140 + :: 2144 2149 + :: 2144 2149 + :: 2144 2149 + :: 2144 2149 + :: 2144 2149 + :: 2144 2148 + :: 2152 2157 + :: 2152 2157 + :: 2152 2157 + :: 2152 2157 + :: 2152 2157 + :: 2152 2156 + :: 2160 2165 + :: 2160 2165 + :: 2160 2165 + :: 2160 2165 + :: 2160 2165 + :: 2160 2164 + :: 2168 2177 + :: 2168 2177 + :: 2168 2177 + :: 2168 2177 + :: 2168 2177 + :: 2168 2176 + :: 2180 2185 + :: 2180 2185 + :: 2180 2185 + :: 2180 2185 + :: 2180 2185 + :: 2180 2184 + :: 2188 2193 + :: 2188 2193 + :: 2188 2193 + :: 2188 2193 + :: 2188 2193 + :: 2188 2192 + :: 2196 2201 + :: 2196 2201 + :: 2196 2201 + :: 2196 2201 + :: 2196 2201 + :: 2196 2200 + :: 2204 2212 + :: 2204 2212 + :: 2204 2212 + :: 2204 2212 + :: 2204 2212 + :: 2204 2211 + :: 2215 2221 + :: 2215 2221 + :: 2215 2221 + :: 2215 2221 + :: 2215 2221 + :: 2215 2220 + :: 2224 2234 + :: 2224 2234 + :: 2224 2234 + :: 2224 2234 + :: 2224 2234 + :: 2224 2233 + :: 2237 2258 + :: 2237 2241 + :: 2237 2241 + :: 2237 2241 + :: 2237 2241 + :: 2237 2240 + :: 2242 2252 + :: 2242 2252 + :: 2242 2252 + :: 2242 2252 + :: 2242 2251 + :: 2253 2258 + :: 2253 2258 + :: 2253 2258 + :: 2253 2258 + :: 2253 2257 + :: 2261 2268 + :: 2261 2268 + :: 2261 2268 + :: 2261 2268 + :: 2261 2268 + :: 2261 2267 + :: 2271 2276 + :: 2271 2276 + :: 2271 2276 + :: 2271 2276 + :: 2271 2276 + :: 2271 2275 + :: 2279 2282 + :: 2279 2282 + :: 2279 2282 + :: 2279 2282 + :: 2279 2282 + :: 2279 2281 + :: 2285 2330 + :: 2285 2290 + :: 2285 2288 + :: 2291 2304 + :: 2291 2299 + :: 2308 2328 + :: 2308 2328 + :: 2308 2317 + :: 2308 2317 + :: 2308 2317 + :: 2308 2317 + :: 2309 2309 + :: 2309 2309 + :: 2310 2310 + :: 2310 2310 + :: 2311 2311 + :: 2311 2311 + :: 2312 2312 + :: 2312 2312 + :: 2313 2313 + :: 2313 2313 + :: 2314 2314 + :: 2314 2314 + :: 2315 2315 + :: 2315 2315 + :: 2318 2328 + :: 2318 2328 + :: 2318 2328 + :: 2318 2328 + :: 2318 2327 + :: 2331 2376 + :: 2331 2336 + :: 2331 2334 + :: 2337 2350 + :: 2337 2341 + :: 2354 2374 + :: 2354 2374 + :: 2354 2363 + :: 2354 2363 + :: 2354 2363 + :: 2354 2363 + :: 2355 2355 + :: 2355 2355 + :: 2356 2356 + :: 2356 2356 + :: 2357 2357 + :: 2357 2357 + :: 2358 2358 + :: 2358 2358 + :: 2359 2359 + :: 2359 2359 + :: 2360 2360 + :: 2360 2360 + :: 2361 2361 + :: 2361 2361 + :: 2364 2374 + :: 2364 2374 + :: 2364 2374 + :: 2364 2374 + :: 2364 2373 + :: 2377 2422 + :: 2377 2382 + :: 2377 2380 + :: 2383 2396 + :: 2383 2390 + :: 2400 2414 + :: 2400 2414 + :: 2400 2403 + :: 2400 2403 + :: 2400 2403 + :: 2400 2403 + :: 2401 2401 + :: 2401 2401 + :: 2404 2414 + :: 2404 2414 + :: 2404 2414 + :: 2404 2414 + :: 2404 2413 + :: 2423 2461 + :: 2423 2436 + :: 2423 2427 + :: 2440 2459 + :: 2440 2452 + :: 2440 2444 + :: 2440 2444 + :: 2440 2444 + :: 2440 2444 + :: 2440 2443 + :: 2445 2447 + :: 2445 2447 + :: 2445 2447 + :: 2445 2447 + :: 2445 2446 + :: 2448 2452 + :: 2448 2452 + :: 2448 2452 + :: 2448 2452 + :: 2448 2451 + :: 2455 2459 + :: 2455 2459 + :: 2455 2459 + :: 2455 2459 + :: 2455 2459 + :: 2455 2458 + :: 2462 2507 + :: 2462 2467 + :: 2462 2465 + :: 2468 2481 + :: 2468 2476 + :: 2485 2499 + :: 2485 2499 + :: 2485 2488 + :: 2485 2488 + :: 2485 2488 + :: 2485 2488 + :: 2486 2486 + :: 2486 2486 + :: 2489 2499 + :: 2489 2499 + :: 2489 2499 + :: 2489 2499 + :: 2489 2498 + :: 2508 2534 + :: 2508 2521 + :: 2508 2515 + :: 2525 2532 + :: 2525 2532 + :: 2525 2532 + :: 2525 2532 + :: 2525 2530 + :: 2525 2530 + :: 2525 2530 + :: 2531 2532 + :: 2535 2574 + :: 2535 2540 + :: 2535 2538 + :: 2541 2554 + :: 2541 2545 + :: 2558 2572 + :: 2558 2572 + :: 2558 2561 + :: 2558 2561 + :: 2558 2561 + :: 2558 2561 + :: 2559 2559 + :: 2559 2559 + :: 2562 2572 + :: 2562 2572 + :: 2562 2572 + :: 2562 2572 + :: 2562 2571 + :: 2575 2620 + :: 2575 2580 + :: 2575 2578 + :: 2581 2594 + :: 2581 2585 + :: 2598 2618 + :: 2598 2618 + :: 2598 2607 + :: 2598 2607 + :: 2598 2607 + :: 2598 2607 + :: 2599 2599 + :: 2599 2599 + :: 2600 2600 + :: 2600 2600 + :: 2601 2601 + :: 2601 2601 + :: 2602 2602 + :: 2602 2602 + :: 2603 2603 + :: 2603 2603 + :: 2604 2604 + :: 2604 2604 + :: 2605 2605 + :: 2605 2605 + :: 2608 2618 + :: 2608 2618 + :: 2608 2618 + :: 2608 2618 + :: 2608 2617 + :: 2621 2666 + :: 2621 2626 + :: 2621 2624 + :: 2627 2640 + :: 2627 2630 + :: 2644 2658 + :: 2644 2658 + :: 2644 2647 + :: 2644 2647 + :: 2644 2647 + :: 2644 2647 + :: 2645 2645 + :: 2645 2645 + :: 2648 2658 + :: 2648 2658 + :: 2648 2658 + :: 2648 2658 + :: 2648 2657 + :: 2667 2713 + :: 2667 2680 + :: 2667 2675 + :: 2684 2705 + :: 2684 2705 + :: 2684 2688 + :: 2684 2688 + :: 2684 2688 + :: 2684 2688 + :: 2684 2687 + :: 2689 2699 + :: 2689 2699 + :: 2689 2699 + :: 2689 2699 + :: 2689 2698 + :: 2700 2705 + :: 2700 2705 + :: 2700 2705 + :: 2700 2705 + :: 2700 2704 + :: 2714 2766 + :: 2714 2727 + :: 2714 2719 + :: 2731 2764 + :: 2731 2764 + :: 2731 2738 + :: 2731 2738 + :: 2731 2738 + :: 2731 2738 + :: 2731 2737 + :: 2739 2764 + :: 2739 2764 + :: 2739 2762 + :: 2740 2761 + :: 2740 2748 + :: 2740 2748 + :: 2740 2748 + :: 2740 2748 + :: 2740 2748 + :: 2740 2747 + :: 2751 2755 + :: 2751 2755 + :: 2751 2755 + :: 2751 2755 + :: 2751 2755 + :: 2751 2754 + :: 2758 2761 + :: 2758 2761 + :: 2758 2761 + :: 2758 2761 + :: 2758 2761 + :: 2758 2761 + :: 2763 2764 + :: 2767 2795 + :: 2767 2772 + :: 2767 2770 + :: 2773 2786 + :: 2773 2774 + :: 2790 2793 + :: 2790 2793 + :: 2790 2793 + :: 2790 2793 + :: 2790 2793 + :: 2790 2793 + :: 2791 2791 + :: 2791 2791 + :: 2796 2841 + :: 2796 2801 + :: 2796 2799 + :: 2802 2815 + :: 2802 2806 + :: 2819 2839 + :: 2819 2839 + :: 2819 2828 + :: 2819 2828 + :: 2819 2828 + :: 2819 2828 + :: 2820 2820 + :: 2820 2820 + :: 2821 2821 + :: 2821 2821 + :: 2822 2822 + :: 2822 2822 + :: 2823 2823 + :: 2823 2823 + :: 2824 2824 + :: 2824 2824 + :: 2825 2825 + :: 2825 2825 + :: 2826 2826 + :: 2826 2826 + :: 2829 2839 + :: 2829 2839 + :: 2829 2839 + :: 2829 2839 + :: 2829 2838 + :: 2842 2884 + :: 2842 2847 + :: 2842 2845 + :: 2848 2861 + :: 2848 2851 + :: 2865 2882 + :: 2865 2882 + :: 2865 2871 + :: 2865 2871 + :: 2865 2871 + :: 2865 2871 + :: 2866 2866 + :: 2866 2866 + :: 2867 2867 + :: 2867 2867 + :: 2868 2868 + :: 2868 2868 + :: 2869 2869 + :: 2869 2869 + :: 2872 2882 + :: 2872 2882 + :: 2872 2882 + :: 2872 2882 + :: 2872 2881 + :: 2885 2930 + :: 2885 2890 + :: 2885 2888 + :: 2891 2904 + :: 2891 2900 + :: 2908 2928 + :: 2908 2928 + :: 2908 2928 + :: 2908 2928 + :: 2908 2926 + :: 2909 2925 + :: 2909 2916 + :: 2909 2916 + :: 2909 2916 + :: 2909 2916 + :: 2909 2916 + :: 2919 2925 + :: 2919 2925 + :: 2919 2925 + :: 2919 2925 + :: 2919 2925 + :: 2919 2925 + :: 2927 2928 + :: 2931 2979 + :: 2931 2936 + :: 2931 2934 + :: 2937 2950 + :: 2937 2944 + :: 2954 2977 + :: 2954 2977 + :: 2954 2966 + :: 2954 2966 + :: 2954 2966 + :: 2954 2966 + :: 2955 2955 + :: 2955 2955 + :: 2956 2956 + :: 2956 2956 + :: 2957 2957 + :: 2957 2957 + :: 2958 2958 + :: 2958 2958 + :: 2959 2959 + :: 2959 2959 + :: 2960 2960 + :: 2960 2960 + :: 2961 2961 + :: 2961 2961 + :: 2962 2962 + :: 2962 2962 + :: 2963 2963 + :: 2963 2963 + :: 2964 2964 + :: 2964 2964 + :: 2967 2977 + :: 2967 2977 + :: 2967 2977 + :: 2967 2977 + :: 2967 2976 + :: 2980 3027 + :: 2980 2985 + :: 2980 2983 + :: 2986 2999 + :: 2986 2991 + :: 3003 3024 + :: 3003 3024 + :: 3003 3013 + :: 3003 3013 + :: 3003 3013 + :: 3003 3013 + :: 3004 3004 + :: 3004 3004 + :: 3005 3005 + :: 3005 3005 + :: 3006 3006 + :: 3006 3006 + :: 3007 3007 + :: 3007 3007 + :: 3008 3008 + :: 3008 3008 + :: 3009 3009 + :: 3009 3009 + :: 3010 3010 + :: 3010 3010 + :: 3011 3011 + :: 3011 3011 :: 3014 3024 :: 3014 3024 :: 3014 3024 - :: 3014 3024 - :: 3015 3015 - :: 3015 3015 - :: 3016 3016 - :: 3016 3016 - :: 3017 3017 - :: 3017 3017 - :: 3018 3018 - :: 3018 3018 - :: 3019 3019 - :: 3019 3019 - :: 3020 3020 - :: 3020 3020 - :: 3021 3021 - :: 3021 3021 - :: 3022 3022 - :: 3022 3022 - :: 3025 3035 - :: 3025 3035 - :: 3025 3035 - :: 3025 3035 - :: 3025 3034 + :: 3014 3024 + :: 3014 3023 Index: modules/pt/tests/data/ok/peg_peg-ast-templated-fused/3_peg_itself ================================================================== --- modules/pt/tests/data/ok/peg_peg-ast-templated-fused/3_peg_itself +++ modules/pt/tests/data/ok/peg_peg-ast-templated-fused/3_peg_itself @@ -1,6 +1,6 @@ - :: 0 3143 + :: 0 3132
              :: 99 122 :: 103 111 :: 103 110 :: 112 122 :: 113 119 @@ -642,1046 +642,1055 @@ :: 1207 1217 :: 1207 1217 :: 1207 1217 :: 1207 1217 :: 1207 1216 - :: 1220 1261 + :: 1220 1247 :: 1220 1225 :: 1220 1223 :: 1226 1239 :: 1226 1228 - :: 1243 1259 - :: 1243 1259 - :: 1243 1248 - :: 1243 1248 - :: 1243 1248 - :: 1243 1248 - :: 1244 1244 - :: 1244 1244 - :: 1245 1245 - :: 1245 1245 - :: 1246 1246 - :: 1246 1246 - :: 1249 1259 - :: 1249 1259 - :: 1249 1259 - :: 1249 1259 - :: 1249 1258 - :: 1262 1289 - :: 1262 1267 - :: 1262 1265 - :: 1268 1281 - :: 1268 1270 - :: 1285 1287 - :: 1285 1287 - :: 1285 1287 - :: 1285 1285 - :: 1286 1287 - :: 1286 1287 - :: 1286 1287 - :: 1290 1327 - :: 1290 1295 - :: 1290 1293 - :: 1296 1309 - :: 1296 1298 - :: 1313 1319 - :: 1313 1319 - :: 1313 1319 - :: 1313 1319 - :: 1313 1319 - :: 1313 1319 - :: 1314 1315 - :: 1314 1315 - :: 1314 1315 - :: 1316 1317 - :: 1316 1317 - :: 1316 1317 - :: 1328 1373 - :: 1328 1341 - :: 1328 1337 - :: 1345 1371 - :: 1345 1371 - :: 1345 1353 - :: 1345 1353 - :: 1345 1353 - :: 1345 1353 - :: 1345 1352 - :: 1354 1371 - :: 1354 1371 - :: 1354 1369 - :: 1355 1368 - :: 1355 1368 - :: 1355 1360 - :: 1355 1360 - :: 1355 1360 - :: 1355 1360 - :: 1355 1359 - :: 1361 1368 - :: 1361 1368 - :: 1361 1368 - :: 1361 1368 - :: 1361 1368 - :: 1370 1371 - :: 1374 1429 - :: 1374 1379 - :: 1374 1377 - :: 1380 1393 - :: 1380 1384 - :: 1397 1421 - :: 1397 1421 - :: 1397 1400 - :: 1397 1400 - :: 1397 1400 - :: 1397 1400 - :: 1397 1399 - :: 1401 1410 - :: 1401 1410 - :: 1401 1410 - :: 1401 1410 - :: 1401 1409 - :: 1411 1421 - :: 1411 1421 - :: 1411 1421 - :: 1411 1421 - :: 1411 1420 - :: 1430 1488 - :: 1430 1443 - :: 1430 1436 - :: 1447 1486 - :: 1447 1486 - :: 1447 1457 - :: 1447 1457 - :: 1447 1457 - :: 1447 1457 - :: 1447 1456 - :: 1458 1464 - :: 1458 1464 - :: 1458 1464 - :: 1458 1464 - :: 1458 1463 - :: 1465 1476 - :: 1465 1476 - :: 1465 1474 - :: 1465 1474 - :: 1465 1474 - :: 1475 1476 - :: 1477 1482 - :: 1477 1482 - :: 1477 1482 - :: 1477 1482 - :: 1477 1481 - :: 1483 1486 - :: 1483 1486 - :: 1483 1486 - :: 1483 1486 - :: 1483 1485 - :: 1489 1540 - :: 1489 1494 - :: 1489 1492 - :: 1495 1508 - :: 1495 1499 - :: 1512 1532 - :: 1512 1532 - :: 1512 1521 - :: 1512 1521 - :: 1512 1521 - :: 1512 1521 - :: 1513 1513 - :: 1513 1513 - :: 1514 1514 - :: 1514 1514 - :: 1515 1515 - :: 1515 1515 - :: 1516 1516 - :: 1516 1516 - :: 1517 1517 - :: 1517 1517 - :: 1518 1518 - :: 1518 1518 - :: 1519 1519 - :: 1519 1519 - :: 1522 1532 - :: 1522 1532 - :: 1522 1532 - :: 1522 1532 - :: 1522 1531 - :: 1541 1584 - :: 1541 1554 - :: 1541 1546 - :: 1558 1582 - :: 1558 1582 - :: 1558 1561 - :: 1558 1561 - :: 1558 1561 - :: 1558 1561 - :: 1558 1560 - :: 1562 1572 - :: 1562 1572 - :: 1562 1572 - :: 1562 1572 - :: 1562 1571 - :: 1573 1582 - :: 1573 1582 - :: 1573 1582 - :: 1573 1582 - :: 1573 1581 - :: 1585 1650 - :: 1585 1590 - :: 1585 1588 - :: 1591 1604 - :: 1591 1595 - :: 1608 1642 - :: 1608 1642 - :: 1608 1624 - :: 1608 1624 - :: 1608 1624 - :: 1609 1622 - :: 1609 1613 - :: 1609 1613 - :: 1609 1613 - :: 1609 1613 - :: 1609 1613 - :: 1610 1610 - :: 1610 1610 - :: 1610 1610 - :: 1611 1611 - :: 1611 1611 - :: 1611 1611 - :: 1616 1622 - :: 1616 1622 - :: 1616 1622 - :: 1616 1622 - :: 1616 1622 - :: 1625 1642 - :: 1625 1642 - :: 1625 1640 - :: 1626 1639 - :: 1626 1630 - :: 1626 1630 - :: 1626 1630 - :: 1626 1630 - :: 1626 1630 - :: 1627 1627 - :: 1627 1627 - :: 1627 1627 - :: 1628 1628 - :: 1628 1628 - :: 1628 1628 - :: 1633 1639 - :: 1633 1639 - :: 1633 1639 - :: 1633 1639 - :: 1633 1639 - :: 1641 1642 - :: 1651 1686 - :: 1651 1664 - :: 1651 1660 - :: 1668 1684 - :: 1668 1684 - :: 1668 1673 - :: 1668 1673 - :: 1668 1673 - :: 1668 1673 - :: 1668 1672 - :: 1674 1684 - :: 1674 1684 - :: 1674 1684 - :: 1674 1684 - :: 1674 1683 - :: 1687 1727 - :: 1687 1692 - :: 1687 1690 - :: 1693 1706 - :: 1693 1694 - :: 1710 1725 - :: 1710 1725 - :: 1710 1714 - :: 1710 1714 - :: 1710 1714 - :: 1710 1714 - :: 1711 1711 - :: 1711 1711 - :: 1712 1712 - :: 1712 1712 - :: 1715 1725 - :: 1715 1725 - :: 1715 1725 - :: 1715 1725 - :: 1715 1724 - :: 1728 1776 - :: 1728 1733 - :: 1728 1731 - :: 1734 1747 - :: 1734 1737 - :: 1751 1768 - :: 1751 1768 - :: 1751 1757 - :: 1751 1757 - :: 1751 1757 - :: 1751 1757 - :: 1752 1752 - :: 1752 1752 - :: 1753 1753 - :: 1753 1753 - :: 1754 1754 - :: 1754 1754 - :: 1755 1755 - :: 1755 1755 - :: 1758 1768 - :: 1758 1768 - :: 1758 1768 - :: 1758 1768 - :: 1758 1767 - :: 1777 1900 - :: 1777 1790 - :: 1777 1783 - :: 1794 1898 - :: 1794 1843 + :: 1243 1245 + :: 1243 1245 + :: 1243 1245 + :: 1243 1243 + :: 1244 1245 + :: 1244 1245 + :: 1244 1245 + :: 1248 1285 + :: 1248 1253 + :: 1248 1251 + :: 1254 1267 + :: 1254 1256 + :: 1271 1277 + :: 1271 1277 + :: 1271 1277 + :: 1271 1277 + :: 1271 1277 + :: 1271 1277 + :: 1272 1273 + :: 1272 1273 + :: 1272 1273 + :: 1274 1275 + :: 1274 1275 + :: 1274 1275 + :: 1286 1331 + :: 1286 1299 + :: 1286 1295 + :: 1303 1329 + :: 1303 1329 + :: 1303 1311 + :: 1303 1311 + :: 1303 1311 + :: 1303 1311 + :: 1303 1310 + :: 1312 1329 + :: 1312 1329 + :: 1312 1327 + :: 1313 1326 + :: 1313 1326 + :: 1313 1318 + :: 1313 1318 + :: 1313 1318 + :: 1313 1318 + :: 1313 1317 + :: 1319 1326 + :: 1319 1326 + :: 1319 1326 + :: 1319 1326 + :: 1319 1326 + :: 1328 1329 + :: 1332 1400 + :: 1332 1337 + :: 1332 1335 + :: 1338 1351 + :: 1338 1342 + :: 1355 1392 + :: 1355 1392 + :: 1355 1360 + :: 1355 1360 + :: 1355 1360 + :: 1355 1360 + :: 1356 1356 + :: 1356 1356 + :: 1357 1357 + :: 1357 1357 + :: 1358 1358 + :: 1358 1358 + :: 1361 1371 + :: 1361 1371 + :: 1361 1371 + :: 1361 1371 + :: 1361 1370 + :: 1372 1381 + :: 1372 1381 + :: 1372 1381 + :: 1372 1381 + :: 1372 1380 + :: 1382 1392 + :: 1382 1392 + :: 1382 1392 + :: 1382 1392 + :: 1382 1391 + :: 1401 1459 + :: 1401 1414 + :: 1401 1407 + :: 1418 1457 + :: 1418 1457 + :: 1418 1428 + :: 1418 1428 + :: 1418 1428 + :: 1418 1428 + :: 1418 1427 + :: 1429 1435 + :: 1429 1435 + :: 1429 1435 + :: 1429 1435 + :: 1429 1434 + :: 1436 1447 + :: 1436 1447 + :: 1436 1445 + :: 1436 1445 + :: 1436 1445 + :: 1446 1447 + :: 1448 1453 + :: 1448 1453 + :: 1448 1453 + :: 1448 1453 + :: 1448 1452 + :: 1454 1457 + :: 1454 1457 + :: 1454 1457 + :: 1454 1457 + :: 1454 1456 + :: 1460 1511 + :: 1460 1465 + :: 1460 1463 + :: 1466 1479 + :: 1466 1470 + :: 1483 1503 + :: 1483 1503 + :: 1483 1492 + :: 1483 1492 + :: 1483 1492 + :: 1483 1492 + :: 1484 1484 + :: 1484 1484 + :: 1485 1485 + :: 1485 1485 + :: 1486 1486 + :: 1486 1486 + :: 1487 1487 + :: 1487 1487 + :: 1488 1488 + :: 1488 1488 + :: 1489 1489 + :: 1489 1489 + :: 1490 1490 + :: 1490 1490 + :: 1493 1503 + :: 1493 1503 + :: 1493 1503 + :: 1493 1503 + :: 1493 1502 + :: 1512 1555 + :: 1512 1525 + :: 1512 1517 + :: 1529 1553 + :: 1529 1553 + :: 1529 1532 + :: 1529 1532 + :: 1529 1532 + :: 1529 1532 + :: 1529 1531 + :: 1533 1543 + :: 1533 1543 + :: 1533 1543 + :: 1533 1543 + :: 1533 1542 + :: 1544 1553 + :: 1544 1553 + :: 1544 1553 + :: 1544 1553 + :: 1544 1552 + :: 1556 1621 + :: 1556 1561 + :: 1556 1559 + :: 1562 1575 + :: 1562 1566 + :: 1579 1613 + :: 1579 1613 + :: 1579 1595 + :: 1579 1595 + :: 1579 1595 + :: 1580 1593 + :: 1580 1584 + :: 1580 1584 + :: 1580 1584 + :: 1580 1584 + :: 1580 1584 + :: 1581 1581 + :: 1581 1581 + :: 1581 1581 + :: 1582 1582 + :: 1582 1582 + :: 1582 1582 + :: 1587 1593 + :: 1587 1593 + :: 1587 1593 + :: 1587 1593 + :: 1587 1593 + :: 1596 1613 + :: 1596 1613 + :: 1596 1611 + :: 1597 1610 + :: 1597 1601 + :: 1597 1601 + :: 1597 1601 + :: 1597 1601 + :: 1597 1601 + :: 1598 1598 + :: 1598 1598 + :: 1598 1598 + :: 1599 1599 + :: 1599 1599 + :: 1599 1599 + :: 1604 1610 + :: 1604 1610 + :: 1604 1610 + :: 1604 1610 + :: 1604 1610 + :: 1612 1613 + :: 1622 1657 + :: 1622 1635 + :: 1622 1631 + :: 1639 1655 + :: 1639 1655 + :: 1639 1644 + :: 1639 1644 + :: 1639 1644 + :: 1639 1644 + :: 1639 1643 + :: 1645 1655 + :: 1645 1655 + :: 1645 1655 + :: 1645 1655 + :: 1645 1654 + :: 1658 1698 + :: 1658 1663 + :: 1658 1661 + :: 1664 1677 + :: 1664 1665 + :: 1681 1696 + :: 1681 1696 + :: 1681 1685 + :: 1681 1685 + :: 1681 1685 + :: 1681 1685 + :: 1682 1682 + :: 1682 1682 + :: 1683 1683 + :: 1683 1683 + :: 1686 1696 + :: 1686 1696 + :: 1686 1696 + :: 1686 1696 + :: 1686 1695 + :: 1699 1747 + :: 1699 1704 + :: 1699 1702 + :: 1705 1718 + :: 1705 1708 + :: 1722 1739 + :: 1722 1739 + :: 1722 1728 + :: 1722 1728 + :: 1722 1728 + :: 1722 1728 + :: 1723 1723 + :: 1723 1723 + :: 1724 1724 + :: 1724 1724 + :: 1725 1725 + :: 1725 1725 + :: 1726 1726 + :: 1726 1726 + :: 1729 1739 + :: 1729 1739 + :: 1729 1739 + :: 1729 1739 + :: 1729 1738 + :: 1748 1871 + :: 1748 1761 + :: 1748 1754 + :: 1765 1869 + :: 1765 1814 + :: 1765 1774 + :: 1765 1774 + :: 1765 1774 + :: 1765 1774 + :: 1765 1773 + :: 1775 1793 + :: 1775 1793 + :: 1775 1791 + :: 1776 1790 + :: 1776 1790 + :: 1776 1786 + :: 1776 1776 + :: 1777 1786 + :: 1777 1786 + :: 1777 1786 + :: 1777 1785 + :: 1787 1790 + :: 1787 1790 + :: 1787 1790 + :: 1787 1790 + :: 1787 1790 + :: 1792 1793 :: 1794 1803 :: 1794 1803 :: 1794 1803 :: 1794 1803 :: 1794 1802 - :: 1804 1822 - :: 1804 1822 - :: 1804 1820 - :: 1805 1819 - :: 1805 1819 - :: 1805 1815 - :: 1805 1805 - :: 1806 1815 - :: 1806 1815 - :: 1806 1815 - :: 1806 1814 - :: 1816 1819 - :: 1816 1819 - :: 1816 1819 - :: 1816 1819 - :: 1816 1819 - :: 1821 1822 - :: 1823 1832 - :: 1823 1832 - :: 1823 1832 - :: 1823 1832 - :: 1823 1831 - :: 1833 1843 - :: 1833 1843 - :: 1833 1843 - :: 1833 1843 - :: 1833 1842 - :: 1846 1898 - :: 1846 1856 - :: 1846 1856 - :: 1846 1856 - :: 1846 1856 - :: 1846 1855 - :: 1857 1876 - :: 1857 1876 - :: 1857 1874 - :: 1858 1873 - :: 1858 1873 - :: 1858 1869 - :: 1858 1858 - :: 1859 1869 - :: 1859 1869 - :: 1859 1869 - :: 1859 1868 - :: 1870 1873 - :: 1870 1873 - :: 1870 1873 - :: 1870 1873 - :: 1870 1873 - :: 1875 1876 - :: 1877 1887 - :: 1877 1887 - :: 1877 1887 - :: 1877 1887 - :: 1877 1886 - :: 1888 1898 - :: 1888 1898 - :: 1888 1898 - :: 1888 1898 - :: 1888 1897 - :: 1901 1946 - :: 1901 1906 - :: 1901 1904 - :: 1907 1920 - :: 1907 1911 - :: 1924 1944 - :: 1924 1944 - :: 1924 1933 - :: 1924 1933 - :: 1924 1933 - :: 1924 1933 - :: 1925 1925 - :: 1925 1925 - :: 1926 1926 - :: 1926 1926 - :: 1927 1927 - :: 1927 1927 - :: 1928 1928 - :: 1928 1928 - :: 1929 1929 - :: 1929 1929 - :: 1930 1930 - :: 1930 1930 - :: 1931 1931 - :: 1931 1931 - :: 1934 1944 - :: 1934 1944 - :: 1934 1944 - :: 1934 1944 - :: 1934 1943 - :: 1947 1986 - :: 1947 1952 - :: 1947 1950 - :: 1953 1966 - :: 1953 1955 - :: 1970 1984 - :: 1970 1984 - :: 1970 1973 - :: 1970 1973 - :: 1970 1973 - :: 1970 1973 - :: 1971 1971 - :: 1971 1971 - :: 1974 1984 - :: 1974 1984 - :: 1974 1984 - :: 1974 1984 - :: 1974 1983 - :: 1987 2026 - :: 1987 1992 - :: 1987 1990 - :: 1993 2006 - :: 1993 1996 - :: 2010 2024 - :: 2010 2024 - :: 2010 2013 - :: 2010 2013 - :: 2010 2013 - :: 2010 2013 - :: 2011 2011 - :: 2011 2011 - :: 2014 2024 - :: 2014 2024 - :: 2014 2024 - :: 2014 2024 - :: 2014 2023 - :: 2027 2056 - :: 2027 2032 - :: 2027 2030 - :: 2033 2046 - :: 2033 2037 - :: 2050 2054 - :: 2050 2054 - :: 2050 2054 - :: 2050 2054 - :: 2050 2054 - :: 2050 2054 - :: 2051 2052 - :: 2051 2052 - :: 2057 2098 - :: 2057 2062 - :: 2057 2060 - :: 2063 2076 - :: 2063 2065 - :: 2080 2096 - :: 2080 2096 - :: 2080 2085 - :: 2080 2085 - :: 2080 2085 - :: 2080 2085 - :: 2081 2081 - :: 2081 2081 - :: 2082 2082 - :: 2082 2082 - :: 2083 2083 - :: 2083 2083 - :: 2086 2096 - :: 2086 2096 - :: 2086 2096 - :: 2086 2096 - :: 2086 2095 - :: 2099 2144 - :: 2099 2104 - :: 2099 2102 - :: 2105 2118 - :: 2105 2108 - :: 2122 2136 - :: 2122 2136 - :: 2122 2125 - :: 2122 2125 - :: 2122 2125 - :: 2122 2125 - :: 2123 2123 - :: 2123 2123 - :: 2126 2136 - :: 2126 2136 - :: 2126 2136 - :: 2126 2136 - :: 2126 2135 - :: 2145 2189 - :: 2145 2158 - :: 2145 2150 - :: 2162 2181 - :: 2162 2181 - :: 2162 2174 - :: 2162 2174 - :: 2162 2172 - :: 2163 2171 - :: 2163 2166 - :: 2163 2166 - :: 2163 2166 - :: 2163 2166 - :: 2163 2166 - :: 2163 2165 - :: 2169 2171 - :: 2169 2171 - :: 2169 2171 - :: 2169 2171 - :: 2169 2171 - :: 2169 2171 - :: 2173 2174 - :: 2175 2181 - :: 2175 2181 - :: 2175 2181 - :: 2175 2181 - :: 2175 2180 - :: 2190 2390 - :: 2190 2203 - :: 2190 2196 - :: 2207 2388 - :: 2207 2212 - :: 2207 2212 - :: 2207 2212 - :: 2207 2212 - :: 2207 2212 - :: 2207 2211 - :: 2215 2220 - :: 2215 2220 - :: 2215 2220 - :: 2215 2220 - :: 2215 2220 - :: 2215 2219 - :: 2223 2228 - :: 2223 2228 - :: 2223 2228 - :: 2223 2228 - :: 2223 2228 - :: 2223 2227 - :: 2231 2238 - :: 2231 2238 - :: 2231 2238 - :: 2231 2238 - :: 2231 2238 - :: 2231 2237 - :: 2241 2247 - :: 2241 2247 - :: 2241 2247 - :: 2241 2247 - :: 2241 2247 - :: 2241 2246 - :: 2250 2255 - :: 2250 2255 - :: 2250 2255 - :: 2250 2255 - :: 2250 2255 - :: 2250 2254 - :: 2258 2263 - :: 2258 2263 - :: 2258 2263 - :: 2258 2263 - :: 2258 2263 - :: 2258 2262 - :: 2266 2271 - :: 2266 2271 - :: 2266 2271 - :: 2266 2271 - :: 2266 2271 - :: 2266 2270 - :: 2274 2283 - :: 2274 2283 - :: 2274 2283 - :: 2274 2283 - :: 2274 2283 - :: 2274 2282 - :: 2286 2291 - :: 2286 2291 - :: 2286 2291 - :: 2286 2291 - :: 2286 2291 - :: 2286 2290 - :: 2294 2299 - :: 2294 2299 - :: 2294 2299 - :: 2294 2299 - :: 2294 2299 - :: 2294 2298 - :: 2302 2307 - :: 2302 2307 - :: 2302 2307 - :: 2302 2307 - :: 2302 2307 - :: 2302 2306 - :: 2310 2318 - :: 2310 2318 - :: 2310 2318 - :: 2310 2318 - :: 2310 2318 - :: 2310 2317 - :: 2321 2327 - :: 2321 2327 - :: 2321 2327 - :: 2321 2327 - :: 2321 2327 - :: 2321 2326 - :: 2330 2340 - :: 2330 2340 - :: 2330 2340 - :: 2330 2340 - :: 2330 2340 - :: 2330 2339 - :: 2343 2364 - :: 2343 2347 - :: 2343 2347 - :: 2343 2347 - :: 2343 2347 - :: 2343 2346 - :: 2348 2358 - :: 2348 2358 - :: 2348 2358 - :: 2348 2358 - :: 2348 2357 - :: 2359 2364 - :: 2359 2364 - :: 2359 2364 - :: 2359 2364 - :: 2359 2363 - :: 2367 2374 - :: 2367 2374 - :: 2367 2374 - :: 2367 2374 - :: 2367 2374 - :: 2367 2373 - :: 2377 2382 - :: 2377 2382 - :: 2377 2382 - :: 2377 2382 - :: 2377 2382 - :: 2377 2381 - :: 2385 2388 - :: 2385 2388 - :: 2385 2388 - :: 2385 2388 - :: 2385 2388 - :: 2385 2387 - :: 2391 2436 - :: 2391 2396 - :: 2391 2394 - :: 2397 2410 - :: 2397 2405 - :: 2414 2434 - :: 2414 2434 - :: 2414 2423 - :: 2414 2423 - :: 2414 2423 - :: 2414 2423 - :: 2415 2415 - :: 2415 2415 - :: 2416 2416 - :: 2416 2416 - :: 2417 2417 - :: 2417 2417 - :: 2418 2418 - :: 2418 2418 - :: 2419 2419 - :: 2419 2419 - :: 2420 2420 - :: 2420 2420 - :: 2421 2421 - :: 2421 2421 - :: 2424 2434 - :: 2424 2434 - :: 2424 2434 - :: 2424 2434 - :: 2424 2433 - :: 2437 2482 - :: 2437 2442 - :: 2437 2440 - :: 2443 2456 - :: 2443 2447 - :: 2460 2480 - :: 2460 2480 - :: 2460 2469 - :: 2460 2469 - :: 2460 2469 - :: 2460 2469 - :: 2461 2461 - :: 2461 2461 - :: 2462 2462 - :: 2462 2462 - :: 2463 2463 - :: 2463 2463 - :: 2464 2464 - :: 2464 2464 - :: 2465 2465 - :: 2465 2465 - :: 2466 2466 - :: 2466 2466 - :: 2467 2467 - :: 2467 2467 - :: 2470 2480 - :: 2470 2480 - :: 2470 2480 - :: 2470 2480 - :: 2470 2479 - :: 2483 2528 - :: 2483 2488 - :: 2483 2486 - :: 2489 2502 - :: 2489 2496 - :: 2506 2520 - :: 2506 2520 - :: 2506 2509 - :: 2506 2509 - :: 2506 2509 - :: 2506 2509 - :: 2507 2507 - :: 2507 2507 - :: 2510 2520 - :: 2510 2520 - :: 2510 2520 - :: 2510 2520 - :: 2510 2519 - :: 2529 2567 - :: 2529 2542 - :: 2529 2533 - :: 2546 2565 - :: 2546 2558 - :: 2546 2550 - :: 2546 2550 - :: 2546 2550 - :: 2546 2550 - :: 2546 2549 - :: 2551 2553 - :: 2551 2553 - :: 2551 2553 - :: 2551 2553 - :: 2551 2552 - :: 2554 2558 - :: 2554 2558 - :: 2554 2558 - :: 2554 2558 - :: 2554 2557 - :: 2561 2565 - :: 2561 2565 - :: 2561 2565 - :: 2561 2565 - :: 2561 2565 - :: 2561 2564 - :: 2568 2613 - :: 2568 2573 - :: 2568 2571 - :: 2574 2587 - :: 2574 2582 - :: 2591 2605 - :: 2591 2605 - :: 2591 2594 - :: 2591 2594 - :: 2591 2594 - :: 2591 2594 - :: 2592 2592 - :: 2592 2592 - :: 2595 2605 - :: 2595 2605 - :: 2595 2605 - :: 2595 2605 - :: 2595 2604 - :: 2614 2640 - :: 2614 2627 - :: 2614 2621 - :: 2631 2638 - :: 2631 2638 - :: 2631 2638 - :: 2631 2638 - :: 2631 2636 - :: 2631 2636 - :: 2631 2636 - :: 2637 2638 - :: 2641 2680 - :: 2641 2646 - :: 2641 2644 - :: 2647 2660 - :: 2647 2651 - :: 2664 2678 - :: 2664 2678 - :: 2664 2667 - :: 2664 2667 - :: 2664 2667 - :: 2664 2667 - :: 2665 2665 - :: 2665 2665 - :: 2668 2678 - :: 2668 2678 - :: 2668 2678 - :: 2668 2678 - :: 2668 2677 - :: 2681 2726 - :: 2681 2686 - :: 2681 2684 - :: 2687 2700 - :: 2687 2691 - :: 2704 2724 - :: 2704 2724 - :: 2704 2713 - :: 2704 2713 - :: 2704 2713 - :: 2704 2713 - :: 2705 2705 - :: 2705 2705 - :: 2706 2706 - :: 2706 2706 - :: 2707 2707 - :: 2707 2707 - :: 2708 2708 - :: 2708 2708 - :: 2709 2709 - :: 2709 2709 - :: 2710 2710 - :: 2710 2710 - :: 2711 2711 - :: 2711 2711 - :: 2714 2724 - :: 2714 2724 - :: 2714 2724 - :: 2714 2724 - :: 2714 2723 - :: 2727 2772 - :: 2727 2732 - :: 2727 2730 - :: 2733 2746 - :: 2733 2736 - :: 2750 2764 - :: 2750 2764 - :: 2750 2753 - :: 2750 2753 - :: 2750 2753 - :: 2750 2753 - :: 2751 2751 - :: 2751 2751 - :: 2754 2764 - :: 2754 2764 - :: 2754 2764 - :: 2754 2764 - :: 2754 2763 - :: 2773 2819 - :: 2773 2786 - :: 2773 2781 - :: 2790 2811 - :: 2790 2811 - :: 2790 2794 - :: 2790 2794 - :: 2790 2794 - :: 2790 2794 - :: 2790 2793 - :: 2795 2805 - :: 2795 2805 - :: 2795 2805 - :: 2795 2805 - :: 2795 2804 - :: 2806 2811 - :: 2806 2811 - :: 2806 2811 - :: 2806 2811 - :: 2806 2810 - :: 2820 2872 - :: 2820 2833 - :: 2820 2825 - :: 2837 2870 - :: 2837 2870 - :: 2837 2844 - :: 2837 2844 - :: 2837 2844 - :: 2837 2844 - :: 2837 2843 - :: 2845 2870 - :: 2845 2870 - :: 2845 2868 - :: 2846 2867 - :: 2846 2854 - :: 2846 2854 - :: 2846 2854 - :: 2846 2854 - :: 2846 2854 - :: 2846 2853 - :: 2857 2861 - :: 2857 2861 - :: 2857 2861 - :: 2857 2861 - :: 2857 2861 - :: 2857 2860 - :: 2864 2867 - :: 2864 2867 - :: 2864 2867 - :: 2864 2867 - :: 2864 2867 - :: 2864 2867 - :: 2869 2870 - :: 2873 2901 - :: 2873 2878 - :: 2873 2876 - :: 2879 2892 - :: 2879 2880 - :: 2896 2899 - :: 2896 2899 - :: 2896 2899 - :: 2896 2899 - :: 2896 2899 - :: 2896 2899 - :: 2897 2897 - :: 2897 2897 - :: 2902 2947 - :: 2902 2907 - :: 2902 2905 - :: 2908 2921 - :: 2908 2912 - :: 2925 2945 - :: 2925 2945 - :: 2925 2934 - :: 2925 2934 - :: 2925 2934 - :: 2925 2934 - :: 2926 2926 - :: 2926 2926 - :: 2927 2927 - :: 2927 2927 - :: 2928 2928 - :: 2928 2928 - :: 2929 2929 - :: 2929 2929 - :: 2930 2930 - :: 2930 2930 - :: 2931 2931 - :: 2931 2931 - :: 2932 2932 - :: 2932 2932 - :: 2935 2945 - :: 2935 2945 - :: 2935 2945 - :: 2935 2945 - :: 2935 2944 - :: 2948 2990 - :: 2948 2953 - :: 2948 2951 - :: 2954 2967 - :: 2954 2957 - :: 2971 2988 - :: 2971 2988 - :: 2971 2977 - :: 2971 2977 - :: 2971 2977 - :: 2971 2977 - :: 2972 2972 - :: 2972 2972 - :: 2973 2973 - :: 2973 2973 - :: 2974 2974 - :: 2974 2974 - :: 2975 2975 - :: 2975 2975 - :: 2978 2988 - :: 2978 2988 - :: 2978 2988 - :: 2978 2988 - :: 2978 2987 - :: 2991 3036 - :: 2991 2996 - :: 2991 2994 - :: 2997 3010 - :: 2997 3006 - :: 3014 3034 - :: 3014 3034 - :: 3014 3034 - :: 3014 3034 - :: 3014 3032 - :: 3015 3031 - :: 3015 3022 - :: 3015 3022 - :: 3015 3022 - :: 3015 3022 - :: 3015 3022 - :: 3025 3031 - :: 3025 3031 - :: 3025 3031 - :: 3025 3031 - :: 3025 3031 - :: 3025 3031 - :: 3033 3034 - :: 3037 3085 - :: 3037 3042 - :: 3037 3040 - :: 3043 3056 - :: 3043 3050 - :: 3060 3083 - :: 3060 3083 - :: 3060 3072 - :: 3060 3072 - :: 3060 3072 - :: 3060 3072 - :: 3061 3061 - :: 3061 3061 - :: 3062 3062 - :: 3062 3062 - :: 3063 3063 - :: 3063 3063 - :: 3064 3064 - :: 3064 3064 - :: 3065 3065 - :: 3065 3065 - :: 3066 3066 - :: 3066 3066 - :: 3067 3067 - :: 3067 3067 - :: 3068 3068 - :: 3068 3068 - :: 3069 3069 - :: 3069 3069 - :: 3070 3070 - :: 3070 3070 - :: 3073 3083 - :: 3073 3083 - :: 3073 3083 - :: 3073 3083 - :: 3073 3082 - :: 3086 3133 - :: 3086 3091 - :: 3086 3089 - :: 3092 3105 - :: 3092 3097 - :: 3109 3130 - :: 3109 3130 + :: 1804 1814 + :: 1804 1814 + :: 1804 1814 + :: 1804 1814 + :: 1804 1813 + :: 1817 1869 + :: 1817 1827 + :: 1817 1827 + :: 1817 1827 + :: 1817 1827 + :: 1817 1826 + :: 1828 1847 + :: 1828 1847 + :: 1828 1845 + :: 1829 1844 + :: 1829 1844 + :: 1829 1840 + :: 1829 1829 + :: 1830 1840 + :: 1830 1840 + :: 1830 1840 + :: 1830 1839 + :: 1841 1844 + :: 1841 1844 + :: 1841 1844 + :: 1841 1844 + :: 1841 1844 + :: 1846 1847 + :: 1848 1858 + :: 1848 1858 + :: 1848 1858 + :: 1848 1858 + :: 1848 1857 + :: 1859 1869 + :: 1859 1869 + :: 1859 1869 + :: 1859 1869 + :: 1859 1868 + :: 1872 1917 + :: 1872 1877 + :: 1872 1875 + :: 1878 1891 + :: 1878 1882 + :: 1895 1915 + :: 1895 1915 + :: 1895 1904 + :: 1895 1904 + :: 1895 1904 + :: 1895 1904 + :: 1896 1896 + :: 1896 1896 + :: 1897 1897 + :: 1897 1897 + :: 1898 1898 + :: 1898 1898 + :: 1899 1899 + :: 1899 1899 + :: 1900 1900 + :: 1900 1900 + :: 1901 1901 + :: 1901 1901 + :: 1902 1902 + :: 1902 1902 + :: 1905 1915 + :: 1905 1915 + :: 1905 1915 + :: 1905 1915 + :: 1905 1914 + :: 1918 1957 + :: 1918 1923 + :: 1918 1921 + :: 1924 1937 + :: 1924 1926 + :: 1941 1955 + :: 1941 1955 + :: 1941 1944 + :: 1941 1944 + :: 1941 1944 + :: 1941 1944 + :: 1942 1942 + :: 1942 1942 + :: 1945 1955 + :: 1945 1955 + :: 1945 1955 + :: 1945 1955 + :: 1945 1954 + :: 1958 1997 + :: 1958 1963 + :: 1958 1961 + :: 1964 1977 + :: 1964 1967 + :: 1981 1995 + :: 1981 1995 + :: 1981 1984 + :: 1981 1984 + :: 1981 1984 + :: 1981 1984 + :: 1982 1982 + :: 1982 1982 + :: 1985 1995 + :: 1985 1995 + :: 1985 1995 + :: 1985 1995 + :: 1985 1994 + :: 1998 2027 + :: 1998 2003 + :: 1998 2001 + :: 2004 2017 + :: 2004 2008 + :: 2021 2025 + :: 2021 2025 + :: 2021 2025 + :: 2021 2025 + :: 2021 2025 + :: 2021 2025 + :: 2022 2023 + :: 2022 2023 + :: 2028 2087 + :: 2028 2033 + :: 2028 2031 + :: 2034 2047 + :: 2034 2036 + :: 2051 2085 + :: 2051 2085 + :: 2051 2056 + :: 2051 2056 + :: 2051 2056 + :: 2051 2056 + :: 2052 2052 + :: 2052 2052 + :: 2053 2053 + :: 2053 2053 + :: 2054 2054 + :: 2054 2054 + :: 2057 2074 + :: 2057 2057 + :: 2058 2074 + :: 2058 2074 + :: 2059 2072 + :: 2059 2063 + :: 2059 2063 + :: 2059 2063 + :: 2059 2063 + :: 2059 2063 + :: 2060 2060 + :: 2060 2060 + :: 2060 2060 + :: 2061 2061 + :: 2061 2061 + :: 2061 2061 + :: 2066 2072 + :: 2066 2072 + :: 2066 2072 + :: 2066 2072 + :: 2066 2072 + :: 2075 2085 + :: 2075 2085 + :: 2075 2085 + :: 2075 2085 + :: 2075 2084 + :: 2088 2133 + :: 2088 2093 + :: 2088 2091 + :: 2094 2107 + :: 2094 2097 + :: 2111 2125 + :: 2111 2125 + :: 2111 2114 + :: 2111 2114 + :: 2111 2114 + :: 2111 2114 + :: 2112 2112 + :: 2112 2112 + :: 2115 2125 + :: 2115 2125 + :: 2115 2125 + :: 2115 2125 + :: 2115 2124 + :: 2134 2178 + :: 2134 2147 + :: 2134 2139 + :: 2151 2170 + :: 2151 2170 + :: 2151 2163 + :: 2151 2163 + :: 2151 2161 + :: 2152 2160 + :: 2152 2155 + :: 2152 2155 + :: 2152 2155 + :: 2152 2155 + :: 2152 2155 + :: 2152 2154 + :: 2158 2160 + :: 2158 2160 + :: 2158 2160 + :: 2158 2160 + :: 2158 2160 + :: 2158 2160 + :: 2162 2163 + :: 2164 2170 + :: 2164 2170 + :: 2164 2170 + :: 2164 2170 + :: 2164 2169 + :: 2179 2379 + :: 2179 2192 + :: 2179 2185 + :: 2196 2377 + :: 2196 2201 + :: 2196 2201 + :: 2196 2201 + :: 2196 2201 + :: 2196 2201 + :: 2196 2200 + :: 2204 2209 + :: 2204 2209 + :: 2204 2209 + :: 2204 2209 + :: 2204 2209 + :: 2204 2208 + :: 2212 2217 + :: 2212 2217 + :: 2212 2217 + :: 2212 2217 + :: 2212 2217 + :: 2212 2216 + :: 2220 2227 + :: 2220 2227 + :: 2220 2227 + :: 2220 2227 + :: 2220 2227 + :: 2220 2226 + :: 2230 2236 + :: 2230 2236 + :: 2230 2236 + :: 2230 2236 + :: 2230 2236 + :: 2230 2235 + :: 2239 2244 + :: 2239 2244 + :: 2239 2244 + :: 2239 2244 + :: 2239 2244 + :: 2239 2243 + :: 2247 2252 + :: 2247 2252 + :: 2247 2252 + :: 2247 2252 + :: 2247 2252 + :: 2247 2251 + :: 2255 2260 + :: 2255 2260 + :: 2255 2260 + :: 2255 2260 + :: 2255 2260 + :: 2255 2259 + :: 2263 2272 + :: 2263 2272 + :: 2263 2272 + :: 2263 2272 + :: 2263 2272 + :: 2263 2271 + :: 2275 2280 + :: 2275 2280 + :: 2275 2280 + :: 2275 2280 + :: 2275 2280 + :: 2275 2279 + :: 2283 2288 + :: 2283 2288 + :: 2283 2288 + :: 2283 2288 + :: 2283 2288 + :: 2283 2287 + :: 2291 2296 + :: 2291 2296 + :: 2291 2296 + :: 2291 2296 + :: 2291 2296 + :: 2291 2295 + :: 2299 2307 + :: 2299 2307 + :: 2299 2307 + :: 2299 2307 + :: 2299 2307 + :: 2299 2306 + :: 2310 2316 + :: 2310 2316 + :: 2310 2316 + :: 2310 2316 + :: 2310 2316 + :: 2310 2315 + :: 2319 2329 + :: 2319 2329 + :: 2319 2329 + :: 2319 2329 + :: 2319 2329 + :: 2319 2328 + :: 2332 2353 + :: 2332 2336 + :: 2332 2336 + :: 2332 2336 + :: 2332 2336 + :: 2332 2335 + :: 2337 2347 + :: 2337 2347 + :: 2337 2347 + :: 2337 2347 + :: 2337 2346 + :: 2348 2353 + :: 2348 2353 + :: 2348 2353 + :: 2348 2353 + :: 2348 2352 + :: 2356 2363 + :: 2356 2363 + :: 2356 2363 + :: 2356 2363 + :: 2356 2363 + :: 2356 2362 + :: 2366 2371 + :: 2366 2371 + :: 2366 2371 + :: 2366 2371 + :: 2366 2371 + :: 2366 2370 + :: 2374 2377 + :: 2374 2377 + :: 2374 2377 + :: 2374 2377 + :: 2374 2377 + :: 2374 2376 + :: 2380 2425 + :: 2380 2385 + :: 2380 2383 + :: 2386 2399 + :: 2386 2394 + :: 2403 2423 + :: 2403 2423 + :: 2403 2412 + :: 2403 2412 + :: 2403 2412 + :: 2403 2412 + :: 2404 2404 + :: 2404 2404 + :: 2405 2405 + :: 2405 2405 + :: 2406 2406 + :: 2406 2406 + :: 2407 2407 + :: 2407 2407 + :: 2408 2408 + :: 2408 2408 + :: 2409 2409 + :: 2409 2409 + :: 2410 2410 + :: 2410 2410 + :: 2413 2423 + :: 2413 2423 + :: 2413 2423 + :: 2413 2423 + :: 2413 2422 + :: 2426 2471 + :: 2426 2431 + :: 2426 2429 + :: 2432 2445 + :: 2432 2436 + :: 2449 2469 + :: 2449 2469 + :: 2449 2458 + :: 2449 2458 + :: 2449 2458 + :: 2449 2458 + :: 2450 2450 + :: 2450 2450 + :: 2451 2451 + :: 2451 2451 + :: 2452 2452 + :: 2452 2452 + :: 2453 2453 + :: 2453 2453 + :: 2454 2454 + :: 2454 2454 + :: 2455 2455 + :: 2455 2455 + :: 2456 2456 + :: 2456 2456 + :: 2459 2469 + :: 2459 2469 + :: 2459 2469 + :: 2459 2469 + :: 2459 2468 + :: 2472 2517 + :: 2472 2477 + :: 2472 2475 + :: 2478 2491 + :: 2478 2485 + :: 2495 2509 + :: 2495 2509 + :: 2495 2498 + :: 2495 2498 + :: 2495 2498 + :: 2495 2498 + :: 2496 2496 + :: 2496 2496 + :: 2499 2509 + :: 2499 2509 + :: 2499 2509 + :: 2499 2509 + :: 2499 2508 + :: 2518 2556 + :: 2518 2531 + :: 2518 2522 + :: 2535 2554 + :: 2535 2547 + :: 2535 2539 + :: 2535 2539 + :: 2535 2539 + :: 2535 2539 + :: 2535 2538 + :: 2540 2542 + :: 2540 2542 + :: 2540 2542 + :: 2540 2542 + :: 2540 2541 + :: 2543 2547 + :: 2543 2547 + :: 2543 2547 + :: 2543 2547 + :: 2543 2546 + :: 2550 2554 + :: 2550 2554 + :: 2550 2554 + :: 2550 2554 + :: 2550 2554 + :: 2550 2553 + :: 2557 2602 + :: 2557 2562 + :: 2557 2560 + :: 2563 2576 + :: 2563 2571 + :: 2580 2594 + :: 2580 2594 + :: 2580 2583 + :: 2580 2583 + :: 2580 2583 + :: 2580 2583 + :: 2581 2581 + :: 2581 2581 + :: 2584 2594 + :: 2584 2594 + :: 2584 2594 + :: 2584 2594 + :: 2584 2593 + :: 2603 2629 + :: 2603 2616 + :: 2603 2610 + :: 2620 2627 + :: 2620 2627 + :: 2620 2627 + :: 2620 2627 + :: 2620 2625 + :: 2620 2625 + :: 2620 2625 + :: 2626 2627 + :: 2630 2669 + :: 2630 2635 + :: 2630 2633 + :: 2636 2649 + :: 2636 2640 + :: 2653 2667 + :: 2653 2667 + :: 2653 2656 + :: 2653 2656 + :: 2653 2656 + :: 2653 2656 + :: 2654 2654 + :: 2654 2654 + :: 2657 2667 + :: 2657 2667 + :: 2657 2667 + :: 2657 2667 + :: 2657 2666 + :: 2670 2715 + :: 2670 2675 + :: 2670 2673 + :: 2676 2689 + :: 2676 2680 + :: 2693 2713 + :: 2693 2713 + :: 2693 2702 + :: 2693 2702 + :: 2693 2702 + :: 2693 2702 + :: 2694 2694 + :: 2694 2694 + :: 2695 2695 + :: 2695 2695 + :: 2696 2696 + :: 2696 2696 + :: 2697 2697 + :: 2697 2697 + :: 2698 2698 + :: 2698 2698 + :: 2699 2699 + :: 2699 2699 + :: 2700 2700 + :: 2700 2700 + :: 2703 2713 + :: 2703 2713 + :: 2703 2713 + :: 2703 2713 + :: 2703 2712 + :: 2716 2761 + :: 2716 2721 + :: 2716 2719 + :: 2722 2735 + :: 2722 2725 + :: 2739 2753 + :: 2739 2753 + :: 2739 2742 + :: 2739 2742 + :: 2739 2742 + :: 2739 2742 + :: 2740 2740 + :: 2740 2740 + :: 2743 2753 + :: 2743 2753 + :: 2743 2753 + :: 2743 2753 + :: 2743 2752 + :: 2762 2808 + :: 2762 2775 + :: 2762 2770 + :: 2779 2800 + :: 2779 2800 + :: 2779 2783 + :: 2779 2783 + :: 2779 2783 + :: 2779 2783 + :: 2779 2782 + :: 2784 2794 + :: 2784 2794 + :: 2784 2794 + :: 2784 2794 + :: 2784 2793 + :: 2795 2800 + :: 2795 2800 + :: 2795 2800 + :: 2795 2800 + :: 2795 2799 + :: 2809 2861 + :: 2809 2822 + :: 2809 2814 + :: 2826 2859 + :: 2826 2859 + :: 2826 2833 + :: 2826 2833 + :: 2826 2833 + :: 2826 2833 + :: 2826 2832 + :: 2834 2859 + :: 2834 2859 + :: 2834 2857 + :: 2835 2856 + :: 2835 2843 + :: 2835 2843 + :: 2835 2843 + :: 2835 2843 + :: 2835 2843 + :: 2835 2842 + :: 2846 2850 + :: 2846 2850 + :: 2846 2850 + :: 2846 2850 + :: 2846 2850 + :: 2846 2849 + :: 2853 2856 + :: 2853 2856 + :: 2853 2856 + :: 2853 2856 + :: 2853 2856 + :: 2853 2856 + :: 2858 2859 + :: 2862 2890 + :: 2862 2867 + :: 2862 2865 + :: 2868 2881 + :: 2868 2869 + :: 2885 2888 + :: 2885 2888 + :: 2885 2888 + :: 2885 2888 + :: 2885 2888 + :: 2885 2888 + :: 2886 2886 + :: 2886 2886 + :: 2891 2936 + :: 2891 2896 + :: 2891 2894 + :: 2897 2910 + :: 2897 2901 + :: 2914 2934 + :: 2914 2934 + :: 2914 2923 + :: 2914 2923 + :: 2914 2923 + :: 2914 2923 + :: 2915 2915 + :: 2915 2915 + :: 2916 2916 + :: 2916 2916 + :: 2917 2917 + :: 2917 2917 + :: 2918 2918 + :: 2918 2918 + :: 2919 2919 + :: 2919 2919 + :: 2920 2920 + :: 2920 2920 + :: 2921 2921 + :: 2921 2921 + :: 2924 2934 + :: 2924 2934 + :: 2924 2934 + :: 2924 2934 + :: 2924 2933 + :: 2937 2979 + :: 2937 2942 + :: 2937 2940 + :: 2943 2956 + :: 2943 2946 + :: 2960 2977 + :: 2960 2977 + :: 2960 2966 + :: 2960 2966 + :: 2960 2966 + :: 2960 2966 + :: 2961 2961 + :: 2961 2961 + :: 2962 2962 + :: 2962 2962 + :: 2963 2963 + :: 2963 2963 + :: 2964 2964 + :: 2964 2964 + :: 2967 2977 + :: 2967 2977 + :: 2967 2977 + :: 2967 2977 + :: 2967 2976 + :: 2980 3025 + :: 2980 2985 + :: 2980 2983 + :: 2986 2999 + :: 2986 2995 + :: 3003 3023 + :: 3003 3023 + :: 3003 3023 + :: 3003 3023 + :: 3003 3021 + :: 3004 3020 + :: 3004 3011 + :: 3004 3011 + :: 3004 3011 + :: 3004 3011 + :: 3004 3011 + :: 3014 3020 + :: 3014 3020 + :: 3014 3020 + :: 3014 3020 + :: 3014 3020 + :: 3014 3020 + :: 3022 3023 + :: 3026 3074 + :: 3026 3031 + :: 3026 3029 + :: 3032 3045 + :: 3032 3039 + :: 3049 3072 + :: 3049 3072 + :: 3049 3061 + :: 3049 3061 + :: 3049 3061 + :: 3049 3061 + :: 3050 3050 + :: 3050 3050 + :: 3051 3051 + :: 3051 3051 + :: 3052 3052 + :: 3052 3052 + :: 3053 3053 + :: 3053 3053 + :: 3054 3054 + :: 3054 3054 + :: 3055 3055 + :: 3055 3055 + :: 3056 3056 + :: 3056 3056 + :: 3057 3057 + :: 3057 3057 + :: 3058 3058 + :: 3058 3058 + :: 3059 3059 + :: 3059 3059 + :: 3062 3072 + :: 3062 3072 + :: 3062 3072 + :: 3062 3072 + :: 3062 3071 + :: 3075 3122 + :: 3075 3080 + :: 3075 3078 + :: 3081 3094 + :: 3081 3086 + :: 3098 3119 + :: 3098 3119 + :: 3098 3108 + :: 3098 3108 + :: 3098 3108 + :: 3098 3108 + :: 3099 3099 + :: 3099 3099 + :: 3100 3100 + :: 3100 3100 + :: 3101 3101 + :: 3101 3101 + :: 3102 3102 + :: 3102 3102 + :: 3103 3103 + :: 3103 3103 + :: 3104 3104 + :: 3104 3104 + :: 3105 3105 + :: 3105 3105 + :: 3106 3106 + :: 3106 3106 :: 3109 3119 :: 3109 3119 :: 3109 3119 - :: 3109 3119 - :: 3110 3110 - :: 3110 3110 - :: 3111 3111 - :: 3111 3111 - :: 3112 3112 - :: 3112 3112 - :: 3113 3113 - :: 3113 3113 - :: 3114 3114 - :: 3114 3114 - :: 3115 3115 - :: 3115 3115 - :: 3116 3116 - :: 3116 3116 - :: 3117 3117 - :: 3117 3117 - :: 3120 3130 - :: 3120 3130 - :: 3120 3130 - :: 3120 3130 - :: 3120 3129 + :: 3109 3119 + :: 3109 3118 Index: modules/pt/tests/data/ok/peg_peg-ast-templated/3_peg_itself ================================================================== --- modules/pt/tests/data/ok/peg_peg-ast-templated/3_peg_itself +++ modules/pt/tests/data/ok/peg_peg-ast-templated/3_peg_itself @@ -1,6 +1,6 @@ - :: 0 3504 + :: 0 3498
              :: 99 122 :: 103 111 :: 103 110 :: 112 122 :: 113 119 @@ -834,1307 +834,1319 @@ :: 1364 1374 :: 1364 1374 :: 1364 1374 :: 1364 1374 :: 1364 1373 - :: 1377 1424 + :: 1377 1404 :: 1377 1382 :: 1377 1380 :: 1383 1396 :: 1383 1385 - :: 1400 1422 - :: 1400 1422 - :: 1400 1403 - :: 1400 1403 - :: 1400 1403 - :: 1400 1403 - :: 1401 1401 - :: 1401 1401 - :: 1404 1407 - :: 1404 1407 - :: 1404 1407 - :: 1404 1407 - :: 1405 1405 - :: 1405 1405 - :: 1408 1411 - :: 1408 1411 - :: 1408 1411 - :: 1408 1411 - :: 1409 1409 - :: 1409 1409 - :: 1412 1422 - :: 1412 1422 - :: 1412 1422 - :: 1412 1422 - :: 1412 1421 - :: 1425 1452 - :: 1425 1430 - :: 1425 1428 - :: 1431 1444 - :: 1431 1433 - :: 1448 1450 - :: 1448 1450 - :: 1448 1450 - :: 1448 1448 - :: 1449 1450 - :: 1449 1450 - :: 1449 1450 - :: 1453 1495 - :: 1453 1458 - :: 1453 1456 - :: 1459 1472 - :: 1459 1461 - :: 1476 1487 - :: 1476 1480 - :: 1476 1480 - :: 1476 1480 - :: 1476 1480 - :: 1476 1480 - :: 1477 1478 - :: 1477 1478 - :: 1483 1487 - :: 1483 1487 - :: 1483 1487 - :: 1483 1487 - :: 1483 1487 - :: 1484 1485 - :: 1484 1485 - :: 1496 1541 - :: 1496 1509 - :: 1496 1505 - :: 1513 1539 - :: 1513 1539 - :: 1513 1521 - :: 1513 1521 - :: 1513 1521 - :: 1513 1521 - :: 1513 1520 - :: 1522 1539 - :: 1522 1539 - :: 1522 1537 - :: 1523 1536 - :: 1523 1536 - :: 1523 1528 - :: 1523 1528 - :: 1523 1528 - :: 1523 1528 - :: 1523 1527 - :: 1529 1536 - :: 1529 1536 - :: 1529 1536 - :: 1529 1536 - :: 1529 1536 - :: 1538 1539 - :: 1542 1597 - :: 1542 1547 - :: 1542 1545 - :: 1548 1561 - :: 1548 1552 - :: 1565 1589 - :: 1565 1589 - :: 1565 1568 - :: 1565 1568 - :: 1565 1568 - :: 1565 1568 - :: 1565 1567 - :: 1569 1578 - :: 1569 1578 - :: 1569 1578 - :: 1569 1578 - :: 1569 1577 - :: 1579 1589 - :: 1579 1589 - :: 1579 1589 - :: 1579 1589 - :: 1579 1588 - :: 1598 1656 - :: 1598 1611 - :: 1598 1604 - :: 1615 1654 - :: 1615 1654 - :: 1615 1625 - :: 1615 1625 - :: 1615 1625 - :: 1615 1625 - :: 1615 1624 - :: 1626 1632 - :: 1626 1632 - :: 1626 1632 - :: 1626 1632 - :: 1626 1631 - :: 1633 1644 - :: 1633 1644 - :: 1633 1642 - :: 1633 1642 - :: 1633 1642 - :: 1643 1644 - :: 1645 1650 - :: 1645 1650 - :: 1645 1650 - :: 1645 1650 - :: 1645 1649 + :: 1400 1402 + :: 1400 1402 + :: 1400 1402 + :: 1400 1400 + :: 1401 1402 + :: 1401 1402 + :: 1401 1402 + :: 1405 1447 + :: 1405 1410 + :: 1405 1408 + :: 1411 1424 + :: 1411 1413 + :: 1428 1439 + :: 1428 1432 + :: 1428 1432 + :: 1428 1432 + :: 1428 1432 + :: 1428 1432 + :: 1429 1430 + :: 1429 1430 + :: 1435 1439 + :: 1435 1439 + :: 1435 1439 + :: 1435 1439 + :: 1435 1439 + :: 1436 1437 + :: 1436 1437 + :: 1448 1493 + :: 1448 1461 + :: 1448 1457 + :: 1465 1491 + :: 1465 1491 + :: 1465 1473 + :: 1465 1473 + :: 1465 1473 + :: 1465 1473 + :: 1465 1472 + :: 1474 1491 + :: 1474 1491 + :: 1474 1489 + :: 1475 1488 + :: 1475 1488 + :: 1475 1480 + :: 1475 1480 + :: 1475 1480 + :: 1475 1480 + :: 1475 1479 + :: 1481 1488 + :: 1481 1488 + :: 1481 1488 + :: 1481 1488 + :: 1481 1488 + :: 1490 1491 + :: 1494 1568 + :: 1494 1499 + :: 1494 1497 + :: 1500 1513 + :: 1500 1504 + :: 1517 1560 + :: 1517 1560 + :: 1517 1520 + :: 1517 1520 + :: 1517 1520 + :: 1517 1520 + :: 1518 1518 + :: 1518 1518 + :: 1521 1524 + :: 1521 1524 + :: 1521 1524 + :: 1521 1524 + :: 1522 1522 + :: 1522 1522 + :: 1525 1528 + :: 1525 1528 + :: 1525 1528 + :: 1525 1528 + :: 1526 1526 + :: 1526 1526 + :: 1529 1539 + :: 1529 1539 + :: 1529 1539 + :: 1529 1539 + :: 1529 1538 + :: 1540 1549 + :: 1540 1549 + :: 1540 1549 + :: 1540 1549 + :: 1540 1548 + :: 1550 1560 + :: 1550 1560 + :: 1550 1560 + :: 1550 1560 + :: 1550 1559 + :: 1569 1627 + :: 1569 1582 + :: 1569 1575 + :: 1586 1625 + :: 1586 1625 + :: 1586 1596 + :: 1586 1596 + :: 1586 1596 + :: 1586 1596 + :: 1586 1595 + :: 1597 1603 + :: 1597 1603 + :: 1597 1603 + :: 1597 1603 + :: 1597 1602 + :: 1604 1615 + :: 1604 1615 + :: 1604 1613 + :: 1604 1613 + :: 1604 1613 + :: 1614 1615 + :: 1616 1621 + :: 1616 1621 + :: 1616 1621 + :: 1616 1621 + :: 1616 1620 + :: 1622 1625 + :: 1622 1625 + :: 1622 1625 + :: 1622 1625 + :: 1622 1624 + :: 1628 1697 + :: 1628 1633 + :: 1628 1631 + :: 1634 1647 + :: 1634 1638 + :: 1651 1689 + :: 1651 1689 :: 1651 1654 :: 1651 1654 :: 1651 1654 - :: 1651 1654 - :: 1651 1653 - :: 1657 1726 - :: 1657 1662 - :: 1657 1660 - :: 1663 1676 - :: 1663 1667 - :: 1680 1718 - :: 1680 1718 - :: 1680 1683 - :: 1680 1683 - :: 1680 1683 - :: 1680 1683 - :: 1681 1681 - :: 1681 1681 - :: 1684 1687 - :: 1684 1687 - :: 1684 1687 - :: 1684 1687 - :: 1685 1685 - :: 1685 1685 - :: 1688 1691 - :: 1688 1691 - :: 1688 1691 - :: 1688 1691 - :: 1689 1689 - :: 1689 1689 - :: 1692 1695 - :: 1692 1695 - :: 1692 1695 - :: 1692 1695 - :: 1693 1693 - :: 1693 1693 - :: 1696 1699 - :: 1696 1699 - :: 1696 1699 - :: 1696 1699 - :: 1697 1697 - :: 1697 1697 - :: 1700 1703 - :: 1700 1703 - :: 1700 1703 - :: 1700 1703 - :: 1701 1701 - :: 1701 1701 - :: 1704 1707 - :: 1704 1707 - :: 1704 1707 - :: 1704 1707 - :: 1705 1705 - :: 1705 1705 - :: 1708 1718 - :: 1708 1718 - :: 1708 1718 - :: 1708 1718 - :: 1708 1717 - :: 1727 1770 - :: 1727 1740 - :: 1727 1732 - :: 1744 1768 - :: 1744 1768 - :: 1744 1747 - :: 1744 1747 - :: 1744 1747 - :: 1744 1747 - :: 1744 1746 - :: 1748 1758 - :: 1748 1758 - :: 1748 1758 - :: 1748 1758 - :: 1748 1757 - :: 1759 1768 - :: 1759 1768 - :: 1759 1768 - :: 1759 1768 - :: 1759 1767 - :: 1771 1846 - :: 1771 1776 - :: 1771 1774 - :: 1777 1790 - :: 1777 1781 - :: 1794 1838 - :: 1794 1838 - :: 1794 1815 - :: 1794 1815 - :: 1794 1815 - :: 1795 1813 - :: 1795 1798 - :: 1795 1798 - :: 1795 1798 - :: 1795 1798 - :: 1795 1798 - :: 1796 1796 - :: 1796 1796 - :: 1801 1804 - :: 1801 1804 - :: 1801 1804 - :: 1801 1804 - :: 1801 1804 - :: 1802 1802 - :: 1802 1802 - :: 1807 1813 - :: 1807 1813 - :: 1807 1813 - :: 1807 1813 - :: 1807 1813 - :: 1816 1838 - :: 1816 1838 - :: 1816 1836 - :: 1817 1835 - :: 1817 1820 - :: 1817 1820 - :: 1817 1820 - :: 1817 1820 - :: 1817 1820 - :: 1818 1818 - :: 1818 1818 - :: 1823 1826 - :: 1823 1826 - :: 1823 1826 - :: 1823 1826 - :: 1823 1826 - :: 1824 1824 - :: 1824 1824 - :: 1829 1835 - :: 1829 1835 - :: 1829 1835 - :: 1829 1835 - :: 1829 1835 - :: 1837 1838 - :: 1847 1882 - :: 1847 1860 - :: 1847 1856 - :: 1864 1880 - :: 1864 1880 - :: 1864 1869 - :: 1864 1869 - :: 1864 1869 - :: 1864 1869 - :: 1864 1868 - :: 1870 1880 - :: 1870 1880 - :: 1870 1880 - :: 1870 1880 - :: 1870 1879 - :: 1883 1926 - :: 1883 1888 - :: 1883 1886 - :: 1889 1902 - :: 1889 1890 - :: 1906 1924 - :: 1906 1924 - :: 1906 1909 - :: 1906 1909 - :: 1906 1909 - :: 1906 1909 - :: 1907 1907 - :: 1907 1907 - :: 1910 1913 - :: 1910 1913 - :: 1910 1913 - :: 1910 1913 - :: 1911 1911 - :: 1911 1911 - :: 1914 1924 - :: 1914 1924 - :: 1914 1924 - :: 1914 1924 - :: 1914 1923 - :: 1927 1984 - :: 1927 1932 - :: 1927 1930 - :: 1933 1946 - :: 1933 1936 - :: 1950 1976 - :: 1950 1976 - :: 1950 1953 - :: 1950 1953 - :: 1950 1953 - :: 1950 1953 - :: 1951 1951 - :: 1951 1951 - :: 1954 1957 - :: 1954 1957 - :: 1954 1957 - :: 1954 1957 - :: 1955 1955 - :: 1955 1955 - :: 1958 1961 - :: 1958 1961 - :: 1958 1961 - :: 1958 1961 - :: 1959 1959 - :: 1959 1959 - :: 1962 1965 - :: 1962 1965 - :: 1962 1965 - :: 1962 1965 - :: 1963 1963 - :: 1963 1963 - :: 1966 1976 - :: 1966 1976 - :: 1966 1976 - :: 1966 1976 - :: 1966 1975 - :: 1985 2108 - :: 1985 1998 - :: 1985 1991 - :: 2002 2106 - :: 2002 2051 + :: 1651 1654 + :: 1652 1652 + :: 1652 1652 + :: 1655 1658 + :: 1655 1658 + :: 1655 1658 + :: 1655 1658 + :: 1656 1656 + :: 1656 1656 + :: 1659 1662 + :: 1659 1662 + :: 1659 1662 + :: 1659 1662 + :: 1660 1660 + :: 1660 1660 + :: 1663 1666 + :: 1663 1666 + :: 1663 1666 + :: 1663 1666 + :: 1664 1664 + :: 1664 1664 + :: 1667 1670 + :: 1667 1670 + :: 1667 1670 + :: 1667 1670 + :: 1668 1668 + :: 1668 1668 + :: 1671 1674 + :: 1671 1674 + :: 1671 1674 + :: 1671 1674 + :: 1672 1672 + :: 1672 1672 + :: 1675 1678 + :: 1675 1678 + :: 1675 1678 + :: 1675 1678 + :: 1676 1676 + :: 1676 1676 + :: 1679 1689 + :: 1679 1689 + :: 1679 1689 + :: 1679 1689 + :: 1679 1688 + :: 1698 1741 + :: 1698 1711 + :: 1698 1703 + :: 1715 1739 + :: 1715 1739 + :: 1715 1718 + :: 1715 1718 + :: 1715 1718 + :: 1715 1718 + :: 1715 1717 + :: 1719 1729 + :: 1719 1729 + :: 1719 1729 + :: 1719 1729 + :: 1719 1728 + :: 1730 1739 + :: 1730 1739 + :: 1730 1739 + :: 1730 1739 + :: 1730 1738 + :: 1742 1817 + :: 1742 1747 + :: 1742 1745 + :: 1748 1761 + :: 1748 1752 + :: 1765 1809 + :: 1765 1809 + :: 1765 1786 + :: 1765 1786 + :: 1765 1786 + :: 1766 1784 + :: 1766 1769 + :: 1766 1769 + :: 1766 1769 + :: 1766 1769 + :: 1766 1769 + :: 1767 1767 + :: 1767 1767 + :: 1772 1775 + :: 1772 1775 + :: 1772 1775 + :: 1772 1775 + :: 1772 1775 + :: 1773 1773 + :: 1773 1773 + :: 1778 1784 + :: 1778 1784 + :: 1778 1784 + :: 1778 1784 + :: 1778 1784 + :: 1787 1809 + :: 1787 1809 + :: 1787 1807 + :: 1788 1806 + :: 1788 1791 + :: 1788 1791 + :: 1788 1791 + :: 1788 1791 + :: 1788 1791 + :: 1789 1789 + :: 1789 1789 + :: 1794 1797 + :: 1794 1797 + :: 1794 1797 + :: 1794 1797 + :: 1794 1797 + :: 1795 1795 + :: 1795 1795 + :: 1800 1806 + :: 1800 1806 + :: 1800 1806 + :: 1800 1806 + :: 1800 1806 + :: 1808 1809 + :: 1818 1853 + :: 1818 1831 + :: 1818 1827 + :: 1835 1851 + :: 1835 1851 + :: 1835 1840 + :: 1835 1840 + :: 1835 1840 + :: 1835 1840 + :: 1835 1839 + :: 1841 1851 + :: 1841 1851 + :: 1841 1851 + :: 1841 1851 + :: 1841 1850 + :: 1854 1897 + :: 1854 1859 + :: 1854 1857 + :: 1860 1873 + :: 1860 1861 + :: 1877 1895 + :: 1877 1895 + :: 1877 1880 + :: 1877 1880 + :: 1877 1880 + :: 1877 1880 + :: 1878 1878 + :: 1878 1878 + :: 1881 1884 + :: 1881 1884 + :: 1881 1884 + :: 1881 1884 + :: 1882 1882 + :: 1882 1882 + :: 1885 1895 + :: 1885 1895 + :: 1885 1895 + :: 1885 1895 + :: 1885 1894 + :: 1898 1955 + :: 1898 1903 + :: 1898 1901 + :: 1904 1917 + :: 1904 1907 + :: 1921 1947 + :: 1921 1947 + :: 1921 1924 + :: 1921 1924 + :: 1921 1924 + :: 1921 1924 + :: 1922 1922 + :: 1922 1922 + :: 1925 1928 + :: 1925 1928 + :: 1925 1928 + :: 1925 1928 + :: 1926 1926 + :: 1926 1926 + :: 1929 1932 + :: 1929 1932 + :: 1929 1932 + :: 1929 1932 + :: 1930 1930 + :: 1930 1930 + :: 1933 1936 + :: 1933 1936 + :: 1933 1936 + :: 1933 1936 + :: 1934 1934 + :: 1934 1934 + :: 1937 1947 + :: 1937 1947 + :: 1937 1947 + :: 1937 1947 + :: 1937 1946 + :: 1956 2079 + :: 1956 1969 + :: 1956 1962 + :: 1973 2077 + :: 1973 2022 + :: 1973 1982 + :: 1973 1982 + :: 1973 1982 + :: 1973 1982 + :: 1973 1981 + :: 1983 2001 + :: 1983 2001 + :: 1983 1999 + :: 1984 1998 + :: 1984 1998 + :: 1984 1994 + :: 1984 1984 + :: 1985 1994 + :: 1985 1994 + :: 1985 1994 + :: 1985 1993 + :: 1995 1998 + :: 1995 1998 + :: 1995 1998 + :: 1995 1998 + :: 1995 1998 + :: 2000 2001 :: 2002 2011 :: 2002 2011 :: 2002 2011 :: 2002 2011 :: 2002 2010 - :: 2012 2030 - :: 2012 2030 - :: 2012 2028 - :: 2013 2027 - :: 2013 2027 - :: 2013 2023 - :: 2013 2013 - :: 2014 2023 - :: 2014 2023 - :: 2014 2023 - :: 2014 2022 - :: 2024 2027 - :: 2024 2027 - :: 2024 2027 - :: 2024 2027 - :: 2024 2027 - :: 2029 2030 - :: 2031 2040 - :: 2031 2040 - :: 2031 2040 - :: 2031 2040 - :: 2031 2039 - :: 2041 2051 - :: 2041 2051 - :: 2041 2051 - :: 2041 2051 - :: 2041 2050 - :: 2054 2106 - :: 2054 2064 - :: 2054 2064 - :: 2054 2064 - :: 2054 2064 - :: 2054 2063 - :: 2065 2084 - :: 2065 2084 - :: 2065 2082 - :: 2066 2081 - :: 2066 2081 - :: 2066 2077 - :: 2066 2066 - :: 2067 2077 - :: 2067 2077 - :: 2067 2077 - :: 2067 2076 - :: 2078 2081 - :: 2078 2081 - :: 2078 2081 - :: 2078 2081 - :: 2078 2081 - :: 2083 2084 - :: 2085 2095 - :: 2085 2095 - :: 2085 2095 - :: 2085 2095 - :: 2085 2094 - :: 2096 2106 - :: 2096 2106 - :: 2096 2106 - :: 2096 2106 - :: 2096 2105 - :: 2109 2172 - :: 2109 2114 - :: 2109 2112 - :: 2115 2128 - :: 2115 2119 - :: 2132 2170 - :: 2132 2170 - :: 2132 2135 - :: 2132 2135 - :: 2132 2135 - :: 2132 2135 - :: 2133 2133 - :: 2133 2133 - :: 2136 2139 - :: 2136 2139 - :: 2136 2139 - :: 2136 2139 - :: 2137 2137 - :: 2137 2137 - :: 2140 2143 - :: 2140 2143 - :: 2140 2143 - :: 2140 2143 - :: 2141 2141 - :: 2141 2141 - :: 2144 2147 - :: 2144 2147 - :: 2144 2147 - :: 2144 2147 - :: 2145 2145 - :: 2145 2145 - :: 2148 2151 - :: 2148 2151 - :: 2148 2151 - :: 2148 2151 - :: 2149 2149 - :: 2149 2149 - :: 2152 2155 - :: 2152 2155 - :: 2152 2155 - :: 2152 2155 - :: 2153 2153 - :: 2153 2153 - :: 2156 2159 - :: 2156 2159 - :: 2156 2159 - :: 2156 2159 - :: 2157 2157 - :: 2157 2157 - :: 2160 2170 - :: 2160 2170 - :: 2160 2170 - :: 2160 2170 - :: 2160 2169 - :: 2173 2212 - :: 2173 2178 - :: 2173 2176 - :: 2179 2192 - :: 2179 2181 - :: 2196 2210 - :: 2196 2210 - :: 2196 2199 - :: 2196 2199 - :: 2196 2199 - :: 2196 2199 - :: 2197 2197 - :: 2197 2197 - :: 2200 2210 - :: 2200 2210 - :: 2200 2210 - :: 2200 2210 - :: 2200 2209 - :: 2213 2252 - :: 2213 2218 - :: 2213 2216 - :: 2219 2232 - :: 2219 2222 - :: 2236 2250 - :: 2236 2250 - :: 2236 2239 - :: 2236 2239 - :: 2236 2239 - :: 2236 2239 - :: 2237 2237 - :: 2237 2237 - :: 2240 2250 - :: 2240 2250 - :: 2240 2250 - :: 2240 2250 - :: 2240 2249 - :: 2253 2282 - :: 2253 2258 - :: 2253 2256 - :: 2259 2272 - :: 2259 2263 - :: 2276 2280 - :: 2276 2280 - :: 2276 2280 - :: 2276 2280 - :: 2276 2280 - :: 2276 2280 - :: 2277 2278 - :: 2277 2278 - :: 2283 2330 - :: 2283 2288 - :: 2283 2286 - :: 2289 2302 - :: 2289 2291 - :: 2306 2328 - :: 2306 2328 - :: 2306 2309 - :: 2306 2309 - :: 2306 2309 - :: 2306 2309 - :: 2307 2307 - :: 2307 2307 - :: 2310 2313 - :: 2310 2313 - :: 2310 2313 - :: 2310 2313 - :: 2311 2311 - :: 2311 2311 - :: 2314 2317 - :: 2314 2317 - :: 2314 2317 - :: 2314 2317 - :: 2315 2315 - :: 2315 2315 - :: 2318 2328 - :: 2318 2328 - :: 2318 2328 - :: 2318 2328 - :: 2318 2327 - :: 2331 2376 - :: 2331 2336 - :: 2331 2334 - :: 2337 2350 - :: 2337 2340 - :: 2354 2368 - :: 2354 2368 - :: 2354 2357 - :: 2354 2357 - :: 2354 2357 - :: 2354 2357 - :: 2355 2355 - :: 2355 2355 - :: 2358 2368 - :: 2358 2368 - :: 2358 2368 - :: 2358 2368 - :: 2358 2367 - :: 2377 2421 - :: 2377 2390 - :: 2377 2382 - :: 2394 2413 - :: 2394 2413 - :: 2394 2406 - :: 2394 2406 - :: 2394 2404 - :: 2395 2403 - :: 2395 2398 - :: 2395 2398 - :: 2395 2398 - :: 2395 2398 - :: 2395 2398 + :: 2012 2022 + :: 2012 2022 + :: 2012 2022 + :: 2012 2022 + :: 2012 2021 + :: 2025 2077 + :: 2025 2035 + :: 2025 2035 + :: 2025 2035 + :: 2025 2035 + :: 2025 2034 + :: 2036 2055 + :: 2036 2055 + :: 2036 2053 + :: 2037 2052 + :: 2037 2052 + :: 2037 2048 + :: 2037 2037 + :: 2038 2048 + :: 2038 2048 + :: 2038 2048 + :: 2038 2047 + :: 2049 2052 + :: 2049 2052 + :: 2049 2052 + :: 2049 2052 + :: 2049 2052 + :: 2054 2055 + :: 2056 2066 + :: 2056 2066 + :: 2056 2066 + :: 2056 2066 + :: 2056 2065 + :: 2067 2077 + :: 2067 2077 + :: 2067 2077 + :: 2067 2077 + :: 2067 2076 + :: 2080 2143 + :: 2080 2085 + :: 2080 2083 + :: 2086 2099 + :: 2086 2090 + :: 2103 2141 + :: 2103 2141 + :: 2103 2106 + :: 2103 2106 + :: 2103 2106 + :: 2103 2106 + :: 2104 2104 + :: 2104 2104 + :: 2107 2110 + :: 2107 2110 + :: 2107 2110 + :: 2107 2110 + :: 2108 2108 + :: 2108 2108 + :: 2111 2114 + :: 2111 2114 + :: 2111 2114 + :: 2111 2114 + :: 2112 2112 + :: 2112 2112 + :: 2115 2118 + :: 2115 2118 + :: 2115 2118 + :: 2115 2118 + :: 2116 2116 + :: 2116 2116 + :: 2119 2122 + :: 2119 2122 + :: 2119 2122 + :: 2119 2122 + :: 2120 2120 + :: 2120 2120 + :: 2123 2126 + :: 2123 2126 + :: 2123 2126 + :: 2123 2126 + :: 2124 2124 + :: 2124 2124 + :: 2127 2130 + :: 2127 2130 + :: 2127 2130 + :: 2127 2130 + :: 2128 2128 + :: 2128 2128 + :: 2131 2141 + :: 2131 2141 + :: 2131 2141 + :: 2131 2141 + :: 2131 2140 + :: 2144 2183 + :: 2144 2149 + :: 2144 2147 + :: 2150 2163 + :: 2150 2152 + :: 2167 2181 + :: 2167 2181 + :: 2167 2170 + :: 2167 2170 + :: 2167 2170 + :: 2167 2170 + :: 2168 2168 + :: 2168 2168 + :: 2171 2181 + :: 2171 2181 + :: 2171 2181 + :: 2171 2181 + :: 2171 2180 + :: 2184 2223 + :: 2184 2189 + :: 2184 2187 + :: 2190 2203 + :: 2190 2193 + :: 2207 2221 + :: 2207 2221 + :: 2207 2210 + :: 2207 2210 + :: 2207 2210 + :: 2207 2210 + :: 2208 2208 + :: 2208 2208 + :: 2211 2221 + :: 2211 2221 + :: 2211 2221 + :: 2211 2221 + :: 2211 2220 + :: 2224 2253 + :: 2224 2229 + :: 2224 2227 + :: 2230 2243 + :: 2230 2234 + :: 2247 2251 + :: 2247 2251 + :: 2247 2251 + :: 2247 2251 + :: 2247 2251 + :: 2247 2251 + :: 2248 2249 + :: 2248 2249 + :: 2254 2324 + :: 2254 2259 + :: 2254 2257 + :: 2260 2273 + :: 2260 2262 + :: 2277 2322 + :: 2277 2322 + :: 2277 2280 + :: 2277 2280 + :: 2277 2280 + :: 2277 2280 + :: 2278 2278 + :: 2278 2278 + :: 2281 2284 + :: 2281 2284 + :: 2281 2284 + :: 2281 2284 + :: 2282 2282 + :: 2282 2282 + :: 2285 2288 + :: 2285 2288 + :: 2285 2288 + :: 2285 2288 + :: 2286 2286 + :: 2286 2286 + :: 2289 2311 + :: 2289 2289 + :: 2290 2311 + :: 2290 2311 + :: 2291 2309 + :: 2291 2294 + :: 2291 2294 + :: 2291 2294 + :: 2291 2294 + :: 2291 2294 + :: 2292 2292 + :: 2292 2292 + :: 2297 2300 + :: 2297 2300 + :: 2297 2300 + :: 2297 2300 + :: 2297 2300 + :: 2298 2298 + :: 2298 2298 + :: 2303 2309 + :: 2303 2309 + :: 2303 2309 + :: 2303 2309 + :: 2303 2309 + :: 2312 2322 + :: 2312 2322 + :: 2312 2322 + :: 2312 2322 + :: 2312 2321 + :: 2325 2370 + :: 2325 2330 + :: 2325 2328 + :: 2331 2344 + :: 2331 2334 + :: 2348 2362 + :: 2348 2362 + :: 2348 2351 + :: 2348 2351 + :: 2348 2351 + :: 2348 2351 + :: 2349 2349 + :: 2349 2349 + :: 2352 2362 + :: 2352 2362 + :: 2352 2362 + :: 2352 2362 + :: 2352 2361 + :: 2371 2415 + :: 2371 2384 + :: 2371 2376 + :: 2388 2407 + :: 2388 2407 + :: 2388 2400 + :: 2388 2400 + :: 2388 2398 + :: 2389 2397 + :: 2389 2392 + :: 2389 2392 + :: 2389 2392 + :: 2389 2392 + :: 2389 2392 + :: 2389 2391 + :: 2395 2397 + :: 2395 2397 + :: 2395 2397 + :: 2395 2397 + :: 2395 2397 :: 2395 2397 - :: 2401 2403 - :: 2401 2403 - :: 2401 2403 - :: 2401 2403 - :: 2401 2403 - :: 2401 2403 - :: 2405 2406 - :: 2407 2413 - :: 2407 2413 - :: 2407 2413 - :: 2407 2413 - :: 2407 2412 - :: 2422 2622 - :: 2422 2435 - :: 2422 2428 - :: 2439 2620 - :: 2439 2444 - :: 2439 2444 - :: 2439 2444 - :: 2439 2444 - :: 2439 2444 - :: 2439 2443 - :: 2447 2452 - :: 2447 2452 - :: 2447 2452 - :: 2447 2452 - :: 2447 2452 - :: 2447 2451 - :: 2455 2460 - :: 2455 2460 - :: 2455 2460 - :: 2455 2460 - :: 2455 2460 - :: 2455 2459 - :: 2463 2470 - :: 2463 2470 - :: 2463 2470 - :: 2463 2470 - :: 2463 2470 - :: 2463 2469 - :: 2473 2479 - :: 2473 2479 - :: 2473 2479 - :: 2473 2479 - :: 2473 2479 - :: 2473 2478 - :: 2482 2487 - :: 2482 2487 - :: 2482 2487 - :: 2482 2487 - :: 2482 2487 - :: 2482 2486 - :: 2490 2495 - :: 2490 2495 - :: 2490 2495 - :: 2490 2495 - :: 2490 2495 - :: 2490 2494 - :: 2498 2503 - :: 2498 2503 - :: 2498 2503 - :: 2498 2503 - :: 2498 2503 - :: 2498 2502 - :: 2506 2515 - :: 2506 2515 - :: 2506 2515 - :: 2506 2515 - :: 2506 2515 - :: 2506 2514 - :: 2518 2523 - :: 2518 2523 - :: 2518 2523 - :: 2518 2523 - :: 2518 2523 - :: 2518 2522 - :: 2526 2531 - :: 2526 2531 - :: 2526 2531 - :: 2526 2531 - :: 2526 2531 - :: 2526 2530 - :: 2534 2539 - :: 2534 2539 - :: 2534 2539 - :: 2534 2539 - :: 2534 2539 - :: 2534 2538 - :: 2542 2550 - :: 2542 2550 - :: 2542 2550 - :: 2542 2550 - :: 2542 2550 - :: 2542 2549 - :: 2553 2559 - :: 2553 2559 - :: 2553 2559 - :: 2553 2559 - :: 2553 2559 - :: 2553 2558 - :: 2562 2572 - :: 2562 2572 - :: 2562 2572 - :: 2562 2572 - :: 2562 2572 - :: 2562 2571 - :: 2575 2596 - :: 2575 2579 - :: 2575 2579 - :: 2575 2579 - :: 2575 2579 - :: 2575 2578 - :: 2580 2590 - :: 2580 2590 - :: 2580 2590 - :: 2580 2590 - :: 2580 2589 - :: 2591 2596 - :: 2591 2596 - :: 2591 2596 - :: 2591 2596 - :: 2591 2595 - :: 2599 2606 - :: 2599 2606 - :: 2599 2606 - :: 2599 2606 - :: 2599 2606 - :: 2599 2605 - :: 2609 2614 - :: 2609 2614 - :: 2609 2614 - :: 2609 2614 - :: 2609 2614 - :: 2609 2613 - :: 2617 2620 - :: 2617 2620 - :: 2617 2620 - :: 2617 2620 - :: 2617 2620 - :: 2617 2619 - :: 2623 2686 - :: 2623 2628 - :: 2623 2626 - :: 2629 2642 - :: 2629 2637 - :: 2646 2684 - :: 2646 2684 - :: 2646 2649 - :: 2646 2649 - :: 2646 2649 - :: 2646 2649 - :: 2647 2647 - :: 2647 2647 - :: 2650 2653 - :: 2650 2653 - :: 2650 2653 - :: 2650 2653 - :: 2651 2651 - :: 2651 2651 - :: 2654 2657 - :: 2654 2657 - :: 2654 2657 - :: 2654 2657 - :: 2655 2655 - :: 2655 2655 - :: 2658 2661 - :: 2658 2661 - :: 2658 2661 - :: 2658 2661 - :: 2659 2659 - :: 2659 2659 - :: 2662 2665 - :: 2662 2665 - :: 2662 2665 - :: 2662 2665 - :: 2663 2663 - :: 2663 2663 - :: 2666 2669 - :: 2666 2669 - :: 2666 2669 - :: 2666 2669 - :: 2667 2667 - :: 2667 2667 - :: 2670 2673 - :: 2670 2673 - :: 2670 2673 - :: 2670 2673 - :: 2671 2671 - :: 2671 2671 - :: 2674 2684 - :: 2674 2684 - :: 2674 2684 - :: 2674 2684 - :: 2674 2683 - :: 2687 2750 - :: 2687 2692 - :: 2687 2690 - :: 2693 2706 - :: 2693 2697 - :: 2710 2748 - :: 2710 2748 - :: 2710 2713 - :: 2710 2713 - :: 2710 2713 - :: 2710 2713 - :: 2711 2711 - :: 2711 2711 - :: 2714 2717 - :: 2714 2717 - :: 2714 2717 - :: 2714 2717 - :: 2715 2715 - :: 2715 2715 - :: 2718 2721 - :: 2718 2721 - :: 2718 2721 - :: 2718 2721 - :: 2719 2719 - :: 2719 2719 - :: 2722 2725 - :: 2722 2725 - :: 2722 2725 - :: 2722 2725 - :: 2723 2723 - :: 2723 2723 - :: 2726 2729 - :: 2726 2729 - :: 2726 2729 - :: 2726 2729 - :: 2727 2727 - :: 2727 2727 - :: 2730 2733 - :: 2730 2733 - :: 2730 2733 - :: 2730 2733 - :: 2731 2731 - :: 2731 2731 - :: 2734 2737 - :: 2734 2737 - :: 2734 2737 - :: 2734 2737 - :: 2735 2735 - :: 2735 2735 - :: 2738 2748 - :: 2738 2748 - :: 2738 2748 - :: 2738 2748 - :: 2738 2747 - :: 2751 2796 - :: 2751 2756 - :: 2751 2754 - :: 2757 2770 - :: 2757 2764 - :: 2774 2788 - :: 2774 2788 - :: 2774 2777 - :: 2774 2777 - :: 2774 2777 - :: 2774 2777 - :: 2775 2775 - :: 2775 2775 - :: 2778 2788 - :: 2778 2788 - :: 2778 2788 - :: 2778 2788 - :: 2778 2787 - :: 2797 2835 - :: 2797 2810 - :: 2797 2801 - :: 2814 2833 - :: 2814 2826 - :: 2814 2818 - :: 2814 2818 - :: 2814 2818 - :: 2814 2818 - :: 2814 2817 - :: 2819 2821 - :: 2819 2821 - :: 2819 2821 - :: 2819 2821 - :: 2819 2820 - :: 2822 2826 - :: 2822 2826 - :: 2822 2826 - :: 2822 2826 - :: 2822 2825 - :: 2829 2833 - :: 2829 2833 - :: 2829 2833 - :: 2829 2833 - :: 2829 2833 - :: 2829 2832 - :: 2836 2881 - :: 2836 2841 - :: 2836 2839 - :: 2842 2855 - :: 2842 2850 - :: 2859 2873 - :: 2859 2873 - :: 2859 2862 - :: 2859 2862 - :: 2859 2862 - :: 2859 2862 - :: 2860 2860 - :: 2860 2860 - :: 2863 2873 - :: 2863 2873 - :: 2863 2873 - :: 2863 2873 - :: 2863 2872 - :: 2882 2908 - :: 2882 2895 - :: 2882 2889 - :: 2899 2906 - :: 2899 2906 - :: 2899 2906 - :: 2899 2906 - :: 2899 2904 - :: 2899 2904 - :: 2899 2904 - :: 2905 2906 - :: 2909 2948 - :: 2909 2914 - :: 2909 2912 - :: 2915 2928 - :: 2915 2919 - :: 2932 2946 - :: 2932 2946 - :: 2932 2935 - :: 2932 2935 - :: 2932 2935 - :: 2932 2935 - :: 2933 2933 - :: 2933 2933 - :: 2936 2946 - :: 2936 2946 - :: 2936 2946 - :: 2936 2946 - :: 2936 2945 - :: 2949 3012 - :: 2949 2954 - :: 2949 2952 - :: 2955 2968 - :: 2955 2959 - :: 2972 3010 - :: 2972 3010 - :: 2972 2975 - :: 2972 2975 - :: 2972 2975 - :: 2972 2975 - :: 2973 2973 - :: 2973 2973 - :: 2976 2979 - :: 2976 2979 - :: 2976 2979 - :: 2976 2979 - :: 2977 2977 - :: 2977 2977 - :: 2980 2983 - :: 2980 2983 - :: 2980 2983 - :: 2980 2983 - :: 2981 2981 - :: 2981 2981 - :: 2984 2987 - :: 2984 2987 - :: 2984 2987 - :: 2984 2987 - :: 2985 2985 - :: 2985 2985 - :: 2988 2991 - :: 2988 2991 - :: 2988 2991 - :: 2988 2991 - :: 2989 2989 - :: 2989 2989 - :: 2992 2995 - :: 2992 2995 - :: 2992 2995 - :: 2992 2995 - :: 2993 2993 - :: 2993 2993 - :: 2996 2999 - :: 2996 2999 - :: 2996 2999 - :: 2996 2999 - :: 2997 2997 - :: 2997 2997 - :: 3000 3010 - :: 3000 3010 - :: 3000 3010 - :: 3000 3010 - :: 3000 3009 - :: 3013 3058 - :: 3013 3018 - :: 3013 3016 - :: 3019 3032 - :: 3019 3022 - :: 3036 3050 - :: 3036 3050 - :: 3036 3039 - :: 3036 3039 - :: 3036 3039 - :: 3036 3039 - :: 3037 3037 - :: 3037 3037 - :: 3040 3050 - :: 3040 3050 - :: 3040 3050 - :: 3040 3050 - :: 3040 3049 - :: 3059 3105 - :: 3059 3072 - :: 3059 3067 - :: 3076 3097 - :: 3076 3097 - :: 3076 3080 - :: 3076 3080 - :: 3076 3080 - :: 3076 3080 - :: 3076 3079 - :: 3081 3091 - :: 3081 3091 - :: 3081 3091 - :: 3081 3091 - :: 3081 3090 - :: 3092 3097 - :: 3092 3097 - :: 3092 3097 - :: 3092 3097 - :: 3092 3096 - :: 3106 3158 - :: 3106 3119 - :: 3106 3111 - :: 3123 3156 - :: 3123 3156 - :: 3123 3130 - :: 3123 3130 - :: 3123 3130 - :: 3123 3130 - :: 3123 3129 - :: 3131 3156 - :: 3131 3156 - :: 3131 3154 - :: 3132 3153 - :: 3132 3140 - :: 3132 3140 - :: 3132 3140 - :: 3132 3140 - :: 3132 3140 - :: 3132 3139 - :: 3143 3147 - :: 3143 3147 - :: 3143 3147 - :: 3143 3147 - :: 3143 3147 - :: 3143 3146 - :: 3150 3153 - :: 3150 3153 - :: 3150 3153 - :: 3150 3153 - :: 3150 3153 - :: 3150 3153 - :: 3155 3156 - :: 3159 3187 - :: 3159 3164 - :: 3159 3162 - :: 3165 3178 - :: 3165 3166 - :: 3182 3185 - :: 3182 3185 - :: 3182 3185 - :: 3182 3185 - :: 3182 3185 - :: 3182 3185 - :: 3183 3183 - :: 3183 3183 - :: 3188 3251 - :: 3188 3193 - :: 3188 3191 - :: 3194 3207 - :: 3194 3198 - :: 3211 3249 - :: 3211 3249 - :: 3211 3214 - :: 3211 3214 - :: 3211 3214 - :: 3211 3214 - :: 3212 3212 - :: 3212 3212 - :: 3215 3218 - :: 3215 3218 - :: 3215 3218 - :: 3215 3218 - :: 3216 3216 - :: 3216 3216 - :: 3219 3222 - :: 3219 3222 - :: 3219 3222 - :: 3219 3222 - :: 3220 3220 - :: 3220 3220 - :: 3223 3226 - :: 3223 3226 - :: 3223 3226 - :: 3223 3226 - :: 3224 3224 - :: 3224 3224 - :: 3227 3230 - :: 3227 3230 - :: 3227 3230 - :: 3227 3230 - :: 3228 3228 - :: 3228 3228 - :: 3231 3234 - :: 3231 3234 - :: 3231 3234 - :: 3231 3234 - :: 3232 3232 - :: 3232 3232 - :: 3235 3238 - :: 3235 3238 - :: 3235 3238 - :: 3235 3238 - :: 3236 3236 - :: 3236 3236 - :: 3239 3249 - :: 3239 3249 - :: 3239 3249 - :: 3239 3249 - :: 3239 3248 - :: 3252 3303 - :: 3252 3257 - :: 3252 3255 - :: 3258 3271 - :: 3258 3261 - :: 3275 3301 - :: 3275 3301 - :: 3275 3278 - :: 3275 3278 - :: 3275 3278 - :: 3275 3278 - :: 3276 3276 - :: 3276 3276 - :: 3279 3282 - :: 3279 3282 - :: 3279 3282 - :: 3279 3282 - :: 3280 3280 - :: 3280 3280 - :: 3283 3286 - :: 3283 3286 - :: 3283 3286 - :: 3283 3286 - :: 3284 3284 - :: 3284 3284 - :: 3287 3290 - :: 3287 3290 - :: 3287 3290 - :: 3287 3290 - :: 3288 3288 - :: 3288 3288 - :: 3291 3301 - :: 3291 3301 - :: 3291 3301 - :: 3291 3301 - :: 3291 3300 - :: 3304 3349 - :: 3304 3309 - :: 3304 3307 - :: 3310 3323 - :: 3310 3319 - :: 3327 3347 - :: 3327 3347 - :: 3327 3347 - :: 3327 3347 - :: 3327 3345 - :: 3328 3344 - :: 3328 3335 - :: 3328 3335 - :: 3328 3335 - :: 3328 3335 - :: 3328 3335 - :: 3338 3344 - :: 3338 3344 - :: 3338 3344 - :: 3338 3344 - :: 3338 3344 - :: 3338 3344 - :: 3346 3347 - :: 3350 3425 - :: 3350 3355 - :: 3350 3353 - :: 3356 3369 - :: 3356 3363 - :: 3373 3423 - :: 3373 3423 - :: 3373 3376 - :: 3373 3376 - :: 3373 3376 - :: 3373 3376 - :: 3374 3374 - :: 3374 3374 - :: 3377 3380 - :: 3377 3380 - :: 3377 3380 - :: 3377 3380 - :: 3378 3378 - :: 3378 3378 - :: 3381 3384 - :: 3381 3384 - :: 3381 3384 - :: 3381 3384 - :: 3382 3382 - :: 3382 3382 - :: 3385 3388 - :: 3385 3388 - :: 3385 3388 - :: 3385 3388 - :: 3386 3386 - :: 3386 3386 - :: 3389 3392 - :: 3389 3392 - :: 3389 3392 - :: 3389 3392 - :: 3390 3390 - :: 3390 3390 - :: 3393 3396 - :: 3393 3396 - :: 3393 3396 - :: 3393 3396 - :: 3394 3394 - :: 3394 3394 - :: 3397 3400 - :: 3397 3400 - :: 3397 3400 - :: 3397 3400 - :: 3398 3398 - :: 3398 3398 - :: 3401 3404 - :: 3401 3404 - :: 3401 3404 - :: 3401 3404 - :: 3402 3402 - :: 3402 3402 - :: 3405 3408 - :: 3405 3408 - :: 3405 3408 - :: 3405 3408 - :: 3406 3406 - :: 3406 3406 - :: 3409 3412 - :: 3409 3412 - :: 3409 3412 - :: 3409 3412 - :: 3410 3410 - :: 3410 3410 - :: 3413 3423 - :: 3413 3423 - :: 3413 3423 - :: 3413 3423 - :: 3413 3422 - :: 3426 3494 - :: 3426 3431 - :: 3426 3429 - :: 3432 3445 - :: 3432 3437 - :: 3449 3491 - :: 3449 3491 - :: 3449 3452 - :: 3449 3452 - :: 3449 3452 - :: 3449 3452 - :: 3450 3450 - :: 3450 3450 - :: 3453 3456 - :: 3453 3456 - :: 3453 3456 - :: 3453 3456 - :: 3454 3454 - :: 3454 3454 - :: 3457 3460 - :: 3457 3460 - :: 3457 3460 - :: 3457 3460 - :: 3458 3458 - :: 3458 3458 - :: 3461 3464 - :: 3461 3464 - :: 3461 3464 - :: 3461 3464 - :: 3462 3462 - :: 3462 3462 - :: 3465 3468 - :: 3465 3468 - :: 3465 3468 - :: 3465 3468 - :: 3466 3466 - :: 3466 3466 - :: 3469 3472 - :: 3469 3472 - :: 3469 3472 - :: 3469 3472 - :: 3470 3470 - :: 3470 3470 - :: 3473 3476 - :: 3473 3476 - :: 3473 3476 - :: 3473 3476 - :: 3474 3474 - :: 3474 3474 - :: 3477 3480 - :: 3477 3480 - :: 3477 3480 - :: 3477 3480 - :: 3478 3478 - :: 3478 3478 - :: 3481 3491 - :: 3481 3491 - :: 3481 3491 - :: 3481 3491 - :: 3481 3490 + :: 2399 2400 + :: 2401 2407 + :: 2401 2407 + :: 2401 2407 + :: 2401 2407 + :: 2401 2406 + :: 2416 2616 + :: 2416 2429 + :: 2416 2422 + :: 2433 2614 + :: 2433 2438 + :: 2433 2438 + :: 2433 2438 + :: 2433 2438 + :: 2433 2438 + :: 2433 2437 + :: 2441 2446 + :: 2441 2446 + :: 2441 2446 + :: 2441 2446 + :: 2441 2446 + :: 2441 2445 + :: 2449 2454 + :: 2449 2454 + :: 2449 2454 + :: 2449 2454 + :: 2449 2454 + :: 2449 2453 + :: 2457 2464 + :: 2457 2464 + :: 2457 2464 + :: 2457 2464 + :: 2457 2464 + :: 2457 2463 + :: 2467 2473 + :: 2467 2473 + :: 2467 2473 + :: 2467 2473 + :: 2467 2473 + :: 2467 2472 + :: 2476 2481 + :: 2476 2481 + :: 2476 2481 + :: 2476 2481 + :: 2476 2481 + :: 2476 2480 + :: 2484 2489 + :: 2484 2489 + :: 2484 2489 + :: 2484 2489 + :: 2484 2489 + :: 2484 2488 + :: 2492 2497 + :: 2492 2497 + :: 2492 2497 + :: 2492 2497 + :: 2492 2497 + :: 2492 2496 + :: 2500 2509 + :: 2500 2509 + :: 2500 2509 + :: 2500 2509 + :: 2500 2509 + :: 2500 2508 + :: 2512 2517 + :: 2512 2517 + :: 2512 2517 + :: 2512 2517 + :: 2512 2517 + :: 2512 2516 + :: 2520 2525 + :: 2520 2525 + :: 2520 2525 + :: 2520 2525 + :: 2520 2525 + :: 2520 2524 + :: 2528 2533 + :: 2528 2533 + :: 2528 2533 + :: 2528 2533 + :: 2528 2533 + :: 2528 2532 + :: 2536 2544 + :: 2536 2544 + :: 2536 2544 + :: 2536 2544 + :: 2536 2544 + :: 2536 2543 + :: 2547 2553 + :: 2547 2553 + :: 2547 2553 + :: 2547 2553 + :: 2547 2553 + :: 2547 2552 + :: 2556 2566 + :: 2556 2566 + :: 2556 2566 + :: 2556 2566 + :: 2556 2566 + :: 2556 2565 + :: 2569 2590 + :: 2569 2573 + :: 2569 2573 + :: 2569 2573 + :: 2569 2573 + :: 2569 2572 + :: 2574 2584 + :: 2574 2584 + :: 2574 2584 + :: 2574 2584 + :: 2574 2583 + :: 2585 2590 + :: 2585 2590 + :: 2585 2590 + :: 2585 2590 + :: 2585 2589 + :: 2593 2600 + :: 2593 2600 + :: 2593 2600 + :: 2593 2600 + :: 2593 2600 + :: 2593 2599 + :: 2603 2608 + :: 2603 2608 + :: 2603 2608 + :: 2603 2608 + :: 2603 2608 + :: 2603 2607 + :: 2611 2614 + :: 2611 2614 + :: 2611 2614 + :: 2611 2614 + :: 2611 2614 + :: 2611 2613 + :: 2617 2680 + :: 2617 2622 + :: 2617 2620 + :: 2623 2636 + :: 2623 2631 + :: 2640 2678 + :: 2640 2678 + :: 2640 2643 + :: 2640 2643 + :: 2640 2643 + :: 2640 2643 + :: 2641 2641 + :: 2641 2641 + :: 2644 2647 + :: 2644 2647 + :: 2644 2647 + :: 2644 2647 + :: 2645 2645 + :: 2645 2645 + :: 2648 2651 + :: 2648 2651 + :: 2648 2651 + :: 2648 2651 + :: 2649 2649 + :: 2649 2649 + :: 2652 2655 + :: 2652 2655 + :: 2652 2655 + :: 2652 2655 + :: 2653 2653 + :: 2653 2653 + :: 2656 2659 + :: 2656 2659 + :: 2656 2659 + :: 2656 2659 + :: 2657 2657 + :: 2657 2657 + :: 2660 2663 + :: 2660 2663 + :: 2660 2663 + :: 2660 2663 + :: 2661 2661 + :: 2661 2661 + :: 2664 2667 + :: 2664 2667 + :: 2664 2667 + :: 2664 2667 + :: 2665 2665 + :: 2665 2665 + :: 2668 2678 + :: 2668 2678 + :: 2668 2678 + :: 2668 2678 + :: 2668 2677 + :: 2681 2744 + :: 2681 2686 + :: 2681 2684 + :: 2687 2700 + :: 2687 2691 + :: 2704 2742 + :: 2704 2742 + :: 2704 2707 + :: 2704 2707 + :: 2704 2707 + :: 2704 2707 + :: 2705 2705 + :: 2705 2705 + :: 2708 2711 + :: 2708 2711 + :: 2708 2711 + :: 2708 2711 + :: 2709 2709 + :: 2709 2709 + :: 2712 2715 + :: 2712 2715 + :: 2712 2715 + :: 2712 2715 + :: 2713 2713 + :: 2713 2713 + :: 2716 2719 + :: 2716 2719 + :: 2716 2719 + :: 2716 2719 + :: 2717 2717 + :: 2717 2717 + :: 2720 2723 + :: 2720 2723 + :: 2720 2723 + :: 2720 2723 + :: 2721 2721 + :: 2721 2721 + :: 2724 2727 + :: 2724 2727 + :: 2724 2727 + :: 2724 2727 + :: 2725 2725 + :: 2725 2725 + :: 2728 2731 + :: 2728 2731 + :: 2728 2731 + :: 2728 2731 + :: 2729 2729 + :: 2729 2729 + :: 2732 2742 + :: 2732 2742 + :: 2732 2742 + :: 2732 2742 + :: 2732 2741 + :: 2745 2790 + :: 2745 2750 + :: 2745 2748 + :: 2751 2764 + :: 2751 2758 + :: 2768 2782 + :: 2768 2782 + :: 2768 2771 + :: 2768 2771 + :: 2768 2771 + :: 2768 2771 + :: 2769 2769 + :: 2769 2769 + :: 2772 2782 + :: 2772 2782 + :: 2772 2782 + :: 2772 2782 + :: 2772 2781 + :: 2791 2829 + :: 2791 2804 + :: 2791 2795 + :: 2808 2827 + :: 2808 2820 + :: 2808 2812 + :: 2808 2812 + :: 2808 2812 + :: 2808 2812 + :: 2808 2811 + :: 2813 2815 + :: 2813 2815 + :: 2813 2815 + :: 2813 2815 + :: 2813 2814 + :: 2816 2820 + :: 2816 2820 + :: 2816 2820 + :: 2816 2820 + :: 2816 2819 + :: 2823 2827 + :: 2823 2827 + :: 2823 2827 + :: 2823 2827 + :: 2823 2827 + :: 2823 2826 + :: 2830 2875 + :: 2830 2835 + :: 2830 2833 + :: 2836 2849 + :: 2836 2844 + :: 2853 2867 + :: 2853 2867 + :: 2853 2856 + :: 2853 2856 + :: 2853 2856 + :: 2853 2856 + :: 2854 2854 + :: 2854 2854 + :: 2857 2867 + :: 2857 2867 + :: 2857 2867 + :: 2857 2867 + :: 2857 2866 + :: 2876 2902 + :: 2876 2889 + :: 2876 2883 + :: 2893 2900 + :: 2893 2900 + :: 2893 2900 + :: 2893 2900 + :: 2893 2898 + :: 2893 2898 + :: 2893 2898 + :: 2899 2900 + :: 2903 2942 + :: 2903 2908 + :: 2903 2906 + :: 2909 2922 + :: 2909 2913 + :: 2926 2940 + :: 2926 2940 + :: 2926 2929 + :: 2926 2929 + :: 2926 2929 + :: 2926 2929 + :: 2927 2927 + :: 2927 2927 + :: 2930 2940 + :: 2930 2940 + :: 2930 2940 + :: 2930 2940 + :: 2930 2939 + :: 2943 3006 + :: 2943 2948 + :: 2943 2946 + :: 2949 2962 + :: 2949 2953 + :: 2966 3004 + :: 2966 3004 + :: 2966 2969 + :: 2966 2969 + :: 2966 2969 + :: 2966 2969 + :: 2967 2967 + :: 2967 2967 + :: 2970 2973 + :: 2970 2973 + :: 2970 2973 + :: 2970 2973 + :: 2971 2971 + :: 2971 2971 + :: 2974 2977 + :: 2974 2977 + :: 2974 2977 + :: 2974 2977 + :: 2975 2975 + :: 2975 2975 + :: 2978 2981 + :: 2978 2981 + :: 2978 2981 + :: 2978 2981 + :: 2979 2979 + :: 2979 2979 + :: 2982 2985 + :: 2982 2985 + :: 2982 2985 + :: 2982 2985 + :: 2983 2983 + :: 2983 2983 + :: 2986 2989 + :: 2986 2989 + :: 2986 2989 + :: 2986 2989 + :: 2987 2987 + :: 2987 2987 + :: 2990 2993 + :: 2990 2993 + :: 2990 2993 + :: 2990 2993 + :: 2991 2991 + :: 2991 2991 + :: 2994 3004 + :: 2994 3004 + :: 2994 3004 + :: 2994 3004 + :: 2994 3003 + :: 3007 3052 + :: 3007 3012 + :: 3007 3010 + :: 3013 3026 + :: 3013 3016 + :: 3030 3044 + :: 3030 3044 + :: 3030 3033 + :: 3030 3033 + :: 3030 3033 + :: 3030 3033 + :: 3031 3031 + :: 3031 3031 + :: 3034 3044 + :: 3034 3044 + :: 3034 3044 + :: 3034 3044 + :: 3034 3043 + :: 3053 3099 + :: 3053 3066 + :: 3053 3061 + :: 3070 3091 + :: 3070 3091 + :: 3070 3074 + :: 3070 3074 + :: 3070 3074 + :: 3070 3074 + :: 3070 3073 + :: 3075 3085 + :: 3075 3085 + :: 3075 3085 + :: 3075 3085 + :: 3075 3084 + :: 3086 3091 + :: 3086 3091 + :: 3086 3091 + :: 3086 3091 + :: 3086 3090 + :: 3100 3152 + :: 3100 3113 + :: 3100 3105 + :: 3117 3150 + :: 3117 3150 + :: 3117 3124 + :: 3117 3124 + :: 3117 3124 + :: 3117 3124 + :: 3117 3123 + :: 3125 3150 + :: 3125 3150 + :: 3125 3148 + :: 3126 3147 + :: 3126 3134 + :: 3126 3134 + :: 3126 3134 + :: 3126 3134 + :: 3126 3134 + :: 3126 3133 + :: 3137 3141 + :: 3137 3141 + :: 3137 3141 + :: 3137 3141 + :: 3137 3141 + :: 3137 3140 + :: 3144 3147 + :: 3144 3147 + :: 3144 3147 + :: 3144 3147 + :: 3144 3147 + :: 3144 3147 + :: 3149 3150 + :: 3153 3181 + :: 3153 3158 + :: 3153 3156 + :: 3159 3172 + :: 3159 3160 + :: 3176 3179 + :: 3176 3179 + :: 3176 3179 + :: 3176 3179 + :: 3176 3179 + :: 3176 3179 + :: 3177 3177 + :: 3177 3177 + :: 3182 3245 + :: 3182 3187 + :: 3182 3185 + :: 3188 3201 + :: 3188 3192 + :: 3205 3243 + :: 3205 3243 + :: 3205 3208 + :: 3205 3208 + :: 3205 3208 + :: 3205 3208 + :: 3206 3206 + :: 3206 3206 + :: 3209 3212 + :: 3209 3212 + :: 3209 3212 + :: 3209 3212 + :: 3210 3210 + :: 3210 3210 + :: 3213 3216 + :: 3213 3216 + :: 3213 3216 + :: 3213 3216 + :: 3214 3214 + :: 3214 3214 + :: 3217 3220 + :: 3217 3220 + :: 3217 3220 + :: 3217 3220 + :: 3218 3218 + :: 3218 3218 + :: 3221 3224 + :: 3221 3224 + :: 3221 3224 + :: 3221 3224 + :: 3222 3222 + :: 3222 3222 + :: 3225 3228 + :: 3225 3228 + :: 3225 3228 + :: 3225 3228 + :: 3226 3226 + :: 3226 3226 + :: 3229 3232 + :: 3229 3232 + :: 3229 3232 + :: 3229 3232 + :: 3230 3230 + :: 3230 3230 + :: 3233 3243 + :: 3233 3243 + :: 3233 3243 + :: 3233 3243 + :: 3233 3242 + :: 3246 3297 + :: 3246 3251 + :: 3246 3249 + :: 3252 3265 + :: 3252 3255 + :: 3269 3295 + :: 3269 3295 + :: 3269 3272 + :: 3269 3272 + :: 3269 3272 + :: 3269 3272 + :: 3270 3270 + :: 3270 3270 + :: 3273 3276 + :: 3273 3276 + :: 3273 3276 + :: 3273 3276 + :: 3274 3274 + :: 3274 3274 + :: 3277 3280 + :: 3277 3280 + :: 3277 3280 + :: 3277 3280 + :: 3278 3278 + :: 3278 3278 + :: 3281 3284 + :: 3281 3284 + :: 3281 3284 + :: 3281 3284 + :: 3282 3282 + :: 3282 3282 + :: 3285 3295 + :: 3285 3295 + :: 3285 3295 + :: 3285 3295 + :: 3285 3294 + :: 3298 3343 + :: 3298 3303 + :: 3298 3301 + :: 3304 3317 + :: 3304 3313 + :: 3321 3341 + :: 3321 3341 + :: 3321 3341 + :: 3321 3341 + :: 3321 3339 + :: 3322 3338 + :: 3322 3329 + :: 3322 3329 + :: 3322 3329 + :: 3322 3329 + :: 3322 3329 + :: 3332 3338 + :: 3332 3338 + :: 3332 3338 + :: 3332 3338 + :: 3332 3338 + :: 3332 3338 + :: 3340 3341 + :: 3344 3419 + :: 3344 3349 + :: 3344 3347 + :: 3350 3363 + :: 3350 3357 + :: 3367 3417 + :: 3367 3417 + :: 3367 3370 + :: 3367 3370 + :: 3367 3370 + :: 3367 3370 + :: 3368 3368 + :: 3368 3368 + :: 3371 3374 + :: 3371 3374 + :: 3371 3374 + :: 3371 3374 + :: 3372 3372 + :: 3372 3372 + :: 3375 3378 + :: 3375 3378 + :: 3375 3378 + :: 3375 3378 + :: 3376 3376 + :: 3376 3376 + :: 3379 3382 + :: 3379 3382 + :: 3379 3382 + :: 3379 3382 + :: 3380 3380 + :: 3380 3380 + :: 3383 3386 + :: 3383 3386 + :: 3383 3386 + :: 3383 3386 + :: 3384 3384 + :: 3384 3384 + :: 3387 3390 + :: 3387 3390 + :: 3387 3390 + :: 3387 3390 + :: 3388 3388 + :: 3388 3388 + :: 3391 3394 + :: 3391 3394 + :: 3391 3394 + :: 3391 3394 + :: 3392 3392 + :: 3392 3392 + :: 3395 3398 + :: 3395 3398 + :: 3395 3398 + :: 3395 3398 + :: 3396 3396 + :: 3396 3396 + :: 3399 3402 + :: 3399 3402 + :: 3399 3402 + :: 3399 3402 + :: 3400 3400 + :: 3400 3400 + :: 3403 3406 + :: 3403 3406 + :: 3403 3406 + :: 3403 3406 + :: 3404 3404 + :: 3404 3404 + :: 3407 3417 + :: 3407 3417 + :: 3407 3417 + :: 3407 3417 + :: 3407 3416 + :: 3420 3488 + :: 3420 3425 + :: 3420 3423 + :: 3426 3439 + :: 3426 3431 + :: 3443 3485 + :: 3443 3485 + :: 3443 3446 + :: 3443 3446 + :: 3443 3446 + :: 3443 3446 + :: 3444 3444 + :: 3444 3444 + :: 3447 3450 + :: 3447 3450 + :: 3447 3450 + :: 3447 3450 + :: 3448 3448 + :: 3448 3448 + :: 3451 3454 + :: 3451 3454 + :: 3451 3454 + :: 3451 3454 + :: 3452 3452 + :: 3452 3452 + :: 3455 3458 + :: 3455 3458 + :: 3455 3458 + :: 3455 3458 + :: 3456 3456 + :: 3456 3456 + :: 3459 3462 + :: 3459 3462 + :: 3459 3462 + :: 3459 3462 + :: 3460 3460 + :: 3460 3460 + :: 3463 3466 + :: 3463 3466 + :: 3463 3466 + :: 3463 3466 + :: 3464 3464 + :: 3464 3464 + :: 3467 3470 + :: 3467 3470 + :: 3467 3470 + :: 3467 3470 + :: 3468 3468 + :: 3468 3468 + :: 3471 3474 + :: 3471 3474 + :: 3471 3474 + :: 3471 3474 + :: 3472 3472 + :: 3472 3472 + :: 3475 3485 + :: 3475 3485 + :: 3475 3485 + :: 3475 3485 + :: 3475 3484 Index: modules/pt/tests/data/ok/peg_peg-ast/3_peg_itself ================================================================== --- modules/pt/tests/data/ok/peg_peg-ast/3_peg_itself +++ modules/pt/tests/data/ok/peg_peg-ast/3_peg_itself @@ -1,6 +1,6 @@ - :: 0 3404 + :: 0 3398
              :: 0 27 :: 4 16 :: 4 15 :: 17 27 :: 18 24 @@ -834,1307 +834,1319 @@ :: 1269 1279 :: 1269 1279 :: 1269 1279 :: 1269 1279 :: 1269 1278 - :: 1282 1329 + :: 1282 1309 :: 1282 1287 :: 1282 1285 :: 1288 1301 :: 1288 1290 - :: 1305 1327 - :: 1305 1327 - :: 1305 1308 - :: 1305 1308 - :: 1305 1308 - :: 1305 1308 - :: 1306 1306 - :: 1306 1306 - :: 1309 1312 - :: 1309 1312 - :: 1309 1312 - :: 1309 1312 - :: 1310 1310 - :: 1310 1310 - :: 1313 1316 - :: 1313 1316 - :: 1313 1316 - :: 1313 1316 - :: 1314 1314 - :: 1314 1314 - :: 1317 1327 - :: 1317 1327 - :: 1317 1327 - :: 1317 1327 - :: 1317 1326 - :: 1330 1357 - :: 1330 1335 - :: 1330 1333 - :: 1336 1349 - :: 1336 1338 - :: 1353 1355 - :: 1353 1355 - :: 1353 1355 - :: 1353 1353 - :: 1354 1355 - :: 1354 1355 - :: 1354 1355 - :: 1358 1400 - :: 1358 1363 - :: 1358 1361 - :: 1364 1377 - :: 1364 1366 - :: 1381 1392 - :: 1381 1385 - :: 1381 1385 - :: 1381 1385 - :: 1381 1385 - :: 1381 1385 - :: 1382 1383 - :: 1382 1383 - :: 1388 1392 - :: 1388 1392 - :: 1388 1392 - :: 1388 1392 - :: 1388 1392 - :: 1389 1390 - :: 1389 1390 - :: 1401 1446 - :: 1401 1414 - :: 1401 1410 - :: 1418 1444 - :: 1418 1444 - :: 1418 1426 - :: 1418 1426 - :: 1418 1426 - :: 1418 1426 - :: 1418 1425 - :: 1427 1444 - :: 1427 1444 - :: 1427 1442 - :: 1428 1441 - :: 1428 1441 - :: 1428 1433 - :: 1428 1433 - :: 1428 1433 - :: 1428 1433 - :: 1428 1432 - :: 1434 1441 - :: 1434 1441 - :: 1434 1441 - :: 1434 1441 - :: 1434 1441 - :: 1443 1444 - :: 1447 1502 - :: 1447 1452 - :: 1447 1450 - :: 1453 1466 - :: 1453 1457 - :: 1470 1494 - :: 1470 1494 - :: 1470 1473 - :: 1470 1473 - :: 1470 1473 - :: 1470 1473 - :: 1470 1472 - :: 1474 1483 - :: 1474 1483 - :: 1474 1483 - :: 1474 1483 - :: 1474 1482 - :: 1484 1494 - :: 1484 1494 - :: 1484 1494 - :: 1484 1494 - :: 1484 1493 - :: 1503 1561 - :: 1503 1516 - :: 1503 1509 - :: 1520 1559 - :: 1520 1559 - :: 1520 1530 - :: 1520 1530 - :: 1520 1530 - :: 1520 1530 - :: 1520 1529 - :: 1531 1537 - :: 1531 1537 - :: 1531 1537 - :: 1531 1537 - :: 1531 1536 - :: 1538 1549 - :: 1538 1549 - :: 1538 1547 - :: 1538 1547 - :: 1538 1547 - :: 1548 1549 - :: 1550 1555 - :: 1550 1555 - :: 1550 1555 - :: 1550 1555 - :: 1550 1554 + :: 1305 1307 + :: 1305 1307 + :: 1305 1307 + :: 1305 1305 + :: 1306 1307 + :: 1306 1307 + :: 1306 1307 + :: 1310 1352 + :: 1310 1315 + :: 1310 1313 + :: 1316 1329 + :: 1316 1318 + :: 1333 1344 + :: 1333 1337 + :: 1333 1337 + :: 1333 1337 + :: 1333 1337 + :: 1333 1337 + :: 1334 1335 + :: 1334 1335 + :: 1340 1344 + :: 1340 1344 + :: 1340 1344 + :: 1340 1344 + :: 1340 1344 + :: 1341 1342 + :: 1341 1342 + :: 1353 1398 + :: 1353 1366 + :: 1353 1362 + :: 1370 1396 + :: 1370 1396 + :: 1370 1378 + :: 1370 1378 + :: 1370 1378 + :: 1370 1378 + :: 1370 1377 + :: 1379 1396 + :: 1379 1396 + :: 1379 1394 + :: 1380 1393 + :: 1380 1393 + :: 1380 1385 + :: 1380 1385 + :: 1380 1385 + :: 1380 1385 + :: 1380 1384 + :: 1386 1393 + :: 1386 1393 + :: 1386 1393 + :: 1386 1393 + :: 1386 1393 + :: 1395 1396 + :: 1399 1473 + :: 1399 1404 + :: 1399 1402 + :: 1405 1418 + :: 1405 1409 + :: 1422 1465 + :: 1422 1465 + :: 1422 1425 + :: 1422 1425 + :: 1422 1425 + :: 1422 1425 + :: 1423 1423 + :: 1423 1423 + :: 1426 1429 + :: 1426 1429 + :: 1426 1429 + :: 1426 1429 + :: 1427 1427 + :: 1427 1427 + :: 1430 1433 + :: 1430 1433 + :: 1430 1433 + :: 1430 1433 + :: 1431 1431 + :: 1431 1431 + :: 1434 1444 + :: 1434 1444 + :: 1434 1444 + :: 1434 1444 + :: 1434 1443 + :: 1445 1454 + :: 1445 1454 + :: 1445 1454 + :: 1445 1454 + :: 1445 1453 + :: 1455 1465 + :: 1455 1465 + :: 1455 1465 + :: 1455 1465 + :: 1455 1464 + :: 1474 1532 + :: 1474 1487 + :: 1474 1480 + :: 1491 1530 + :: 1491 1530 + :: 1491 1501 + :: 1491 1501 + :: 1491 1501 + :: 1491 1501 + :: 1491 1500 + :: 1502 1508 + :: 1502 1508 + :: 1502 1508 + :: 1502 1508 + :: 1502 1507 + :: 1509 1520 + :: 1509 1520 + :: 1509 1518 + :: 1509 1518 + :: 1509 1518 + :: 1519 1520 + :: 1521 1526 + :: 1521 1526 + :: 1521 1526 + :: 1521 1526 + :: 1521 1525 + :: 1527 1530 + :: 1527 1530 + :: 1527 1530 + :: 1527 1530 + :: 1527 1529 + :: 1533 1602 + :: 1533 1538 + :: 1533 1536 + :: 1539 1552 + :: 1539 1543 + :: 1556 1594 + :: 1556 1594 :: 1556 1559 :: 1556 1559 :: 1556 1559 - :: 1556 1559 - :: 1556 1558 - :: 1562 1631 - :: 1562 1567 - :: 1562 1565 - :: 1568 1581 - :: 1568 1572 - :: 1585 1623 - :: 1585 1623 - :: 1585 1588 - :: 1585 1588 - :: 1585 1588 - :: 1585 1588 - :: 1586 1586 - :: 1586 1586 - :: 1589 1592 - :: 1589 1592 - :: 1589 1592 - :: 1589 1592 - :: 1590 1590 - :: 1590 1590 - :: 1593 1596 - :: 1593 1596 - :: 1593 1596 - :: 1593 1596 - :: 1594 1594 - :: 1594 1594 - :: 1597 1600 - :: 1597 1600 - :: 1597 1600 - :: 1597 1600 - :: 1598 1598 - :: 1598 1598 - :: 1601 1604 - :: 1601 1604 - :: 1601 1604 - :: 1601 1604 - :: 1602 1602 - :: 1602 1602 - :: 1605 1608 - :: 1605 1608 - :: 1605 1608 - :: 1605 1608 - :: 1606 1606 - :: 1606 1606 - :: 1609 1612 - :: 1609 1612 - :: 1609 1612 - :: 1609 1612 - :: 1610 1610 - :: 1610 1610 - :: 1613 1623 - :: 1613 1623 - :: 1613 1623 - :: 1613 1623 - :: 1613 1622 - :: 1632 1675 - :: 1632 1645 - :: 1632 1637 - :: 1649 1673 - :: 1649 1673 - :: 1649 1652 - :: 1649 1652 - :: 1649 1652 - :: 1649 1652 - :: 1649 1651 - :: 1653 1663 - :: 1653 1663 - :: 1653 1663 - :: 1653 1663 - :: 1653 1662 - :: 1664 1673 - :: 1664 1673 - :: 1664 1673 - :: 1664 1673 - :: 1664 1672 - :: 1676 1751 - :: 1676 1681 - :: 1676 1679 - :: 1682 1695 - :: 1682 1686 - :: 1699 1743 - :: 1699 1743 - :: 1699 1720 - :: 1699 1720 - :: 1699 1720 - :: 1700 1718 - :: 1700 1703 - :: 1700 1703 - :: 1700 1703 - :: 1700 1703 - :: 1700 1703 - :: 1701 1701 - :: 1701 1701 - :: 1706 1709 - :: 1706 1709 - :: 1706 1709 - :: 1706 1709 - :: 1706 1709 - :: 1707 1707 - :: 1707 1707 - :: 1712 1718 - :: 1712 1718 - :: 1712 1718 - :: 1712 1718 - :: 1712 1718 - :: 1721 1743 - :: 1721 1743 - :: 1721 1741 - :: 1722 1740 - :: 1722 1725 - :: 1722 1725 - :: 1722 1725 - :: 1722 1725 - :: 1722 1725 - :: 1723 1723 - :: 1723 1723 - :: 1728 1731 - :: 1728 1731 - :: 1728 1731 - :: 1728 1731 - :: 1728 1731 - :: 1729 1729 - :: 1729 1729 - :: 1734 1740 - :: 1734 1740 - :: 1734 1740 - :: 1734 1740 - :: 1734 1740 - :: 1742 1743 - :: 1752 1787 - :: 1752 1765 - :: 1752 1761 - :: 1769 1785 - :: 1769 1785 - :: 1769 1774 - :: 1769 1774 - :: 1769 1774 - :: 1769 1774 - :: 1769 1773 - :: 1775 1785 - :: 1775 1785 - :: 1775 1785 - :: 1775 1785 - :: 1775 1784 - :: 1788 1831 - :: 1788 1793 - :: 1788 1791 - :: 1794 1807 - :: 1794 1795 - :: 1811 1829 - :: 1811 1829 - :: 1811 1814 - :: 1811 1814 - :: 1811 1814 - :: 1811 1814 - :: 1812 1812 - :: 1812 1812 - :: 1815 1818 - :: 1815 1818 - :: 1815 1818 - :: 1815 1818 - :: 1816 1816 - :: 1816 1816 - :: 1819 1829 - :: 1819 1829 - :: 1819 1829 - :: 1819 1829 - :: 1819 1828 - :: 1832 1889 - :: 1832 1837 - :: 1832 1835 - :: 1838 1851 - :: 1838 1841 - :: 1855 1881 - :: 1855 1881 - :: 1855 1858 - :: 1855 1858 - :: 1855 1858 - :: 1855 1858 - :: 1856 1856 - :: 1856 1856 - :: 1859 1862 - :: 1859 1862 - :: 1859 1862 - :: 1859 1862 - :: 1860 1860 - :: 1860 1860 - :: 1863 1866 - :: 1863 1866 - :: 1863 1866 - :: 1863 1866 - :: 1864 1864 - :: 1864 1864 - :: 1867 1870 - :: 1867 1870 - :: 1867 1870 - :: 1867 1870 - :: 1868 1868 - :: 1868 1868 - :: 1871 1881 - :: 1871 1881 - :: 1871 1881 - :: 1871 1881 - :: 1871 1880 - :: 1890 2013 - :: 1890 1903 - :: 1890 1896 - :: 1907 2011 - :: 1907 1956 + :: 1556 1559 + :: 1557 1557 + :: 1557 1557 + :: 1560 1563 + :: 1560 1563 + :: 1560 1563 + :: 1560 1563 + :: 1561 1561 + :: 1561 1561 + :: 1564 1567 + :: 1564 1567 + :: 1564 1567 + :: 1564 1567 + :: 1565 1565 + :: 1565 1565 + :: 1568 1571 + :: 1568 1571 + :: 1568 1571 + :: 1568 1571 + :: 1569 1569 + :: 1569 1569 + :: 1572 1575 + :: 1572 1575 + :: 1572 1575 + :: 1572 1575 + :: 1573 1573 + :: 1573 1573 + :: 1576 1579 + :: 1576 1579 + :: 1576 1579 + :: 1576 1579 + :: 1577 1577 + :: 1577 1577 + :: 1580 1583 + :: 1580 1583 + :: 1580 1583 + :: 1580 1583 + :: 1581 1581 + :: 1581 1581 + :: 1584 1594 + :: 1584 1594 + :: 1584 1594 + :: 1584 1594 + :: 1584 1593 + :: 1603 1646 + :: 1603 1616 + :: 1603 1608 + :: 1620 1644 + :: 1620 1644 + :: 1620 1623 + :: 1620 1623 + :: 1620 1623 + :: 1620 1623 + :: 1620 1622 + :: 1624 1634 + :: 1624 1634 + :: 1624 1634 + :: 1624 1634 + :: 1624 1633 + :: 1635 1644 + :: 1635 1644 + :: 1635 1644 + :: 1635 1644 + :: 1635 1643 + :: 1647 1722 + :: 1647 1652 + :: 1647 1650 + :: 1653 1666 + :: 1653 1657 + :: 1670 1714 + :: 1670 1714 + :: 1670 1691 + :: 1670 1691 + :: 1670 1691 + :: 1671 1689 + :: 1671 1674 + :: 1671 1674 + :: 1671 1674 + :: 1671 1674 + :: 1671 1674 + :: 1672 1672 + :: 1672 1672 + :: 1677 1680 + :: 1677 1680 + :: 1677 1680 + :: 1677 1680 + :: 1677 1680 + :: 1678 1678 + :: 1678 1678 + :: 1683 1689 + :: 1683 1689 + :: 1683 1689 + :: 1683 1689 + :: 1683 1689 + :: 1692 1714 + :: 1692 1714 + :: 1692 1712 + :: 1693 1711 + :: 1693 1696 + :: 1693 1696 + :: 1693 1696 + :: 1693 1696 + :: 1693 1696 + :: 1694 1694 + :: 1694 1694 + :: 1699 1702 + :: 1699 1702 + :: 1699 1702 + :: 1699 1702 + :: 1699 1702 + :: 1700 1700 + :: 1700 1700 + :: 1705 1711 + :: 1705 1711 + :: 1705 1711 + :: 1705 1711 + :: 1705 1711 + :: 1713 1714 + :: 1723 1758 + :: 1723 1736 + :: 1723 1732 + :: 1740 1756 + :: 1740 1756 + :: 1740 1745 + :: 1740 1745 + :: 1740 1745 + :: 1740 1745 + :: 1740 1744 + :: 1746 1756 + :: 1746 1756 + :: 1746 1756 + :: 1746 1756 + :: 1746 1755 + :: 1759 1802 + :: 1759 1764 + :: 1759 1762 + :: 1765 1778 + :: 1765 1766 + :: 1782 1800 + :: 1782 1800 + :: 1782 1785 + :: 1782 1785 + :: 1782 1785 + :: 1782 1785 + :: 1783 1783 + :: 1783 1783 + :: 1786 1789 + :: 1786 1789 + :: 1786 1789 + :: 1786 1789 + :: 1787 1787 + :: 1787 1787 + :: 1790 1800 + :: 1790 1800 + :: 1790 1800 + :: 1790 1800 + :: 1790 1799 + :: 1803 1860 + :: 1803 1808 + :: 1803 1806 + :: 1809 1822 + :: 1809 1812 + :: 1826 1852 + :: 1826 1852 + :: 1826 1829 + :: 1826 1829 + :: 1826 1829 + :: 1826 1829 + :: 1827 1827 + :: 1827 1827 + :: 1830 1833 + :: 1830 1833 + :: 1830 1833 + :: 1830 1833 + :: 1831 1831 + :: 1831 1831 + :: 1834 1837 + :: 1834 1837 + :: 1834 1837 + :: 1834 1837 + :: 1835 1835 + :: 1835 1835 + :: 1838 1841 + :: 1838 1841 + :: 1838 1841 + :: 1838 1841 + :: 1839 1839 + :: 1839 1839 + :: 1842 1852 + :: 1842 1852 + :: 1842 1852 + :: 1842 1852 + :: 1842 1851 + :: 1861 1984 + :: 1861 1874 + :: 1861 1867 + :: 1878 1982 + :: 1878 1927 + :: 1878 1887 + :: 1878 1887 + :: 1878 1887 + :: 1878 1887 + :: 1878 1886 + :: 1888 1906 + :: 1888 1906 + :: 1888 1904 + :: 1889 1903 + :: 1889 1903 + :: 1889 1899 + :: 1889 1889 + :: 1890 1899 + :: 1890 1899 + :: 1890 1899 + :: 1890 1898 + :: 1900 1903 + :: 1900 1903 + :: 1900 1903 + :: 1900 1903 + :: 1900 1903 + :: 1905 1906 :: 1907 1916 :: 1907 1916 :: 1907 1916 :: 1907 1916 :: 1907 1915 - :: 1917 1935 - :: 1917 1935 - :: 1917 1933 - :: 1918 1932 - :: 1918 1932 - :: 1918 1928 - :: 1918 1918 - :: 1919 1928 - :: 1919 1928 - :: 1919 1928 - :: 1919 1927 - :: 1929 1932 - :: 1929 1932 - :: 1929 1932 - :: 1929 1932 - :: 1929 1932 - :: 1934 1935 - :: 1936 1945 - :: 1936 1945 - :: 1936 1945 - :: 1936 1945 - :: 1936 1944 - :: 1946 1956 - :: 1946 1956 - :: 1946 1956 - :: 1946 1956 - :: 1946 1955 - :: 1959 2011 - :: 1959 1969 - :: 1959 1969 - :: 1959 1969 - :: 1959 1969 - :: 1959 1968 - :: 1970 1989 - :: 1970 1989 - :: 1970 1987 - :: 1971 1986 - :: 1971 1986 - :: 1971 1982 - :: 1971 1971 - :: 1972 1982 - :: 1972 1982 - :: 1972 1982 - :: 1972 1981 - :: 1983 1986 - :: 1983 1986 - :: 1983 1986 - :: 1983 1986 - :: 1983 1986 - :: 1988 1989 - :: 1990 2000 - :: 1990 2000 - :: 1990 2000 - :: 1990 2000 - :: 1990 1999 - :: 2001 2011 - :: 2001 2011 - :: 2001 2011 - :: 2001 2011 - :: 2001 2010 - :: 2014 2077 - :: 2014 2019 - :: 2014 2017 - :: 2020 2033 - :: 2020 2024 - :: 2037 2075 - :: 2037 2075 - :: 2037 2040 - :: 2037 2040 - :: 2037 2040 - :: 2037 2040 - :: 2038 2038 - :: 2038 2038 - :: 2041 2044 - :: 2041 2044 - :: 2041 2044 - :: 2041 2044 - :: 2042 2042 - :: 2042 2042 - :: 2045 2048 - :: 2045 2048 - :: 2045 2048 - :: 2045 2048 - :: 2046 2046 - :: 2046 2046 - :: 2049 2052 - :: 2049 2052 - :: 2049 2052 - :: 2049 2052 - :: 2050 2050 - :: 2050 2050 - :: 2053 2056 - :: 2053 2056 - :: 2053 2056 - :: 2053 2056 - :: 2054 2054 - :: 2054 2054 - :: 2057 2060 - :: 2057 2060 - :: 2057 2060 - :: 2057 2060 - :: 2058 2058 - :: 2058 2058 - :: 2061 2064 - :: 2061 2064 - :: 2061 2064 - :: 2061 2064 - :: 2062 2062 - :: 2062 2062 - :: 2065 2075 - :: 2065 2075 - :: 2065 2075 - :: 2065 2075 - :: 2065 2074 - :: 2078 2117 - :: 2078 2083 - :: 2078 2081 - :: 2084 2097 - :: 2084 2086 - :: 2101 2115 - :: 2101 2115 - :: 2101 2104 - :: 2101 2104 - :: 2101 2104 - :: 2101 2104 - :: 2102 2102 - :: 2102 2102 - :: 2105 2115 - :: 2105 2115 - :: 2105 2115 - :: 2105 2115 - :: 2105 2114 - :: 2118 2157 - :: 2118 2123 - :: 2118 2121 - :: 2124 2137 - :: 2124 2127 - :: 2141 2155 - :: 2141 2155 - :: 2141 2144 - :: 2141 2144 - :: 2141 2144 - :: 2141 2144 - :: 2142 2142 - :: 2142 2142 - :: 2145 2155 - :: 2145 2155 - :: 2145 2155 - :: 2145 2155 - :: 2145 2154 - :: 2158 2187 - :: 2158 2163 - :: 2158 2161 - :: 2164 2177 - :: 2164 2168 - :: 2181 2185 - :: 2181 2185 - :: 2181 2185 - :: 2181 2185 - :: 2181 2185 - :: 2181 2185 - :: 2182 2183 - :: 2182 2183 - :: 2188 2235 - :: 2188 2193 - :: 2188 2191 - :: 2194 2207 - :: 2194 2196 - :: 2211 2233 - :: 2211 2233 - :: 2211 2214 - :: 2211 2214 - :: 2211 2214 - :: 2211 2214 - :: 2212 2212 - :: 2212 2212 - :: 2215 2218 - :: 2215 2218 - :: 2215 2218 - :: 2215 2218 - :: 2216 2216 - :: 2216 2216 - :: 2219 2222 - :: 2219 2222 - :: 2219 2222 - :: 2219 2222 - :: 2220 2220 - :: 2220 2220 - :: 2223 2233 - :: 2223 2233 - :: 2223 2233 - :: 2223 2233 - :: 2223 2232 - :: 2236 2281 - :: 2236 2241 - :: 2236 2239 - :: 2242 2255 - :: 2242 2245 - :: 2259 2273 - :: 2259 2273 - :: 2259 2262 - :: 2259 2262 - :: 2259 2262 - :: 2259 2262 - :: 2260 2260 - :: 2260 2260 - :: 2263 2273 - :: 2263 2273 - :: 2263 2273 - :: 2263 2273 - :: 2263 2272 - :: 2282 2326 - :: 2282 2295 - :: 2282 2287 - :: 2299 2318 - :: 2299 2318 - :: 2299 2311 - :: 2299 2311 - :: 2299 2309 - :: 2300 2308 - :: 2300 2303 - :: 2300 2303 - :: 2300 2303 - :: 2300 2303 - :: 2300 2303 + :: 1917 1927 + :: 1917 1927 + :: 1917 1927 + :: 1917 1927 + :: 1917 1926 + :: 1930 1982 + :: 1930 1940 + :: 1930 1940 + :: 1930 1940 + :: 1930 1940 + :: 1930 1939 + :: 1941 1960 + :: 1941 1960 + :: 1941 1958 + :: 1942 1957 + :: 1942 1957 + :: 1942 1953 + :: 1942 1942 + :: 1943 1953 + :: 1943 1953 + :: 1943 1953 + :: 1943 1952 + :: 1954 1957 + :: 1954 1957 + :: 1954 1957 + :: 1954 1957 + :: 1954 1957 + :: 1959 1960 + :: 1961 1971 + :: 1961 1971 + :: 1961 1971 + :: 1961 1971 + :: 1961 1970 + :: 1972 1982 + :: 1972 1982 + :: 1972 1982 + :: 1972 1982 + :: 1972 1981 + :: 1985 2048 + :: 1985 1990 + :: 1985 1988 + :: 1991 2004 + :: 1991 1995 + :: 2008 2046 + :: 2008 2046 + :: 2008 2011 + :: 2008 2011 + :: 2008 2011 + :: 2008 2011 + :: 2009 2009 + :: 2009 2009 + :: 2012 2015 + :: 2012 2015 + :: 2012 2015 + :: 2012 2015 + :: 2013 2013 + :: 2013 2013 + :: 2016 2019 + :: 2016 2019 + :: 2016 2019 + :: 2016 2019 + :: 2017 2017 + :: 2017 2017 + :: 2020 2023 + :: 2020 2023 + :: 2020 2023 + :: 2020 2023 + :: 2021 2021 + :: 2021 2021 + :: 2024 2027 + :: 2024 2027 + :: 2024 2027 + :: 2024 2027 + :: 2025 2025 + :: 2025 2025 + :: 2028 2031 + :: 2028 2031 + :: 2028 2031 + :: 2028 2031 + :: 2029 2029 + :: 2029 2029 + :: 2032 2035 + :: 2032 2035 + :: 2032 2035 + :: 2032 2035 + :: 2033 2033 + :: 2033 2033 + :: 2036 2046 + :: 2036 2046 + :: 2036 2046 + :: 2036 2046 + :: 2036 2045 + :: 2049 2088 + :: 2049 2054 + :: 2049 2052 + :: 2055 2068 + :: 2055 2057 + :: 2072 2086 + :: 2072 2086 + :: 2072 2075 + :: 2072 2075 + :: 2072 2075 + :: 2072 2075 + :: 2073 2073 + :: 2073 2073 + :: 2076 2086 + :: 2076 2086 + :: 2076 2086 + :: 2076 2086 + :: 2076 2085 + :: 2089 2128 + :: 2089 2094 + :: 2089 2092 + :: 2095 2108 + :: 2095 2098 + :: 2112 2126 + :: 2112 2126 + :: 2112 2115 + :: 2112 2115 + :: 2112 2115 + :: 2112 2115 + :: 2113 2113 + :: 2113 2113 + :: 2116 2126 + :: 2116 2126 + :: 2116 2126 + :: 2116 2126 + :: 2116 2125 + :: 2129 2158 + :: 2129 2134 + :: 2129 2132 + :: 2135 2148 + :: 2135 2139 + :: 2152 2156 + :: 2152 2156 + :: 2152 2156 + :: 2152 2156 + :: 2152 2156 + :: 2152 2156 + :: 2153 2154 + :: 2153 2154 + :: 2159 2229 + :: 2159 2164 + :: 2159 2162 + :: 2165 2178 + :: 2165 2167 + :: 2182 2227 + :: 2182 2227 + :: 2182 2185 + :: 2182 2185 + :: 2182 2185 + :: 2182 2185 + :: 2183 2183 + :: 2183 2183 + :: 2186 2189 + :: 2186 2189 + :: 2186 2189 + :: 2186 2189 + :: 2187 2187 + :: 2187 2187 + :: 2190 2193 + :: 2190 2193 + :: 2190 2193 + :: 2190 2193 + :: 2191 2191 + :: 2191 2191 + :: 2194 2216 + :: 2194 2194 + :: 2195 2216 + :: 2195 2216 + :: 2196 2214 + :: 2196 2199 + :: 2196 2199 + :: 2196 2199 + :: 2196 2199 + :: 2196 2199 + :: 2197 2197 + :: 2197 2197 + :: 2202 2205 + :: 2202 2205 + :: 2202 2205 + :: 2202 2205 + :: 2202 2205 + :: 2203 2203 + :: 2203 2203 + :: 2208 2214 + :: 2208 2214 + :: 2208 2214 + :: 2208 2214 + :: 2208 2214 + :: 2217 2227 + :: 2217 2227 + :: 2217 2227 + :: 2217 2227 + :: 2217 2226 + :: 2230 2275 + :: 2230 2235 + :: 2230 2233 + :: 2236 2249 + :: 2236 2239 + :: 2253 2267 + :: 2253 2267 + :: 2253 2256 + :: 2253 2256 + :: 2253 2256 + :: 2253 2256 + :: 2254 2254 + :: 2254 2254 + :: 2257 2267 + :: 2257 2267 + :: 2257 2267 + :: 2257 2267 + :: 2257 2266 + :: 2276 2320 + :: 2276 2289 + :: 2276 2281 + :: 2293 2312 + :: 2293 2312 + :: 2293 2305 + :: 2293 2305 + :: 2293 2303 + :: 2294 2302 + :: 2294 2297 + :: 2294 2297 + :: 2294 2297 + :: 2294 2297 + :: 2294 2297 + :: 2294 2296 + :: 2300 2302 + :: 2300 2302 + :: 2300 2302 + :: 2300 2302 + :: 2300 2302 :: 2300 2302 - :: 2306 2308 - :: 2306 2308 - :: 2306 2308 - :: 2306 2308 - :: 2306 2308 - :: 2306 2308 - :: 2310 2311 - :: 2312 2318 - :: 2312 2318 - :: 2312 2318 - :: 2312 2318 - :: 2312 2317 - :: 2327 2527 - :: 2327 2340 - :: 2327 2333 - :: 2344 2525 - :: 2344 2349 - :: 2344 2349 - :: 2344 2349 - :: 2344 2349 - :: 2344 2349 - :: 2344 2348 - :: 2352 2357 - :: 2352 2357 - :: 2352 2357 - :: 2352 2357 - :: 2352 2357 - :: 2352 2356 - :: 2360 2365 - :: 2360 2365 - :: 2360 2365 - :: 2360 2365 - :: 2360 2365 - :: 2360 2364 - :: 2368 2375 - :: 2368 2375 - :: 2368 2375 - :: 2368 2375 - :: 2368 2375 - :: 2368 2374 - :: 2378 2384 - :: 2378 2384 - :: 2378 2384 - :: 2378 2384 - :: 2378 2384 - :: 2378 2383 - :: 2387 2392 - :: 2387 2392 - :: 2387 2392 - :: 2387 2392 - :: 2387 2392 - :: 2387 2391 - :: 2395 2400 - :: 2395 2400 - :: 2395 2400 - :: 2395 2400 - :: 2395 2400 - :: 2395 2399 - :: 2403 2408 - :: 2403 2408 - :: 2403 2408 - :: 2403 2408 - :: 2403 2408 - :: 2403 2407 - :: 2411 2420 - :: 2411 2420 - :: 2411 2420 - :: 2411 2420 - :: 2411 2420 - :: 2411 2419 - :: 2423 2428 - :: 2423 2428 - :: 2423 2428 - :: 2423 2428 - :: 2423 2428 - :: 2423 2427 - :: 2431 2436 - :: 2431 2436 - :: 2431 2436 - :: 2431 2436 - :: 2431 2436 - :: 2431 2435 - :: 2439 2444 - :: 2439 2444 - :: 2439 2444 - :: 2439 2444 - :: 2439 2444 - :: 2439 2443 - :: 2447 2455 - :: 2447 2455 - :: 2447 2455 - :: 2447 2455 - :: 2447 2455 - :: 2447 2454 - :: 2458 2464 - :: 2458 2464 - :: 2458 2464 - :: 2458 2464 - :: 2458 2464 - :: 2458 2463 - :: 2467 2477 - :: 2467 2477 - :: 2467 2477 - :: 2467 2477 - :: 2467 2477 - :: 2467 2476 - :: 2480 2501 - :: 2480 2484 - :: 2480 2484 - :: 2480 2484 - :: 2480 2484 - :: 2480 2483 - :: 2485 2495 - :: 2485 2495 - :: 2485 2495 - :: 2485 2495 - :: 2485 2494 - :: 2496 2501 - :: 2496 2501 - :: 2496 2501 - :: 2496 2501 - :: 2496 2500 - :: 2504 2511 - :: 2504 2511 - :: 2504 2511 - :: 2504 2511 - :: 2504 2511 - :: 2504 2510 - :: 2514 2519 - :: 2514 2519 - :: 2514 2519 - :: 2514 2519 - :: 2514 2519 - :: 2514 2518 - :: 2522 2525 - :: 2522 2525 - :: 2522 2525 - :: 2522 2525 - :: 2522 2525 - :: 2522 2524 - :: 2528 2591 - :: 2528 2533 - :: 2528 2531 - :: 2534 2547 - :: 2534 2542 - :: 2551 2589 - :: 2551 2589 - :: 2551 2554 - :: 2551 2554 - :: 2551 2554 - :: 2551 2554 - :: 2552 2552 - :: 2552 2552 - :: 2555 2558 - :: 2555 2558 - :: 2555 2558 - :: 2555 2558 - :: 2556 2556 - :: 2556 2556 - :: 2559 2562 - :: 2559 2562 - :: 2559 2562 - :: 2559 2562 - :: 2560 2560 - :: 2560 2560 - :: 2563 2566 - :: 2563 2566 - :: 2563 2566 - :: 2563 2566 - :: 2564 2564 - :: 2564 2564 - :: 2567 2570 - :: 2567 2570 - :: 2567 2570 - :: 2567 2570 - :: 2568 2568 - :: 2568 2568 - :: 2571 2574 - :: 2571 2574 - :: 2571 2574 - :: 2571 2574 - :: 2572 2572 - :: 2572 2572 - :: 2575 2578 - :: 2575 2578 - :: 2575 2578 - :: 2575 2578 - :: 2576 2576 - :: 2576 2576 - :: 2579 2589 - :: 2579 2589 - :: 2579 2589 - :: 2579 2589 - :: 2579 2588 - :: 2592 2655 - :: 2592 2597 - :: 2592 2595 - :: 2598 2611 - :: 2598 2602 - :: 2615 2653 - :: 2615 2653 - :: 2615 2618 - :: 2615 2618 - :: 2615 2618 - :: 2615 2618 - :: 2616 2616 - :: 2616 2616 - :: 2619 2622 - :: 2619 2622 - :: 2619 2622 - :: 2619 2622 - :: 2620 2620 - :: 2620 2620 - :: 2623 2626 - :: 2623 2626 - :: 2623 2626 - :: 2623 2626 - :: 2624 2624 - :: 2624 2624 - :: 2627 2630 - :: 2627 2630 - :: 2627 2630 - :: 2627 2630 - :: 2628 2628 - :: 2628 2628 - :: 2631 2634 - :: 2631 2634 - :: 2631 2634 - :: 2631 2634 - :: 2632 2632 - :: 2632 2632 - :: 2635 2638 - :: 2635 2638 - :: 2635 2638 - :: 2635 2638 - :: 2636 2636 - :: 2636 2636 - :: 2639 2642 - :: 2639 2642 - :: 2639 2642 - :: 2639 2642 - :: 2640 2640 - :: 2640 2640 - :: 2643 2653 - :: 2643 2653 - :: 2643 2653 - :: 2643 2653 - :: 2643 2652 - :: 2656 2701 - :: 2656 2661 - :: 2656 2659 - :: 2662 2675 - :: 2662 2669 - :: 2679 2693 - :: 2679 2693 - :: 2679 2682 - :: 2679 2682 - :: 2679 2682 - :: 2679 2682 - :: 2680 2680 - :: 2680 2680 - :: 2683 2693 - :: 2683 2693 - :: 2683 2693 - :: 2683 2693 - :: 2683 2692 - :: 2702 2740 - :: 2702 2715 - :: 2702 2706 - :: 2719 2738 - :: 2719 2731 - :: 2719 2723 - :: 2719 2723 - :: 2719 2723 - :: 2719 2723 - :: 2719 2722 - :: 2724 2726 - :: 2724 2726 - :: 2724 2726 - :: 2724 2726 - :: 2724 2725 - :: 2727 2731 - :: 2727 2731 - :: 2727 2731 - :: 2727 2731 - :: 2727 2730 - :: 2734 2738 - :: 2734 2738 - :: 2734 2738 - :: 2734 2738 - :: 2734 2738 - :: 2734 2737 - :: 2741 2786 - :: 2741 2746 - :: 2741 2744 - :: 2747 2760 - :: 2747 2755 - :: 2764 2778 - :: 2764 2778 - :: 2764 2767 - :: 2764 2767 - :: 2764 2767 - :: 2764 2767 - :: 2765 2765 - :: 2765 2765 - :: 2768 2778 - :: 2768 2778 - :: 2768 2778 - :: 2768 2778 - :: 2768 2777 - :: 2787 2813 - :: 2787 2800 - :: 2787 2794 - :: 2804 2811 - :: 2804 2811 - :: 2804 2811 - :: 2804 2811 - :: 2804 2809 - :: 2804 2809 - :: 2804 2809 - :: 2810 2811 - :: 2814 2853 - :: 2814 2819 - :: 2814 2817 - :: 2820 2833 - :: 2820 2824 - :: 2837 2851 - :: 2837 2851 - :: 2837 2840 - :: 2837 2840 - :: 2837 2840 - :: 2837 2840 - :: 2838 2838 - :: 2838 2838 - :: 2841 2851 - :: 2841 2851 - :: 2841 2851 - :: 2841 2851 - :: 2841 2850 - :: 2854 2917 - :: 2854 2859 - :: 2854 2857 - :: 2860 2873 - :: 2860 2864 - :: 2877 2915 - :: 2877 2915 - :: 2877 2880 - :: 2877 2880 - :: 2877 2880 - :: 2877 2880 - :: 2878 2878 - :: 2878 2878 - :: 2881 2884 - :: 2881 2884 - :: 2881 2884 - :: 2881 2884 - :: 2882 2882 - :: 2882 2882 - :: 2885 2888 - :: 2885 2888 - :: 2885 2888 - :: 2885 2888 - :: 2886 2886 - :: 2886 2886 - :: 2889 2892 - :: 2889 2892 - :: 2889 2892 - :: 2889 2892 - :: 2890 2890 - :: 2890 2890 - :: 2893 2896 - :: 2893 2896 - :: 2893 2896 - :: 2893 2896 - :: 2894 2894 - :: 2894 2894 - :: 2897 2900 - :: 2897 2900 - :: 2897 2900 - :: 2897 2900 - :: 2898 2898 - :: 2898 2898 - :: 2901 2904 - :: 2901 2904 - :: 2901 2904 - :: 2901 2904 - :: 2902 2902 - :: 2902 2902 - :: 2905 2915 - :: 2905 2915 - :: 2905 2915 - :: 2905 2915 - :: 2905 2914 - :: 2918 2963 - :: 2918 2923 - :: 2918 2921 - :: 2924 2937 - :: 2924 2927 - :: 2941 2955 - :: 2941 2955 - :: 2941 2944 - :: 2941 2944 - :: 2941 2944 - :: 2941 2944 - :: 2942 2942 - :: 2942 2942 - :: 2945 2955 - :: 2945 2955 - :: 2945 2955 - :: 2945 2955 - :: 2945 2954 - :: 2964 3010 - :: 2964 2977 - :: 2964 2972 - :: 2981 3002 - :: 2981 3002 - :: 2981 2985 - :: 2981 2985 - :: 2981 2985 - :: 2981 2985 - :: 2981 2984 - :: 2986 2996 - :: 2986 2996 - :: 2986 2996 - :: 2986 2996 - :: 2986 2995 - :: 2997 3002 - :: 2997 3002 - :: 2997 3002 - :: 2997 3002 - :: 2997 3001 - :: 3011 3063 - :: 3011 3024 - :: 3011 3016 - :: 3028 3061 - :: 3028 3061 - :: 3028 3035 - :: 3028 3035 - :: 3028 3035 - :: 3028 3035 - :: 3028 3034 - :: 3036 3061 - :: 3036 3061 - :: 3036 3059 - :: 3037 3058 - :: 3037 3045 - :: 3037 3045 - :: 3037 3045 - :: 3037 3045 - :: 3037 3045 - :: 3037 3044 - :: 3048 3052 - :: 3048 3052 - :: 3048 3052 - :: 3048 3052 - :: 3048 3052 - :: 3048 3051 - :: 3055 3058 - :: 3055 3058 - :: 3055 3058 - :: 3055 3058 - :: 3055 3058 - :: 3055 3058 - :: 3060 3061 - :: 3064 3092 - :: 3064 3069 - :: 3064 3067 - :: 3070 3083 - :: 3070 3071 - :: 3087 3090 - :: 3087 3090 - :: 3087 3090 - :: 3087 3090 - :: 3087 3090 - :: 3087 3090 - :: 3088 3088 - :: 3088 3088 - :: 3093 3156 - :: 3093 3098 - :: 3093 3096 - :: 3099 3112 - :: 3099 3103 - :: 3116 3154 - :: 3116 3154 - :: 3116 3119 - :: 3116 3119 - :: 3116 3119 - :: 3116 3119 - :: 3117 3117 - :: 3117 3117 - :: 3120 3123 - :: 3120 3123 - :: 3120 3123 - :: 3120 3123 - :: 3121 3121 - :: 3121 3121 - :: 3124 3127 - :: 3124 3127 - :: 3124 3127 - :: 3124 3127 - :: 3125 3125 - :: 3125 3125 - :: 3128 3131 - :: 3128 3131 - :: 3128 3131 - :: 3128 3131 - :: 3129 3129 - :: 3129 3129 - :: 3132 3135 - :: 3132 3135 - :: 3132 3135 - :: 3132 3135 - :: 3133 3133 - :: 3133 3133 - :: 3136 3139 - :: 3136 3139 - :: 3136 3139 - :: 3136 3139 - :: 3137 3137 - :: 3137 3137 - :: 3140 3143 - :: 3140 3143 - :: 3140 3143 - :: 3140 3143 - :: 3141 3141 - :: 3141 3141 - :: 3144 3154 - :: 3144 3154 - :: 3144 3154 - :: 3144 3154 - :: 3144 3153 - :: 3157 3208 - :: 3157 3162 - :: 3157 3160 - :: 3163 3176 - :: 3163 3166 - :: 3180 3206 - :: 3180 3206 - :: 3180 3183 - :: 3180 3183 - :: 3180 3183 - :: 3180 3183 - :: 3181 3181 - :: 3181 3181 - :: 3184 3187 - :: 3184 3187 - :: 3184 3187 - :: 3184 3187 - :: 3185 3185 - :: 3185 3185 - :: 3188 3191 - :: 3188 3191 - :: 3188 3191 - :: 3188 3191 - :: 3189 3189 - :: 3189 3189 - :: 3192 3195 - :: 3192 3195 - :: 3192 3195 - :: 3192 3195 - :: 3193 3193 - :: 3193 3193 - :: 3196 3206 - :: 3196 3206 - :: 3196 3206 - :: 3196 3206 - :: 3196 3205 - :: 3209 3254 - :: 3209 3214 - :: 3209 3212 - :: 3215 3228 - :: 3215 3224 - :: 3232 3252 - :: 3232 3252 - :: 3232 3252 - :: 3232 3252 - :: 3232 3250 - :: 3233 3249 - :: 3233 3240 - :: 3233 3240 - :: 3233 3240 - :: 3233 3240 - :: 3233 3240 - :: 3243 3249 - :: 3243 3249 - :: 3243 3249 - :: 3243 3249 - :: 3243 3249 - :: 3243 3249 - :: 3251 3252 - :: 3255 3330 - :: 3255 3260 - :: 3255 3258 - :: 3261 3274 - :: 3261 3268 - :: 3278 3328 - :: 3278 3328 - :: 3278 3281 - :: 3278 3281 - :: 3278 3281 - :: 3278 3281 - :: 3279 3279 - :: 3279 3279 - :: 3282 3285 - :: 3282 3285 - :: 3282 3285 - :: 3282 3285 - :: 3283 3283 - :: 3283 3283 - :: 3286 3289 - :: 3286 3289 - :: 3286 3289 - :: 3286 3289 - :: 3287 3287 - :: 3287 3287 - :: 3290 3293 - :: 3290 3293 - :: 3290 3293 - :: 3290 3293 - :: 3291 3291 - :: 3291 3291 - :: 3294 3297 - :: 3294 3297 - :: 3294 3297 - :: 3294 3297 - :: 3295 3295 - :: 3295 3295 - :: 3298 3301 - :: 3298 3301 - :: 3298 3301 - :: 3298 3301 - :: 3299 3299 - :: 3299 3299 - :: 3302 3305 - :: 3302 3305 - :: 3302 3305 - :: 3302 3305 - :: 3303 3303 - :: 3303 3303 - :: 3306 3309 - :: 3306 3309 - :: 3306 3309 - :: 3306 3309 - :: 3307 3307 - :: 3307 3307 - :: 3310 3313 - :: 3310 3313 - :: 3310 3313 - :: 3310 3313 - :: 3311 3311 - :: 3311 3311 - :: 3314 3317 - :: 3314 3317 - :: 3314 3317 - :: 3314 3317 - :: 3315 3315 - :: 3315 3315 - :: 3318 3328 - :: 3318 3328 - :: 3318 3328 - :: 3318 3328 - :: 3318 3327 - :: 3331 3399 - :: 3331 3336 - :: 3331 3334 - :: 3337 3350 - :: 3337 3342 - :: 3354 3396 - :: 3354 3396 - :: 3354 3357 - :: 3354 3357 - :: 3354 3357 - :: 3354 3357 - :: 3355 3355 - :: 3355 3355 - :: 3358 3361 - :: 3358 3361 - :: 3358 3361 - :: 3358 3361 - :: 3359 3359 - :: 3359 3359 - :: 3362 3365 - :: 3362 3365 - :: 3362 3365 - :: 3362 3365 - :: 3363 3363 - :: 3363 3363 - :: 3366 3369 - :: 3366 3369 - :: 3366 3369 - :: 3366 3369 - :: 3367 3367 - :: 3367 3367 - :: 3370 3373 - :: 3370 3373 - :: 3370 3373 - :: 3370 3373 - :: 3371 3371 - :: 3371 3371 - :: 3374 3377 - :: 3374 3377 - :: 3374 3377 - :: 3374 3377 - :: 3375 3375 - :: 3375 3375 - :: 3378 3381 - :: 3378 3381 - :: 3378 3381 - :: 3378 3381 - :: 3379 3379 - :: 3379 3379 - :: 3382 3385 - :: 3382 3385 - :: 3382 3385 - :: 3382 3385 - :: 3383 3383 - :: 3383 3383 - :: 3386 3396 - :: 3386 3396 - :: 3386 3396 - :: 3386 3396 - :: 3386 3395 + :: 2304 2305 + :: 2306 2312 + :: 2306 2312 + :: 2306 2312 + :: 2306 2312 + :: 2306 2311 + :: 2321 2521 + :: 2321 2334 + :: 2321 2327 + :: 2338 2519 + :: 2338 2343 + :: 2338 2343 + :: 2338 2343 + :: 2338 2343 + :: 2338 2343 + :: 2338 2342 + :: 2346 2351 + :: 2346 2351 + :: 2346 2351 + :: 2346 2351 + :: 2346 2351 + :: 2346 2350 + :: 2354 2359 + :: 2354 2359 + :: 2354 2359 + :: 2354 2359 + :: 2354 2359 + :: 2354 2358 + :: 2362 2369 + :: 2362 2369 + :: 2362 2369 + :: 2362 2369 + :: 2362 2369 + :: 2362 2368 + :: 2372 2378 + :: 2372 2378 + :: 2372 2378 + :: 2372 2378 + :: 2372 2378 + :: 2372 2377 + :: 2381 2386 + :: 2381 2386 + :: 2381 2386 + :: 2381 2386 + :: 2381 2386 + :: 2381 2385 + :: 2389 2394 + :: 2389 2394 + :: 2389 2394 + :: 2389 2394 + :: 2389 2394 + :: 2389 2393 + :: 2397 2402 + :: 2397 2402 + :: 2397 2402 + :: 2397 2402 + :: 2397 2402 + :: 2397 2401 + :: 2405 2414 + :: 2405 2414 + :: 2405 2414 + :: 2405 2414 + :: 2405 2414 + :: 2405 2413 + :: 2417 2422 + :: 2417 2422 + :: 2417 2422 + :: 2417 2422 + :: 2417 2422 + :: 2417 2421 + :: 2425 2430 + :: 2425 2430 + :: 2425 2430 + :: 2425 2430 + :: 2425 2430 + :: 2425 2429 + :: 2433 2438 + :: 2433 2438 + :: 2433 2438 + :: 2433 2438 + :: 2433 2438 + :: 2433 2437 + :: 2441 2449 + :: 2441 2449 + :: 2441 2449 + :: 2441 2449 + :: 2441 2449 + :: 2441 2448 + :: 2452 2458 + :: 2452 2458 + :: 2452 2458 + :: 2452 2458 + :: 2452 2458 + :: 2452 2457 + :: 2461 2471 + :: 2461 2471 + :: 2461 2471 + :: 2461 2471 + :: 2461 2471 + :: 2461 2470 + :: 2474 2495 + :: 2474 2478 + :: 2474 2478 + :: 2474 2478 + :: 2474 2478 + :: 2474 2477 + :: 2479 2489 + :: 2479 2489 + :: 2479 2489 + :: 2479 2489 + :: 2479 2488 + :: 2490 2495 + :: 2490 2495 + :: 2490 2495 + :: 2490 2495 + :: 2490 2494 + :: 2498 2505 + :: 2498 2505 + :: 2498 2505 + :: 2498 2505 + :: 2498 2505 + :: 2498 2504 + :: 2508 2513 + :: 2508 2513 + :: 2508 2513 + :: 2508 2513 + :: 2508 2513 + :: 2508 2512 + :: 2516 2519 + :: 2516 2519 + :: 2516 2519 + :: 2516 2519 + :: 2516 2519 + :: 2516 2518 + :: 2522 2585 + :: 2522 2527 + :: 2522 2525 + :: 2528 2541 + :: 2528 2536 + :: 2545 2583 + :: 2545 2583 + :: 2545 2548 + :: 2545 2548 + :: 2545 2548 + :: 2545 2548 + :: 2546 2546 + :: 2546 2546 + :: 2549 2552 + :: 2549 2552 + :: 2549 2552 + :: 2549 2552 + :: 2550 2550 + :: 2550 2550 + :: 2553 2556 + :: 2553 2556 + :: 2553 2556 + :: 2553 2556 + :: 2554 2554 + :: 2554 2554 + :: 2557 2560 + :: 2557 2560 + :: 2557 2560 + :: 2557 2560 + :: 2558 2558 + :: 2558 2558 + :: 2561 2564 + :: 2561 2564 + :: 2561 2564 + :: 2561 2564 + :: 2562 2562 + :: 2562 2562 + :: 2565 2568 + :: 2565 2568 + :: 2565 2568 + :: 2565 2568 + :: 2566 2566 + :: 2566 2566 + :: 2569 2572 + :: 2569 2572 + :: 2569 2572 + :: 2569 2572 + :: 2570 2570 + :: 2570 2570 + :: 2573 2583 + :: 2573 2583 + :: 2573 2583 + :: 2573 2583 + :: 2573 2582 + :: 2586 2649 + :: 2586 2591 + :: 2586 2589 + :: 2592 2605 + :: 2592 2596 + :: 2609 2647 + :: 2609 2647 + :: 2609 2612 + :: 2609 2612 + :: 2609 2612 + :: 2609 2612 + :: 2610 2610 + :: 2610 2610 + :: 2613 2616 + :: 2613 2616 + :: 2613 2616 + :: 2613 2616 + :: 2614 2614 + :: 2614 2614 + :: 2617 2620 + :: 2617 2620 + :: 2617 2620 + :: 2617 2620 + :: 2618 2618 + :: 2618 2618 + :: 2621 2624 + :: 2621 2624 + :: 2621 2624 + :: 2621 2624 + :: 2622 2622 + :: 2622 2622 + :: 2625 2628 + :: 2625 2628 + :: 2625 2628 + :: 2625 2628 + :: 2626 2626 + :: 2626 2626 + :: 2629 2632 + :: 2629 2632 + :: 2629 2632 + :: 2629 2632 + :: 2630 2630 + :: 2630 2630 + :: 2633 2636 + :: 2633 2636 + :: 2633 2636 + :: 2633 2636 + :: 2634 2634 + :: 2634 2634 + :: 2637 2647 + :: 2637 2647 + :: 2637 2647 + :: 2637 2647 + :: 2637 2646 + :: 2650 2695 + :: 2650 2655 + :: 2650 2653 + :: 2656 2669 + :: 2656 2663 + :: 2673 2687 + :: 2673 2687 + :: 2673 2676 + :: 2673 2676 + :: 2673 2676 + :: 2673 2676 + :: 2674 2674 + :: 2674 2674 + :: 2677 2687 + :: 2677 2687 + :: 2677 2687 + :: 2677 2687 + :: 2677 2686 + :: 2696 2734 + :: 2696 2709 + :: 2696 2700 + :: 2713 2732 + :: 2713 2725 + :: 2713 2717 + :: 2713 2717 + :: 2713 2717 + :: 2713 2717 + :: 2713 2716 + :: 2718 2720 + :: 2718 2720 + :: 2718 2720 + :: 2718 2720 + :: 2718 2719 + :: 2721 2725 + :: 2721 2725 + :: 2721 2725 + :: 2721 2725 + :: 2721 2724 + :: 2728 2732 + :: 2728 2732 + :: 2728 2732 + :: 2728 2732 + :: 2728 2732 + :: 2728 2731 + :: 2735 2780 + :: 2735 2740 + :: 2735 2738 + :: 2741 2754 + :: 2741 2749 + :: 2758 2772 + :: 2758 2772 + :: 2758 2761 + :: 2758 2761 + :: 2758 2761 + :: 2758 2761 + :: 2759 2759 + :: 2759 2759 + :: 2762 2772 + :: 2762 2772 + :: 2762 2772 + :: 2762 2772 + :: 2762 2771 + :: 2781 2807 + :: 2781 2794 + :: 2781 2788 + :: 2798 2805 + :: 2798 2805 + :: 2798 2805 + :: 2798 2805 + :: 2798 2803 + :: 2798 2803 + :: 2798 2803 + :: 2804 2805 + :: 2808 2847 + :: 2808 2813 + :: 2808 2811 + :: 2814 2827 + :: 2814 2818 + :: 2831 2845 + :: 2831 2845 + :: 2831 2834 + :: 2831 2834 + :: 2831 2834 + :: 2831 2834 + :: 2832 2832 + :: 2832 2832 + :: 2835 2845 + :: 2835 2845 + :: 2835 2845 + :: 2835 2845 + :: 2835 2844 + :: 2848 2911 + :: 2848 2853 + :: 2848 2851 + :: 2854 2867 + :: 2854 2858 + :: 2871 2909 + :: 2871 2909 + :: 2871 2874 + :: 2871 2874 + :: 2871 2874 + :: 2871 2874 + :: 2872 2872 + :: 2872 2872 + :: 2875 2878 + :: 2875 2878 + :: 2875 2878 + :: 2875 2878 + :: 2876 2876 + :: 2876 2876 + :: 2879 2882 + :: 2879 2882 + :: 2879 2882 + :: 2879 2882 + :: 2880 2880 + :: 2880 2880 + :: 2883 2886 + :: 2883 2886 + :: 2883 2886 + :: 2883 2886 + :: 2884 2884 + :: 2884 2884 + :: 2887 2890 + :: 2887 2890 + :: 2887 2890 + :: 2887 2890 + :: 2888 2888 + :: 2888 2888 + :: 2891 2894 + :: 2891 2894 + :: 2891 2894 + :: 2891 2894 + :: 2892 2892 + :: 2892 2892 + :: 2895 2898 + :: 2895 2898 + :: 2895 2898 + :: 2895 2898 + :: 2896 2896 + :: 2896 2896 + :: 2899 2909 + :: 2899 2909 + :: 2899 2909 + :: 2899 2909 + :: 2899 2908 + :: 2912 2957 + :: 2912 2917 + :: 2912 2915 + :: 2918 2931 + :: 2918 2921 + :: 2935 2949 + :: 2935 2949 + :: 2935 2938 + :: 2935 2938 + :: 2935 2938 + :: 2935 2938 + :: 2936 2936 + :: 2936 2936 + :: 2939 2949 + :: 2939 2949 + :: 2939 2949 + :: 2939 2949 + :: 2939 2948 + :: 2958 3004 + :: 2958 2971 + :: 2958 2966 + :: 2975 2996 + :: 2975 2996 + :: 2975 2979 + :: 2975 2979 + :: 2975 2979 + :: 2975 2979 + :: 2975 2978 + :: 2980 2990 + :: 2980 2990 + :: 2980 2990 + :: 2980 2990 + :: 2980 2989 + :: 2991 2996 + :: 2991 2996 + :: 2991 2996 + :: 2991 2996 + :: 2991 2995 + :: 3005 3057 + :: 3005 3018 + :: 3005 3010 + :: 3022 3055 + :: 3022 3055 + :: 3022 3029 + :: 3022 3029 + :: 3022 3029 + :: 3022 3029 + :: 3022 3028 + :: 3030 3055 + :: 3030 3055 + :: 3030 3053 + :: 3031 3052 + :: 3031 3039 + :: 3031 3039 + :: 3031 3039 + :: 3031 3039 + :: 3031 3039 + :: 3031 3038 + :: 3042 3046 + :: 3042 3046 + :: 3042 3046 + :: 3042 3046 + :: 3042 3046 + :: 3042 3045 + :: 3049 3052 + :: 3049 3052 + :: 3049 3052 + :: 3049 3052 + :: 3049 3052 + :: 3049 3052 + :: 3054 3055 + :: 3058 3086 + :: 3058 3063 + :: 3058 3061 + :: 3064 3077 + :: 3064 3065 + :: 3081 3084 + :: 3081 3084 + :: 3081 3084 + :: 3081 3084 + :: 3081 3084 + :: 3081 3084 + :: 3082 3082 + :: 3082 3082 + :: 3087 3150 + :: 3087 3092 + :: 3087 3090 + :: 3093 3106 + :: 3093 3097 + :: 3110 3148 + :: 3110 3148 + :: 3110 3113 + :: 3110 3113 + :: 3110 3113 + :: 3110 3113 + :: 3111 3111 + :: 3111 3111 + :: 3114 3117 + :: 3114 3117 + :: 3114 3117 + :: 3114 3117 + :: 3115 3115 + :: 3115 3115 + :: 3118 3121 + :: 3118 3121 + :: 3118 3121 + :: 3118 3121 + :: 3119 3119 + :: 3119 3119 + :: 3122 3125 + :: 3122 3125 + :: 3122 3125 + :: 3122 3125 + :: 3123 3123 + :: 3123 3123 + :: 3126 3129 + :: 3126 3129 + :: 3126 3129 + :: 3126 3129 + :: 3127 3127 + :: 3127 3127 + :: 3130 3133 + :: 3130 3133 + :: 3130 3133 + :: 3130 3133 + :: 3131 3131 + :: 3131 3131 + :: 3134 3137 + :: 3134 3137 + :: 3134 3137 + :: 3134 3137 + :: 3135 3135 + :: 3135 3135 + :: 3138 3148 + :: 3138 3148 + :: 3138 3148 + :: 3138 3148 + :: 3138 3147 + :: 3151 3202 + :: 3151 3156 + :: 3151 3154 + :: 3157 3170 + :: 3157 3160 + :: 3174 3200 + :: 3174 3200 + :: 3174 3177 + :: 3174 3177 + :: 3174 3177 + :: 3174 3177 + :: 3175 3175 + :: 3175 3175 + :: 3178 3181 + :: 3178 3181 + :: 3178 3181 + :: 3178 3181 + :: 3179 3179 + :: 3179 3179 + :: 3182 3185 + :: 3182 3185 + :: 3182 3185 + :: 3182 3185 + :: 3183 3183 + :: 3183 3183 + :: 3186 3189 + :: 3186 3189 + :: 3186 3189 + :: 3186 3189 + :: 3187 3187 + :: 3187 3187 + :: 3190 3200 + :: 3190 3200 + :: 3190 3200 + :: 3190 3200 + :: 3190 3199 + :: 3203 3248 + :: 3203 3208 + :: 3203 3206 + :: 3209 3222 + :: 3209 3218 + :: 3226 3246 + :: 3226 3246 + :: 3226 3246 + :: 3226 3246 + :: 3226 3244 + :: 3227 3243 + :: 3227 3234 + :: 3227 3234 + :: 3227 3234 + :: 3227 3234 + :: 3227 3234 + :: 3237 3243 + :: 3237 3243 + :: 3237 3243 + :: 3237 3243 + :: 3237 3243 + :: 3237 3243 + :: 3245 3246 + :: 3249 3324 + :: 3249 3254 + :: 3249 3252 + :: 3255 3268 + :: 3255 3262 + :: 3272 3322 + :: 3272 3322 + :: 3272 3275 + :: 3272 3275 + :: 3272 3275 + :: 3272 3275 + :: 3273 3273 + :: 3273 3273 + :: 3276 3279 + :: 3276 3279 + :: 3276 3279 + :: 3276 3279 + :: 3277 3277 + :: 3277 3277 + :: 3280 3283 + :: 3280 3283 + :: 3280 3283 + :: 3280 3283 + :: 3281 3281 + :: 3281 3281 + :: 3284 3287 + :: 3284 3287 + :: 3284 3287 + :: 3284 3287 + :: 3285 3285 + :: 3285 3285 + :: 3288 3291 + :: 3288 3291 + :: 3288 3291 + :: 3288 3291 + :: 3289 3289 + :: 3289 3289 + :: 3292 3295 + :: 3292 3295 + :: 3292 3295 + :: 3292 3295 + :: 3293 3293 + :: 3293 3293 + :: 3296 3299 + :: 3296 3299 + :: 3296 3299 + :: 3296 3299 + :: 3297 3297 + :: 3297 3297 + :: 3300 3303 + :: 3300 3303 + :: 3300 3303 + :: 3300 3303 + :: 3301 3301 + :: 3301 3301 + :: 3304 3307 + :: 3304 3307 + :: 3304 3307 + :: 3304 3307 + :: 3305 3305 + :: 3305 3305 + :: 3308 3311 + :: 3308 3311 + :: 3308 3311 + :: 3308 3311 + :: 3309 3309 + :: 3309 3309 + :: 3312 3322 + :: 3312 3322 + :: 3312 3322 + :: 3312 3322 + :: 3312 3321 + :: 3325 3393 + :: 3325 3330 + :: 3325 3328 + :: 3331 3344 + :: 3331 3336 + :: 3348 3390 + :: 3348 3390 + :: 3348 3351 + :: 3348 3351 + :: 3348 3351 + :: 3348 3351 + :: 3349 3349 + :: 3349 3349 + :: 3352 3355 + :: 3352 3355 + :: 3352 3355 + :: 3352 3355 + :: 3353 3353 + :: 3353 3353 + :: 3356 3359 + :: 3356 3359 + :: 3356 3359 + :: 3356 3359 + :: 3357 3357 + :: 3357 3357 + :: 3360 3363 + :: 3360 3363 + :: 3360 3363 + :: 3360 3363 + :: 3361 3361 + :: 3361 3361 + :: 3364 3367 + :: 3364 3367 + :: 3364 3367 + :: 3364 3367 + :: 3365 3365 + :: 3365 3365 + :: 3368 3371 + :: 3368 3371 + :: 3368 3371 + :: 3368 3371 + :: 3369 3369 + :: 3369 3369 + :: 3372 3375 + :: 3372 3375 + :: 3372 3375 + :: 3372 3375 + :: 3373 3373 + :: 3373 3373 + :: 3376 3379 + :: 3376 3379 + :: 3376 3379 + :: 3376 3379 + :: 3377 3377 + :: 3377 3377 + :: 3380 3390 + :: 3380 3390 + :: 3380 3390 + :: 3380 3390 + :: 3380 3389 Index: modules/pt/tests/data/ok/peg_peg-fused/3_peg_itself ================================================================== --- modules/pt/tests/data/ok/peg_peg-fused/3_peg_itself +++ modules/pt/tests/data/ok/peg_peg-fused/3_peg_itself @@ -21,15 +21,14 @@ void: DAPOSTROPH <- '\"' ; leaf: DDIGIT <- '' WHITESPACE ; Definition <- Attribute? Identifier IS Expression SEMICOLON ; leaf: DIGIT <- '' WHITESPACE ; leaf: DOT <- '.' WHITESPACE ; -void: END <- 'END' WHITESPACE ; void: EOF <- !. ; void: EOL <- [\n\r] ; Expression <- Sequence (SLASH Sequence)* ; -void: Final <- END SEMICOLON WHITESPACE ; +void: Final <- 'END' WHITESPACE SEMICOLON WHITESPACE ; Grammar <- WHITESPACE Header Definition* Final EOF ; leaf: GRAPH <- '' WHITESPACE ; Header <- PEG Identifier StartExpr ; leaf: Ident <- ([_:] / ) ([_:] / )* ; Identifier <- Ident WHITESPACE ; @@ -38,11 +37,11 @@ Literal <- APOSTROPH (!APOSTROPH Char)* APOSTROPH WHITESPACE / DAPOSTROPH (!DAPOSTROPH Char)* DAPOSTROPH WHITESPACE ; leaf: LOWER <- '' WHITESPACE ; leaf: NOT <- '!' WHITESPACE ; void: OPEN <- '(' WHITESPACE ; void: OPENB <- '\[' ; -void: PEG <- 'PEG' WHITESPACE ; +void: PEG <- 'PEG' !([_:] / ) WHITESPACE ; leaf: PLUS <- '+' WHITESPACE ; Prefix <- (AND / NOT)? Suffix ; Primary <- ALNUM / ALPHA / ASCII / CONTROL / DDIGIT / DIGIT / GRAPH / LOWER / PRINTABLE / PUNCT / SPACE / UPPER / WORDCHAR / XDIGIT / Identifier / OPEN Expression CLOSE / Literal / Class / DOT ; leaf: PRINTABLE <- '' WHITESPACE ; leaf: PUNCT <- '' WHITESPACE ; Index: modules/pt/tests/data/ok/peg_peg-templated-fused/3_peg_itself ================================================================== --- modules/pt/tests/data/ok/peg_peg-templated-fused/3_peg_itself +++ modules/pt/tests/data/ok/peg_peg-templated-fused/3_peg_itself @@ -25,15 +25,14 @@ void: DAPOSTROPH <- '\"' ; leaf: DDIGIT <- '' WHITESPACE ; Definition <- Attribute? Identifier IS Expression SEMICOLON ; leaf: DIGIT <- '' WHITESPACE ; leaf: DOT <- '.' WHITESPACE ; -void: END <- 'END' WHITESPACE ; void: EOF <- !. ; void: EOL <- [\n\r] ; Expression <- Sequence (SLASH Sequence)* ; -void: Final <- END SEMICOLON WHITESPACE ; +void: Final <- 'END' WHITESPACE SEMICOLON WHITESPACE ; Grammar <- WHITESPACE Header Definition* Final EOF ; leaf: GRAPH <- '' WHITESPACE ; Header <- PEG Identifier StartExpr ; leaf: Ident <- ([_:] / ) ([_:] / )* ; Identifier <- Ident WHITESPACE ; @@ -42,11 +41,11 @@ Literal <- APOSTROPH (!APOSTROPH Char)* APOSTROPH WHITESPACE / DAPOSTROPH (!DAPOSTROPH Char)* DAPOSTROPH WHITESPACE ; leaf: LOWER <- '' WHITESPACE ; leaf: NOT <- '!' WHITESPACE ; void: OPEN <- '(' WHITESPACE ; void: OPENB <- '\[' ; -void: PEG <- 'PEG' WHITESPACE ; +void: PEG <- 'PEG' !([_:] / ) WHITESPACE ; leaf: PLUS <- '+' WHITESPACE ; Prefix <- (AND / NOT)? Suffix ; Primary <- ALNUM / ALPHA / ASCII / CONTROL / DDIGIT / DIGIT / GRAPH / LOWER / PRINTABLE / PUNCT / SPACE / UPPER / WORDCHAR / XDIGIT / Identifier / OPEN Expression CLOSE / Literal / Class / DOT ; leaf: PRINTABLE <- '' WHITESPACE ; leaf: PUNCT <- '' WHITESPACE ; Index: modules/pt/tests/data/ok/peg_peg-templated/3_peg_itself ================================================================== --- modules/pt/tests/data/ok/peg_peg-templated/3_peg_itself +++ modules/pt/tests/data/ok/peg_peg-templated/3_peg_itself @@ -25,15 +25,14 @@ void: DAPOSTROPH <- '\"' ; leaf: DDIGIT <- '<' 'd' 'd' 'i' 'g' 'i' 't' '>' WHITESPACE ; Definition <- Attribute? Identifier IS Expression SEMICOLON ; leaf: DIGIT <- '<' 'd' 'i' 'g' 'i' 't' '>' WHITESPACE ; leaf: DOT <- '.' WHITESPACE ; -void: END <- 'E' 'N' 'D' WHITESPACE ; void: EOF <- !. ; void: EOL <- '\n' / '\r' ; Expression <- Sequence (SLASH Sequence)* ; -void: Final <- END SEMICOLON WHITESPACE ; +void: Final <- 'E' 'N' 'D' WHITESPACE SEMICOLON WHITESPACE ; Grammar <- WHITESPACE Header Definition* Final EOF ; leaf: GRAPH <- '<' 'g' 'r' 'a' 'p' 'h' '>' WHITESPACE ; Header <- PEG Identifier StartExpr ; leaf: Ident <- ('_' / ':' / ) ('_' / ':' / )* ; Identifier <- Ident WHITESPACE ; @@ -42,11 +41,11 @@ Literal <- APOSTROPH (!APOSTROPH Char)* APOSTROPH WHITESPACE / DAPOSTROPH (!DAPOSTROPH Char)* DAPOSTROPH WHITESPACE ; leaf: LOWER <- '<' 'l' 'o' 'w' 'e' 'r' '>' WHITESPACE ; leaf: NOT <- '!' WHITESPACE ; void: OPEN <- '(' WHITESPACE ; void: OPENB <- '\[' ; -void: PEG <- 'P' 'E' 'G' WHITESPACE ; +void: PEG <- 'P' 'E' 'G' !('_' / ':' / ) WHITESPACE ; leaf: PLUS <- '+' WHITESPACE ; Prefix <- (AND / NOT)? Suffix ; Primary <- ALNUM / ALPHA / ASCII / CONTROL / DDIGIT / DIGIT / GRAPH / LOWER / PRINTABLE / PUNCT / SPACE / UPPER / WORDCHAR / XDIGIT / Identifier / OPEN Expression CLOSE / Literal / Class / DOT ; leaf: PRINTABLE <- '<' 'p' 'r' 'i' 'n' 't' '>' WHITESPACE ; leaf: PUNCT <- '<' 'p' 'u' 'n' 'c' 't' '>' WHITESPACE ; Index: modules/pt/tests/data/ok/peg_peg/3_peg_itself ================================================================== --- modules/pt/tests/data/ok/peg_peg/3_peg_itself +++ modules/pt/tests/data/ok/peg_peg/3_peg_itself @@ -21,15 +21,14 @@ void: DAPOSTROPH <- '\"' ; leaf: DDIGIT <- '<' 'd' 'd' 'i' 'g' 'i' 't' '>' WHITESPACE ; Definition <- Attribute? Identifier IS Expression SEMICOLON ; leaf: DIGIT <- '<' 'd' 'i' 'g' 'i' 't' '>' WHITESPACE ; leaf: DOT <- '.' WHITESPACE ; -void: END <- 'E' 'N' 'D' WHITESPACE ; void: EOF <- !. ; void: EOL <- '\n' / '\r' ; Expression <- Sequence (SLASH Sequence)* ; -void: Final <- END SEMICOLON WHITESPACE ; +void: Final <- 'E' 'N' 'D' WHITESPACE SEMICOLON WHITESPACE ; Grammar <- WHITESPACE Header Definition* Final EOF ; leaf: GRAPH <- '<' 'g' 'r' 'a' 'p' 'h' '>' WHITESPACE ; Header <- PEG Identifier StartExpr ; leaf: Ident <- ('_' / ':' / ) ('_' / ':' / )* ; Identifier <- Ident WHITESPACE ; @@ -38,11 +37,11 @@ Literal <- APOSTROPH (!APOSTROPH Char)* APOSTROPH WHITESPACE / DAPOSTROPH (!DAPOSTROPH Char)* DAPOSTROPH WHITESPACE ; leaf: LOWER <- '<' 'l' 'o' 'w' 'e' 'r' '>' WHITESPACE ; leaf: NOT <- '!' WHITESPACE ; void: OPEN <- '(' WHITESPACE ; void: OPENB <- '\[' ; -void: PEG <- 'P' 'E' 'G' WHITESPACE ; +void: PEG <- 'P' 'E' 'G' !('_' / ':' / ) WHITESPACE ; leaf: PLUS <- '+' WHITESPACE ; Prefix <- (AND / NOT)? Suffix ; Primary <- ALNUM / ALPHA / ASCII / CONTROL / DDIGIT / DIGIT / GRAPH / LOWER / PRINTABLE / PUNCT / SPACE / UPPER / WORDCHAR / XDIGIT / Identifier / OPEN Expression CLOSE / Literal / Class / DOT ; leaf: PRINTABLE <- '<' 'p' 'r' 'i' 'n' 't' '>' WHITESPACE ; leaf: PUNCT <- '<' 'p' 'u' 'n' 'c' 't' '>' WHITESPACE ; Index: modules/pt/tests/data/ok/peg_serial-canonical/3_peg_itself ================================================================== --- modules/pt/tests/data/ok/peg_serial-canonical/3_peg_itself +++ modules/pt/tests/data/ok/peg_serial-canonical/3_peg_itself @@ -1,2 +1,2 @@ -pt::grammar::peg {rules {ALNUM {is {x {t <} {t a} {t l} {t n} {t u} {t m} {t >} {n WHITESPACE}} mode leaf} ALPHA {is {x {t <} {t a} {t l} {t p} {t h} {t a} {t >} {n WHITESPACE}} mode leaf} AND {is {x {t &} {n WHITESPACE}} mode leaf} APOSTROPH {is {t '} mode void} ASCII {is {x {t <} {t a} {t s} {t c} {t i} {t i} {t >} {n WHITESPACE}} mode leaf} Attribute {is {x {/ {n VOID} {n LEAF}} {n COLON}} mode value} Char {is {/ {n CharSpecial} {n CharOctalFull} {n CharOctalPart} {n CharUnicode} {n CharUnescaped}} mode value} CharOctalFull {is {x {t \\} {.. 0 2} {.. 0 7} {.. 0 7}} mode leaf} CharOctalPart {is {x {t \\} {.. 0 7} {? {.. 0 7}}} mode leaf} CharSpecial {is {x {t \\} {/ {t n} {t r} {t t} {t '} {t {"}} {t {[}} {t \]} {t \\}}} mode leaf} CharUnescaped {is {x {! {t \\}} dot} mode leaf} CharUnicode {is {x {t \\} {t u} xdigit {? {x xdigit {? {x xdigit {? xdigit}}}}}} mode leaf} Class {is {x {n OPENB} {* {x {! {n CLOSEB}} {n Range}}} {n CLOSEB} {n WHITESPACE}} mode value} CLOSE {is {x {t )} {n WHITESPACE}} mode void} CLOSEB {is {t \]} mode void} COLON {is {x {t :} {n WHITESPACE}} mode void} COMMENT {is {x {t #} {* {x {! {n EOL}} dot}} {n EOL}} mode void} CONTROL {is {x {t <} {t c} {t o} {t n} {t t} {t r} {t o} {t l} {t >} {n WHITESPACE}} mode leaf} DAPOSTROPH {is {t {"}} mode void} DDIGIT {is {x {t <} {t d} {t d} {t i} {t g} {t i} {t t} {t >} {n WHITESPACE}} mode leaf} Definition {is {x {? {n Attribute}} {n Identifier} {n IS} {n Expression} {n SEMICOLON}} mode value} DIGIT {is {x {t <} {t d} {t i} {t g} {t i} {t t} {t >} {n WHITESPACE}} mode leaf} DOT {is {x {t .} {n WHITESPACE}} mode leaf} END {is {x {t E} {t N} {t D} {n WHITESPACE}} mode void} EOF {is {! dot} mode void} EOL {is {/ {t { -}} {t { }}} mode void} Expression {is {x {n Sequence} {* {x {n SLASH} {n Sequence}}}} mode value} Final {is {x {n END} {n SEMICOLON} {n WHITESPACE}} mode void} Grammar {is {x {n WHITESPACE} {n Header} {* {n Definition}} {n Final} {n EOF}} mode value} GRAPH {is {x {t <} {t g} {t r} {t a} {t p} {t h} {t >} {n WHITESPACE}} mode leaf} Header {is {x {n PEG} {n Identifier} {n StartExpr}} mode value} Ident {is {x {/ {t _} {t :} alpha} {* {/ {t _} {t :} alnum}}} mode leaf} Identifier {is {x {n Ident} {n WHITESPACE}} mode value} IS {is {x {t <} {t -} {n WHITESPACE}} mode void} LEAF {is {x {t l} {t e} {t a} {t f} {n WHITESPACE}} mode leaf} Literal {is {/ {x {n APOSTROPH} {* {x {! {n APOSTROPH}} {n Char}}} {n APOSTROPH} {n WHITESPACE}} {x {n DAPOSTROPH} {* {x {! {n DAPOSTROPH}} {n Char}}} {n DAPOSTROPH} {n WHITESPACE}}} mode value} LOWER {is {x {t <} {t l} {t o} {t w} {t e} {t r} {t >} {n WHITESPACE}} mode leaf} NOT {is {x {t !} {n WHITESPACE}} mode leaf} OPEN {is {x {t (} {n WHITESPACE}} mode void} OPENB {is {t {[}} mode void} PEG {is {x {t P} {t E} {t G} {n WHITESPACE}} mode void} PLUS {is {x {t +} {n WHITESPACE}} mode leaf} Prefix {is {x {? {/ {n AND} {n NOT}}} {n Suffix}} mode value} Primary {is {/ {n ALNUM} {n ALPHA} {n ASCII} {n CONTROL} {n DDIGIT} {n DIGIT} {n GRAPH} {n LOWER} {n PRINTABLE} {n PUNCT} {n SPACE} {n UPPER} {n WORDCHAR} {n XDIGIT} {n Identifier} {x {n OPEN} {n Expression} {n CLOSE}} {n Literal} {n Class} {n DOT}} mode value} PRINTABLE {is {x {t <} {t p} {t r} {t i} {t n} {t t} {t >} {n WHITESPACE}} mode leaf} PUNCT {is {x {t <} {t p} {t u} {t n} {t c} {t t} {t >} {n WHITESPACE}} mode leaf} QUESTION {is {x {t ?} {n WHITESPACE}} mode leaf} Range {is {/ {x {n Char} {n TO} {n Char}} {n Char}} mode value} SEMICOLON {is {x {t {;}} {n WHITESPACE}} mode void} Sequence {is {+ {n Prefix}} mode value} SLASH {is {x {t /} {n WHITESPACE}} mode void} SPACE {is {x {t <} {t s} {t p} {t a} {t c} {t e} {t >} {n WHITESPACE}} mode leaf} STAR {is {x {t *} {n WHITESPACE}} mode leaf} StartExpr {is {x {n OPEN} {n Expression} {n CLOSE}} mode value} Suffix {is {x {n Primary} {? {/ {n QUESTION} {n STAR} {n PLUS}}}} mode value} TO {is {t -} mode void} UPPER {is {x {t <} {t u} {t p} {t p} {t e} {t r} {t >} {n WHITESPACE}} mode leaf} VOID {is {x {t v} {t o} {t i} {t d} {n WHITESPACE}} mode leaf} WHITESPACE {is {* {/ space {n COMMENT}}} mode void} WORDCHAR {is {x {t <} {t w} {t o} {t r} {t d} {t c} {t h} {t a} {t r} {t >} {n WHITESPACE}} mode leaf} XDIGIT {is {x {t <} {t x} {t d} {t i} {t g} {t i} {t t} {t >} {n WHITESPACE}} mode leaf}} start {n Grammar}} +pt::grammar::peg {rules {ALNUM {is {x {t <} {t a} {t l} {t n} {t u} {t m} {t >} {n WHITESPACE}} mode leaf} ALPHA {is {x {t <} {t a} {t l} {t p} {t h} {t a} {t >} {n WHITESPACE}} mode leaf} AND {is {x {t &} {n WHITESPACE}} mode leaf} APOSTROPH {is {t '} mode void} ASCII {is {x {t <} {t a} {t s} {t c} {t i} {t i} {t >} {n WHITESPACE}} mode leaf} Attribute {is {x {/ {n VOID} {n LEAF}} {n COLON}} mode value} Char {is {/ {n CharSpecial} {n CharOctalFull} {n CharOctalPart} {n CharUnicode} {n CharUnescaped}} mode value} CharOctalFull {is {x {t \\} {.. 0 2} {.. 0 7} {.. 0 7}} mode leaf} CharOctalPart {is {x {t \\} {.. 0 7} {? {.. 0 7}}} mode leaf} CharSpecial {is {x {t \\} {/ {t n} {t r} {t t} {t '} {t {"}} {t {[}} {t \]} {t \\}}} mode leaf} CharUnescaped {is {x {! {t \\}} dot} mode leaf} CharUnicode {is {x {t \\} {t u} xdigit {? {x xdigit {? {x xdigit {? xdigit}}}}}} mode leaf} Class {is {x {n OPENB} {* {x {! {n CLOSEB}} {n Range}}} {n CLOSEB} {n WHITESPACE}} mode value} CLOSE {is {x {t )} {n WHITESPACE}} mode void} CLOSEB {is {t \]} mode void} COLON {is {x {t :} {n WHITESPACE}} mode void} COMMENT {is {x {t #} {* {x {! {n EOL}} dot}} {n EOL}} mode void} CONTROL {is {x {t <} {t c} {t o} {t n} {t t} {t r} {t o} {t l} {t >} {n WHITESPACE}} mode leaf} DAPOSTROPH {is {t {"}} mode void} DDIGIT {is {x {t <} {t d} {t d} {t i} {t g} {t i} {t t} {t >} {n WHITESPACE}} mode leaf} Definition {is {x {? {n Attribute}} {n Identifier} {n IS} {n Expression} {n SEMICOLON}} mode value} DIGIT {is {x {t <} {t d} {t i} {t g} {t i} {t t} {t >} {n WHITESPACE}} mode leaf} DOT {is {x {t .} {n WHITESPACE}} mode leaf} EOF {is {! dot} mode void} EOL {is {/ {t { +}} {t { }}} mode void} Expression {is {x {n Sequence} {* {x {n SLASH} {n Sequence}}}} mode value} Final {is {x {t E} {t N} {t D} {n WHITESPACE} {n SEMICOLON} {n WHITESPACE}} mode void} Grammar {is {x {n WHITESPACE} {n Header} {* {n Definition}} {n Final} {n EOF}} mode value} GRAPH {is {x {t <} {t g} {t r} {t a} {t p} {t h} {t >} {n WHITESPACE}} mode leaf} Header {is {x {n PEG} {n Identifier} {n StartExpr}} mode value} Ident {is {x {/ {t _} {t :} alpha} {* {/ {t _} {t :} alnum}}} mode leaf} Identifier {is {x {n Ident} {n WHITESPACE}} mode value} IS {is {x {t <} {t -} {n WHITESPACE}} mode void} LEAF {is {x {t l} {t e} {t a} {t f} {n WHITESPACE}} mode leaf} Literal {is {/ {x {n APOSTROPH} {* {x {! {n APOSTROPH}} {n Char}}} {n APOSTROPH} {n WHITESPACE}} {x {n DAPOSTROPH} {* {x {! {n DAPOSTROPH}} {n Char}}} {n DAPOSTROPH} {n WHITESPACE}}} mode value} LOWER {is {x {t <} {t l} {t o} {t w} {t e} {t r} {t >} {n WHITESPACE}} mode leaf} NOT {is {x {t !} {n WHITESPACE}} mode leaf} OPEN {is {x {t (} {n WHITESPACE}} mode void} OPENB {is {t {[}} mode void} PEG {is {x {t P} {t E} {t G} {! {/ {t _} {t :} alnum}} {n WHITESPACE}} mode void} PLUS {is {x {t +} {n WHITESPACE}} mode leaf} Prefix {is {x {? {/ {n AND} {n NOT}}} {n Suffix}} mode value} Primary {is {/ {n ALNUM} {n ALPHA} {n ASCII} {n CONTROL} {n DDIGIT} {n DIGIT} {n GRAPH} {n LOWER} {n PRINTABLE} {n PUNCT} {n SPACE} {n UPPER} {n WORDCHAR} {n XDIGIT} {n Identifier} {x {n OPEN} {n Expression} {n CLOSE}} {n Literal} {n Class} {n DOT}} mode value} PRINTABLE {is {x {t <} {t p} {t r} {t i} {t n} {t t} {t >} {n WHITESPACE}} mode leaf} PUNCT {is {x {t <} {t p} {t u} {t n} {t c} {t t} {t >} {n WHITESPACE}} mode leaf} QUESTION {is {x {t ?} {n WHITESPACE}} mode leaf} Range {is {/ {x {n Char} {n TO} {n Char}} {n Char}} mode value} SEMICOLON {is {x {t {;}} {n WHITESPACE}} mode void} Sequence {is {+ {n Prefix}} mode value} SLASH {is {x {t /} {n WHITESPACE}} mode void} SPACE {is {x {t <} {t s} {t p} {t a} {t c} {t e} {t >} {n WHITESPACE}} mode leaf} STAR {is {x {t *} {n WHITESPACE}} mode leaf} StartExpr {is {x {n OPEN} {n Expression} {n CLOSE}} mode value} Suffix {is {x {n Primary} {? {/ {n QUESTION} {n STAR} {n PLUS}}}} mode value} TO {is {t -} mode void} UPPER {is {x {t <} {t u} {t p} {t p} {t e} {t r} {t >} {n WHITESPACE}} mode leaf} VOID {is {x {t v} {t o} {t i} {t d} {n WHITESPACE}} mode leaf} WHITESPACE {is {* {/ space {n COMMENT}}} mode void} WORDCHAR {is {x {t <} {t w} {t o} {t r} {t d} {t c} {t h} {t a} {t r} {t >} {n WHITESPACE}} mode leaf} XDIGIT {is {x {t <} {t x} {t d} {t i} {t g} {t i} {t t} {t >} {n WHITESPACE}} mode leaf}} start {n Grammar}} Index: modules/pt/tests/data/ok/peg_serial-print/3_peg_itself ================================================================== --- modules/pt/tests/data/ok/peg_serial-print/3_peg_itself +++ modules/pt/tests/data/ok/peg_serial-print/3_peg_itself @@ -166,16 +166,10 @@ (Attribute) (Identifier) (IS) (Expression) (SEMICOLON) - END :: := - x - 'E' - 'N' - 'D' - (WHITESPACE) EOF :: := ! EOL :: := / @@ -188,11 +182,14 @@ x (SLASH) (Sequence) Final :: := x - (END) + 'E' + 'N' + 'D' + (WHITESPACE) (SEMICOLON) (WHITESPACE) GRAPH :: := x '<' @@ -286,10 +283,15 @@ PEG :: := x 'P' 'E' 'G' + ! + / + '_' + ':' + (WHITESPACE) PLUS :: := x '+' (WHITESPACE) Index: modules/pt/tests/data/ok/peg_serial/3_peg_itself ================================================================== --- modules/pt/tests/data/ok/peg_serial/3_peg_itself +++ modules/pt/tests/data/ok/peg_serial/3_peg_itself @@ -21,15 +21,14 @@ DAPOSTROPH {mode void is {t \42}} DDIGIT {mode leaf is {x {t <} {t d} {t d} {t i} {t g} {t i} {t t} {t >} {n WHITESPACE}}} DIGIT {mode leaf is {x {t <} {t d} {t i} {t g} {t i} {t t} {t >} {n WHITESPACE}}} DOT {mode leaf is {x {t .} {n WHITESPACE}}} Definition {mode value is {x {? {n Attribute}} {n Identifier} {n IS} {n Expression} {n SEMICOLON}}} - END {mode void is {x {t E} {t N} {t D} {n WHITESPACE}}} EOF {mode void is {! dot}} EOL {mode void is {/ {t \n} {t \r}}} Expression {mode value is {x {n Sequence} {* {x {n SLASH} {n Sequence}}}}} - Final {mode void is {x {n END} {n SEMICOLON} {n WHITESPACE}}} + Final {mode void is {x {t E} {t N} {t D} {n WHITESPACE} {n SEMICOLON} {n WHITESPACE}}} GRAPH {mode leaf is {x {t <} {t g} {t r} {t a} {t p} {t h} {t >} {n WHITESPACE}}} Grammar {mode value is {x {n WHITESPACE} {n Header} {* {n Definition}} {n Final} {n EOF}}} Header {mode value is {x {n PEG} {n Identifier} {n StartExpr}}} IS {mode void is {x {t <} {t -} {n WHITESPACE}}} Ident {mode leaf is {x {/ {t _} {t :} alpha} {* {/ {t _} {t :} alnum}}}} @@ -38,11 +37,11 @@ LOWER {mode leaf is {x {t <} {t l} {t o} {t w} {t e} {t r} {t >} {n WHITESPACE}}} Literal {mode value is {/ {x {n APOSTROPH} {* {x {! {n APOSTROPH}} {n Char}}} {n APOSTROPH} {n WHITESPACE}} {x {n DAPOSTROPH} {* {x {! {n DAPOSTROPH}} {n Char}}} {n DAPOSTROPH} {n WHITESPACE}}}} NOT {mode leaf is {x {t !} {n WHITESPACE}}} OPEN {mode void is {x {t \50} {n WHITESPACE}}} OPENB {mode void is {t \133}} - PEG {mode void is {x {t P} {t E} {t G} {n WHITESPACE}}} + PEG {mode void is {x {t P} {t E} {t G} {! {/ {t _} {t :} alnum}} {n WHITESPACE}}} PLUS {mode leaf is {x {t +} {n WHITESPACE}}} PRINTABLE {mode leaf is {x {t <} {t p} {t r} {t i} {t n} {t t} {t >} {n WHITESPACE}}} PUNCT {mode leaf is {x {t <} {t p} {t u} {t n} {t c} {t t} {t >} {n WHITESPACE}}} Prefix {mode value is {x {? {/ {n AND} {n NOT}}} {n Suffix}}} Primary {mode value is {/ {n ALNUM} {n ALPHA} {n ASCII} {n CONTROL} {n DDIGIT} {n DIGIT} {n GRAPH} {n LOWER} {n PRINTABLE} {n PUNCT} {n SPACE} {n UPPER} {n WORDCHAR} {n XDIGIT} {n Identifier} {x {n OPEN} {n Expression} {n CLOSE}} {n Literal} {n Class} {n DOT}}} Index: modules/pt/tests/data/ok/peg_tclparam-snit/3_peg_itself ================================================================== --- modules/pt/tests/data/ok/peg_tclparam-snit/3_peg_itself +++ modules/pt/tests/data/ok/peg_tclparam-snit/3_peg_itself @@ -948,53 +948,25 @@ sym_WHITESPACE $myparser si:void_state_merge return } - # - # void Symbol 'END' - # - - proc sym_END {} { upvar 1 myparser myparser - # x - # "END" - # (WHITESPACE) - - $myparser si:void_void_symbol_start END - sequence_158 - $myparser si:void_clear_symbol_end END - return - } - - proc sequence_158 {} { upvar 1 myparser myparser - # x - # "END" - # (WHITESPACE) - - $myparser si:void_state_push - $myparser si:next_str END - $myparser si:voidvoid_part - sym_WHITESPACE - $myparser si:void_state_merge - return - } - # # void Symbol 'EOF' # proc sym_EOF {} { upvar 1 myparser myparser # ! # $myparser si:void_void_symbol_start EOF - notahead_162 + notahead_157 $myparser si:void_clear_symbol_end EOF return } - proc notahead_162 {} { upvar 1 myparser myparser + proc notahead_157 {} { upvar 1 myparser myparser # ! # $myparser i_loc_push $myparser i_input_next dot @@ -1026,16 +998,16 @@ # x # (SLASH) # (Sequence) $myparser si:value_symbol_start Expression - sequence_174 + sequence_169 $myparser si:reduce_symbol_end Expression return } - proc sequence_174 {} { upvar 1 myparser myparser + proc sequence_169 {} { upvar 1 myparser myparser # x # (Sequence) # * # x # (SLASH) @@ -1042,30 +1014,30 @@ # (Sequence) $myparser si:value_state_push sym_Sequence $myparser si:valuevalue_part - kleene_172 + kleene_167 $myparser si:value_state_merge return } - proc kleene_172 {} { upvar 1 myparser myparser + proc kleene_167 {} { upvar 1 myparser myparser # * # x # (SLASH) # (Sequence) while {1} { $myparser si:void2_state_push - sequence_170 + sequence_165 $myparser si:kleene_close } return } - proc sequence_170 {} { upvar 1 myparser myparser + proc sequence_165 {} { upvar 1 myparser myparser # x # (SLASH) # (Sequence) $myparser si:void_state_push @@ -1080,28 +1052,32 @@ # void Symbol 'Final' # proc sym_Final {} { upvar 1 myparser myparser # x - # (END) + # "END" + # (WHITESPACE) # (SEMICOLON) # (WHITESPACE) $myparser si:void_void_symbol_start Final - sequence_180 + sequence_176 $myparser si:void_clear_symbol_end Final return } - proc sequence_180 {} { upvar 1 myparser myparser + proc sequence_176 {} { upvar 1 myparser myparser # x - # (END) + # "END" + # (WHITESPACE) # (SEMICOLON) # (WHITESPACE) $myparser si:void_state_push - sym_END + $myparser si:next_str END + $myparser si:voidvoid_part + sym_WHITESPACE $myparser si:voidvoid_part sym_SEMICOLON $myparser si:voidvoid_part sym_WHITESPACE $myparser si:void_state_merge @@ -1120,16 +1096,16 @@ # (Definition) # (Final) # (EOF) $myparser si:value_symbol_start Grammar - sequence_190 + sequence_186 $myparser si:reduce_symbol_end Grammar return } - proc sequence_190 {} { upvar 1 myparser myparser + proc sequence_186 {} { upvar 1 myparser myparser # x # (WHITESPACE) # (Header) # * # (Definition) @@ -1139,20 +1115,20 @@ $myparser si:void_state_push sym_WHITESPACE $myparser si:voidvalue_part sym_Header $myparser si:valuevalue_part - kleene_186 + kleene_182 $myparser si:valuevalue_part sym_Final $myparser si:valuevalue_part sym_EOF $myparser si:value_state_merge return } - proc kleene_186 {} { upvar 1 myparser myparser + proc kleene_182 {} { upvar 1 myparser myparser # * # (Definition) while {1} { $myparser si:void2_state_push @@ -1170,16 +1146,16 @@ # x # "" # (WHITESPACE) $myparser si:void_symbol_start GRAPH - sequence_195 + sequence_191 $myparser si:void_leaf_symbol_end GRAPH return } - proc sequence_195 {} { upvar 1 myparser myparser + proc sequence_191 {} { upvar 1 myparser myparser # x # "" # (WHITESPACE) $myparser si:void_state_push @@ -1199,16 +1175,16 @@ # (PEG) # (Identifier) # (StartExpr) $myparser si:value_symbol_start Header - sequence_201 + sequence_197 $myparser si:reduce_symbol_end Header return } - proc sequence_201 {} { upvar 1 myparser myparser + proc sequence_197 {} { upvar 1 myparser myparser # x # (PEG) # (Identifier) # (StartExpr) @@ -1235,16 +1211,16 @@ # / # [_:] # $myparser si:void_symbol_start Ident - sequence_214 + sequence_210 $myparser si:void_leaf_symbol_end Ident return } - proc sequence_214 {} { upvar 1 myparser myparser + proc sequence_210 {} { upvar 1 myparser myparser # x # / # [_:] # # * @@ -1251,18 +1227,18 @@ # / # [_:] # $myparser si:void_state_push - choice_206 + choice_202 $myparser si:voidvoid_part - kleene_212 + kleene_208 $myparser si:void_state_merge return } - proc choice_206 {} { upvar 1 myparser myparser + proc choice_202 {} { upvar 1 myparser myparser # / # [_:] # $myparser si:void_state_push @@ -1271,25 +1247,25 @@ $myparser si:next_alpha $myparser si:void_state_merge return } - proc kleene_212 {} { upvar 1 myparser myparser + proc kleene_208 {} { upvar 1 myparser myparser # * # / # [_:] # while {1} { $myparser si:void2_state_push - choice_210 + choice_206 $myparser si:kleene_close } return } - proc choice_210 {} { upvar 1 myparser myparser + proc choice_206 {} { upvar 1 myparser myparser # / # [_:] # $myparser si:void_state_push @@ -1308,16 +1284,16 @@ # x # (Ident) # (WHITESPACE) $myparser si:value_symbol_start Identifier - sequence_219 + sequence_215 $myparser si:reduce_symbol_end Identifier return } - proc sequence_219 {} { upvar 1 myparser myparser + proc sequence_215 {} { upvar 1 myparser myparser # x # (Ident) # (WHITESPACE) $myparser si:value_state_push @@ -1336,16 +1312,16 @@ # x # "<-" # (WHITESPACE) $myparser si:void_void_symbol_start IS - sequence_224 + sequence_220 $myparser si:void_clear_symbol_end IS return } - proc sequence_224 {} { upvar 1 myparser myparser + proc sequence_220 {} { upvar 1 myparser myparser # x # "<-" # (WHITESPACE) $myparser si:void_state_push @@ -1364,16 +1340,16 @@ # x # "leaf" # (WHITESPACE) $myparser si:void_symbol_start LEAF - sequence_229 + sequence_225 $myparser si:void_leaf_symbol_end LEAF return } - proc sequence_229 {} { upvar 1 myparser myparser + proc sequence_225 {} { upvar 1 myparser myparser # x # "leaf" # (WHITESPACE) $myparser si:void_state_push @@ -1408,16 +1384,16 @@ # (Char) # (DAPOSTROPH) # (WHITESPACE) $myparser si:value_symbol_start Literal - choice_258 + choice_254 $myparser si:reduce_symbol_end Literal return } - proc choice_258 {} { upvar 1 myparser myparser + proc choice_254 {} { upvar 1 myparser myparser # / # x # (APOSTROPH) # * # x @@ -1435,18 +1411,18 @@ # (Char) # (DAPOSTROPH) # (WHITESPACE) $myparser si:value_state_push - sequence_243 + sequence_239 $myparser si:valuevalue_branch - sequence_256 + sequence_252 $myparser si:value_state_merge return } - proc sequence_243 {} { upvar 1 myparser myparser + proc sequence_239 {} { upvar 1 myparser myparser # x # (APOSTROPH) # * # x # ! @@ -1456,59 +1432,59 @@ # (WHITESPACE) $myparser si:void_state_push sym_APOSTROPH $myparser si:voidvalue_part - kleene_239 + kleene_235 $myparser si:valuevalue_part sym_APOSTROPH $myparser si:valuevalue_part sym_WHITESPACE $myparser si:value_state_merge return } - proc kleene_239 {} { upvar 1 myparser myparser + proc kleene_235 {} { upvar 1 myparser myparser # * # x # ! # (APOSTROPH) # (Char) while {1} { $myparser si:void2_state_push - sequence_237 + sequence_233 $myparser si:kleene_close } return } - proc sequence_237 {} { upvar 1 myparser myparser + proc sequence_233 {} { upvar 1 myparser myparser # x # ! # (APOSTROPH) # (Char) $myparser si:void_state_push - notahead_234 + notahead_230 $myparser si:voidvalue_part sym_Char $myparser si:value_state_merge return } - proc notahead_234 {} { upvar 1 myparser myparser + proc notahead_230 {} { upvar 1 myparser myparser # ! # (APOSTROPH) $myparser i_loc_push sym_APOSTROPH $myparser si:void_notahead_exit return } - proc sequence_256 {} { upvar 1 myparser myparser + proc sequence_252 {} { upvar 1 myparser myparser # x # (DAPOSTROPH) # * # x # ! @@ -1518,49 +1494,49 @@ # (WHITESPACE) $myparser si:void_state_push sym_DAPOSTROPH $myparser si:voidvalue_part - kleene_252 + kleene_248 $myparser si:valuevalue_part sym_DAPOSTROPH $myparser si:valuevalue_part sym_WHITESPACE $myparser si:value_state_merge return } - proc kleene_252 {} { upvar 1 myparser myparser + proc kleene_248 {} { upvar 1 myparser myparser # * # x # ! # (DAPOSTROPH) # (Char) while {1} { $myparser si:void2_state_push - sequence_250 + sequence_246 $myparser si:kleene_close } return } - proc sequence_250 {} { upvar 1 myparser myparser + proc sequence_246 {} { upvar 1 myparser myparser # x # ! # (DAPOSTROPH) # (Char) $myparser si:void_state_push - notahead_247 + notahead_243 $myparser si:voidvalue_part sym_Char $myparser si:value_state_merge return } - proc notahead_247 {} { upvar 1 myparser myparser + proc notahead_243 {} { upvar 1 myparser myparser # ! # (DAPOSTROPH) $myparser i_loc_push sym_DAPOSTROPH @@ -1576,16 +1552,16 @@ # x # "" # (WHITESPACE) $myparser si:void_symbol_start LOWER - sequence_263 + sequence_259 $myparser si:void_leaf_symbol_end LOWER return } - proc sequence_263 {} { upvar 1 myparser myparser + proc sequence_259 {} { upvar 1 myparser myparser # x # "" # (WHITESPACE) $myparser si:void_state_push @@ -1604,16 +1580,16 @@ # x # '!' # (WHITESPACE) $myparser si:void_symbol_start NOT - sequence_268 + sequence_264 $myparser si:void_leaf_symbol_end NOT return } - proc sequence_268 {} { upvar 1 myparser myparser + proc sequence_264 {} { upvar 1 myparser myparser # x # '!' # (WHITESPACE) $myparser si:void_state_push @@ -1632,16 +1608,16 @@ # x # '\(' # (WHITESPACE) $myparser si:void_void_symbol_start OPEN - sequence_273 + sequence_269 $myparser si:void_clear_symbol_end OPEN return } - proc sequence_273 {} { upvar 1 myparser myparser + proc sequence_269 {} { upvar 1 myparser myparser # x # '\(' # (WHITESPACE) $myparser si:void_state_push @@ -1670,30 +1646,52 @@ # proc sym_PEG {} { upvar 1 myparser myparser # x # "PEG" + # ! + # / + # [_:] + # # (WHITESPACE) $myparser si:void_void_symbol_start PEG - sequence_280 + sequence_281 $myparser si:void_clear_symbol_end PEG return } - proc sequence_280 {} { upvar 1 myparser myparser + proc sequence_281 {} { upvar 1 myparser myparser # x # "PEG" + # ! + # / + # [_:] + # # (WHITESPACE) $myparser si:void_state_push $myparser si:next_str PEG + $myparser si:voidvoid_part + notahead_278 $myparser si:voidvoid_part sym_WHITESPACE $myparser si:void_state_merge return } + + proc notahead_278 {} { upvar 1 myparser myparser + # ! + # / + # [_:] + # + + $myparser i_loc_push + choice_206 + $myparser si:void_notahead_exit + return + } # # leaf Symbol 'PLUS' # @@ -1701,16 +1699,16 @@ # x # '+' # (WHITESPACE) $myparser si:void_symbol_start PLUS - sequence_285 + sequence_286 $myparser si:void_leaf_symbol_end PLUS return } - proc sequence_285 {} { upvar 1 myparser myparser + proc sequence_286 {} { upvar 1 myparser myparser # x # '+' # (WHITESPACE) $myparser si:void_state_push @@ -1732,44 +1730,44 @@ # (AND) # (NOT) # (Suffix) $myparser si:value_symbol_start Prefix - sequence_295 + sequence_296 $myparser si:reduce_symbol_end Prefix return } - proc sequence_295 {} { upvar 1 myparser myparser + proc sequence_296 {} { upvar 1 myparser myparser # x # ? # / # (AND) # (NOT) # (Suffix) $myparser si:value_state_push - optional_292 + optional_293 $myparser si:valuevalue_part sym_Suffix $myparser si:value_state_merge return } - proc optional_292 {} { upvar 1 myparser myparser + proc optional_293 {} { upvar 1 myparser myparser # ? # / # (AND) # (NOT) $myparser si:void2_state_push - choice_290 + choice_291 $myparser si:void_state_merge_ok return } - proc choice_290 {} { upvar 1 myparser myparser + proc choice_291 {} { upvar 1 myparser myparser # / # (AND) # (NOT) $myparser si:value_state_push @@ -1808,16 +1806,16 @@ # (Literal) # (Class) # (DOT) $myparser si:value_symbol_start Primary - choice_321 + choice_322 $myparser si:reduce_symbol_end Primary return } - proc choice_321 {} { upvar 1 myparser myparser + proc choice_322 {} { upvar 1 myparser myparser # / # (ALNUM) # (ALPHA) # (ASCII) # (CONTROL) @@ -1869,11 +1867,11 @@ $myparser si:valuevalue_branch sym_XDIGIT $myparser si:valuevalue_branch sym_Identifier $myparser si:valuevalue_branch - sequence_316 + sequence_317 $myparser si:valuevalue_branch sym_Literal $myparser si:valuevalue_branch sym_Class $myparser si:valuevalue_branch @@ -1880,11 +1878,11 @@ sym_DOT $myparser si:value_state_merge return } - proc sequence_316 {} { upvar 1 myparser myparser + proc sequence_317 {} { upvar 1 myparser myparser # x # (OPEN) # (Expression) # (CLOSE) @@ -1906,16 +1904,16 @@ # x # "" # (WHITESPACE) $myparser si:void_symbol_start PRINTABLE - sequence_326 + sequence_327 $myparser si:void_leaf_symbol_end PRINTABLE return } - proc sequence_326 {} { upvar 1 myparser myparser + proc sequence_327 {} { upvar 1 myparser myparser # x # "" # (WHITESPACE) $myparser si:void_state_push @@ -1934,16 +1932,16 @@ # x # "" # (WHITESPACE) $myparser si:void_symbol_start PUNCT - sequence_331 + sequence_332 $myparser si:void_leaf_symbol_end PUNCT return } - proc sequence_331 {} { upvar 1 myparser myparser + proc sequence_332 {} { upvar 1 myparser myparser # x # "" # (WHITESPACE) $myparser si:void_state_push @@ -1962,16 +1960,16 @@ # x # '?' # (WHITESPACE) $myparser si:void_symbol_start QUESTION - sequence_336 + sequence_337 $myparser si:void_leaf_symbol_end QUESTION return } - proc sequence_336 {} { upvar 1 myparser myparser + proc sequence_337 {} { upvar 1 myparser myparser # x # '?' # (WHITESPACE) $myparser si:void_state_push @@ -1993,32 +1991,32 @@ # (TO) # (Char) # (Char) $myparser si:value_symbol_start Range - choice_345 + choice_346 $myparser si:reduce_symbol_end Range return } - proc choice_345 {} { upvar 1 myparser myparser + proc choice_346 {} { upvar 1 myparser myparser # / # x # (Char) # (TO) # (Char) # (Char) $myparser si:value_state_push - sequence_342 + sequence_343 $myparser si:valuevalue_branch sym_Char $myparser si:value_state_merge return } - proc sequence_342 {} { upvar 1 myparser myparser + proc sequence_343 {} { upvar 1 myparser myparser # x # (Char) # (TO) # (Char) @@ -2040,16 +2038,16 @@ # x # ';' # (WHITESPACE) $myparser si:void_void_symbol_start SEMICOLON - sequence_350 + sequence_351 $myparser si:void_clear_symbol_end SEMICOLON return } - proc sequence_350 {} { upvar 1 myparser myparser + proc sequence_351 {} { upvar 1 myparser myparser # x # ';' # (WHITESPACE) $myparser si:void_state_push @@ -2067,16 +2065,16 @@ proc sym_Sequence {} { upvar 1 myparser myparser # + # (Prefix) $myparser si:value_symbol_start Sequence - poskleene_354 + poskleene_355 $myparser si:reduce_symbol_end Sequence return } - proc poskleene_354 {} { upvar 1 myparser myparser + proc poskleene_355 {} { upvar 1 myparser myparser # + # (Prefix) $myparser i_loc_push sym_Prefix @@ -2097,16 +2095,16 @@ # x # '/' # (WHITESPACE) $myparser si:void_void_symbol_start SLASH - sequence_359 + sequence_360 $myparser si:void_clear_symbol_end SLASH return } - proc sequence_359 {} { upvar 1 myparser myparser + proc sequence_360 {} { upvar 1 myparser myparser # x # '/' # (WHITESPACE) $myparser si:void_state_push @@ -2125,16 +2123,16 @@ # x # "" # (WHITESPACE) $myparser si:void_symbol_start SPACE - sequence_364 + sequence_365 $myparser si:void_leaf_symbol_end SPACE return } - proc sequence_364 {} { upvar 1 myparser myparser + proc sequence_365 {} { upvar 1 myparser myparser # x # "" # (WHITESPACE) $myparser si:void_state_push @@ -2153,16 +2151,16 @@ # x # '*' # (WHITESPACE) $myparser si:void_symbol_start STAR - sequence_369 + sequence_370 $myparser si:void_leaf_symbol_end STAR return } - proc sequence_369 {} { upvar 1 myparser myparser + proc sequence_370 {} { upvar 1 myparser myparser # x # '*' # (WHITESPACE) $myparser si:void_state_push @@ -2182,11 +2180,11 @@ # (OPEN) # (Expression) # (CLOSE) $myparser si:value_symbol_start StartExpr - sequence_316 + sequence_317 $myparser si:reduce_symbol_end StartExpr return } # @@ -2201,16 +2199,16 @@ # (QUESTION) # (STAR) # (PLUS) $myparser si:value_symbol_start Suffix - sequence_385 + sequence_386 $myparser si:reduce_symbol_end Suffix return } - proc sequence_385 {} { upvar 1 myparser myparser + proc sequence_386 {} { upvar 1 myparser myparser # x # (Primary) # ? # / # (QUESTION) @@ -2218,29 +2216,29 @@ # (PLUS) $myparser si:value_state_push sym_Primary $myparser si:valuevalue_part - optional_383 + optional_384 $myparser si:value_state_merge return } - proc optional_383 {} { upvar 1 myparser myparser + proc optional_384 {} { upvar 1 myparser myparser # ? # / # (QUESTION) # (STAR) # (PLUS) $myparser si:void2_state_push - choice_381 + choice_382 $myparser si:void_state_merge_ok return } - proc choice_381 {} { upvar 1 myparser myparser + proc choice_382 {} { upvar 1 myparser myparser # / # (QUESTION) # (STAR) # (PLUS) @@ -2275,16 +2273,16 @@ # x # "" # (WHITESPACE) $myparser si:void_symbol_start UPPER - sequence_392 + sequence_393 $myparser si:void_leaf_symbol_end UPPER return } - proc sequence_392 {} { upvar 1 myparser myparser + proc sequence_393 {} { upvar 1 myparser myparser # x # "" # (WHITESPACE) $myparser si:void_state_push @@ -2303,16 +2301,16 @@ # x # "void" # (WHITESPACE) $myparser si:void_symbol_start VOID - sequence_397 + sequence_398 $myparser si:void_leaf_symbol_end VOID return } - proc sequence_397 {} { upvar 1 myparser myparser + proc sequence_398 {} { upvar 1 myparser myparser # x # "void" # (WHITESPACE) $myparser si:void_state_push @@ -2332,30 +2330,30 @@ # / # # (COMMENT) $myparser si:void_void_symbol_start WHITESPACE - kleene_404 + kleene_405 $myparser si:void_clear_symbol_end WHITESPACE return } - proc kleene_404 {} { upvar 1 myparser myparser + proc kleene_405 {} { upvar 1 myparser myparser # * # / # # (COMMENT) while {1} { $myparser si:void2_state_push - choice_402 + choice_403 $myparser si:kleene_close } return } - proc choice_402 {} { upvar 1 myparser myparser + proc choice_403 {} { upvar 1 myparser myparser # / # # (COMMENT) $myparser si:void_state_push @@ -2374,16 +2372,16 @@ # x # "" # (WHITESPACE) $myparser si:void_symbol_start WORDCHAR - sequence_409 + sequence_410 $myparser si:void_leaf_symbol_end WORDCHAR return } - proc sequence_409 {} { upvar 1 myparser myparser + proc sequence_410 {} { upvar 1 myparser myparser # x # "" # (WHITESPACE) $myparser si:void_state_push @@ -2402,16 +2400,16 @@ # x # "" # (WHITESPACE) $myparser si:void_symbol_start XDIGIT - sequence_414 + sequence_415 $myparser si:void_leaf_symbol_end XDIGIT return } - proc sequence_414 {} { upvar 1 myparser myparser + proc sequence_415 {} { upvar 1 myparser myparser # x # "" # (WHITESPACE) $myparser si:void_state_push Index: modules/pt/tests/data/ok/peg_tclparam-tcloo/3_peg_itself ================================================================== --- modules/pt/tests/data/ok/peg_tclparam-tcloo/3_peg_itself +++ modules/pt/tests/data/ok/peg_tclparam-tcloo/3_peg_itself @@ -934,53 +934,25 @@ my sym_WHITESPACE my si:void_state_merge return } - # - # void Symbol 'END' - # - - method sym_END {} { - # x - # "END" - # (WHITESPACE) - - my si:void_void_symbol_start END - my sequence_158 - my si:void_clear_symbol_end END - return - } - - method sequence_158 {} { - # x - # "END" - # (WHITESPACE) - - my si:void_state_push - my si:next_str END - my si:voidvoid_part - my sym_WHITESPACE - my si:void_state_merge - return - } - # # void Symbol 'EOF' # method sym_EOF {} { # ! # my si:void_void_symbol_start EOF - my notahead_162 + my notahead_157 my si:void_clear_symbol_end EOF return } - method notahead_162 {} { + method notahead_157 {} { # ! # my i_loc_push my i_input_next dot @@ -1012,16 +984,16 @@ # x # (SLASH) # (Sequence) my si:value_symbol_start Expression - my sequence_174 + my sequence_169 my si:reduce_symbol_end Expression return } - method sequence_174 {} { + method sequence_169 {} { # x # (Sequence) # * # x # (SLASH) @@ -1028,30 +1000,30 @@ # (Sequence) my si:value_state_push my sym_Sequence my si:valuevalue_part - my kleene_172 + my kleene_167 my si:value_state_merge return } - method kleene_172 {} { + method kleene_167 {} { # * # x # (SLASH) # (Sequence) while {1} { my si:void2_state_push - my sequence_170 + my sequence_165 my si:kleene_close } return } - method sequence_170 {} { + method sequence_165 {} { # x # (SLASH) # (Sequence) my si:void_state_push @@ -1066,28 +1038,32 @@ # void Symbol 'Final' # method sym_Final {} { # x - # (END) + # "END" + # (WHITESPACE) # (SEMICOLON) # (WHITESPACE) my si:void_void_symbol_start Final - my sequence_180 + my sequence_176 my si:void_clear_symbol_end Final return } - method sequence_180 {} { + method sequence_176 {} { # x - # (END) + # "END" + # (WHITESPACE) # (SEMICOLON) # (WHITESPACE) my si:void_state_push - my sym_END + my si:next_str END + my si:voidvoid_part + my sym_WHITESPACE my si:voidvoid_part my sym_SEMICOLON my si:voidvoid_part my sym_WHITESPACE my si:void_state_merge @@ -1106,16 +1082,16 @@ # (Definition) # (Final) # (EOF) my si:value_symbol_start Grammar - my sequence_190 + my sequence_186 my si:reduce_symbol_end Grammar return } - method sequence_190 {} { + method sequence_186 {} { # x # (WHITESPACE) # (Header) # * # (Definition) @@ -1125,20 +1101,20 @@ my si:void_state_push my sym_WHITESPACE my si:voidvalue_part my sym_Header my si:valuevalue_part - my kleene_186 + my kleene_182 my si:valuevalue_part my sym_Final my si:valuevalue_part my sym_EOF my si:value_state_merge return } - method kleene_186 {} { + method kleene_182 {} { # * # (Definition) while {1} { my si:void2_state_push @@ -1156,16 +1132,16 @@ # x # "" # (WHITESPACE) my si:void_symbol_start GRAPH - my sequence_195 + my sequence_191 my si:void_leaf_symbol_end GRAPH return } - method sequence_195 {} { + method sequence_191 {} { # x # "" # (WHITESPACE) my si:void_state_push @@ -1185,16 +1161,16 @@ # (PEG) # (Identifier) # (StartExpr) my si:value_symbol_start Header - my sequence_201 + my sequence_197 my si:reduce_symbol_end Header return } - method sequence_201 {} { + method sequence_197 {} { # x # (PEG) # (Identifier) # (StartExpr) @@ -1221,16 +1197,16 @@ # / # [_:] # my si:void_symbol_start Ident - my sequence_214 + my sequence_210 my si:void_leaf_symbol_end Ident return } - method sequence_214 {} { + method sequence_210 {} { # x # / # [_:] # # * @@ -1237,18 +1213,18 @@ # / # [_:] # my si:void_state_push - my choice_206 + my choice_202 my si:voidvoid_part - my kleene_212 + my kleene_208 my si:void_state_merge return } - method choice_206 {} { + method choice_202 {} { # / # [_:] # my si:void_state_push @@ -1257,25 +1233,25 @@ my si:next_alpha my si:void_state_merge return } - method kleene_212 {} { + method kleene_208 {} { # * # / # [_:] # while {1} { my si:void2_state_push - my choice_210 + my choice_206 my si:kleene_close } return } - method choice_210 {} { + method choice_206 {} { # / # [_:] # my si:void_state_push @@ -1294,16 +1270,16 @@ # x # (Ident) # (WHITESPACE) my si:value_symbol_start Identifier - my sequence_219 + my sequence_215 my si:reduce_symbol_end Identifier return } - method sequence_219 {} { + method sequence_215 {} { # x # (Ident) # (WHITESPACE) my si:value_state_push @@ -1322,16 +1298,16 @@ # x # "<-" # (WHITESPACE) my si:void_void_symbol_start IS - my sequence_224 + my sequence_220 my si:void_clear_symbol_end IS return } - method sequence_224 {} { + method sequence_220 {} { # x # "<-" # (WHITESPACE) my si:void_state_push @@ -1350,16 +1326,16 @@ # x # "leaf" # (WHITESPACE) my si:void_symbol_start LEAF - my sequence_229 + my sequence_225 my si:void_leaf_symbol_end LEAF return } - method sequence_229 {} { + method sequence_225 {} { # x # "leaf" # (WHITESPACE) my si:void_state_push @@ -1394,16 +1370,16 @@ # (Char) # (DAPOSTROPH) # (WHITESPACE) my si:value_symbol_start Literal - my choice_258 + my choice_254 my si:reduce_symbol_end Literal return } - method choice_258 {} { + method choice_254 {} { # / # x # (APOSTROPH) # * # x @@ -1421,18 +1397,18 @@ # (Char) # (DAPOSTROPH) # (WHITESPACE) my si:value_state_push - my sequence_243 + my sequence_239 my si:valuevalue_branch - my sequence_256 + my sequence_252 my si:value_state_merge return } - method sequence_243 {} { + method sequence_239 {} { # x # (APOSTROPH) # * # x # ! @@ -1442,59 +1418,59 @@ # (WHITESPACE) my si:void_state_push my sym_APOSTROPH my si:voidvalue_part - my kleene_239 + my kleene_235 my si:valuevalue_part my sym_APOSTROPH my si:valuevalue_part my sym_WHITESPACE my si:value_state_merge return } - method kleene_239 {} { + method kleene_235 {} { # * # x # ! # (APOSTROPH) # (Char) while {1} { my si:void2_state_push - my sequence_237 + my sequence_233 my si:kleene_close } return } - method sequence_237 {} { + method sequence_233 {} { # x # ! # (APOSTROPH) # (Char) my si:void_state_push - my notahead_234 + my notahead_230 my si:voidvalue_part my sym_Char my si:value_state_merge return } - method notahead_234 {} { + method notahead_230 {} { # ! # (APOSTROPH) my i_loc_push my sym_APOSTROPH my si:void_notahead_exit return } - method sequence_256 {} { + method sequence_252 {} { # x # (DAPOSTROPH) # * # x # ! @@ -1504,49 +1480,49 @@ # (WHITESPACE) my si:void_state_push my sym_DAPOSTROPH my si:voidvalue_part - my kleene_252 + my kleene_248 my si:valuevalue_part my sym_DAPOSTROPH my si:valuevalue_part my sym_WHITESPACE my si:value_state_merge return } - method kleene_252 {} { + method kleene_248 {} { # * # x # ! # (DAPOSTROPH) # (Char) while {1} { my si:void2_state_push - my sequence_250 + my sequence_246 my si:kleene_close } return } - method sequence_250 {} { + method sequence_246 {} { # x # ! # (DAPOSTROPH) # (Char) my si:void_state_push - my notahead_247 + my notahead_243 my si:voidvalue_part my sym_Char my si:value_state_merge return } - method notahead_247 {} { + method notahead_243 {} { # ! # (DAPOSTROPH) my i_loc_push my sym_DAPOSTROPH @@ -1562,16 +1538,16 @@ # x # "" # (WHITESPACE) my si:void_symbol_start LOWER - my sequence_263 + my sequence_259 my si:void_leaf_symbol_end LOWER return } - method sequence_263 {} { + method sequence_259 {} { # x # "" # (WHITESPACE) my si:void_state_push @@ -1590,16 +1566,16 @@ # x # '!' # (WHITESPACE) my si:void_symbol_start NOT - my sequence_268 + my sequence_264 my si:void_leaf_symbol_end NOT return } - method sequence_268 {} { + method sequence_264 {} { # x # '!' # (WHITESPACE) my si:void_state_push @@ -1618,16 +1594,16 @@ # x # '\(' # (WHITESPACE) my si:void_void_symbol_start OPEN - my sequence_273 + my sequence_269 my si:void_clear_symbol_end OPEN return } - method sequence_273 {} { + method sequence_269 {} { # x # '\(' # (WHITESPACE) my si:void_state_push @@ -1656,30 +1632,52 @@ # method sym_PEG {} { # x # "PEG" + # ! + # / + # [_:] + # # (WHITESPACE) my si:void_void_symbol_start PEG - my sequence_280 + my sequence_281 my si:void_clear_symbol_end PEG return } - method sequence_280 {} { + method sequence_281 {} { # x # "PEG" + # ! + # / + # [_:] + # # (WHITESPACE) my si:void_state_push my si:next_str PEG + my si:voidvoid_part + my notahead_278 my si:voidvoid_part my sym_WHITESPACE my si:void_state_merge return } + + method notahead_278 {} { + # ! + # / + # [_:] + # + + my i_loc_push + my choice_206 + my si:void_notahead_exit + return + } # # leaf Symbol 'PLUS' # @@ -1687,16 +1685,16 @@ # x # '+' # (WHITESPACE) my si:void_symbol_start PLUS - my sequence_285 + my sequence_286 my si:void_leaf_symbol_end PLUS return } - method sequence_285 {} { + method sequence_286 {} { # x # '+' # (WHITESPACE) my si:void_state_push @@ -1718,44 +1716,44 @@ # (AND) # (NOT) # (Suffix) my si:value_symbol_start Prefix - my sequence_295 + my sequence_296 my si:reduce_symbol_end Prefix return } - method sequence_295 {} { + method sequence_296 {} { # x # ? # / # (AND) # (NOT) # (Suffix) my si:value_state_push - my optional_292 + my optional_293 my si:valuevalue_part my sym_Suffix my si:value_state_merge return } - method optional_292 {} { + method optional_293 {} { # ? # / # (AND) # (NOT) my si:void2_state_push - my choice_290 + my choice_291 my si:void_state_merge_ok return } - method choice_290 {} { + method choice_291 {} { # / # (AND) # (NOT) my si:value_state_push @@ -1794,16 +1792,16 @@ # (Literal) # (Class) # (DOT) my si:value_symbol_start Primary - my choice_321 + my choice_322 my si:reduce_symbol_end Primary return } - method choice_321 {} { + method choice_322 {} { # / # (ALNUM) # (ALPHA) # (ASCII) # (CONTROL) @@ -1855,11 +1853,11 @@ my si:valuevalue_branch my sym_XDIGIT my si:valuevalue_branch my sym_Identifier my si:valuevalue_branch - my sequence_316 + my sequence_317 my si:valuevalue_branch my sym_Literal my si:valuevalue_branch my sym_Class my si:valuevalue_branch @@ -1866,11 +1864,11 @@ my sym_DOT my si:value_state_merge return } - method sequence_316 {} { + method sequence_317 {} { # x # (OPEN) # (Expression) # (CLOSE) @@ -1892,16 +1890,16 @@ # x # "" # (WHITESPACE) my si:void_symbol_start PRINTABLE - my sequence_326 + my sequence_327 my si:void_leaf_symbol_end PRINTABLE return } - method sequence_326 {} { + method sequence_327 {} { # x # "" # (WHITESPACE) my si:void_state_push @@ -1920,16 +1918,16 @@ # x # "" # (WHITESPACE) my si:void_symbol_start PUNCT - my sequence_331 + my sequence_332 my si:void_leaf_symbol_end PUNCT return } - method sequence_331 {} { + method sequence_332 {} { # x # "" # (WHITESPACE) my si:void_state_push @@ -1948,16 +1946,16 @@ # x # '?' # (WHITESPACE) my si:void_symbol_start QUESTION - my sequence_336 + my sequence_337 my si:void_leaf_symbol_end QUESTION return } - method sequence_336 {} { + method sequence_337 {} { # x # '?' # (WHITESPACE) my si:void_state_push @@ -1979,32 +1977,32 @@ # (TO) # (Char) # (Char) my si:value_symbol_start Range - my choice_345 + my choice_346 my si:reduce_symbol_end Range return } - method choice_345 {} { + method choice_346 {} { # / # x # (Char) # (TO) # (Char) # (Char) my si:value_state_push - my sequence_342 + my sequence_343 my si:valuevalue_branch my sym_Char my si:value_state_merge return } - method sequence_342 {} { + method sequence_343 {} { # x # (Char) # (TO) # (Char) @@ -2026,16 +2024,16 @@ # x # ';' # (WHITESPACE) my si:void_void_symbol_start SEMICOLON - my sequence_350 + my sequence_351 my si:void_clear_symbol_end SEMICOLON return } - method sequence_350 {} { + method sequence_351 {} { # x # ';' # (WHITESPACE) my si:void_state_push @@ -2053,16 +2051,16 @@ method sym_Sequence {} { # + # (Prefix) my si:value_symbol_start Sequence - my poskleene_354 + my poskleene_355 my si:reduce_symbol_end Sequence return } - method poskleene_354 {} { + method poskleene_355 {} { # + # (Prefix) my i_loc_push my sym_Prefix @@ -2083,16 +2081,16 @@ # x # '/' # (WHITESPACE) my si:void_void_symbol_start SLASH - my sequence_359 + my sequence_360 my si:void_clear_symbol_end SLASH return } - method sequence_359 {} { + method sequence_360 {} { # x # '/' # (WHITESPACE) my si:void_state_push @@ -2111,16 +2109,16 @@ # x # "" # (WHITESPACE) my si:void_symbol_start SPACE - my sequence_364 + my sequence_365 my si:void_leaf_symbol_end SPACE return } - method sequence_364 {} { + method sequence_365 {} { # x # "" # (WHITESPACE) my si:void_state_push @@ -2139,16 +2137,16 @@ # x # '*' # (WHITESPACE) my si:void_symbol_start STAR - my sequence_369 + my sequence_370 my si:void_leaf_symbol_end STAR return } - method sequence_369 {} { + method sequence_370 {} { # x # '*' # (WHITESPACE) my si:void_state_push @@ -2168,11 +2166,11 @@ # (OPEN) # (Expression) # (CLOSE) my si:value_symbol_start StartExpr - my sequence_316 + my sequence_317 my si:reduce_symbol_end StartExpr return } # @@ -2187,16 +2185,16 @@ # (QUESTION) # (STAR) # (PLUS) my si:value_symbol_start Suffix - my sequence_385 + my sequence_386 my si:reduce_symbol_end Suffix return } - method sequence_385 {} { + method sequence_386 {} { # x # (Primary) # ? # / # (QUESTION) @@ -2204,29 +2202,29 @@ # (PLUS) my si:value_state_push my sym_Primary my si:valuevalue_part - my optional_383 + my optional_384 my si:value_state_merge return } - method optional_383 {} { + method optional_384 {} { # ? # / # (QUESTION) # (STAR) # (PLUS) my si:void2_state_push - my choice_381 + my choice_382 my si:void_state_merge_ok return } - method choice_381 {} { + method choice_382 {} { # / # (QUESTION) # (STAR) # (PLUS) @@ -2261,16 +2259,16 @@ # x # "" # (WHITESPACE) my si:void_symbol_start UPPER - my sequence_392 + my sequence_393 my si:void_leaf_symbol_end UPPER return } - method sequence_392 {} { + method sequence_393 {} { # x # "" # (WHITESPACE) my si:void_state_push @@ -2289,16 +2287,16 @@ # x # "void" # (WHITESPACE) my si:void_symbol_start VOID - my sequence_397 + my sequence_398 my si:void_leaf_symbol_end VOID return } - method sequence_397 {} { + method sequence_398 {} { # x # "void" # (WHITESPACE) my si:void_state_push @@ -2318,30 +2316,30 @@ # / # # (COMMENT) my si:void_void_symbol_start WHITESPACE - my kleene_404 + my kleene_405 my si:void_clear_symbol_end WHITESPACE return } - method kleene_404 {} { + method kleene_405 {} { # * # / # # (COMMENT) while {1} { my si:void2_state_push - my choice_402 + my choice_403 my si:kleene_close } return } - method choice_402 {} { + method choice_403 {} { # / # # (COMMENT) my si:void_state_push @@ -2360,16 +2358,16 @@ # x # "" # (WHITESPACE) my si:void_symbol_start WORDCHAR - my sequence_409 + my sequence_410 my si:void_leaf_symbol_end WORDCHAR return } - method sequence_409 {} { + method sequence_410 {} { # x # "" # (WHITESPACE) my si:void_state_push @@ -2388,16 +2386,16 @@ # x # "" # (WHITESPACE) my si:void_symbol_start XDIGIT - my sequence_414 + my sequence_415 my si:void_leaf_symbol_end XDIGIT return } - method sequence_414 {} { + method sequence_415 {} { # x # "" # (WHITESPACE) my si:void_state_push Index: modules/pt/tests/data/ok/peg_tclparam/3_peg_itself ================================================================== --- modules/pt/tests/data/ok/peg_tclparam/3_peg_itself +++ modules/pt/tests/data/ok/peg_tclparam/3_peg_itself @@ -891,53 +891,25 @@ <> sym_WHITESPACE <> si:void_state_merge return } -# -# void Symbol 'END' -# - -<> <>sym_END {} { - # x - # "END" - # (WHITESPACE) - - <> si:void_void_symbol_start END - <> sequence_158 - <> si:void_clear_symbol_end END - return -} - -<> <>sequence_158 {} { - # x - # "END" - # (WHITESPACE) - - <> si:void_state_push - <> si:next_str END - <> si:voidvoid_part - <> sym_WHITESPACE - <> si:void_state_merge - return -} - # # void Symbol 'EOF' # <> <>sym_EOF {} { # ! # <> si:void_void_symbol_start EOF - <> notahead_162 + <> notahead_157 <> si:void_clear_symbol_end EOF return } -<> <>notahead_162 {} { +<> <>notahead_157 {} { # ! # <> i_loc_push <> i_input_next dot @@ -969,16 +941,16 @@ # x # (SLASH) # (Sequence) <> si:value_symbol_start Expression - <> sequence_174 + <> sequence_169 <> si:reduce_symbol_end Expression return } -<> <>sequence_174 {} { +<> <>sequence_169 {} { # x # (Sequence) # * # x # (SLASH) @@ -985,30 +957,30 @@ # (Sequence) <> si:value_state_push <> sym_Sequence <> si:valuevalue_part - <> kleene_172 + <> kleene_167 <> si:value_state_merge return } -<> <>kleene_172 {} { +<> <>kleene_167 {} { # * # x # (SLASH) # (Sequence) while {1} { <> si:void2_state_push - <> sequence_170 + <> sequence_165 <> si:kleene_close } return } -<> <>sequence_170 {} { +<> <>sequence_165 {} { # x # (SLASH) # (Sequence) <> si:void_state_push @@ -1023,28 +995,32 @@ # void Symbol 'Final' # <> <>sym_Final {} { # x - # (END) + # "END" + # (WHITESPACE) # (SEMICOLON) # (WHITESPACE) <> si:void_void_symbol_start Final - <> sequence_180 + <> sequence_176 <> si:void_clear_symbol_end Final return } -<> <>sequence_180 {} { +<> <>sequence_176 {} { # x - # (END) + # "END" + # (WHITESPACE) # (SEMICOLON) # (WHITESPACE) <> si:void_state_push - <> sym_END + <> si:next_str END + <> si:voidvoid_part + <> sym_WHITESPACE <> si:voidvoid_part <> sym_SEMICOLON <> si:voidvoid_part <> sym_WHITESPACE <> si:void_state_merge @@ -1063,16 +1039,16 @@ # (Definition) # (Final) # (EOF) <> si:value_symbol_start Grammar - <> sequence_190 + <> sequence_186 <> si:reduce_symbol_end Grammar return } -<> <>sequence_190 {} { +<> <>sequence_186 {} { # x # (WHITESPACE) # (Header) # * # (Definition) @@ -1082,20 +1058,20 @@ <> si:void_state_push <> sym_WHITESPACE <> si:voidvalue_part <> sym_Header <> si:valuevalue_part - <> kleene_186 + <> kleene_182 <> si:valuevalue_part <> sym_Final <> si:valuevalue_part <> sym_EOF <> si:value_state_merge return } -<> <>kleene_186 {} { +<> <>kleene_182 {} { # * # (Definition) while {1} { <> si:void2_state_push @@ -1113,16 +1089,16 @@ # x # "" # (WHITESPACE) <> si:void_symbol_start GRAPH - <> sequence_195 + <> sequence_191 <> si:void_leaf_symbol_end GRAPH return } -<> <>sequence_195 {} { +<> <>sequence_191 {} { # x # "" # (WHITESPACE) <> si:void_state_push @@ -1142,16 +1118,16 @@ # (PEG) # (Identifier) # (StartExpr) <> si:value_symbol_start Header - <> sequence_201 + <> sequence_197 <> si:reduce_symbol_end Header return } -<> <>sequence_201 {} { +<> <>sequence_197 {} { # x # (PEG) # (Identifier) # (StartExpr) @@ -1178,16 +1154,16 @@ # / # [_:] # <> si:void_symbol_start Ident - <> sequence_214 + <> sequence_210 <> si:void_leaf_symbol_end Ident return } -<> <>sequence_214 {} { +<> <>sequence_210 {} { # x # / # [_:] # # * @@ -1194,18 +1170,18 @@ # / # [_:] # <> si:void_state_push - <> choice_206 + <> choice_202 <> si:voidvoid_part - <> kleene_212 + <> kleene_208 <> si:void_state_merge return } -<> <>choice_206 {} { +<> <>choice_202 {} { # / # [_:] # <> si:void_state_push @@ -1214,25 +1190,25 @@ <> si:next_alpha <> si:void_state_merge return } -<> <>kleene_212 {} { +<> <>kleene_208 {} { # * # / # [_:] # while {1} { <> si:void2_state_push - <> choice_210 + <> choice_206 <> si:kleene_close } return } -<> <>choice_210 {} { +<> <>choice_206 {} { # / # [_:] # <> si:void_state_push @@ -1251,16 +1227,16 @@ # x # (Ident) # (WHITESPACE) <> si:value_symbol_start Identifier - <> sequence_219 + <> sequence_215 <> si:reduce_symbol_end Identifier return } -<> <>sequence_219 {} { +<> <>sequence_215 {} { # x # (Ident) # (WHITESPACE) <> si:value_state_push @@ -1279,16 +1255,16 @@ # x # "<-" # (WHITESPACE) <> si:void_void_symbol_start IS - <> sequence_224 + <> sequence_220 <> si:void_clear_symbol_end IS return } -<> <>sequence_224 {} { +<> <>sequence_220 {} { # x # "<-" # (WHITESPACE) <> si:void_state_push @@ -1307,16 +1283,16 @@ # x # "leaf" # (WHITESPACE) <> si:void_symbol_start LEAF - <> sequence_229 + <> sequence_225 <> si:void_leaf_symbol_end LEAF return } -<> <>sequence_229 {} { +<> <>sequence_225 {} { # x # "leaf" # (WHITESPACE) <> si:void_state_push @@ -1351,16 +1327,16 @@ # (Char) # (DAPOSTROPH) # (WHITESPACE) <> si:value_symbol_start Literal - <> choice_258 + <> choice_254 <> si:reduce_symbol_end Literal return } -<> <>choice_258 {} { +<> <>choice_254 {} { # / # x # (APOSTROPH) # * # x @@ -1378,18 +1354,18 @@ # (Char) # (DAPOSTROPH) # (WHITESPACE) <> si:value_state_push - <> sequence_243 + <> sequence_239 <> si:valuevalue_branch - <> sequence_256 + <> sequence_252 <> si:value_state_merge return } -<> <>sequence_243 {} { +<> <>sequence_239 {} { # x # (APOSTROPH) # * # x # ! @@ -1399,59 +1375,59 @@ # (WHITESPACE) <> si:void_state_push <> sym_APOSTROPH <> si:voidvalue_part - <> kleene_239 + <> kleene_235 <> si:valuevalue_part <> sym_APOSTROPH <> si:valuevalue_part <> sym_WHITESPACE <> si:value_state_merge return } -<> <>kleene_239 {} { +<> <>kleene_235 {} { # * # x # ! # (APOSTROPH) # (Char) while {1} { <> si:void2_state_push - <> sequence_237 + <> sequence_233 <> si:kleene_close } return } -<> <>sequence_237 {} { +<> <>sequence_233 {} { # x # ! # (APOSTROPH) # (Char) <> si:void_state_push - <> notahead_234 + <> notahead_230 <> si:voidvalue_part <> sym_Char <> si:value_state_merge return } -<> <>notahead_234 {} { +<> <>notahead_230 {} { # ! # (APOSTROPH) <> i_loc_push <> sym_APOSTROPH <> si:void_notahead_exit return } -<> <>sequence_256 {} { +<> <>sequence_252 {} { # x # (DAPOSTROPH) # * # x # ! @@ -1461,49 +1437,49 @@ # (WHITESPACE) <> si:void_state_push <> sym_DAPOSTROPH <> si:voidvalue_part - <> kleene_252 + <> kleene_248 <> si:valuevalue_part <> sym_DAPOSTROPH <> si:valuevalue_part <> sym_WHITESPACE <> si:value_state_merge return } -<> <>kleene_252 {} { +<> <>kleene_248 {} { # * # x # ! # (DAPOSTROPH) # (Char) while {1} { <> si:void2_state_push - <> sequence_250 + <> sequence_246 <> si:kleene_close } return } -<> <>sequence_250 {} { +<> <>sequence_246 {} { # x # ! # (DAPOSTROPH) # (Char) <> si:void_state_push - <> notahead_247 + <> notahead_243 <> si:voidvalue_part <> sym_Char <> si:value_state_merge return } -<> <>notahead_247 {} { +<> <>notahead_243 {} { # ! # (DAPOSTROPH) <> i_loc_push <> sym_DAPOSTROPH @@ -1519,16 +1495,16 @@ # x # "" # (WHITESPACE) <> si:void_symbol_start LOWER - <> sequence_263 + <> sequence_259 <> si:void_leaf_symbol_end LOWER return } -<> <>sequence_263 {} { +<> <>sequence_259 {} { # x # "" # (WHITESPACE) <> si:void_state_push @@ -1547,16 +1523,16 @@ # x # '!' # (WHITESPACE) <> si:void_symbol_start NOT - <> sequence_268 + <> sequence_264 <> si:void_leaf_symbol_end NOT return } -<> <>sequence_268 {} { +<> <>sequence_264 {} { # x # '!' # (WHITESPACE) <> si:void_state_push @@ -1575,16 +1551,16 @@ # x # '\(' # (WHITESPACE) <> si:void_void_symbol_start OPEN - <> sequence_273 + <> sequence_269 <> si:void_clear_symbol_end OPEN return } -<> <>sequence_273 {} { +<> <>sequence_269 {} { # x # '\(' # (WHITESPACE) <> si:void_state_push @@ -1613,30 +1589,52 @@ # <> <>sym_PEG {} { # x # "PEG" + # ! + # / + # [_:] + # # (WHITESPACE) <> si:void_void_symbol_start PEG - <> sequence_280 + <> sequence_281 <> si:void_clear_symbol_end PEG return } -<> <>sequence_280 {} { +<> <>sequence_281 {} { # x # "PEG" + # ! + # / + # [_:] + # # (WHITESPACE) <> si:void_state_push <> si:next_str PEG + <> si:voidvoid_part + <> notahead_278 <> si:voidvoid_part <> sym_WHITESPACE <> si:void_state_merge return } + +<> <>notahead_278 {} { + # ! + # / + # [_:] + # + + <> i_loc_push + <> choice_206 + <> si:void_notahead_exit + return +} # # leaf Symbol 'PLUS' # @@ -1644,16 +1642,16 @@ # x # '+' # (WHITESPACE) <> si:void_symbol_start PLUS - <> sequence_285 + <> sequence_286 <> si:void_leaf_symbol_end PLUS return } -<> <>sequence_285 {} { +<> <>sequence_286 {} { # x # '+' # (WHITESPACE) <> si:void_state_push @@ -1675,44 +1673,44 @@ # (AND) # (NOT) # (Suffix) <> si:value_symbol_start Prefix - <> sequence_295 + <> sequence_296 <> si:reduce_symbol_end Prefix return } -<> <>sequence_295 {} { +<> <>sequence_296 {} { # x # ? # / # (AND) # (NOT) # (Suffix) <> si:value_state_push - <> optional_292 + <> optional_293 <> si:valuevalue_part <> sym_Suffix <> si:value_state_merge return } -<> <>optional_292 {} { +<> <>optional_293 {} { # ? # / # (AND) # (NOT) <> si:void2_state_push - <> choice_290 + <> choice_291 <> si:void_state_merge_ok return } -<> <>choice_290 {} { +<> <>choice_291 {} { # / # (AND) # (NOT) <> si:value_state_push @@ -1751,16 +1749,16 @@ # (Literal) # (Class) # (DOT) <> si:value_symbol_start Primary - <> choice_321 + <> choice_322 <> si:reduce_symbol_end Primary return } -<> <>choice_321 {} { +<> <>choice_322 {} { # / # (ALNUM) # (ALPHA) # (ASCII) # (CONTROL) @@ -1812,11 +1810,11 @@ <> si:valuevalue_branch <> sym_XDIGIT <> si:valuevalue_branch <> sym_Identifier <> si:valuevalue_branch - <> sequence_316 + <> sequence_317 <> si:valuevalue_branch <> sym_Literal <> si:valuevalue_branch <> sym_Class <> si:valuevalue_branch @@ -1823,11 +1821,11 @@ <> sym_DOT <> si:value_state_merge return } -<> <>sequence_316 {} { +<> <>sequence_317 {} { # x # (OPEN) # (Expression) # (CLOSE) @@ -1849,16 +1847,16 @@ # x # "" # (WHITESPACE) <> si:void_symbol_start PRINTABLE - <> sequence_326 + <> sequence_327 <> si:void_leaf_symbol_end PRINTABLE return } -<> <>sequence_326 {} { +<> <>sequence_327 {} { # x # "" # (WHITESPACE) <> si:void_state_push @@ -1877,16 +1875,16 @@ # x # "" # (WHITESPACE) <> si:void_symbol_start PUNCT - <> sequence_331 + <> sequence_332 <> si:void_leaf_symbol_end PUNCT return } -<> <>sequence_331 {} { +<> <>sequence_332 {} { # x # "" # (WHITESPACE) <> si:void_state_push @@ -1905,16 +1903,16 @@ # x # '?' # (WHITESPACE) <> si:void_symbol_start QUESTION - <> sequence_336 + <> sequence_337 <> si:void_leaf_symbol_end QUESTION return } -<> <>sequence_336 {} { +<> <>sequence_337 {} { # x # '?' # (WHITESPACE) <> si:void_state_push @@ -1936,32 +1934,32 @@ # (TO) # (Char) # (Char) <> si:value_symbol_start Range - <> choice_345 + <> choice_346 <> si:reduce_symbol_end Range return } -<> <>choice_345 {} { +<> <>choice_346 {} { # / # x # (Char) # (TO) # (Char) # (Char) <> si:value_state_push - <> sequence_342 + <> sequence_343 <> si:valuevalue_branch <> sym_Char <> si:value_state_merge return } -<> <>sequence_342 {} { +<> <>sequence_343 {} { # x # (Char) # (TO) # (Char) @@ -1983,16 +1981,16 @@ # x # ';' # (WHITESPACE) <> si:void_void_symbol_start SEMICOLON - <> sequence_350 + <> sequence_351 <> si:void_clear_symbol_end SEMICOLON return } -<> <>sequence_350 {} { +<> <>sequence_351 {} { # x # ';' # (WHITESPACE) <> si:void_state_push @@ -2010,16 +2008,16 @@ <> <>sym_Sequence {} { # + # (Prefix) <> si:value_symbol_start Sequence - <> poskleene_354 + <> poskleene_355 <> si:reduce_symbol_end Sequence return } -<> <>poskleene_354 {} { +<> <>poskleene_355 {} { # + # (Prefix) <> i_loc_push <> sym_Prefix @@ -2040,16 +2038,16 @@ # x # '/' # (WHITESPACE) <> si:void_void_symbol_start SLASH - <> sequence_359 + <> sequence_360 <> si:void_clear_symbol_end SLASH return } -<> <>sequence_359 {} { +<> <>sequence_360 {} { # x # '/' # (WHITESPACE) <> si:void_state_push @@ -2068,16 +2066,16 @@ # x # "" # (WHITESPACE) <> si:void_symbol_start SPACE - <> sequence_364 + <> sequence_365 <> si:void_leaf_symbol_end SPACE return } -<> <>sequence_364 {} { +<> <>sequence_365 {} { # x # "" # (WHITESPACE) <> si:void_state_push @@ -2096,16 +2094,16 @@ # x # '*' # (WHITESPACE) <> si:void_symbol_start STAR - <> sequence_369 + <> sequence_370 <> si:void_leaf_symbol_end STAR return } -<> <>sequence_369 {} { +<> <>sequence_370 {} { # x # '*' # (WHITESPACE) <> si:void_state_push @@ -2125,11 +2123,11 @@ # (OPEN) # (Expression) # (CLOSE) <> si:value_symbol_start StartExpr - <> sequence_316 + <> sequence_317 <> si:reduce_symbol_end StartExpr return } # @@ -2144,16 +2142,16 @@ # (QUESTION) # (STAR) # (PLUS) <> si:value_symbol_start Suffix - <> sequence_385 + <> sequence_386 <> si:reduce_symbol_end Suffix return } -<> <>sequence_385 {} { +<> <>sequence_386 {} { # x # (Primary) # ? # / # (QUESTION) @@ -2161,29 +2159,29 @@ # (PLUS) <> si:value_state_push <> sym_Primary <> si:valuevalue_part - <> optional_383 + <> optional_384 <> si:value_state_merge return } -<> <>optional_383 {} { +<> <>optional_384 {} { # ? # / # (QUESTION) # (STAR) # (PLUS) <> si:void2_state_push - <> choice_381 + <> choice_382 <> si:void_state_merge_ok return } -<> <>choice_381 {} { +<> <>choice_382 {} { # / # (QUESTION) # (STAR) # (PLUS) @@ -2218,16 +2216,16 @@ # x # "" # (WHITESPACE) <> si:void_symbol_start UPPER - <> sequence_392 + <> sequence_393 <> si:void_leaf_symbol_end UPPER return } -<> <>sequence_392 {} { +<> <>sequence_393 {} { # x # "" # (WHITESPACE) <> si:void_state_push @@ -2246,16 +2244,16 @@ # x # "void" # (WHITESPACE) <> si:void_symbol_start VOID - <> sequence_397 + <> sequence_398 <> si:void_leaf_symbol_end VOID return } -<> <>sequence_397 {} { +<> <>sequence_398 {} { # x # "void" # (WHITESPACE) <> si:void_state_push @@ -2275,30 +2273,30 @@ # / # # (COMMENT) <> si:void_void_symbol_start WHITESPACE - <> kleene_404 + <> kleene_405 <> si:void_clear_symbol_end WHITESPACE return } -<> <>kleene_404 {} { +<> <>kleene_405 {} { # * # / # # (COMMENT) while {1} { <> si:void2_state_push - <> choice_402 + <> choice_403 <> si:kleene_close } return } -<> <>choice_402 {} { +<> <>choice_403 {} { # / # # (COMMENT) <> si:void_state_push @@ -2317,16 +2315,16 @@ # x # "" # (WHITESPACE) <> si:void_symbol_start WORDCHAR - <> sequence_409 + <> sequence_410 <> si:void_leaf_symbol_end WORDCHAR return } -<> <>sequence_409 {} { +<> <>sequence_410 {} { # x # "" # (WHITESPACE) <> si:void_state_push @@ -2345,16 +2343,16 @@ # x # "" # (WHITESPACE) <> si:void_symbol_start XDIGIT - <> sequence_414 + <> sequence_415 <> si:void_leaf_symbol_end XDIGIT return } -<> <>sequence_414 {} { +<> <>sequence_415 {} { # x # "" # (WHITESPACE) <> si:void_state_push Index: modules/pt/tests/pt_cparam_config_critcl.tests ================================================================== --- modules/pt/tests/pt_cparam_config_critcl.tests +++ modules/pt/tests/pt_cparam_config_critcl.tests @@ -1,41 +1,45 @@ # -*- tcl -*- # General set of error cases regarding the number of arguments. test pt-cparam-config-critcl-1.0 {convert, wrong#args} -body { pt::cparam::configuration::critcl def -} -returnCodes error -result {wrong # args: should be "pt::cparam::configuration::critcl def class pkg cmd"} +} -returnCodes error -result {wrong # args: should be "pt::cparam::configuration::critcl def class pkg version cmd"} test pt-cparam-config-critcl-1.1 {convert, wrong#args} -body { pt::cparam::configuration::critcl def C -} -returnCodes error -result {wrong # args: should be "pt::cparam::configuration::critcl def class pkg cmd"} +} -returnCodes error -result {wrong # args: should be "pt::cparam::configuration::critcl def class pkg version cmd"} -test pt-cparam-config-critcl-1.1 {convert, wrong#args} -body { +test pt-cparam-config-critcl-1.2 {convert, wrong#args} -body { pt::cparam::configuration::critcl def C P -} -returnCodes error -result {wrong # args: should be "pt::cparam::configuration::critcl def class pkg cmd"} +} -returnCodes error -result {wrong # args: should be "pt::cparam::configuration::critcl def class pkg version cmd"} + +test pt-cparam-config-critcl-1.3 {convert, wrong#args} -body { + pt::cparam::configuration::critcl def C P V +} -returnCodes error -result {wrong # args: should be "pt::cparam::configuration::critcl def class pkg version cmd"} test pt-cparam-config-critcl-2.0 {reset, wrong#args} -body { - pt::cparam::configuration::critcl def C P C XXX -} -returnCodes error -result {wrong # args: should be "pt::cparam::configuration::critcl def class pkg cmd"} + pt::cparam::configuration::critcl def C P V C XXX +} -returnCodes error -result {wrong # args: should be "pt::cparam::configuration::critcl def class pkg version cmd"} # ------------------------------------------------------------------------- # TODO :: Tests missing for: configure/cget, reset # ------------------------------------------------------------------------- -# Testing the generation of tcl/param output configured for critcl. +# Testing the generation of c/param output configured for critcl. TestFilesProcess $mytestdir ok peg_serial-canonical peg_cparam-critcl -> n label input data expected { test pt-cparam-config-critcl-3.$n "pt::cparam::configuration::critcl, $label, ok :- $input" -setup { pt::peg::to::cparam reset pt::peg::to::cparam configure -name TEMPLATE pt::peg::to::cparam configure -file TEST pt::cparam::configuration::critcl def \ - PARSER PACKAGE \ + PARSER PACKAGE 1 \ {pt::peg::to::cparam configure} } -body { pt::peg::to::cparam convert $data } -cleanup { ADDED modules/pt/tests/pt_cparam_config_tea.tests Index: modules/pt/tests/pt_cparam_config_tea.tests ================================================================== --- /dev/null +++ modules/pt/tests/pt_cparam_config_tea.tests @@ -0,0 +1,52 @@ +# -*- tcl -*- +# General set of error cases regarding the number of arguments. + +test pt-cparam-config-tea-1.0 {convert, wrong#args} -body { + pt::cparam::configuration::tea def +} -returnCodes error -result {wrong # args: should be "pt::cparam::configuration::tea def class pkg version cmd"} + +test pt-cparam-config-tea-1.1 {convert, wrong#args} -body { + pt::cparam::configuration::tea def C +} -returnCodes error -result {wrong # args: should be "pt::cparam::configuration::tea def class pkg version cmd"} + +test pt-cparam-config-tea-1.2 {convert, wrong#args} -body { + pt::cparam::configuration::tea def C P +} -returnCodes error -result {wrong # args: should be "pt::cparam::configuration::tea def class pkg version cmd"} + +test pt-cparam-config-tea-1.3 {convert, wrong#args} -body { + pt::cparam::configuration::tea def C P V +} -returnCodes error -result {wrong # args: should be "pt::cparam::configuration::tea def class pkg version cmd"} + +test pt-cparam-config-tea-2.0 {reset, wrong#args} -body { + pt::cparam::configuration::tea def C P V C XXX +} -returnCodes error -result {wrong # args: should be "pt::cparam::configuration::tea def class pkg version cmd"} + +# ------------------------------------------------------------------------- + +# TODO :: Tests missing for: configure/cget, reset + +# ------------------------------------------------------------------------- + +# Testing the generation of c/param output configured for tea. + +TestFilesProcess $mytestdir ok peg_serial-canonical peg_cparam-tea -> n label input data expected { + test pt-cparam-config-tea-3.$n "pt::cparam::configuration::tea, $label, ok :- $input" -setup { + + pt::peg::to::cparam reset + pt::peg::to::cparam configure -name TEMPLATE + pt::peg::to::cparam configure -file TEST + + pt::cparam::configuration::tea def \ + PARSER PACKAGE 1 \ + {pt::peg::to::cparam configure} + + } -body { + pt::peg::to::cparam convert $data + } -cleanup { + pt::peg::to::cparam reset + } -result $expected +} + + +#---------------------------------------------------------------------- +unset n label input data expected ADDED modules/pt/tests/pt_pgen.tests Index: modules/pt/tests/pt_pgen.tests ================================================================== --- /dev/null +++ modules/pt/tests/pt_pgen.tests @@ -0,0 +1,121 @@ +# -*- tcl -*- +# Testsuite for pt::pgen. +# Called by the ../pt_pgen.test driver file. + +#---------------------------------------------------------------------- +## I. Testing the generator operation itself + +# TODO testing of the pt::pgen command API (#args, options, outputs) ... + +#---------------------------------------------------------------------- +## II. Using generated parsers to test behaviour on good and bad +## input, i.e. the error handling implemented in our PEG parsers. + +## See data/gr/README.txt for the documentation of the directory +## structure used to organize the test-cases used here. + +foreach {format notes} { + container {grammar interpreter - reference} + snit {snit::type Tcl parser} + oo {TclOO class Tcl parser} + critcl {PARAM based C class parser} +} { + # Ignore critcl-based parsers if the environment does not support + # their generation (no critcl package). + if {$format eq "critcl" && + ![tcltest::testConstraint critcl]} continue + + TestFilesProcessIn $mytestdir gr def -> n glabel grfile grdata { + # Make parser instance. Shared across tests. Amortize the time + # spent on dynamically making it. + set p [make-parser $format $glabel $grdata] + + # Test parser on good inputs for the grammar. + TestFilesProcess $mytestdir gr ok-${glabel} ok-${glabel}-res -> k label infile text expected { + test pt-pgen-parse:${parseimpl}-rde:${rdeimpl}-stack:${stackimpl}-f:${format}-g:${glabel}-t:${label}-1.$n.$k \ + "$format parser $glabel, good input - $label" -setup { + } -body { + $p parset $text + } -result $expected + } + + # Test parser on bad inputs for the grammar. + ## + # Note how the expected output depends not only on grammar, + # but the parser format as well. Different optimizations and + # such leading to different instructions implementing matches. + # Example: "next_str" vs. "sequence of next_char". + + TestFilesProcess $mytestdir gr fail-${glabel} fail-${glabel}-${format}-res -> k label infile text expected { + test pt-pgen-parse:${parseimpl}-rde:${rdeimpl}-stack:${stackimpl}-f:${format}-g:${glabel}-t:${label}-2.$n.$k \ + "$format parser $glabel, bad input - $label" -setup { + } -body { + set code [catch { + $p parset $text + } msg] + # msg = list ("pt::rde" location list(msg)) + # Sort the messages for a canonical result. + # NOTE: The data out of the RDE/critcl is sorted + # by msg id, that is not necessarily + # lexicographical, nor matching the Tcl results. + lassign $msg tag loc mlist + set msg [list $tag $loc [lsort -dict $mlist]] + + # TODO: Convert message to readable. + list $code $msg + } -result $expected + } yes ;# Allow missing testsets, for two reasons: + # # (a) Easier during testsuite development, allowing incremental buildup + # # (b) Some grammar construction *cannot* fail (Ex: x*), thus we cannot provide + # # failure cases either. + + # Kill shared parser instance. + $p destroy + } + + # Testing the handling of generated parsers for single + # characters, for characters special to Tcl, C, and + # PEGs. I.e. ensure that the various forms of quoting are done + # correctly. + + foreach {n peg input message hmsg} $chars { + set glabel "T_$hmsg" + set grdata [string map [list @ $peg] $gtemplate] + set edata [string map [list @ $hmsg] $etemplate] + + # Make parser instance. Shared across tests. + # Amortize the time spent on dynamically making it. + set p [make-parser $format $glabel $grdata] + + test pt-pgen-parse:${parseimpl}-rde:${rdeimpl}-stack:${stackimpl}-f:${format}-g:${glabel}-3.$n \ + "$format parser $glabel, good input" -setup { + } -body { + $p parset $input + } -result {} + + test pt-pgen-parse:${parseimpl}-rde:${rdeimpl}-stack:${stackimpl}-f:${format}-g:${glabel}-4.$n \ + "$format parser $glabel, bad input, tcl error" -setup { + } -body { + set code [catch { + $p parset X + } msg] + lassign $msg tag loc mlist + list $tag $loc [lsort -dict $mlist] + } -result [list pt::rde 0 [list $message]] + + test pt-pgen-parse:${parseimpl}-rde:${rdeimpl}-stack:${stackimpl}-f:${format}-g:${glabel}-5.$n \ + "$format parser $glabel, bad input, readable error" -setup { + } -body { + set code [catch { + $p parset X + } msg] + lassign $msg tag loc mlist + pt::util::error2readable [list $tag $loc [lsort -dict $mlist]] X + } -result $edata + + # Kill shared parser instance. + $p destroy + } +} + +#---------------------------------------------------------------------- Index: modules/pt/tests/pt_rdengine.tests ================================================================== --- modules/pt/tests/pt_rdengine.tests +++ modules/pt/tests/pt_rdengine.tests @@ -24,11 +24,11 @@ myrde destroy } -returnCodes error \ -match glob \ -result [take \ {unknown subcommand "foo": namespace ::pt::rde_tcl::Snit_inst* does not export any commands} \ - {bad option "foo": must be amarked, ast, asts, chan, complete, current, data, destroy, emarked, error, lmarked, location, ok, reset, scached, symbols, tokens, value, i:fail_continue, i:fail_return, i:ok_continue, i:ok_return, i_status_fail, i_status_negate, i_status_ok, i_error_clear, i_error_nonterminal, i_error_pop_merge, i_error_push, i:fail_loc_pop_rewind, i_loc_pop_discard, i_loc_pop_rewind/discard, i_loc_pop_rewind, i_loc_push, i:fail_ast_pop_rewind, i_ast_pop_discard, i_ast_pop_discard/rewind, i_ast_pop_rewind/discard, i_ast_pop_rewind, i_ast_push, i:ok_ast_value_push, i_symbol_restore, i_symbol_save, i_value_clear/leaf, i_value_clear, i_value_clear/reduce, i_input_next, i_test_alnum, i_test_alpha, i_test_ascii, i_test_char, i_test_ddigit, i_test_digit, i_test_graph, i_test_lower, i_test_print, i_test_punct, i_test_range, i_test_space, i_test_upper, i_test_wordchar, i_test_xdigit, i:ok_ast_pop_discard, i_ast_rewind, i:ok_loc_pop_discard, i_loc_rewind, i_error_clear_push, si:void_state_push, si:value_state_push, si:void_state_merge, si:value_state_merge, si:voidvoid_branch, si:voidvalue_branch, si:valuevoid_branch, si:valuevalue_branch, si:voidvoid_part, si:voidvalue_part, si:valuevalue_part, si:next_char, si:next_range, si:next_alnum, si:next_alpha, si:next_ascii, si:next_ddigit, si:next_digit, si:next_graph, si:next_lower, si:next_print, si:next_punct, si:next_space, si:next_upper, si:next_wordchar, si:next_xdigit, si:void2_state_push, si:void_state_merge_ok, si:value_notahead_start, si:void_notahead_exit, si:value_notahead_exit, si:kleene_abort, si:kleene_close, si:value_symbol_start, si:value_void_symbol_start, si:void_symbol_start, si:void_void_symbol_start, si:reduce_symbol_end, si:void_leaf_symbol_end, si:value_leaf_symbol_end, si:value_clear_symbol_end, si:void_clear_symbol_end, si:next_str, or si:next_class}] + {bad option "foo": must be amarked, ast, asts, chan, complete, current, data, destroy, emarked, error, lmarked, location, ok, reset, scached, symbols, tokens, value, i:fail_continue, i:fail_return, i:ok_continue, i:ok_return, i_status_fail, i_status_negate, i_status_ok, i_error_clear, i_error_nonterminal, i_error_pop_merge, i_error_push, i:fail_loc_pop_rewind, i_loc_pop_discard, i_loc_pop_rewind/discard, i_loc_pop_rewind, i_loc_push, i:fail_ast_pop_rewind, i_ast_pop_discard, i_ast_pop_discard/rewind, i_ast_pop_rewind/discard, i_ast_pop_rewind, i_ast_push, i:ok_ast_value_push, i_symbol_restore, i_symbol_save, i_value_clear/leaf, i_value_clear, i_value_clear/reduce, i_input_next, i_test_alnum, i_test_alpha, i_test_ascii, i_test_char, i_test_control, i_test_ddigit, i_test_digit, i_test_graph, i_test_lower, i_test_print, i_test_punct, i_test_range, i_test_space, i_test_upper, i_test_wordchar, i_test_xdigit, i:ok_ast_pop_discard, i_ast_rewind, i:ok_loc_pop_discard, i_loc_rewind, i_error_clear_push, si:void_state_push, si:value_state_push, si:void_state_merge, si:value_state_merge, si:voidvoid_branch, si:voidvalue_branch, si:valuevoid_branch, si:valuevalue_branch, si:voidvoid_part, si:voidvalue_part, si:valuevalue_part, si:next_char, si:next_range, si:next_alnum, si:next_alpha, si:next_ascii, si:next_control, si:next_ddigit, si:next_digit, si:next_graph, si:next_lower, si:next_print, si:next_punct, si:next_space, si:next_upper, si:next_wordchar, si:next_xdigit, si:void2_state_push, si:void_state_merge_ok, si:value_notahead_start, si:void_notahead_exit, si:value_notahead_exit, si:kleene_abort, si:kleene_close, si:value_symbol_start, si:value_void_symbol_start, si:void_symbol_start, si:void_void_symbol_start, si:reduce_symbol_end, si:void_leaf_symbol_end, si:value_leaf_symbol_end, si:value_clear_symbol_end, si:void_clear_symbol_end, si:next_str, or si:next_class}] test pt-rdengine-rde:${rdeimpl}-stack:${stkimpl}-0.3 {rde errors} -body { pt::rde set } -returnCodes error -result {command "::set" already exists} @@ -661,11 +661,11 @@ CC H CL -1 LS -1 ST fail SV {} - ER {0 {{n X}}} + ER {0 {{t Y}}} ES {} TC HE NC {} AR {} AS {}} Index: modules/pt/tests/pt_runtime.tests ================================================================== --- modules/pt/tests/pt_runtime.tests +++ modules/pt/tests/pt_runtime.tests @@ -17,11 +17,11 @@ pt::peg::to::tclparam reset pt::peg::to::tclparam configure -name TEMPLATE$suffix pt::peg::to::tclparam configure -file TEST$suffix pt::tclparam::configuration::snit def \ - PARSER$suffix SNIT_PACKAGE$suffix \ + PARSER$suffix SNIT_PACKAGE$suffix 1 \ {pt::peg::to::tclparam configure} set c [pt::peg::to::tclparam convert [$g serialize]] # The catch is required because the generated code ends in Index: modules/pt/tests/pt_tclparam_config_snit.tests ================================================================== --- modules/pt/tests/pt_tclparam_config_snit.tests +++ modules/pt/tests/pt_tclparam_config_snit.tests @@ -1,23 +1,27 @@ # -*- tcl -*- # General set of error cases regarding the number of arguments. test pt-tclparam-config-snit-1.0 {convert, wrong#args} -body { pt::tclparam::configuration::snit def -} -returnCodes error -result {wrong # args: should be "pt::tclparam::configuration::snit def class pkg cmd"} +} -returnCodes error -result {wrong # args: should be "pt::tclparam::configuration::snit def class pkg version cmd"} test pt-tclparam-config-snit-1.1 {convert, wrong#args} -body { pt::tclparam::configuration::snit def C -} -returnCodes error -result {wrong # args: should be "pt::tclparam::configuration::snit def class pkg cmd"} +} -returnCodes error -result {wrong # args: should be "pt::tclparam::configuration::snit def class pkg version cmd"} test pt-tclparam-config-snit-1.2 {convert, wrong#args} -body { pt::tclparam::configuration::snit def C P -} -returnCodes error -result {wrong # args: should be "pt::tclparam::configuration::snit def class pkg cmd"} +} -returnCodes error -result {wrong # args: should be "pt::tclparam::configuration::snit def class pkg version cmd"} + +test pt-tclparam-config-snit-1.3 {convert, wrong#args} -body { + pt::tclparam::configuration::snit def C P V +} -returnCodes error -result {wrong # args: should be "pt::tclparam::configuration::snit def class pkg version cmd"} test pt-tclparam-config-snit-2.0 {reset, wrong#args} -body { - pt::tclparam::configuration::snit def C P C XXX -} -returnCodes error -result {wrong # args: should be "pt::tclparam::configuration::snit def class pkg cmd"} + pt::tclparam::configuration::snit def C P V C XXX +} -returnCodes error -result {wrong # args: should be "pt::tclparam::configuration::snit def class pkg version cmd"} # ------------------------------------------------------------------------- # TODO :: Tests missing for: configure/cget, reset @@ -31,11 +35,11 @@ pt::peg::to::tclparam reset pt::peg::to::tclparam configure -name TEMPLATE pt::peg::to::tclparam configure -file TEST pt::tclparam::configuration::snit def \ - PARSER SNIT_PACKAGE \ + PARSER SNIT_PACKAGE 1 \ {pt::peg::to::tclparam configure} } -body { pt::peg::to::tclparam convert $data } -cleanup { Index: modules/pt/tests/pt_tclparam_config_tcloo.tests ================================================================== --- modules/pt/tests/pt_tclparam_config_tcloo.tests +++ modules/pt/tests/pt_tclparam_config_tcloo.tests @@ -1,23 +1,27 @@ # -*- tcl -*- # General set of error cases regarding the number of arguments. test pt-tclparam-config-tcloo-1.0 {convert, wrong#args} -body { pt::tclparam::configuration::tcloo def -} -returnCodes error -result {wrong # args: should be "pt::tclparam::configuration::tcloo def class pkg cmd"} +} -returnCodes error -result {wrong # args: should be "pt::tclparam::configuration::tcloo def class pkg version cmd"} test pt-tclparam-config-tcloo-1.1 {convert, wrong#args} -body { pt::tclparam::configuration::tcloo def C -} -returnCodes error -result {wrong # args: should be "pt::tclparam::configuration::tcloo def class pkg cmd"} +} -returnCodes error -result {wrong # args: should be "pt::tclparam::configuration::tcloo def class pkg version cmd"} test pt-tclparam-config-tcloo-1.2 {convert, wrong#args} -body { pt::tclparam::configuration::tcloo def C P -} -returnCodes error -result {wrong # args: should be "pt::tclparam::configuration::tcloo def class pkg cmd"} +} -returnCodes error -result {wrong # args: should be "pt::tclparam::configuration::tcloo def class pkg version cmd"} + +test pt-tclparam-config-tcloo-1.3 {convert, wrong#args} -body { + pt::tclparam::configuration::tcloo def C P V +} -returnCodes error -result {wrong # args: should be "pt::tclparam::configuration::tcloo def class pkg version cmd"} test pt-tclparam-config-tcloo-2.0 {reset, wrong#args} -body { - pt::tclparam::configuration::tcloo def C P C XXX -} -returnCodes error -result {wrong # args: should be "pt::tclparam::configuration::tcloo def class pkg cmd"} + pt::tclparam::configuration::tcloo def C P V C XXX +} -returnCodes error -result {wrong # args: should be "pt::tclparam::configuration::tcloo def class pkg version cmd"} # ------------------------------------------------------------------------- # TODO :: Tests missing for: configure/cget, reset @@ -31,11 +35,11 @@ pt::peg::to::tclparam reset pt::peg::to::tclparam configure -name TEMPLATE pt::peg::to::tclparam configure -file TEST pt::tclparam::configuration::tcloo def \ - PARSER OO_PACKAGE \ + PARSER OO_PACKAGE 1 \ {pt::peg::to::tclparam configure} } -body { pt::peg::to::tclparam convert $data } -cleanup { Index: modules/pt/tools/bench-compare.tcl ================================================================== --- modules/pt/tools/bench-compare.tcl +++ modules/pt/tools/bench-compare.tcl @@ -1,5 +1,7 @@ +#!/usr/bin/env tclsh +# -*- tcl -*- package require Tcl 8.5 package require bench::in package require struct::matrix package require report Index: modules/pt/tools/regenerate_parsers.tcl ================================================================== --- modules/pt/tools/regenerate_parsers.tcl +++ modules/pt/tools/regenerate_parsers.tcl @@ -6,12 +6,14 @@ set self [file normalize [info script]] set selfdir [file dirname $self] set module [file dirname $selfdir] lappend auto_path [file dirname $module] -package require pt::pgen +package require pt::pgen 1.0.3 +package require pt::util package require fileutil +package require try set specification [file join $module tests/data/ok/peg_peg/3_peg_itself] set new_parser_tcl [file join $module pt_parse_peg_tcl.tcl-NEW] set new_parser_critcl [file join $module pt_parse_peg_c.tcl-NEW] set me $tcl_platform(user) @@ -39,36 +41,46 @@ # for bootstrapping is still present, just commented out. puts "Reading spec..." set spec [fileutil::cat $specification] -# 1. -# Generate snit-based Tcl parser for the PEG grammar. - -puts Tcl -fileutil::writeFile $new_parser_tcl \ - [pt::pgen \ - peg $spec \ - snit \ - -name $name \ - -user $me \ - -file [file tail $specification] \ - -class ${class}_tcl \ - -package ${class}_tcl \ - ] - -# 2. -# Generate critcl-based C parser for the PEG grammar. - -puts CriTcl -fileutil::writeFile $new_parser_critcl \ - [pt::pgen \ - peg $spec \ - critcl \ - -name $name \ - -user $me \ - -file [file tail $specification] \ - -class $class \ - -package [string map {:: _} $class]_c \ - ] - -exit +set version 1.0.1 + +puts "Generating $version ..." + +try { + # Generate snit-based Tcl parser for the PEG grammar. + puts ...Tcl + set tcl [pt::pgen \ + peg $spec \ + snit \ + -name $name \ + -user $me \ + -file [file tail $specification] \ + -class ${class}_tcl \ + -package ${class}_tcl \ + -version $version \ + ] + + # Generate critcl-based C parser for the PEG grammar. + puts ...Critcl + set ctcl [pt::pgen \ + peg $spec \ + critcl \ + -name $name \ + -user $me \ + -file [file tail $specification] \ + -class $class \ + -package [string map {:: _} $class]_c \ + -version $version \ + ] +} trap {PT RDE SYNTAX} {e o} { + puts [pt::util error2readable $e $spec] + exit 1 +} + +puts "Saving..." +fileutil::writeFile $new_parser_tcl $tcl +fileutil::writeFile $new_parser_critcl $ctcl + +puts OK +exit 0 Index: support/devel/sak/doc/kwic.txt ================================================================== --- support/devel/sak/doc/kwic.txt +++ support/devel/sak/doc/kwic.txt @@ -427,10 +427,11 @@ [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] +[manpage modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] @@ -458,10 +459,11 @@ [manpage modules/pt/pt_peg_introduction.man pt::pegrammar] [manpage modules/pt/pt_pgen.man pt::pgen] [manpage modules/pt/pt_rdengine.man pt::rde] [manpage modules/pt/pt_tclparam_config_snit.man pt::tclparam::configuration::snit] [manpage modules/pt/pt_tclparam_config_tcloo.man pt::tclparam::configuration::tcloo] +[manpage modules/pt/pt_util.man pt::util] [manpage modules/pt/pt_to_api.man pt_export_api] [manpage modules/pt/pt_from_api.man pt_import_api] [manpage modules/pt/pt_introduction.man pt_introduction] [manpage modules/pt/pt_parse_peg.man pt_parse_peg] [manpage modules/pt/pt_parser_api.man pt_parser_api] @@ -857,10 +859,11 @@ [manpage modules/grammar_aycock/aycock.man grammar::aycock] [key EBNF] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] +[manpage modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] @@ -888,10 +891,11 @@ [manpage modules/pt/pt_peg_introduction.man pt::pegrammar] [manpage modules/pt/pt_pgen.man pt::pgen] [manpage modules/pt/pt_rdengine.man pt::rde] [manpage modules/pt/pt_tclparam_config_snit.man pt::tclparam::configuration::snit] [manpage modules/pt/pt_tclparam_config_tcloo.man pt::tclparam::configuration::tcloo] +[manpage modules/pt/pt_util.man pt::util] [manpage modules/pt/pt_to_api.man pt_export_api] [manpage modules/pt/pt_from_api.man pt_import_api] [manpage modules/pt/pt_introduction.man pt_introduction] [manpage modules/pt/pt_parse_peg.man pt_parse_peg] [manpage modules/pt/pt_parser_api.man pt_parser_api] @@ -1001,10 +1005,11 @@ [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] +[manpage modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] @@ -1032,10 +1037,11 @@ [manpage modules/pt/pt_peg_introduction.man pt::pegrammar] [manpage modules/pt/pt_pgen.man pt::pgen] [manpage modules/pt/pt_rdengine.man pt::rde] [manpage modules/pt/pt_tclparam_config_snit.man pt::tclparam::configuration::snit] [manpage modules/pt/pt_tclparam_config_tcloo.man pt::tclparam::configuration::tcloo] +[manpage modules/pt/pt_util.man pt::util] [manpage modules/pt/pt_to_api.man pt_export_api] [manpage modules/pt/pt_from_api.man pt_import_api] [manpage modules/pt/pt_introduction.man pt_introduction] [manpage modules/pt/pt_parse_peg.man pt_parse_peg] [manpage modules/pt/pt_parser_api.man pt_parser_api] @@ -1223,10 +1229,11 @@ [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] +[manpage modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] @@ -1254,10 +1261,11 @@ [manpage modules/pt/pt_peg_introduction.man pt::pegrammar] [manpage modules/pt/pt_pgen.man pt::pgen] [manpage modules/pt/pt_rdengine.man pt::rde] [manpage modules/pt/pt_tclparam_config_snit.man pt::tclparam::configuration::snit] [manpage modules/pt/pt_tclparam_config_tcloo.man pt::tclparam::configuration::tcloo] +[manpage modules/pt/pt_util.man pt::util] [manpage modules/pt/pt_to_api.man pt_export_api] [manpage modules/pt/pt_from_api.man pt_import_api] [manpage modules/pt/pt_introduction.man pt_introduction] [manpage modules/pt/pt_parse_peg.man pt_parse_peg] [manpage modules/pt/pt_parser_api.man pt_parser_api] @@ -1617,10 +1625,11 @@ [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] +[manpage modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] @@ -1648,10 +1657,11 @@ [manpage modules/pt/pt_peg_introduction.man pt::pegrammar] [manpage modules/pt/pt_pgen.man pt::pgen] [manpage modules/pt/pt_rdengine.man pt::rde] [manpage modules/pt/pt_tclparam_config_snit.man pt::tclparam::configuration::snit] [manpage modules/pt/pt_tclparam_config_tcloo.man pt::tclparam::configuration::tcloo] +[manpage modules/pt/pt_util.man pt::util] [manpage modules/pt/pt_to_api.man pt_export_api] [manpage modules/pt/pt_from_api.man pt_import_api] [manpage modules/pt/pt_introduction.man pt_introduction] [manpage modules/pt/pt_parse_peg.man pt_parse_peg] [manpage modules/pt/pt_parser_api.man pt_parser_api] @@ -1774,10 +1784,11 @@ [manpage modules/grammar_me/me_intro.man grammar::me_intro] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] +[manpage modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] @@ -1805,10 +1816,11 @@ [manpage modules/pt/pt_peg_introduction.man pt::pegrammar] [manpage modules/pt/pt_pgen.man pt::pgen] [manpage modules/pt/pt_rdengine.man pt::rde] [manpage modules/pt/pt_tclparam_config_snit.man pt::tclparam::configuration::snit] [manpage modules/pt/pt_tclparam_config_tcloo.man pt::tclparam::configuration::tcloo] +[manpage modules/pt/pt_util.man pt::util] [manpage modules/pt/pt_to_api.man pt_export_api] [manpage modules/pt/pt_from_api.man pt_import_api] [manpage modules/pt/pt_introduction.man pt_introduction] [manpage modules/pt/pt_parse_peg.man pt_parse_peg] [manpage modules/pt/pt_parser_api.man pt_parser_api] @@ -2095,10 +2107,11 @@ [manpage modules/doctools2toc/toc_parse.man doctools::toc::parse] [manpage modules/grammar_aycock/aycock.man grammar::aycock] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] +[manpage modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] @@ -2126,10 +2139,11 @@ [manpage modules/pt/pt_peg_introduction.man pt::pegrammar] [manpage modules/pt/pt_pgen.man pt::pgen] [manpage modules/pt/pt_rdengine.man pt::rde] [manpage modules/pt/pt_tclparam_config_snit.man pt::tclparam::configuration::snit] [manpage modules/pt/pt_tclparam_config_tcloo.man pt::tclparam::configuration::tcloo] +[manpage modules/pt/pt_util.man pt::util] [manpage modules/pt/pt_to_api.man pt_export_api] [manpage modules/pt/pt_from_api.man pt_import_api] [manpage modules/pt/pt_introduction.man pt_introduction] [manpage modules/pt/pt_parse_peg.man pt_parse_peg] [manpage modules/pt/pt_parser_api.man pt_parser_api] @@ -2174,10 +2188,11 @@ [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] +[manpage modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] @@ -2205,10 +2220,11 @@ [manpage modules/pt/pt_peg_introduction.man pt::pegrammar] [manpage modules/pt/pt_pgen.man pt::pgen] [manpage modules/pt/pt_rdengine.man pt::rde] [manpage modules/pt/pt_tclparam_config_snit.man pt::tclparam::configuration::snit] [manpage modules/pt/pt_tclparam_config_tcloo.man pt::tclparam::configuration::tcloo] +[manpage modules/pt/pt_util.man pt::util] [manpage modules/pt/pt_to_api.man pt_export_api] [manpage modules/pt/pt_from_api.man pt_import_api] [manpage modules/pt/pt_introduction.man pt_introduction] [manpage modules/pt/pt_parse_peg.man pt_parse_peg] [manpage modules/pt/pt_parser_api.man pt_parser_api] @@ -2219,10 +2235,11 @@ [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage modules/page/page_util_peg.man page_util_peg] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] +[manpage modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] @@ -2250,10 +2267,11 @@ [manpage modules/pt/pt_peg_introduction.man pt::pegrammar] [manpage modules/pt/pt_pgen.man pt::pgen] [manpage modules/pt/pt_rdengine.man pt::rde] [manpage modules/pt/pt_tclparam_config_snit.man pt::tclparam::configuration::snit] [manpage modules/pt/pt_tclparam_config_tcloo.man pt::tclparam::configuration::tcloo] +[manpage modules/pt/pt_util.man pt::util] [manpage modules/pt/pt_to_api.man pt_export_api] [manpage modules/pt/pt_from_api.man pt_import_api] [manpage modules/pt/pt_introduction.man pt_introduction] [manpage modules/pt/pt_parse_peg.man pt_parse_peg] [manpage modules/pt/pt_parser_api.man pt_parser_api] @@ -2277,10 +2295,11 @@ [manpage modules/page/page_util_norm_peg.man page_util_norm_peg] [manpage modules/page/page_util_peg.man page_util_peg] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] +[manpage modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] @@ -2308,10 +2327,11 @@ [manpage modules/pt/pt_peg_introduction.man pt::pegrammar] [manpage modules/pt/pt_pgen.man pt::pgen] [manpage modules/pt/pt_rdengine.man pt::rde] [manpage modules/pt/pt_tclparam_config_snit.man pt::tclparam::configuration::snit] [manpage modules/pt/pt_tclparam_config_tcloo.man pt::tclparam::configuration::tcloo] +[manpage modules/pt/pt_util.man pt::util] [manpage modules/pt/pt_to_api.man pt_export_api] [manpage modules/pt/pt_from_api.man pt_import_api] [manpage modules/pt/pt_introduction.man pt_introduction] [manpage modules/pt/pt_parse_peg.man pt_parse_peg] [manpage modules/pt/pt_parser_api.man pt_parser_api] @@ -2426,10 +2446,11 @@ [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] +[manpage modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] @@ -2457,10 +2478,11 @@ [manpage modules/pt/pt_peg_introduction.man pt::pegrammar] [manpage modules/pt/pt_pgen.man pt::pgen] [manpage modules/pt/pt_rdengine.man pt::rde] [manpage modules/pt/pt_tclparam_config_snit.man pt::tclparam::configuration::snit] [manpage modules/pt/pt_tclparam_config_tcloo.man pt::tclparam::configuration::tcloo] +[manpage modules/pt/pt_util.man pt::util] [manpage modules/pt/pt_to_api.man pt_export_api] [manpage modules/pt/pt_from_api.man pt_import_api] [manpage modules/pt/pt_introduction.man pt_introduction] [manpage modules/pt/pt_parse_peg.man pt_parse_peg] [manpage modules/pt/pt_parser_api.man pt_parser_api] @@ -2513,10 +2535,11 @@ [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] +[manpage modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] @@ -2544,10 +2567,11 @@ [manpage modules/pt/pt_peg_introduction.man pt::pegrammar] [manpage modules/pt/pt_pgen.man pt::pgen] [manpage modules/pt/pt_rdengine.man pt::rde] [manpage modules/pt/pt_tclparam_config_snit.man pt::tclparam::configuration::snit] [manpage modules/pt/pt_tclparam_config_tcloo.man pt::tclparam::configuration::tcloo] +[manpage modules/pt/pt_util.man pt::util] [manpage modules/pt/pt_to_api.man pt_export_api] [manpage modules/pt/pt_from_api.man pt_import_api] [manpage modules/pt/pt_introduction.man pt_introduction] [manpage modules/pt/pt_parse_peg.man pt_parse_peg] [manpage modules/pt/pt_parser_api.man pt_parser_api] @@ -2945,10 +2969,11 @@ [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] +[manpage modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] @@ -2976,10 +3001,11 @@ [manpage modules/pt/pt_peg_introduction.man pt::pegrammar] [manpage modules/pt/pt_pgen.man pt::pgen] [manpage modules/pt/pt_rdengine.man pt::rde] [manpage modules/pt/pt_tclparam_config_snit.man pt::tclparam::configuration::snit] [manpage modules/pt/pt_tclparam_config_tcloo.man pt::tclparam::configuration::tcloo] +[manpage modules/pt/pt_util.man pt::util] [manpage modules/pt/pt_to_api.man pt_export_api] [manpage modules/pt/pt_from_api.man pt_import_api] [manpage modules/pt/pt_introduction.man pt_introduction] [manpage modules/pt/pt_parse_peg.man pt_parse_peg] [manpage modules/pt/pt_parser_api.man pt_parser_api] @@ -3107,10 +3133,11 @@ [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] +[manpage modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] @@ -3138,10 +3165,11 @@ [manpage modules/pt/pt_peg_introduction.man pt::pegrammar] [manpage modules/pt/pt_pgen.man pt::pgen] [manpage modules/pt/pt_rdengine.man pt::rde] [manpage modules/pt/pt_tclparam_config_snit.man pt::tclparam::configuration::snit] [manpage modules/pt/pt_tclparam_config_tcloo.man pt::tclparam::configuration::tcloo] +[manpage modules/pt/pt_util.man pt::util] [manpage modules/pt/pt_to_api.man pt_export_api] [manpage modules/pt/pt_from_api.man pt_import_api] [manpage modules/pt/pt_introduction.man pt_introduction] [manpage modules/pt/pt_parse_peg.man pt_parse_peg] [manpage modules/pt/pt_parser_api.man pt_parser_api] @@ -3324,10 +3352,11 @@ [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] +[manpage modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] @@ -3355,10 +3384,11 @@ [manpage modules/pt/pt_peg_introduction.man pt::pegrammar] [manpage modules/pt/pt_pgen.man pt::pgen] [manpage modules/pt/pt_rdengine.man pt::rde] [manpage modules/pt/pt_tclparam_config_snit.man pt::tclparam::configuration::snit] [manpage modules/pt/pt_tclparam_config_tcloo.man pt::tclparam::configuration::tcloo] +[manpage modules/pt/pt_util.man pt::util] [manpage modules/pt/pt_to_api.man pt_export_api] [manpage modules/pt/pt_from_api.man pt_import_api] [manpage modules/pt/pt_introduction.man pt_introduction] [manpage modules/pt/pt_parse_peg.man pt_parse_peg] [manpage modules/pt/pt_parser_api.man pt_parser_api] @@ -3384,10 +3414,11 @@ [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] +[manpage modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] @@ -3415,10 +3446,11 @@ [manpage modules/pt/pt_peg_introduction.man pt::pegrammar] [manpage modules/pt/pt_pgen.man pt::pgen] [manpage modules/pt/pt_rdengine.man pt::rde] [manpage modules/pt/pt_tclparam_config_snit.man pt::tclparam::configuration::snit] [manpage modules/pt/pt_tclparam_config_tcloo.man pt::tclparam::configuration::tcloo] +[manpage modules/pt/pt_util.man pt::util] [manpage modules/pt/pt_to_api.man pt_export_api] [manpage modules/pt/pt_from_api.man pt_import_api] [manpage modules/pt/pt_introduction.man pt_introduction] [manpage modules/pt/pt_parse_peg.man pt_parse_peg] [manpage modules/pt/pt_parser_api.man pt_parser_api] Index: support/devel/sak/doc/manpages.txt ================================================================== --- support/devel/sak/doc/manpages.txt +++ support/devel/sak/doc/manpages.txt @@ -232,10 +232,11 @@ modules/pop3d/pop3d_dbox.man modules/pop3d/pop3d_udb.man modules/profiler/profiler.man modules/pt/pt_astree.man modules/pt/pt_cparam_config_critcl.man +modules/pt/pt_cparam_config_tea.man modules/pt/pt_from_api.man modules/pt/pt_introduction.man modules/pt/pt_json_language.man modules/pt/pt_param.man modules/pt/pt_parse_peg.man @@ -269,10 +270,11 @@ modules/pt/pt_pgen.man modules/pt/pt_rdengine.man modules/pt/pt_tclparam_config_snit.man modules/pt/pt_tclparam_config_tcloo.man modules/pt/pt_to_api.man +modules/pt/pt_util.man modules/rc4/rc4.man modules/rcs/rcs.man modules/report/report.man modules/rest/rest.man modules/ripemd/ripemd128.man Index: support/devel/sak/doc/toc.txt ================================================================== --- support/devel/sak/doc/toc.txt +++ support/devel/sak/doc/toc.txt @@ -270,10 +270,11 @@ [division_end] [division_start {Parsing and Grammars}] [item apps/pt.man pt {Parser Tools Application}] [item modules/pt/pt_astree.man pt::ast {Abstract Syntax Tree Serialization}] [item modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl {C/PARAM, Canned configuration, Critcl}] +[item modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea {C/PARAM, Canned configuration, TEA}] [item modules/pt/pt_json_language.man pt::json_language {The JSON Grammar Exchange Format}] [item modules/pt/pt_param.man pt::param {PackRat Machine Specification}] [item modules/pt/pt_pexpression.man pt::pe {Parsing Expression Serialization}] [item modules/pt/pt_pexpr_op.man pt::pe::op {Parsing Expression Utilities}] [item modules/pt/pt_pegrammar.man pt::peg {Parsing Expression Grammar Serialization}] @@ -301,10 +302,11 @@ [item modules/pt/pt_peg_introduction.man pt::pegrammar {Introduction to Parsing Expression Grammars}] [item modules/pt/pt_pgen.man pt::pgen {Parser Generator}] [item modules/pt/pt_rdengine.man pt::rde {Parsing Runtime Support, PARAM based}] [item modules/pt/pt_tclparam_config_snit.man pt::tclparam::configuration::snit {Tcl/PARAM, Canned configuration, Snit}] [item modules/pt/pt_tclparam_config_tcloo.man pt::tclparam::configuration::tcloo {Tcl/PARAM, Canned configuration, Tcloo}] +[item modules/pt/pt_util.man pt::util {General utilities}] [item modules/pt/pt_to_api.man pt_export_api {Parser Tools Export API}] [item modules/pt/pt_from_api.man pt_import_api {Parser Tools Import API}] [item modules/pt/pt_introduction.man pt_introduction {Introduction to Parser Tools}] [item modules/pt/pt_parse_peg.man pt_parse_peg {Parser Tools PEG Parser}] [item modules/pt/pt_parser_api.man pt_parser_api {Parser API}] @@ -850,10 +852,11 @@ [item modules/profiler/profiler.man profiler {Tcl source code profiler}] [division_end] [division_start pt] [item modules/pt/pt_astree.man pt::ast {Abstract Syntax Tree Serialization}] [item modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl {C/PARAM, Canned configuration, Critcl}] +[item modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea {C/PARAM, Canned configuration, TEA}] [item modules/pt/pt_json_language.man pt::json_language {The JSON Grammar Exchange Format}] [item modules/pt/pt_param.man pt::param {PackRat Machine Specification}] [item modules/pt/pt_pexpression.man pt::pe {Parsing Expression Serialization}] [item modules/pt/pt_pexpr_op.man pt::pe::op {Parsing Expression Utilities}] [item modules/pt/pt_pegrammar.man pt::peg {Parsing Expression Grammar Serialization}] @@ -881,10 +884,11 @@ [item modules/pt/pt_peg_introduction.man pt::pegrammar {Introduction to Parsing Expression Grammars}] [item modules/pt/pt_pgen.man pt::pgen {Parser Generator}] [item modules/pt/pt_rdengine.man pt::rde {Parsing Runtime Support, PARAM based}] [item modules/pt/pt_tclparam_config_snit.man pt::tclparam::configuration::snit {Tcl/PARAM, Canned configuration, Snit}] [item modules/pt/pt_tclparam_config_tcloo.man pt::tclparam::configuration::tcloo {Tcl/PARAM, Canned configuration, Tcloo}] +[item modules/pt/pt_util.man pt::util {General utilities}] [item modules/pt/pt_to_api.man pt_export_api {Parser Tools Export API}] [item modules/pt/pt_from_api.man pt_import_api {Parser Tools Import API}] [item modules/pt/pt_introduction.man pt_introduction {Introduction to Parser Tools}] [item modules/pt/pt_parse_peg.man pt_parse_peg {Parser Tools PEG Parser}] [item modules/pt/pt_parser_api.man pt_parser_api {Parser API}] Index: support/devel/sak/doc/toc_cats.txt ================================================================== --- support/devel/sak/doc/toc_cats.txt +++ support/devel/sak/doc/toc_cats.txt @@ -270,10 +270,11 @@ [division_end] [division_start {Parsing and Grammars}] [item apps/pt.man pt {Parser Tools Application}] [item modules/pt/pt_astree.man pt::ast {Abstract Syntax Tree Serialization}] [item modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl {C/PARAM, Canned configuration, Critcl}] +[item modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea {C/PARAM, Canned configuration, TEA}] [item modules/pt/pt_json_language.man pt::json_language {The JSON Grammar Exchange Format}] [item modules/pt/pt_param.man pt::param {PackRat Machine Specification}] [item modules/pt/pt_pexpression.man pt::pe {Parsing Expression Serialization}] [item modules/pt/pt_pexpr_op.man pt::pe::op {Parsing Expression Utilities}] [item modules/pt/pt_pegrammar.man pt::peg {Parsing Expression Grammar Serialization}] @@ -301,10 +302,11 @@ [item modules/pt/pt_peg_introduction.man pt::pegrammar {Introduction to Parsing Expression Grammars}] [item modules/pt/pt_pgen.man pt::pgen {Parser Generator}] [item modules/pt/pt_rdengine.man pt::rde {Parsing Runtime Support, PARAM based}] [item modules/pt/pt_tclparam_config_snit.man pt::tclparam::configuration::snit {Tcl/PARAM, Canned configuration, Snit}] [item modules/pt/pt_tclparam_config_tcloo.man pt::tclparam::configuration::tcloo {Tcl/PARAM, Canned configuration, Tcloo}] +[item modules/pt/pt_util.man pt::util {General utilities}] [item modules/pt/pt_to_api.man pt_export_api {Parser Tools Export API}] [item modules/pt/pt_from_api.man pt_import_api {Parser Tools Import API}] [item modules/pt/pt_introduction.man pt_introduction {Introduction to Parser Tools}] [item modules/pt/pt_parse_peg.man pt_parse_peg {Parser Tools PEG Parser}] [item modules/pt/pt_parser_api.man pt_parser_api {Parser API}] Index: support/devel/sak/doc/toc_mods.txt ================================================================== --- support/devel/sak/doc/toc_mods.txt +++ support/devel/sak/doc/toc_mods.txt @@ -380,10 +380,11 @@ [item modules/profiler/profiler.man profiler {Tcl source code profiler}] [division_end] [division_start pt] [item modules/pt/pt_astree.man pt::ast {Abstract Syntax Tree Serialization}] [item modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl {C/PARAM, Canned configuration, Critcl}] +[item modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea {C/PARAM, Canned configuration, TEA}] [item modules/pt/pt_json_language.man pt::json_language {The JSON Grammar Exchange Format}] [item modules/pt/pt_param.man pt::param {PackRat Machine Specification}] [item modules/pt/pt_pexpression.man pt::pe {Parsing Expression Serialization}] [item modules/pt/pt_pexpr_op.man pt::pe::op {Parsing Expression Utilities}] [item modules/pt/pt_pegrammar.man pt::peg {Parsing Expression Grammar Serialization}] @@ -411,10 +412,11 @@ [item modules/pt/pt_peg_introduction.man pt::pegrammar {Introduction to Parsing Expression Grammars}] [item modules/pt/pt_pgen.man pt::pgen {Parser Generator}] [item modules/pt/pt_rdengine.man pt::rde {Parsing Runtime Support, PARAM based}] [item modules/pt/pt_tclparam_config_snit.man pt::tclparam::configuration::snit {Tcl/PARAM, Canned configuration, Snit}] [item modules/pt/pt_tclparam_config_tcloo.man pt::tclparam::configuration::tcloo {Tcl/PARAM, Canned configuration, Tcloo}] +[item modules/pt/pt_util.man pt::util {General utilities}] [item modules/pt/pt_to_api.man pt_export_api {Parser Tools Export API}] [item modules/pt/pt_from_api.man pt_import_api {Parser Tools Import API}] [item modules/pt/pt_introduction.man pt_introduction {Introduction to Parser Tools}] [item modules/pt/pt_parse_peg.man pt_parse_peg {Parser Tools PEG Parser}] [item modules/pt/pt_parser_api.man pt_parser_api {Parser API}]