Example #1
0
var (
	Rule = any_type

	any_type        = sickle.Indirect()
	any_type_actual = sickle.Choice(
		b_dict,
		b_list,
		b_string,
		b_int,
	)

	b_dict   = sickle.Seq(dict_start, dict_elements, end)
	b_list   = sickle.Seq(list_start, list_elements, end)
	b_int    = sickle.Seq(int_start, b_sint, end)
	b_string = sickle.LengthValue(sickle.Left(parseUint(b_uint), colon), sickle.Byte())

	dict_elements = sickle.Many(dict_element)
	list_elements = sickle.Many(list_element)

	dict_element = sickle.Seq(b_string, any_type)
	list_element = any_type

	b_uint = flatten(sickle.Choice(zero, whole_num))
	b_sint = flatten(sickle.Choice(zero, whole_num, neg_num))

	zero      = sickle.Ch('0')
	whole_num = sickle.Seq(pos_digit, sickle.Many(digit))
	neg_num   = sickle.Seq(neg, whole_num)

	neg       = sickle.Ch('-')
Example #2
0
// ndt is used to wrap "non-delimiting terminal symbols". These are symbols
// which must be delimited by either a delimiting terminal symbol or whitespace.
func ndt(r sickle.Rule) sickle.Rule {
	return sickle.Left(
		r,
		sickle.And(sickle.Choice(ws, delimiting_terminal_symbol, sickle.End())),
	)
}