// Parse parses a statement using the language defined in the parse tree.
777377
func (t *ParseTree) Parse(p *Parser) (Statement, error) {
	for {
		tok, pos, lit := p.ScanIgnoreWhitespace()
		if subtree := t.Tokens[tok]; subtree != nil {
			t = subtree
			continue
		}

		if stmt := t.Handlers[tok]; stmt != nil {
			return stmt(p)
		}

		// There were no registered handlers. Return the valid tokens in the order they were added.
		return nil, newParseError(tokstr(tok, lit), t.Keys, pos)
	}
}
271508
func (t *Tree) Parse(buf string) (tree *Tree, err error) {
	t.scanner.init(buf)
	t.Root, err = t.parseAny()
	return t, err
}
996649
func (parser *Parser) Parse() error {
	err := parser.parse()
	if err != nil {
		return err
	}

	if len(parser.previous) > 0 {
		return parser.syntaxError("expected end of section, instead found EOF")
	}

	return nil
}
1049431
func (parser *TransitionParser) Parse(data []byte, state string) ([]byte, ParserStateID) {
	currentStateID := parser.GetStateID(state)

	if currentStateID == ParserStateStop {
		return nil, currentStateID // ### return, immediate stop ###
	}

	currentState := parser.tokens[currentStateID]
	dataLen := len(data)
	readStartIdx := 0
	continueIdx := 0

	for parseIdx := 0; parseIdx < dataLen; parseIdx++ {
		node := currentState.MatchStart(data[parseIdx:])
		if node == nil {
			continue // ### continue, no match ###
		}

		t := node.Payload.(Transition)
		if t.callback != nil {
			if t.flags&ParserFlagInclude != 0 {
				t.callback(data[readStartIdx:parseIdx+node.PathLen], currentStateID)
			} else {
				t.callback(data[readStartIdx:parseIdx], currentStateID)
			}
		}

		// Move the reader
		if t.flags&ParserFlagContinue == 0 {
			parseIdx += node.PathLen - 1
		} else {
			parseIdx--
		}
		continueIdx = parseIdx + 1

		if t.flags&ParserFlagAppend == 0 {
			readStartIdx = continueIdx
		}

		nextStateID := t.nextState

		// Pop before push to allow both at the same time
		if t.flags&ParserFlagPop != 0 {
			stackLen := len(parser.stack)
			if stackLen > 0 {
				nextStateID = parser.stack[stackLen-1]
				parser.stack = parser.stack[:stackLen-1]
			}
		}

		if t.flags&ParserFlagPush != 0 {
			parser.stack = append(parser.stack, currentStateID)
		}

		// Transition to next
		currentStateID = nextStateID
		if currentStateID == ParserStateStop {
			break // ### break, stop state ###
		}

		currentState = parser.tokens[currentStateID]
	}

	if readStartIdx == dataLen {
		return nil, currentStateID // ### return, everything parsed ###
	}

	return data[readStartIdx:], currentStateID
}
899825
func (parser *Parser) Parse(sql, charset, collation string) ([]ast.StmtNode, error) {
	if charset == "" {
		charset = mysql.DefaultCharset
	}
	if collation == "" {
		collation = mysql.DefaultCollationName
	}
	parser.charset = charset
	parser.collation = collation
	parser.src = sql
	parser.result = parser.result[:0]

	var l yyLexer
	parser.lexer.reset(sql)
	l = &parser.lexer
	yyParse(l, parser)

	if len(l.Errors()) != 0 {
		return nil, errors.Trace(l.Errors()[0])
	}
	for _, stmt := range parser.result {
		ast.SetFlag(stmt)
	}
	return parser.result, nil
}
787113
func (t *tree) parse() (_ Node, err error) {
	defer func() {
		if p := recover(); p != nil {
			err = fmt.Errorf("parse error: %v", p)
		}
	}()
	return t.O(0), err
}
106997
func (parser *myParser) Parse(s string) error {
	typ := reflect.TypeOf(parser.ptr)
	val := reflect.ValueOf(parser.ptr)
	if typ.Kind() == reflect.Ptr {
		kind := reflect.Indirect(val).Type().Kind()
		if kind == reflect.Struct {
			typElem, valElem := typ.Elem(), val.Elem()
			numField := valElem.NumField()
			for i := 0; i < numField; i++ {
				_, valField := typElem.Field(i), valElem.Field(i)
				if valField.Kind() == reflect.Int &&
					valField.CanSet() {
					valField.SetInt(2)
				}
				if valField.Kind() == reflect.String &&
					valField.CanSet() {
					valField.SetString("B")
				}
			}
		}
	}
	return nil
}
709418
func Parse(src string) []*Language {
	var langs []*Language
	start := 0
	for end, chr := range src {
		switch chr {
		case ',', ';', '.':
			tag := strings.TrimSpace(src[start:end])
			if spec := GetPluralSpec(tag); spec != nil {
				langs = append(langs, &Language{NormalizeTag(tag), spec})
			}
			start = end + 1
		}
	}
	if start > 0 {
		tag := strings.TrimSpace(src[start:])
		if spec := GetPluralSpec(tag); spec != nil {
			langs = append(langs, &Language{NormalizeTag(tag), spec})
		}
		return dedupe(langs)
	}
	if spec := GetPluralSpec(src); spec != nil {
		langs = append(langs, &Language{NormalizeTag(src), spec})
	}
	return langs
}
695042
func (ep EnumParser) Parse(s string) (interface{}, error) {
	if !ep.CaseMatch {
		s = strings.ToLower(s)
	}
	v, ok := ep.vals[s]
	if !ok {
		return false, fmt.Errorf("failed to parse %s %#q", ep.Type, s)
	}
	return v, nil
}
259640
func (ini *INI) Parse(data []byte, lineSep, kvSep string) error {
    return ini.parseINI(data, lineSep, kvSep)
}
45479
func (p *parserImpl) parse(
	blob json.RawMessage,
) ([]*Comment, []*Post, []*Message, error) {
	comments, posts, msgs, listingErr := parseRawListing(blob)
	if listingErr == nil {
		return comments, posts, msgs, nil
	}

	post, threadErr := parseThread(blob)
	if threadErr == nil {
		return nil, []*Post{post}, nil, nil
	}

	return nil, nil, nil, fmt.Errorf(
		"failed to parse as listing [%v] or thread [%v]",
		listingErr, threadErr,
	)
}
1007053
func Parse(input string) (result *ast.Program, err error) {
	// recover error
	defer errRecover(&err)

	parser := new(input)

	// parse
	result = parser.parseProgram()

	// check last token
	token := parser.shift()
	if token.Kind != lexer.TokenEOF {
		// Parsing ended before EOF
		errToken(token, "Syntax error")
	}

	// fix whitespaces
	processWhitespaces(result)

	// named returned values
	return
}
979397
func (c *ChatPostMessageCall) Parse(parse string) *ChatPostMessageCall {
	c.parse = parse
	return c
}
906559
func (e *Expr) parse(s string) error {
	if s == "" {
		return nil
	}
	node, err := parser.ParseExpr(s)
	if err != nil {
		return err
	}
	e.root = node

	v := &visitor{pool: e.pool}
	ast.Walk(v, e.root)
	return v.err
}
790504
func (t *Tree) parse() {
	t.Root = t.O()
	t.expect(itemEOF, "input")
}
39967
func (p *Parser) Parse(r io.Reader, v interface{}) (err error) {
	rv := reflect.ValueOf(v)
	if rv.Kind() == reflect.Interface {
		rv = rv.Elem()
	}
	var stream reflect.Value
	if rv.Kind() == reflect.Chan {
		stream = rv
		rt := rv.Type().Elem()
		rv = reflect.New(rt).Elem()
	}
	rt := rv.Type()
	if rt != p.typ {
		return fmt.Errorf("must parse into value of type %s not %T", p.typ, v)
	}
	baseLexer, err := p.lex.Lex(r)
	if err != nil {
		return err
	}
	lex := lexer.Upgrade(baseLexer)
	caseInsensitive := map[rune]bool{}
	for sym, rn := range p.lex.Symbols() {
		if p.caseInsensitive[sym] {
			caseInsensitive[rn] = true
		}
	}
	ctx, err := newParseContext(lex, p.useLookahead, caseInsensitive)
	if err != nil {
		return err
	}
	// If the grammar implements Parseable, use it.
	if parseable, ok := v.(Parseable); ok {
		return p.rootParseable(ctx, parseable)
	}
	if rt.Kind() != reflect.Ptr || rt.Elem().Kind() != reflect.Struct {
		return fmt.Errorf("target must be a pointer to a struct, not %s", rt)
	}
	if stream.IsValid() {
		return p.parseStreaming(ctx, stream)
	}
	return p.parseOne(ctx, rv)
}
69847
func Parse(query string) (*Ast, error) {
	l := lex.NewLexer(query, InfluxQlDialect)
	p := Parser{l: l, qryText: query}
	return p.parse()
}