aboutsummaryrefslogtreecommitdiff
path: root/lib/main.ex
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <william@herges.fr>2025-11-04 12:30:35 +0100
committerAnhgelus Morhtuuzh <william@herges.fr>2025-11-04 12:30:35 +0100
commit4ac065fbe57ed19760dbb55453e5875b3c0c188d (patch)
tree09d8bdc002902ffe5cc353b563fb489bdbddc254 /lib/main.ex
parentcc2b7a9a7b4c6269a6b93f99581b91b29fccc66d (diff)
feat(parser): default parser
Diffstat (limited to 'lib/main.ex')
-rw-r--r--lib/main.ex28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/main.ex b/lib/main.ex
new file mode 100644
index 0000000..ca73cb5
--- /dev/null
+++ b/lib/main.ex
@@ -0,0 +1,28 @@
+defmodule ElixirMathParser.Main do
+ def process_parse({:error, result}) do
+ IO.puts "\nParse error"
+ IO.inspect result
+ end
+
+ def process_parse({:ok, tree}) do
+ IO.puts "\nParse tree"
+ IO.inspect tree, pretty: true
+ state = ElixirMathParser.process_tree(tree)
+ IO.puts "\nFinal state"
+ IO.inspect state, pretty: true
+ end
+
+ def main(args) do
+ filename = Enum.fetch!(args, 0)
+
+ IO.puts "Parsing #{filename}"
+ text = File.read!(filename)
+
+ {:ok, tokens, line} = :elixir_math_parser_lexer.string(String.to_charlist(text))
+ IO.puts "Parsed #{filename}, stopped at line #{line}"
+ IO.puts "\nTokens:"
+ IO.inspect tokens, pretty: true
+
+ process_parse(:elixir_math_parser.parse(tokens))
+ end
+end