peg_grammar.tcl
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 package require grammar::peg
00021
00022 namespace ::pg::peg::grammar {}
00023
00024
00025
00026
00027 ret ::pg::peg::grammar () {
00028 return $grammar::gr
00029 }
00030
00031
00032
00033
00034
00035 namespace ::pg::peg::grammar {
00036
00037 variable gr [::grammar::peg gr]
00038 }
00039
00040 ret ::pg::peg::grammar::Start (type pe) {
00041 variable gr
00042 $gr start $pe
00043 return
00044 }
00045
00046 ret ::pg::peg::grammar::Define (type mode , type nt , type pe) {
00047 variable gr
00048 $gr nonterminal add $nt $pe
00049 $gr nonterminal mode $nt $mode
00050 return
00051 }
00052
00053
00054
00055
00056 namespace ::pg::peg::grammar {
00057 Start {n Grammar}
00058
00059 Define leaf ALNUM {x {t <} {t a} {t l} {t n} {t u} {t m} {t >} {n SPACE}}
00060 Define leaf ALPHA {x {t <} {t a} {t l} {t p} {t h} {t a} {t >} {n SPACE}}
00061 Define leaf AND {x {t &} {n SPACE}}
00062 Define discard APOSTROPH {t '}
00063 Define value Attribute {x {/ {n VOID} {n LEAF} {n MATCH}} {n COLON}}
00064 Define value Char {/ {n CharSpecial} {n CharOctalFull} {n CharOctalPart} {n CharUnicode} {n CharUnescaped}}
00065 Define match CharOctalFull {x {t \134} {.. 0 2} {.. 0 7} {.. 0 7}}
00066 Define match CharOctalPart {x {t \134} {.. 0 7} {? {.. 0 7}}}
00067 Define match CharSpecial {x {t \134} {/ {t n} {t r} {t t} {t '} {t \42} {t \133} {t \135} {t \134}}}
00068 Define match CharUnescaped {x {! {t \134}} dot}
00069 Define match CharUnicode {x {t \134} {t u} {n HexDigit} {? {x {n HexDigit} {? {x {n HexDigit} {? {n HexDigit}}}}}}}
00070 Define value Class {x {n OPENB} {* {x {! {n CLOSEB}} {n Range}}} {n CLOSEB} {n SPACE}}
00071 Define discard CLOSE {x {t \51} {n SPACE}}
00072 Define discard CLOSEB {t \135}
00073 Define discard COLON {x {t :} {n SPACE}}
00074 Define discard COMMENT {x {t
00075 Define discard DAPOSTROPH {t \42}
00076 Define value Definition {x {? {n Attribute}} {n Identifier} {n IS} {n Expression} {n SEMICOLON}}
00077 Define leaf DOT {x {t .} {n SPACE}}
00078 Define discard END {x {t E} {t N} {t D} {n SPACE}}
00079 Define discard EOF {! dot}
00080 Define discard EOL {/ {x {t \n} {t \r}} {t \n} {t \r}}
00081 Define value Expression {x {n Sequence} {* {x {n SLASH} {n Sequence}}}}
00082 Define discard Final {x {n END} {n SEMICOLON} {n SPACE}}
00083 Define value Grammar {x {n SPACE} {n Header} {+ {n Definition}} {n Final} {n EOF}}
00084 Define value Header {x {n PEG} {n Identifier} {n StartExpr}}
00085 Define discard HexDigit {/ {.. 0 9} {.. a f} {.. A F}}
00086 Define match Ident {x {/ {t _} {t :} alpha} {* {/ {t _} {t :} alnum}}}
00087 Define value Identifier {x {n Ident} {n SPACE}}
00088 Define discard IS {x {t <} {t -} {n SPACE}}
00089 Define leaf LEAF {x {t l} {t e} {t a} {t f} {n SPACE}}
00090 Define value Literal {/ {x {n APOSTROPH} {* {x {! {n APOSTROPH}} {n Char}}} {n APOSTROPH} {n SPACE}} {x {n DAPOSTROPH} {* {x {! {n DAPOSTROPH}} {n Char}}} {n DAPOSTROPH} {n SPACE}}}
00091 Define leaf MATCH {x {t m} {t a} {t t} {t c} {t h} {n SPACE}}
00092 Define leaf NOT {x {t !} {n SPACE}}
00093 Define discard OPEN {x {t \50} {n SPACE}}
00094 Define discard OPENB {t \133}
00095 Define discard PEG {x {t P} {t E} {t G} {n SPACE}}
00096 Define leaf PLUS {x {t +} {n SPACE}}
00097 Define value Prefix {x {? {/ {n AND} {n NOT}}} {n Suffix}}
00098 Define value Primary {/ {n ALNUM} {n ALPHA} {n Identifier} {x {n OPEN} {n Expression} {n CLOSE}} {n Literal} {n Class} {n DOT}}
00099 Define leaf QUESTION {x {t ?} {n SPACE}}
00100 Define value Range {/ {x {n Char} {n TO} {n Char}} {n Char}}
00101 Define discard SEMICOLON {x {t \73} {n SPACE}}
00102 Define value Sequence {+ {n Prefix}}
00103 Define discard SLASH {x {t /} {n SPACE}}
00104 Define discard SPACE {* {/ {t \40} {t \t} {n EOL} {n COMMENT}}}
00105 Define leaf STAR {x {t *} {n SPACE}}
00106 Define value StartExpr {x {n OPEN} {n Expression} {n CLOSE}}
00107 Define value Suffix {x {n Primary} {? {/ {n QUESTION} {n STAR} {n PLUS}}}}
00108 Define discard TO {t -}
00109 Define leaf VOID {x {t v} {t o} {t i} {t d} {n SPACE}}
00110 }
00111
00112
00113
00114
00115 package provide pg::peg::grammar 0.1
00116
00117