Skip to content

Commit

Permalink
Merge pull request #53 from CSchank/dev
Browse files Browse the repository at this point in the history
NFA/DFA Checks Implementation
  • Loading branch information
CSchank authored Feb 7, 2019
2 parents be99197 + 5d7828c commit 1e75e9d
Show file tree
Hide file tree
Showing 3 changed files with 445 additions and 78 deletions.
6 changes: 5 additions & 1 deletion src/Building.elm
Original file line number Diff line number Diff line change
Expand Up @@ -467,12 +467,16 @@ update env msg ( model, pModel, sModel ) =
case model.machineState of
SelectedState stId ->
let
new_q =
Set.remove stId oldMachine.q

newDelta =
Dict.map (\_ d -> Dict.filter (\tId _ -> not <| Dict.member tId removedTransitions) d) oldMachine.delta
|> Dict.filter (\key _ -> Set.member key new_q)

newMachine =
{ oldMachine
| q = Set.remove stId oldMachine.q
| q = new_q
, delta = newDelta
, start = Set.remove stId oldMachine.start
, final = Set.remove stId oldMachine.final
Expand Down
49 changes: 11 additions & 38 deletions src/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ type Msg
| UrlChange Url
| UrlRequest UrlRequest
| GoTo Module
| ShowModal
| HideModal


type Module
Expand All @@ -52,7 +50,6 @@ type ApplicationState
type alias Model =
{ appModel : BetterUndoList ApplicationModel
, environment : Environment
, alertModalOpen : Bool
}


Expand Down Expand Up @@ -81,7 +78,6 @@ main =
\flags url key ->
( { appModel = initAppModel
, environment = Environment.init
, alertModalOpen = False
}
, Task.perform (\vp -> WindowSize ( round vp.viewport.width, round vp.viewport.height )) Browser.Dom.getViewport
)
Expand Down Expand Up @@ -201,7 +197,7 @@ update msg model =

KeyPressed k ->
if k == 16 then
( { model | environment = { oldEnvironment | holdingShift = True } }, Helpers.sendMsg <| HideModal )
( { model | environment = { oldEnvironment | holdingShift = True } }, Cmd.none )

else if k == 89 {- y -} || k == 90 {- z -} then
let
Expand All @@ -223,16 +219,16 @@ update msg model =
else
model.appModel
}
, Helpers.sendMsg <| HideModal
, Cmd.none
)

else if k == 91 then
--pressed meta key
( { model | environment = { oldEnvironment | holdingMeta = True } }, Helpers.sendMsg <| HideModal )
( { model | environment = { oldEnvironment | holdingMeta = True } }, Cmd.none )

else if k == 17 then
--pressed control
( { model | environment = { oldEnvironment | holdingControl = True } }, Helpers.sendMsg <| HideModal )
( { model | environment = { oldEnvironment | holdingControl = True } }, Cmd.none )
{- else if k == 66 then
( model, sendMsg <| GoTo BuildingModule )
Expand All @@ -241,7 +237,7 @@ update msg model =
-}

else
( model, Helpers.sendMsg <| HideModal )
( model, Cmd.none )

GoTo mod ->
let
Expand Down Expand Up @@ -300,35 +296,17 @@ update msg model =

newAppState =
{ currentAppState | appState = Simulating simModel, simulatingData = pModel, sharedModel = sModel }

hasTransitionMistakes =
case sModel.machine.transitionMistakes of
Nothing ->
False

_ ->
True
in
if hasTransitionMistakes then
( model.appModel, Helpers.sendMsg <| ShowModal )

else
( if checkpoint then
new newAppState model.appModel
( if checkpoint then
new newAppState model.appModel

else
replace newAppState model.appModel
, Cmd.map SMsg sCmd
)
else
replace newAppState model.appModel
, Cmd.map SMsg sCmd
)
in
( { model | appModel = enter }, cmd )

ShowModal ->
( { model | alertModalOpen = True }, Cmd.none )

HideModal ->
( { model | alertModalOpen = False }, Cmd.none )


textHtml : String -> Html msg
textHtml t =
Expand Down Expand Up @@ -368,11 +346,6 @@ view model =
, icon False (text "?" |> size 30 |> fixedwidth |> centered |> filled (rgb 220 220 220) |> move ( 0, -9 ))
|> addHyperlink "https://github.com/CSchank/finsm/wiki"
|> move ( winX / 2 - 25, -winY / 2 + 25 )
, if model.alertModalOpen then
errorEpsTrans model

else
group []
]


Expand Down
Loading

0 comments on commit 1e75e9d

Please sign in to comment.