def t_VAR_CURSOR(t): r'([a-zA-Z]\|)|(\|[a-zA-Z])' varString = t.value cursor_idx = varString.index('|') varString = varString.replace('|', '') t.value = xp.NoOpExpression(varString, True, cursor_idx) return t
def t_NUM_CURSOR(t): r'(\d+\|\d*)|(\d*\|\d+)' numString = t.value cursor_idx = numString.index('|') numString = numString.replace('|', '') t.value = xp.NoOpExpression(numString, True, cursor_idx) return t
def __init__(self, midleft): self.midleft = midleft self.text = "" self.index = 0 self.exp = xp.NoOpExpression("") self.surf = xts.smartSurface(self.exp, cursor_show=show_cursor()) self.rect = pygame.Rect( (self.midleft[0], self.midleft[1]), (self.surf.get_rect().w, self.surf.get_rect().h)) self.is_active = False uiExpression.allUiExpressions += [self]
def get_exp(inputStr): if inputStr[1:] == 'loading': return xp.Expression(op.Operator('loading...', lambda x: ''), [xp.NoOpExpression("")]) global error error = False print('processing', inputStr.replace('\u2986', '$').replace('\u2985', '#')) inputStr = preprocess(inputStr) print('got', inputStr.replace('\u2986', '$').replace('\u2985', '#')) resultingExpression = parser.parse(inputStr) if error: raise ValueError("Expression could not parse correctly.") else: return resultingExpression
def p_exp3_cempty(p): 'exp3 : UNF_CURSOR empty' p[0] = xp.NoOpExpression("", True, 0)
def p_exp3_empty(p): 'exp3 : empty' p[0] = xp.NoOpExpression("")
def t_NUMBER(t): r'\d+(\.\d+)?' t.value = xp.NoOpExpression(str(t.value)) return t
def t_VAR(t): r'[a-zA-Z]' t.value = xp.NoOpExpression(t.value) return t