// lexVariable scans a Variable: $Alphanumeric.
// The $ has been scanned.
765858
func lexVariable(l *lexer) stateFn {
	if l.atTerminator() { // Nothing interesting follows -> "$".
		l.emit(itemVariable)
		return lexInsideAction
	}
	return lexFieldOrVariable(l, itemVariable)
}
1008523
func (p *Parser) Variable() bool {

	c, _ := p.Byte()

	if c != '$' {
		p.UnreadByte()
		return false
	}

	c, _ = p.Byte()
	if c == '\\' {
		p.ev.Add("$")
		return true
	}

	p.UnreadByte()

	i := p.ev.Level()

	c, _ = p.Byte()
	if c == '(' {
		p.ev.Add(TypeExpression)
		p.ev.Inc()
		p.Expression()
		p.Space()
		p.Byte() // Should be ')'
	} else {
		p.ev.Add(TypePath)
		p.ev.Inc()
		if c != '{' {
			p.UnreadByte()
		} else {
			p.Space()
		}
		p.Path()

		if c == '{' {
			p.Space()
			p.Byte() // Should be '}'
		}
	}

	// Reset the level
	p.ev.SetLevel(i)

	return true

}
912775
func (*GoFlags) StringVar(s *string, o, d, c string) {
	flag.StringVar(s, o, d, c)
}
532191
func NewVariable(v interface{}) (result Variable, err error) {
	switch v := reflect.ValueOf(v); v.Kind() {
	case reflect.String:
		result.Type = TypeString
	default:
		err = fmt.Errorf("Unknown type: %s", v.Kind())
	}

	result.Value = v
	return
}
204886
func (d *FileDescriptor) VarName() string {
	h := sha256.Sum256([]byte(d.GetName()))
	return fmt.Sprintf("fileDescriptor_%s", hex.EncodeToString(h[:8]))
}
731588
func (l *Lexer) consumeCustomVariableToken() bool {
	// expect to be on a '-'
	l.r.Move(1)
	if l.r.Peek(0) != '-' {
		l.r.Move(-1)
		return false
	}
	if !l.consumeIdentToken() {
		l.r.Move(-1)
		return false
	}
	return true
}
367016
func (l *Lexer) Lex(lval *yySymType) int {
	tok, lit, pos, err := l.s.Scan()
	if err != nil {
		l.e = &Error{Message: err.Error(), Pos: pos, Fatal: true}
	}
	lval.tok = ast.Token{Tok: tok, Lit: lit}
	lval.tok.SetPosition(pos)
	l.lit = lit
	l.pos = pos
	return tok
}
1233495
func lex(name, input, left, right string) *lexer {
	if left == "" {
		left = leftDelim
	}
	if right == "" {
		right = rightDelim
	}
	l := &lexer{
		name:       name,
		input:      input,
		leftDelim:  left,
		rightDelim: right,
		items:      make(chan item),
	}
	go l.run()
	return l
}
335308
func (s *numericCompilerVisitor) AcceptVariable(v tree.Variable) {
	s.err = errors.New("a variable was found in an expression - this is likely a programmer error")
}
1313270
func lexDataPrefix(l *lexer) stateFn {
	l.pos += len(dataPrefix)
	l.emit(itemDataPrefix)
	return lexAfterDataPrefix
}
1134112
func parseVariableDefinition(parser *Parser) (interface{}, error) {
	var (
		variable *ast.Variable
		ttype    ast.Type
		err      error
	)
	start := parser.Token.Start
	if variable, err = parseVariable(parser); err != nil {
		return nil, err
	}
	if _, err = expect(parser, lexer.COLON); err != nil {
		return nil, err
	}
	if ttype, err = parseType(parser); err != nil {
		return nil, err
	}
	var defaultValue ast.Value
	if skp, err := skip(parser, lexer.EQUALS); err != nil {
		return nil, err
	} else if skp {
		if defaultValue, err = parseValueLiteral(parser, true); err != nil {
			return nil, err
		}
	}
	return ast.NewVariableDefinition(&ast.VariableDefinition{
		Variable:     variable,
		Type:         ttype,
		DefaultValue: defaultValue,
		Loc:          loc(parser, start),
	}), nil
}
701539
func (s *Service) UpdateVariable(ctx context.Context, id platform.ID, update *platform.VariableUpdate) (*platform.Variable, error) {
	op := OpPrefix + platform.OpUpdateVariable
	variable, err := s.FindVariableByID(ctx, id)
	if err != nil {
		return nil, &platform.Error{
			Op:  op,
			Err: err,
		}
	}

	if err := update.Apply(variable); err != nil {
		return nil, &platform.Error{
			Op:  op,
			Err: err,
		}
	}

	if err := s.ReplaceVariable(ctx, variable); err != nil {
		return nil, &platform.Error{
			Op:  op,
			Err: err,
		}
	}

	return variable, nil
}
1089905
func (rule *Rule) AddVariable(variable *Variable) {
	for key, existingVariable := range rule.Variables {
		if existingVariable.Name == variable.Name {
			rule.Variables[key] = variable

			return
		}
	}

	rule.Variables = append(rule.Variables, variable)
}
1226524
func (lex *GotestLexer) Scan() bool {
	if !lex.scanner.Scan() {
		return false
	}
	if lex.scanner.Err() != nil {
		return false
	}

	line := lex.scanner.Text()
	lnum := lex.scanner.Line()
	found := false
	for _, typ := range gtTypes {
		if typ.re.MatchString(line) {
			found = true
			lex.tok = &Token{lnum, typ.typ, line}
			break
		}
	}
	if !found {
		lex.tok = &Token{lnum, DataToken, line}
	}

	return true
}
65037
func lexField(l *lexer) stateFn {

	if l.atTerminator() {
		// Nothing interesting follows -> "." or "$".
		l.emit(itemIdentifier)
		return lexInsideAction
	}

	var r rune
	for {
		r = l.next()
		if !isAlphaNumeric(r) {
			l.backup()
			break
		}
	}
	if !l.atTerminator() {
		return l.errorf("bad character %#U", r)
	}
	l.emit(itemField)
	return lexInsideAction
}
1077979
func listVariableSliceToVariableValue(values [][]ast.Variable) []ast.Variable {
	output := make([]ast.Variable, len(values))

	for index, value := range values {
		output[index] = ast.Variable{
			Type:  ast.TypeList,
			Value: value,
		}
	}
	return output
}
302183
func lexVariables(l *lexer) stateFn {
	for {
		n := l.eatSpaceAndComments()
		if n == '@' {
			l.acceptWord()
			l.emit(itemVarName)
			n = l.maybeSpace()
			if n == '=' {
				l.emit(itemEquals)
			}
			n = l.maybeSpace()
			if n == eof {
				l.errorf("unterminated variable assignment")
				return nil
			} else if any(n, quotes) {
				err := l.acceptQuotedString(n)
				if err != nil {
					l.errorf("%s", err)
					return nil
				}
				l.emit(itemQuotedString)
			} else if !any(n, bareStringDisallowed) {
				l.acceptLine(true)
				l.emit(itemBareString)
			} else {
				l.errorf("= must be followed by a string")
				return nil
			}
		} else {
			l.backup()
			return lexPatterns
		}
	}
}