From 750246dcfde061ec0748dba5f2ce3dc7f1d98208 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Sat, 12 Jul 2025 07:19:34 +0100 Subject: [PATCH] format files related to parser --- fcore/parser/all-dfa.sml | 33 +++++++++++++++++++++------------ fcore/parser/brace-dfa.sml | 16 +++++----------- fcore/parser/int-dfa.sml | 11 ++++------- fcore/parser/parse-grid.sml | 15 ++++++++------- fcore/parser/space-dfa.sml | 11 +++-------- 5 files changed, 41 insertions(+), 45 deletions(-) diff --git a/fcore/parser/all-dfa.sml b/fcore/parser/all-dfa.sml index 79b2b3d..67b8a9f 100644 --- a/fcore/parser/all-dfa.sml +++ b/fcore/parser/all-dfa.sml @@ -1,17 +1,21 @@ structure AllDfa = struct - type t = {curInt: int, curSpace: int, curBrace: int, lastInt: int, - lastSpace: int, lastBrace: int} + type t = + { curInt: int + , curSpace: int + , curBrace: int + , lastInt: int + , lastSpace: int + , lastBrace: int + } val initial: t = - { - curInt = IntDfa.start, - curSpace = SpaceDfa.start, - curBrace = BraceDfa.start, - - lastInt = ~1, - lastSpace = ~1, - lastBrace = ~1 + { curInt = IntDfa.start + , curSpace = SpaceDfa.start + , curBrace = BraceDfa.start + , lastInt = ~1 + , lastSpace = ~1 + , lastBrace = ~1 } fun areAllDead ({curInt, curSpace, curBrace, ...}: t) = @@ -29,7 +33,12 @@ struct val lastSpace = if SpaceDfa.isFinal curSpace then pos else lastSpace val lastBrace = if BraceDfa.isFinal curBrace then pos else lastBrace in - {curInt = curInt, curSpace = curSpace, curBrace = curBrace, lastInt = - lastInt, lastBrace = lastBrace, lastSpace = lastSpace} + { curInt = curInt + , curSpace = curSpace + , curBrace = curBrace + , lastInt = lastInt + , lastBrace = lastBrace + , lastSpace = lastSpace + } end end diff --git a/fcore/parser/brace-dfa.sml b/fcore/parser/brace-dfa.sml index 6c376e4..898da35 100644 --- a/fcore/parser/brace-dfa.sml +++ b/fcore/parser/brace-dfa.sml @@ -1,17 +1,12 @@ -structure BraceDfa = -struct +structure BraceDfa = +struct val dead = 0 val start = 1 val final = 2 fun makeStart i = - let - val chr = Char.chr i - in - if chr = #"{" orelse chr = #"}" then - final - else - dead + let val chr = Char.chr i + in if chr = #"{" orelse chr = #"}" then final else dead end val deadTable = SpaceDfa.deadTable @@ -20,8 +15,7 @@ struct val tables = #[deadTable, startTable, finalTable] - fun isFinal state = - state = final + fun isFinal state = state = final fun next (state, chr) = let diff --git a/fcore/parser/int-dfa.sml b/fcore/parser/int-dfa.sml index 2f70b75..01a6718 100644 --- a/fcore/parser/int-dfa.sml +++ b/fcore/parser/int-dfa.sml @@ -5,20 +5,17 @@ struct val final = 2 fun makeStart i = - let - val chr = Char.chr i - in - if Char.isDigit chr then final else dead + let val chr = Char.chr i + in if Char.isDigit chr then final else dead end val deadTable = Vector.tabulate (255, fn _ => dead) - val startTable = Vector.tabulate (255, makeStart) + val startTable = Vector.tabulate (255, makeStart) val finalTable = startTable val tables = #[deadTable, startTable, finalTable] - fun isFinal state = - state = final + fun isFinal state = state = final fun next (state, chr) = let diff --git a/fcore/parser/parse-grid.sml b/fcore/parser/parse-grid.sml index 84aabb0..4eae661 100644 --- a/fcore/parser/parse-grid.sml +++ b/fcore/parser/parse-grid.sml @@ -3,23 +3,24 @@ struct fun make (canvasWidth, canvasHeight) = let val maxPoints = Int.max (canvasWidth, canvasHeight) - val emptyYAxis = Vector.tabulate (maxPoints, fn _ => {r = 0, g = 0, b = 0, a = 0}) + val emptyYAxis = Vector.tabulate (maxPoints, fn _ => + {r = 0, g = 0, b = 0, a = 0}) in Vector.tabulate (maxPoints, fn _ => emptyYAxis) end local fun loopY (yAxis, x, ex, y, ey, colour) = - if y > ey then yAxis + if y > ey then + yAxis else - let - val yAxis = Vector.update (yAxis, y, colour) - in - loopY (yAxis, x, ex, y + 1, ey, colour) + let val yAxis = Vector.update (yAxis, y, colour) + in loopY (yAxis, x, ex, y + 1, ey, colour) end fun loopX (grid, x, ex, y, ey, colour) = - if x > ex then grid + if x > ex then + grid else let val yAxis = Vector.sub (grid, x) diff --git a/fcore/parser/space-dfa.sml b/fcore/parser/space-dfa.sml index a030ca1..01aec5e 100644 --- a/fcore/parser/space-dfa.sml +++ b/fcore/parser/space-dfa.sml @@ -7,12 +7,8 @@ struct fun makeDead _ = 0 fun makeStart i = - let - val chr = Char.chr i - in - if Char.isSpace chr - then final - else dead + let val chr = Char.chr i + in if Char.isSpace chr then final else dead end val deadTable = Vector.tabulate (255, makeDead) @@ -21,8 +17,7 @@ struct val tables = #[deadTable, startTable, finalTable] - fun isFinal state = - state = final + fun isFinal state = state = final fun next (state, chr) = let