Exemple #1
0
	"io/ioutil"
	"log"
	"os"

	"github.com/davecgh/go-spew/spew"
	"sickle"
)

func init() {
	expr.Bind(expr_actual)
}

var (
	Rule = expr

	expr        = sickle.Indirect()
	expr_actual = sickle.Choice(
		sickle.Seq(sickle.Ch('('), expr, sickle.Ch(')')),
		additive_term,
	)

	additive_term = sickle.Choice(
		sickle.Seq(multiplicative_term, sickle.Ch('+'), multiplicative_term),
		sickle.Seq(multiplicative_term, sickle.Ch('-'), multiplicative_term),
		multiplicative_term,
	)

	multiplicative_term = sickle.Choice(
		sickle.Seq(digit, sickle.Ch('*'), digit),
		sickle.Seq(digit, sickle.Ch('/'), digit),
		digit,
Exemple #2
0
}

var (
	Rule = xpath

	xpath = expr

	param_list = tokSepBy1(param, comma)

	param = tokSeq(dollar_sign, eq_name, sickle.Opt(type_declaration))

	function_body = enclosed_expr

	enclosed_expr = tokSeq(left_brace, expr, right_brace)

	expr        = sickle.Indirect()
	expr_actual = tokSepBy1(expr_single, comma)

	expr_single        = sickle.Indirect()
	expr_single_actual = sickle.Choice(
		for_expr,
		let_expr,
		quantified_expr,
		if_expr,
		or_expr,
	)

	for_expr = tokSeq(simple_for_clause, return_token, expr_single)

	simple_for_clause = tokSeq(for_token, tokSepBy1(simple_for_binding, comma))
Exemple #3
0
	"io/ioutil"
	"log"
	"os"
	"strconv"

	"sickle"
)

func init() {
	any_type.Bind(any_type_actual)
}

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)
Exemple #4
0
// Whitespace
var (
	ws = sickle.Many1(sickle.Choice(
		ws_char,
		comment,
	))

	ws_char = sickle.Choice(
		sickle.Ch(0x20),
		sickle.Ch(0x9),
		sickle.Ch(0xD),
		sickle.Ch(0xA),
	)

	comment        = sickle.Indirect()
	comment_actual = sickle.Seq(
		comment_start,
		sickle.Many(sickle.Choice(comment_contents, comment)),
		comment_end,
	)

	comment_contents = sickle.Many1(sickle.Right(
		sickle.Not(sickle.Choice(comment_start, comment_end)),
		char,
	))

	comment_start = sickle.TokenStr("(:")
	comment_end   = sickle.TokenStr(":)")

	char = sickle.Choice(