Exemplo n.º 1
0
func Parse(input string, options *ParseOptions) (*ast.Document, error) {
	source := ast.NewSource(input, "")
	parser, err := newParser(source, options)
	if err != nil {

	}
	return parseDocument(parser)
}
Exemplo n.º 2
0
func ParseValue(input string, options *ParseOptions) {
	source := ast.NewSource(input, "")
	parser, err := newParser(source, options)
	if err != nil {

	}
	return parseValueLiteral(parser)
}
Exemplo n.º 3
0
func TestDollar(t *testing.T) {
	source := ast.NewSource("$", "")
	result, err := Lex(source)(-1)
	expect(t, err, result, DOLLAR, 0, 1, "")
}
Exemplo n.º 4
0
func TestWhitespace(t *testing.T) {
	source := ast.NewSource("\n   foo   \n   ", "")
	result, err := Lex(source)(-1)
	expect(t, err, result, NAME, 4, 7, "foo")
}
Exemplo n.º 5
0
func TestScience(t *testing.T) {
	source := ast.NewSource("123e+4", "")
	result, err := Lex(source)(-1)
	expect(t, err, result, FLOAT, 0, 6, "123e+4")
}
Exemplo n.º 6
0
func TestBang(t *testing.T) {
	source := ast.NewSource("!", "")
	result, err := Lex(source)(-1)
	expect(t, err, result, BANG, 0, 1, "")
}
Exemplo n.º 7
0
func TestNegative(t *testing.T) {
	source := ast.NewSource("-4", "")
	result, err := Lex(source)(-1)
	expect(t, err, result, INT, 0, 2, "-4")
}
Exemplo n.º 8
0
func TestDecimal(t *testing.T) {
	source := ast.NewSource("0.123", "")
	result, err := Lex(source)(-1)
	expect(t, err, result, FLOAT, 0, 5, "0.123")
}
Exemplo n.º 9
0
func TestSlashes(t *testing.T) {
	source := ast.NewSource("\"slashes \\\\ \\/\"", "")
	result, err := Lex(source)(-1)
	expect(t, err, result, STRING, 0, 15, "slashes \\ /")
}
Exemplo n.º 10
0
func TestInt(t *testing.T) {
	source := ast.NewSource("4", "")
	result, err := Lex(source)(-1)
	expect(t, err, result, INT, 0, 1, "4")
}
Exemplo n.º 11
0
func TestEscaped(t *testing.T) {
	source := ast.NewSource("\"escaped \\n\\r\\b\\t\\f\"", "")
	result, err := Lex(source)(-1)
	expect(t, err, result, STRING, 0, 20, "escaped \n\r\b\t\f")
}
Exemplo n.º 12
0
func TestQuotes(t *testing.T) {
	source := ast.NewSource("\"quote \\\"\"", "")
	result, err := Lex(source)(-1)
	expect(t, err, result, STRING, 0, 10, "quote \"")
}
Exemplo n.º 13
0
func TestWhitespaceString(t *testing.T) {
	source := ast.NewSource("\" white space \"", "")
	result, err := Lex(source)(-1)
	expect(t, err, result, STRING, 0, 15, " white space ")
}
Exemplo n.º 14
0
func TestSimpleString(t *testing.T) {
	source := ast.NewSource("\"simple\"", "")
	result, err := Lex(source)(-1)
	expect(t, err, result, STRING, 0, 8, "simple")
}
Exemplo n.º 15
0
func TestComments(t *testing.T) {
	source := ast.NewSource("#hello\nfoo#comment", "")
	result, err := Lex(source)(-1)
	expect(t, err, result, NAME, 7, 10, "foo")
}