diff options
Diffstat (limited to 'tools/Scanner.lean')
| -rw-r--r-- | tools/Scanner.lean | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/tools/Scanner.lean b/tools/Scanner.lean index d6962c7..81b4181 100644 --- a/tools/Scanner.lean +++ b/tools/Scanner.lean @@ -1,22 +1,25 @@ import Scanner.Protocol import Scanner.Parser +import Scanner.Processor open WaylandScanner -def parseProtocol (path : System.FilePath) : IO ProtocolDesc := do +def parseRawProtocol (path : System.FilePath) : IO Raw.ProtocolDesc := do parse (← IO.FS.readFile path) |>.mapError (fun ε ↦ s!"{path}: {ε}") |> IO.ofExcept def process (rootModule : String) (outPath : System.FilePath) (srcPath : System.FilePath) : IO UInt32 := do - let protocols ← (← srcPath.readDir) + let rawProtocols ← (← srcPath.readDir) |>.map IO.FS.DirEntry.path - |>.mapM parseProtocol + |>.mapM parseRawProtocol + let clientProtocols ← processProtocols rawProtocols + |> IO.ofExcept let rootModuleComponents := rootModule.split "." |>.map String.Slice.toString |>.toArray let rootModulePath := rootModuleComponents.foldl (· / ·) outPath - IO.println (reprStr protocols) + IO.println (reprStr clientProtocols) IO.FS.createDirAll rootModulePath let indexPath := rootModulePath.addExtension "lean" IO.FS.writeFile indexPath "" |
