Beispiel #1
0
// InheritedScript provides a parser that succeeds if the Codepoint surrogates to itself
// and is in script Inherited.
func (u UnicodeLexer) InheritedScript() Parser {
	return Satisfy(func(c u8.Codepoint) bool {
		cc := u8.SurrogatePoint(c)
		return len(cc) == 1 && unicode.In(cc[0], unicode.Inherited)
	})
}
Beispiel #2
0
// Printable provides a parser that succeeds if the Codepoint surrogates to itself
// and is printable by Go, i.e. from categories L, M, N, P, S, or U+0020.
func (u UnicodeLexer) Printable() Parser {
	return Satisfy(func(c u8.Codepoint) bool {
		cc := u8.SurrogatePoint(c)
		return len(cc) == 1 && unicode.IsPrint(cc[0])
	})
}
Beispiel #3
0
// SpecialControl provides a parser that succeeds if the Codepoint surrogates to itself
// and is a control character, excluding some such as utf-16 surrogates.
func (u UnicodeLexer) SpecialControl() Parser {
	return Satisfy(func(c u8.Codepoint) bool {
		cc := u8.SurrogatePoint(c)
		return len(cc) == 1 && unicode.IsControl(cc[0])
	})
}
Beispiel #4
0
// UnicodeIn provides a parser that succeeds if the Codepoint surrogates
// to itself, and is a member of one of the ranges.
func (u UnicodeLexer) UnicodeIn(ranges ...*unicode.RangeTable) Parser {
	return Satisfy(func(c u8.Codepoint) bool {
		cc := u8.SurrogatePoint(c)
		return len(cc) == 1 && unicode.In(cc[0], ranges...)
	})
}