Пример #1
0
Файл: ui.go Проект: tav/oldproto
func Identifier(l *lex.Lexer) lex.StateFn {
	typ := ItemIdentifier
	r, _ := utf8.DecodeRuneInString(l.Input[l.Start:])
	if r == '!' {
		l.Ignore()
		typ = ItemBuiltin
	}
	for {
		// should not appear in the first identifier of an expression of sub-expression (since it must be a function)
		r = l.Next()

		if r == ':' {
			typ = ItemArgKey
			l.Backup()
			l.Emit(typ)
			l.Next()
			l.Ignore()
			return InsideAction
		}
		if !IsValidIdentifierChar(r) {
			l.Backup()
			break
		}
	}
	l.Emit(typ)
	return InsideAction
}