Ejemplo n.º 1
0
    def p_time_span(p):
        if len(p) > 2:
            time_unit = p[2]
            amount = parseEntireNumber(p[1])
        else:
            time_unit = p[1]
            amount = 1

        days = 0
        hours = 0
        minutes = 0
        seconds = 0
        if time_unit.startswith("tago"):
            days = math.floor(amount)
            hours = 24 * (amount - math.floor(amount))
        elif time_unit.startswith("horo"):
            hours = math.floor(amount)
            minutes = 60 * (amount - math.floor(amount))
        elif time_unit.startswith("minuto"):
            minutes = math.floor(amount)
            seconds = 60 * (amount - math.floor(amount))
        else:
            seconds = amount
        p[0] = node.TimeSpan(node.Number(days), node.Number(hours),
                             node.Number(minutes), node.Number(seconds))
Ejemplo n.º 2
0
 def p_time_point(p):
     parsed_hour = parseEntireNumber(p[2])
     parsed_minutes = parseEntireNumber(p[4])
     if parsed_minutes < 1:
         parsed_minutes = int(60 * parsed_minutes)
     if parsed_minutes >= 60:
         raise EsperantoSyntaxError("Illegal number of minutes entered: " +
                                    str(parsed_minutes))
     p[0] = node.TimePoint(hour=node.Number(parsed_hour),
                           minute=node.Number(parsed_minutes))
Ejemplo n.º 3
0
 def p_time_fractions(p):
     parsed_fraction = parseEntireNumber(p[3])
     if parsed_fraction >= 1:
         raise EsperantoSyntaxError("Illegal time span format, recieved: " +
                                    " ".join(p[3]) + " (" +
                                    str(parsed_fraction) +
                                    ") when expected fraction")
     p[0] = node.TimeFractionAddition(p[1], node.Number(parsed_fraction))
Ejemplo n.º 4
0
 def p_round_time_point(p):
     if p[3] != "horo":
         raise EsperantoSyntaxError(
             "wrong hour format. expected hour descriptor, then minute number."
         )
     p[0] = node.TimePoint(hour=node.Number(parseEntireNumber(p[2])))
Ejemplo n.º 5
0
 def p_factor_numberLiteral(p):
     p[0] = node.Number(parseEntireNumber(p[1]))
Ejemplo n.º 6
0
 def p_factor_number(p):
     p[0] = node.Number(p[1])
Ejemplo n.º 7
0
 def p_factor_unaryMinus(p):
     p[0] = node.Subtract(node.Number(0), p[2])
Ejemplo n.º 8
0
 def p_variable_arrayAccessViaOrdinal(p):
     p[0] = node.ArrayAccess(node.Number(parseEntireNumber(p[1])), p[3])