From 96299cbf09bdb75e4d6c6849c9c4c3ce000a6fc5 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Mon, 10 Nov 2025 12:27:21 +0100 Subject: feat(parser): supports literal decimal numbers --- lib/elixir_math_parser.ex | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/elixir_math_parser.ex') diff --git a/lib/elixir_math_parser.ex b/lib/elixir_math_parser.ex index 4a96daf..286829e 100644 --- a/lib/elixir_math_parser.ex +++ b/lib/elixir_math_parser.ex @@ -4,11 +4,16 @@ defmodule ElixirMathParser do """ alias ElixirMathParser.Math.Rational alias ElixirMathParser.Math.Calc + alias ElixirMathParser.Math.Conversion defp reduce_to_value({:int, _line, value}, _state) do {:ok, Rational.new(value)} end + defp reduce_to_value({:float, _line, value}, _state) do + {:ok, to_string(value) |> Conversion.literal_float_to_rational()} + end + defp reduce_to_value({:var, line, var}, state) do if !Map.has_key?(state, var) do {:error, line, "value not found for " <> to_string(var)} -- cgit v1.2.3