Diff

Differences From Artifact [6601f36901]:

To Artifact [bccb31a2c9]:


86
87
88
89
90
91
92
















93
94
95
96
	return func(s string) (N, string) {
		n, r := accept(s)
		if !n.Matched {
			return n, s
		}
		if n.Content == value {
			return n, r
















		}
		return N{Matched: false, Content: "", Nodes: []N{n}}, s
	}
}







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>




86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
	return func(s string) (N, string) {
		n, r := accept(s)
		if !n.Matched {
			return n, s
		}
		if n.Content == value {
			return n, r
		}
		return N{Matched: false, Content: "", Nodes: []N{n}}, s
	}
}

// Returns a parser that matches any single digit
// It could have been written as Any(String("0"),String("1"),...,String("9")) as well :)
func Digit() P {
	accept := Accept(1)
	return func(s string) (N, string) {
		n, r := accept(s)
		if !n.Matched {
			return n, s
		}
		if n.Content[0] >= 48 && n.Content[0] <= 57 {
			return n, r
		}
		return N{Matched: false, Content: "", Nodes: []N{n}}, s
	}
}