From 376852b59adce3d2b06e6cde3877e965f814aa7a Mon Sep 17 00:00:00 2001 From: Nikolai Kudasov Date: Thu, 21 Dec 2023 11:40:03 +0300 Subject: [PATCH 01/15] Initialize normalizer project with BNFC --- .gitattributes | 1 + .gitignore | 34 + README.md | 64 +- eo-phi-normalizer/.gitignore | 2 + eo-phi-normalizer/CHANGELOG.md | 11 + eo-phi-normalizer/LICENSE | 30 + eo-phi-normalizer/README.md | 1 + eo-phi-normalizer/Setup.hs | 32 + eo-phi-normalizer/app/Main.hs | 6 + eo-phi-normalizer/eo-phi-normalizer.cabal | 99 + eo-phi-normalizer/grammar/EO/Phi/Syntax.cf | 49 + eo-phi-normalizer/package.yaml | 80 + eo-phi-normalizer/src/Language/EO/Phi.hs | 60 + .../src/Language/EO/Phi/Syntax/Abs.hs | 161 + .../src/Language/EO/Phi/Syntax/Abs.hs.bak | 157 + .../src/Language/EO/Phi/Syntax/Doc.txt | 91 + .../src/Language/EO/Phi/Syntax/Doc.txt.bak | 89 + .../src/Language/EO/Phi/Syntax/ErrM.hs | 91 + .../src/Language/EO/Phi/Syntax/ErrM.hs.bak | 91 + .../src/Language/EO/Phi/Syntax/Lex.hs | 6868 +++++++++++++++++ .../src/Language/EO/Phi/Syntax/Lex.x | 264 + .../src/Language/EO/Phi/Syntax/Lex.x.bak | 264 + .../src/Language/EO/Phi/Syntax/Par.hs | 1523 ++++ .../src/Language/EO/Phi/Syntax/Par.info | 1227 +++ .../src/Language/EO/Phi/Syntax/Par.y | 214 + .../src/Language/EO/Phi/Syntax/Par.y.bak | 212 + .../src/Language/EO/Phi/Syntax/Print.hs | 216 + .../src/Language/EO/Phi/Syntax/Print.hs.bak | 214 + .../src/Language/EO/Phi/Syntax/Skel.hs | 84 + .../src/Language/EO/Phi/Syntax/Skel.hs.bak | 82 + .../src/Language/EO/Phi/Syntax/Test.hs | 76 + .../src/Language/EO/Phi/Syntax/Test.hs.bak | 76 + eo-phi-normalizer/test/Language/EO/PhiSpec.hs | 26 + eo-phi-normalizer/test/Spec.hs | 1 + eo-phi-normalizer/test/eo/phi/test.phi | 4 + .../test/eo/phi/test.phi.normalized | 4 + eo-phi-normalizer/test/eo/phi/test.phi.pretty | 4 + hie.yaml | 10 + stack.yaml | 3 + stack.yaml.lock | 12 + 40 files changed, 12532 insertions(+), 1 deletion(-) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 eo-phi-normalizer/.gitignore create mode 100644 eo-phi-normalizer/CHANGELOG.md create mode 100644 eo-phi-normalizer/LICENSE create mode 100644 eo-phi-normalizer/README.md create mode 100644 eo-phi-normalizer/Setup.hs create mode 100644 eo-phi-normalizer/app/Main.hs create mode 100644 eo-phi-normalizer/eo-phi-normalizer.cabal create mode 100644 eo-phi-normalizer/grammar/EO/Phi/Syntax.cf create mode 100644 eo-phi-normalizer/package.yaml create mode 100644 eo-phi-normalizer/src/Language/EO/Phi.hs create mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Syntax/Abs.hs create mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Syntax/Abs.hs.bak create mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt create mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt.bak create mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Syntax/ErrM.hs create mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Syntax/ErrM.hs.bak create mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.hs create mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.x create mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.x.bak create mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.hs create mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.info create mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y create mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y.bak create mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs create mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs.bak create mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Syntax/Skel.hs create mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Syntax/Skel.hs.bak create mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Syntax/Test.hs create mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Syntax/Test.hs.bak create mode 100644 eo-phi-normalizer/test/Language/EO/PhiSpec.hs create mode 100644 eo-phi-normalizer/test/Spec.hs create mode 100644 eo-phi-normalizer/test/eo/phi/test.phi create mode 100644 eo-phi-normalizer/test/eo/phi/test.phi.normalized create mode 100644 eo-phi-normalizer/test/eo/phi/test.phi.pretty create mode 100644 hie.yaml create mode 100644 stack.yaml create mode 100644 stack.yaml.lock diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..7fe8702d8 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +eo-phi-normalizer/src/Language/EO/Phi/Syntax/* linguist-generated=true diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..4d1733fd7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,34 @@ +.cache/ +.DS_Store +dist +dist-* +cabal-dev +build +*.o +*.hi +*.hie +*.chi +*.chs.h +*.dyn_o +*.dyn_hi +.hpc +.hsenv +.cabal-sandbox/ +cabal.sandbox.config +*.prof +*.aux +*.hp +*.eventlog +.stack-work/ +cabal.project.local +cabal.project.local~ +.HTF/ +.ghc.environment.* +docs/site +result +.direnv +venv +__pycache__ +*.fdb_latexmk +*.fls +*.log diff --git a/README.md b/README.md index 471ae1f21..fb3b23ab0 100644 --- a/README.md +++ b/README.md @@ -1 +1,63 @@ -Command line normalizer of 𝜑-calculus expressions. \ No newline at end of file +# Normalizer for 𝜑-calculus + +Command line normalizer of 𝜑-calculus expressions (as produced by the [EO compiler](https://github.com/objectionary/eo)). + +## About + +This project aims to apply term rewriting techniques to "simplify" an input 𝜑-expression +and prepare it for further optimization passes. The simplification procedure is expected +to be a form of partial evaluation and normalization. +Contrary to traditional normalization in λ-calculus, we aim at rewriting rules that would +help reduce certain metrics of expressions. In particular, we are interested in reducing +attribute access (`t.a`) that amounts to _dynamic dispatch_. + +## Usage + +You can install the normalizer locally with [Stack](https://docs.haskellstack.org/en/stable/README/): + +```sh +git clone https://github.com/objectionary/normalizer.git +cd normalizer +stack install +``` + +This should install `normalize-phi` executable (usually, to `~/.local/bin/` on Linux and macOS). +You can pass a 𝜑-program (e.g. from a file) to it: + +```sh +normalize-phi < FILE +``` + +The output should be a 𝜑-term after normalization. + +## Development + +The project is developed with the [Stack tool](https://docs.haskellstack.org/en/stable/README/). + +For quick local development and testing it is recommended to use `stack`. Clone this project and run `stack build`: + +```sh +git clone https://github.com/objectionary/normalizer.git +cd normalizer +stack build +``` + +The build provides an executable `normalize-phi` which can be used to normalize input expressions: + +```sh +stack exec -- normalize-phi < FILE +``` + +You can also build and run the (default) executable using `stack run`: + +```sh +stack run < FILE +``` + +To run (all) tests, simply use + +```sh +stack test +``` + +[^1]: diff --git a/eo-phi-normalizer/.gitignore b/eo-phi-normalizer/.gitignore new file mode 100644 index 000000000..c368d453b --- /dev/null +++ b/eo-phi-normalizer/.gitignore @@ -0,0 +1,2 @@ +.stack-work/ +*~ \ No newline at end of file diff --git a/eo-phi-normalizer/CHANGELOG.md b/eo-phi-normalizer/CHANGELOG.md new file mode 100644 index 000000000..e90b64123 --- /dev/null +++ b/eo-phi-normalizer/CHANGELOG.md @@ -0,0 +1,11 @@ +# Changelog for `eo-phi-normalizer` + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to the +[Haskell Package Versioning Policy](https://pvp.haskell.org/). + +## Unreleased + +## 0.1.0.0 - YYYY-MM-DD diff --git a/eo-phi-normalizer/LICENSE b/eo-phi-normalizer/LICENSE new file mode 100644 index 000000000..c5b6c1669 --- /dev/null +++ b/eo-phi-normalizer/LICENSE @@ -0,0 +1,30 @@ +Copyright Author name here (c) 2023 + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of Author name here nor the names of other + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/eo-phi-normalizer/README.md b/eo-phi-normalizer/README.md new file mode 100644 index 000000000..125734ca3 --- /dev/null +++ b/eo-phi-normalizer/README.md @@ -0,0 +1 @@ +# eo-phi-normalizer diff --git a/eo-phi-normalizer/Setup.hs b/eo-phi-normalizer/Setup.hs new file mode 100644 index 000000000..ce054df98 --- /dev/null +++ b/eo-phi-normalizer/Setup.hs @@ -0,0 +1,32 @@ +{-# LANGUAGE CPP #-} +-- Source: https://github.com/haskell/cabal/issues/6726#issuecomment-918663262 + +-- | Custom Setup that runs bnfc to generate the language sub-libraries +-- for the parsers included in Ogma. +module Main (main) where + +import Distribution.Simple (defaultMainWithHooks, + hookedPrograms, postConf, + preBuild, simpleUserHooks) +import Distribution.Simple.Program (Program (..), findProgramVersion, + simpleProgram) +import System.Process (system) + +-- | Run BNFC on the grammar before the actual build step. +-- +-- All options for bnfc are hard-coded here. +main :: IO () +main = defaultMainWithHooks $ simpleUserHooks + { hookedPrograms = [ bnfcProgram ] + , postConf = \args flags packageDesc localBuildInfo -> do +#ifndef mingw32_HOST_OS + _ <- system "bnfc -d -p Language.EO.Phi --generic --functor -o src/ grammar/EO/Phi/Syntax.cf" +#endif + postConf simpleUserHooks args flags packageDesc localBuildInfo + } + +-- | TODO: This should be in Cabal.Distribution.Simple.Program.Builtin. +bnfcProgram :: Program +bnfcProgram = (simpleProgram "bnfc") + { programFindVersion = findProgramVersion "--version" id + } diff --git a/eo-phi-normalizer/app/Main.hs b/eo-phi-normalizer/app/Main.hs new file mode 100644 index 000000000..9fa108c46 --- /dev/null +++ b/eo-phi-normalizer/app/Main.hs @@ -0,0 +1,6 @@ +module Main (main) where + +import Language.EO.Phi + +main :: IO () +main = defaultMain diff --git a/eo-phi-normalizer/eo-phi-normalizer.cabal b/eo-phi-normalizer/eo-phi-normalizer.cabal new file mode 100644 index 000000000..aa9d021fc --- /dev/null +++ b/eo-phi-normalizer/eo-phi-normalizer.cabal @@ -0,0 +1,99 @@ +cabal-version: 2.2 + +-- This file has been generated from package.yaml by hpack version 0.36.0. +-- +-- see: https://github.com/sol/hpack + +name: eo-phi-normalizer +version: 0.1.0 +description: Please see the README on GitHub at +homepage: https://github.com/objectionary/eo-phi-normalizer#readme +bug-reports: https://github.com/objectionary/eo-phi-normalizer/issues +author: EO/Polystat Development Team +maintainer: nickolay.kudasov@gmail.com +copyright: 2023 EO/Polystat Development Team +license: BSD-3-Clause +license-file: LICENSE +build-type: Custom +extra-source-files: + README.md + CHANGELOG.md + grammar/EO/Phi/Syntax.cf + +source-repository head + type: git + location: https://github.com/objectionary/eo-phi-normalizer + +custom-setup + setup-depends: + Cabal >=2.4.0.1 && <4.0 + , base >=4.11.0.0 && <5.0 + , process >=1.6.3.0 + +library + exposed-modules: + Language.EO.Phi + Language.EO.Phi.Syntax.Abs + Language.EO.Phi.Syntax.Lex + Language.EO.Phi.Syntax.Par + Language.EO.Phi.Syntax.Print + other-modules: + Paths_eo_phi_normalizer + autogen-modules: + Paths_eo_phi_normalizer + hs-source-dirs: + src + ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints + build-tools: + alex >=3.2.4 + , happy >=1.19.9 + build-tool-depends: + BNFC:bnfc >=2.9.4.1 + build-depends: + array >=0.5.5.0 + , base >=4.7 && <5 + default-language: Haskell2010 + +executable normalize-phi + main-is: Main.hs + other-modules: + Paths_eo_phi_normalizer + autogen-modules: + Paths_eo_phi_normalizer + hs-source-dirs: + app + ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N + build-tools: + alex >=3.2.4 + , happy >=1.19.9 + build-tool-depends: + BNFC:bnfc >=2.9.4.1 + build-depends: + array >=0.5.5.0 + , base >=4.7 && <5 + , eo-phi-normalizer + default-language: Haskell2010 + +test-suite eo-phi-normalizer-test + type: exitcode-stdio-1.0 + main-is: Spec.hs + other-modules: + Language.EO.PhiSpec + Paths_eo_phi_normalizer + autogen-modules: + Paths_eo_phi_normalizer + hs-source-dirs: + test + ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N + build-tools: + alex >=3.2.4 + , happy >=1.19.9 + build-tool-depends: + BNFC:bnfc >=2.9.4.1 + build-depends: + array >=0.5.5.0 + , base >=4.7 && <5 + , eo-phi-normalizer + , hspec + , hspec-discover + default-language: Haskell2010 diff --git a/eo-phi-normalizer/grammar/EO/Phi/Syntax.cf b/eo-phi-normalizer/grammar/EO/Phi/Syntax.cf new file mode 100644 index 000000000..10db3d72e --- /dev/null +++ b/eo-phi-normalizer/grammar/EO/Phi/Syntax.cf @@ -0,0 +1,49 @@ +-- ========================================================== +-- BNFC grammar for φ-programs (translated from EO) +-- ========================================================== +-- +-- This grammar is a (manual) translation of Phi.g4 grammar from objectionary/eo: +-- https://github.com/objectionary/eo/blob/fa24c7cc47e1ac473fb930f3a08ccc4d88d9d1e3/eo-parser/src/main/antlr4/org/eolang/parser/Phi.g4 + +token Bytes ({"--"} | ["0123456789ABCDEF"] ["0123456789ABCDEF"] ({"-"} ["0123456789ABCDEF"] ["0123456789ABCDEF"])* {"--"}) ; +token Function upper (char - [" \r\n\t,.|':;!-?][}{)(⟧⟦"])* ; +token LabelId lower (char - [" \r\n\t,.|':;!-?][}{)(⟧⟦"])* ; +token AlphaIndex ({"α0"} | {"α"} (digit - ["0"]) (digit)* ); + +Program. Program ::= "{" [Binding] "}" ; + +Formation. Object ::= "{" [Binding] "}" ; +Application. Object ::= AbstractObject "{" [Binding] "}" [Bindings]; +Dispatch. Object ::= Dispatch ; +Termination. Object ::= "⊥"; + +AbstractFormation. AbstractObject ::= "{" [Binding] "}" ; +AbstractDispatch. AbstractObject ::= Dispatch ; +AbstractTermination. AbstractObject ::= "⊥" ; + +DispatchedFormation. DispatchedObject ::= "{" [Binding] "}" ; +DispatchedTermination. DispatchedObject ::= "⊥" ; + +AlphaBinding. Binding ::= Attribute "↦" Object ; +EmptyBinding. Binding ::= Attribute "↦" "∅" ; +DeltaBinding. Binding ::= "Δ" "⤍" Bytes; +LambdaBinding. Binding ::= "λ" "⤍" ; +separator Binding "," ; + +Bindings. Bindings ::= "{" [Binding] "}" ; +separator Bindings "" ; + +ObjectDispatch. Dispatch ::= DispatchedObject [Bindings] "." [Attribute] [Disp] ; +HomeDispatch. Dispatch ::= "Φ" "." [Attribute] [Disp] ; +ThisDispatch. Dispatch ::= "ξ" "." [Attribute] [Disp] ; + +Phi. Attribute ::= "φ" ; -- decoratee object +Rho. Attribute ::= "ρ" ; -- parent object +Sigma. Attribute ::= "σ" ; -- ??? +VTX. Attribute ::= "ν" ; -- ??? +Label. Attribute ::= LabelId ; +Alpha. Attribute ::= AlphaIndex ; +separator nonempty Attribute "." ; + +Disp. Disp ::= "{" [Binding] "}" Bindings "." [Attribute] ; +separator Disp "" ; diff --git a/eo-phi-normalizer/package.yaml b/eo-phi-normalizer/package.yaml new file mode 100644 index 000000000..ebe96c897 --- /dev/null +++ b/eo-phi-normalizer/package.yaml @@ -0,0 +1,80 @@ +name: eo-phi-normalizer +version: 0.1.0 +github: "objectionary/eo-phi-normalizer" +license: BSD-3-Clause +author: "EO/Polystat Development Team" +maintainer: "nickolay.kudasov@gmail.com" +copyright: "2023 EO/Polystat Development Team" + +extra-source-files: +- README.md +- CHANGELOG.md +- grammar/EO/Phi/Syntax.cf + +# Metadata used when publishing your package +# synopsis: Short description of your package +# category: Web + +# To avoid duplicated efforts in documentation and dealing with the +# complications of embedding Haddock markup inside cabal files, it is +# common to point users to the README.md file. +description: Please see the README on GitHub at + +custom-setup: + dependencies: + base: ">= 4.11.0.0 && < 5.0" + Cabal: ">= 2.4.0.1 && < 4.0" + process: ">= 1.6.3.0" + +build-tools: + alex: ">= 3.2.4" + happy: ">= 1.19.9" + BNFC:bnfc: ">= 2.9.4.1" + +dependencies: +- base >= 4.7 && < 5 +- array >= 0.5.5.0 + +ghc-options: +- -Wall +- -Wcompat +- -Widentities +- -Wincomplete-record-updates +- -Wincomplete-uni-patterns +- -Wmissing-export-lists +- -Wmissing-home-modules +- -Wpartial-fields +- -Wredundant-constraints + +library: + source-dirs: src + when: + - condition: false + other-modules: + - Language.EO.Phi.Syntax.Test + - Language.EO.Phi.Syntax.ErrM + - Language.EO.Phi.Syntax.Skel + +executables: + normalize-phi: + main: Main.hs + source-dirs: app + ghc-options: + - -threaded + - -rtsopts + - -with-rtsopts=-N + dependencies: + - eo-phi-normalizer + +tests: + eo-phi-normalizer-test: + main: Spec.hs + source-dirs: test + ghc-options: + - -threaded + - -rtsopts + - -with-rtsopts=-N + dependencies: + - eo-phi-normalizer + - hspec + - hspec-discover diff --git a/eo-phi-normalizer/src/Language/EO/Phi.hs b/eo-phi-normalizer/src/Language/EO/Phi.hs new file mode 100644 index 000000000..c8467ba9f --- /dev/null +++ b/eo-phi-normalizer/src/Language/EO/Phi.hs @@ -0,0 +1,60 @@ +module Language.EO.Phi ( + defaultMain, + normalize, + parseProgram, + unsafeParseProgram, + printTree, + module Language.EO.Phi.Syntax.Abs, +) where + +import System.Exit (exitFailure) + +import qualified Language.EO.Phi.Syntax.Par as Phi +import qualified Language.EO.Phi.Syntax.Print as Phi +import Language.EO.Phi.Syntax.Abs +import qualified Language.EO.Phi.Syntax.Abs as Phi + +-- | Normalize an input 𝜑-program. +normalize :: Phi.Program -> Phi.Program +normalize program = program -- do nothing for now + +-- | Parse a 'Program' or return a parsing error. +parseProgram :: String -> Either String Phi.Program +parseProgram input = Phi.pProgram tokens + where + tokens = Phi.myLexer input + +-- | Parse a 'Program' from a 'String'. +-- May throw an 'error` if input has a syntactical or lexical errors. +unsafeParseProgram :: String -> Phi.Program +unsafeParseProgram input = + case parseProgram input of + Left parseError -> error parseError + Right program -> program + +-- | Like 'Phi.printTree', but without spaces around dots. +printTree :: Phi.Print a => a -> String +printTree = shrinkDots . Phi.printTree + +-- | Remove spaces around dots. +-- +-- >>> putStrLn (shrinkDots "a ↦ ξ . a") +-- a ↦ ξ.a +shrinkDots :: String -> String +shrinkDots [] = [] +shrinkDots (' ':'.':' ':cs) = '.':shrinkDots cs +shrinkDots (c:cs) = c : shrinkDots cs + +-- | Default entry point. +-- Parses a 𝜑-program from standard input, normalizes, +-- then pretty-prints the result to standard output. +defaultMain :: IO () +defaultMain = do + input <- getContents -- read entire standard input + let tokens = Phi.myLexer input + case Phi.pProgram tokens of + Left parseError -> do + putStrLn parseError + exitFailure + Right program -> do + putStrLn (printTree program) diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Abs.hs b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Abs.hs new file mode 100644 index 000000000..b234f3e8e --- /dev/null +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Abs.hs @@ -0,0 +1,161 @@ +-- File generated by the BNF Converter (bnfc 2.9.5). + +{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE DeriveTraversable #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE PatternSynonyms #-} + +-- | The abstract syntax of language Syntax. + +module Language.EO.Phi.Syntax.Abs where + +import Prelude (String) +import qualified Prelude as C + ( Eq, Ord, Show, Read + , Functor, Foldable, Traversable + , Int, Maybe(..) + ) +import qualified Data.String + +import qualified Data.Data as C (Data, Typeable) +import qualified GHC.Generics as C (Generic) + +type Program = Program' BNFC'Position +data Program' a = Program a [Binding' a] + deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) + +type Object = Object' BNFC'Position +data Object' a + = Formation a [Binding' a] + | Application a (AbstractObject' a) [Binding' a] [Bindings' a] + | Dispatch a (Dispatch' a) + | Termination a + deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) + +type AbstractObject = AbstractObject' BNFC'Position +data AbstractObject' a + = AbstractFormation a [Binding' a] + | AbstractDispatch a (Dispatch' a) + | AbstractTermination a + deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) + +type DispatchedObject = DispatchedObject' BNFC'Position +data DispatchedObject' a + = DispatchedFormation a [Binding' a] | DispatchedTermination a + deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) + +type Binding = Binding' BNFC'Position +data Binding' a + = AlphaBinding a (Attribute' a) (Object' a) + | EmptyBinding a (Attribute' a) + | DeltaBinding a Bytes + | LambdaBinding a + deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) + +type Bindings = Bindings' BNFC'Position +data Bindings' a = Bindings a [Binding' a] + deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) + +type Dispatch = Dispatch' BNFC'Position +data Dispatch' a + = ObjectDispatch a (DispatchedObject' a) [Bindings' a] [Attribute' a] [Disp' a] + | HomeDispatch a [Attribute' a] [Disp' a] + | ThisDispatch a [Attribute' a] [Disp' a] + deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) + +type Attribute = Attribute' BNFC'Position +data Attribute' a + = Phi a + | Rho a + | Sigma a + | VTX a + | Label a LabelId + | Alpha a AlphaIndex + deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) + +type Disp = Disp' BNFC'Position +data Disp' a = Disp a [Binding' a] (Bindings' a) [Attribute' a] + deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) + +newtype Bytes = Bytes String + deriving (C.Eq, C.Ord, C.Show, C.Read, C.Data, C.Typeable, C.Generic, Data.String.IsString) + +newtype Function = Function String + deriving (C.Eq, C.Ord, C.Show, C.Read, C.Data, C.Typeable, C.Generic, Data.String.IsString) + +newtype LabelId = LabelId String + deriving (C.Eq, C.Ord, C.Show, C.Read, C.Data, C.Typeable, C.Generic, Data.String.IsString) + +newtype AlphaIndex = AlphaIndex String + deriving (C.Eq, C.Ord, C.Show, C.Read, C.Data, C.Typeable, C.Generic, Data.String.IsString) + +-- | Start position (line, column) of something. + +type BNFC'Position = C.Maybe (C.Int, C.Int) + +pattern BNFC'NoPosition :: BNFC'Position +pattern BNFC'NoPosition = C.Nothing + +pattern BNFC'Position :: C.Int -> C.Int -> BNFC'Position +pattern BNFC'Position line col = C.Just (line, col) + +-- | Get the start position of something. + +class HasPosition a where + hasPosition :: a -> BNFC'Position + +instance HasPosition Program where + hasPosition = \case + Program p _ -> p + +instance HasPosition Object where + hasPosition = \case + Formation p _ -> p + Application p _ _ _ -> p + Dispatch p _ -> p + Termination p -> p + +instance HasPosition AbstractObject where + hasPosition = \case + AbstractFormation p _ -> p + AbstractDispatch p _ -> p + AbstractTermination p -> p + +instance HasPosition DispatchedObject where + hasPosition = \case + DispatchedFormation p _ -> p + DispatchedTermination p -> p + +instance HasPosition Binding where + hasPosition = \case + AlphaBinding p _ _ -> p + EmptyBinding p _ -> p + DeltaBinding p _ -> p + LambdaBinding p -> p + +instance HasPosition Bindings where + hasPosition = \case + Bindings p _ -> p + +instance HasPosition Dispatch where + hasPosition = \case + ObjectDispatch p _ _ _ _ -> p + HomeDispatch p _ _ -> p + ThisDispatch p _ _ -> p + +instance HasPosition Attribute where + hasPosition = \case + Phi p -> p + Rho p -> p + Sigma p -> p + VTX p -> p + Label p _ -> p + Alpha p _ -> p + +instance HasPosition Disp where + hasPosition = \case + Disp p _ _ _ -> p + diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Abs.hs.bak b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Abs.hs.bak new file mode 100644 index 000000000..f38a2ccac --- /dev/null +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Abs.hs.bak @@ -0,0 +1,157 @@ +-- File generated by the BNF Converter (bnfc 2.9.5). + +{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE DeriveTraversable #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE PatternSynonyms #-} + +-- | The abstract syntax of language Syntax. + +module Language.EO.Phi.Syntax.Abs where + +import Prelude (String) +import qualified Prelude as C + ( Eq, Ord, Show, Read + , Functor, Foldable, Traversable + , Int, Maybe(..) + ) +import qualified Data.String + +import qualified Data.Data as C (Data, Typeable) +import qualified GHC.Generics as C (Generic) + +type Program = Program' BNFC'Position +data Program' a = Program a [Binding' a] + deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) + +type Object = Object' BNFC'Position +data Object' a + = Formation a [Binding' a] + | Application a (AbstractObject' a) [Binding' a] [Bindings' a] + | Dispatch a (Dispatch' a) + | Termination a + deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) + +type AbstractObject = AbstractObject' BNFC'Position +data AbstractObject' a + = AbstractFormation a [Binding' a] + | AbstractDispatch a (Dispatch' a) + | AbstractTermination a + deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) + +type DispatchedObject = DispatchedObject' BNFC'Position +data DispatchedObject' a + = DispatchedFormation a [Binding' a] | DispatchedTermination a + deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) + +type Binding = Binding' BNFC'Position +data Binding' a + = EmptyBinding a (Attribute' a) + | DeltaBinding a Bytes + | LambdaBinding a + deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) + +type Bindings = Bindings' BNFC'Position +data Bindings' a = Bindings a [Binding' a] + deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) + +type Dispatch = Dispatch' BNFC'Position +data Dispatch' a + = HomeDispatch a [Attribute' a] [Disp' a] + | ThisDispatch a [Attribute' a] [Disp' a] + deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) + +type Attribute = Attribute' BNFC'Position +data Attribute' a + = Phi a + | Rho a + | Sigma a + | VTX a + | Label a LabelId + | Alpha a AlphaIndex + deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) + +type Disp = Disp' BNFC'Position +data Disp' a = Disp a [Binding' a] (Bindings' a) [Attribute' a] + deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) + +newtype Bytes = Bytes String + deriving (C.Eq, C.Ord, C.Show, C.Read, C.Data, C.Typeable, C.Generic, Data.String.IsString) + +newtype Function = Function String + deriving (C.Eq, C.Ord, C.Show, C.Read, C.Data, C.Typeable, C.Generic, Data.String.IsString) + +newtype LabelId = LabelId String + deriving (C.Eq, C.Ord, C.Show, C.Read, C.Data, C.Typeable, C.Generic, Data.String.IsString) + +newtype AlphaIndex = AlphaIndex String + deriving (C.Eq, C.Ord, C.Show, C.Read, C.Data, C.Typeable, C.Generic, Data.String.IsString) + +-- | Start position (line, column) of something. + +type BNFC'Position = C.Maybe (C.Int, C.Int) + +pattern BNFC'NoPosition :: BNFC'Position +pattern BNFC'NoPosition = C.Nothing + +pattern BNFC'Position :: C.Int -> C.Int -> BNFC'Position +pattern BNFC'Position line col = C.Just (line, col) + +-- | Get the start position of something. + +class HasPosition a where + hasPosition :: a -> BNFC'Position + +instance HasPosition Program where + hasPosition = \case + Program p _ -> p + +instance HasPosition Object where + hasPosition = \case + Formation p _ -> p + Application p _ _ _ -> p + Dispatch p _ -> p + Termination p -> p + +instance HasPosition AbstractObject where + hasPosition = \case + AbstractFormation p _ -> p + AbstractDispatch p _ -> p + AbstractTermination p -> p + +instance HasPosition DispatchedObject where + hasPosition = \case + DispatchedFormation p _ -> p + DispatchedTermination p -> p + +instance HasPosition Binding where + hasPosition = \case + EmptyBinding p _ -> p + DeltaBinding p _ -> p + LambdaBinding p -> p + +instance HasPosition Bindings where + hasPosition = \case + Bindings p _ -> p + +instance HasPosition Dispatch where + hasPosition = \case + HomeDispatch p _ _ -> p + ThisDispatch p _ _ -> p + +instance HasPosition Attribute where + hasPosition = \case + Phi p -> p + Rho p -> p + Sigma p -> p + VTX p -> p + Label p _ -> p + Alpha p _ -> p + +instance HasPosition Disp where + hasPosition = \case + Disp p _ _ _ -> p + diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt new file mode 100644 index 000000000..2f1238ec4 --- /dev/null +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt @@ -0,0 +1,91 @@ +The Language Syntax +BNF Converter + + +%Process by txt2tags to generate html or latex + + + +This document was automatically generated by the //BNF-Converter//. It was generated together with the lexer, the parser, and the abstract syntax module, which guarantees that the document matches with the implementation of the language (provided no hand-hacking has taken place). + +==The lexical structure of Syntax== + +===Literals=== + + + + + +Bytes literals are recognized by the regular expression +`````{"--"} | ["0123456789ABCDEF"] ["0123456789ABCDEF"] ('-' ["0123456789ABCDEF"] ["0123456789ABCDEF"])* {"--"}````` + +Function literals are recognized by the regular expression +`````upper (char - [" + !'(),-.:;?[]{|}⟦⟧"])*````` + +LabelId literals are recognized by the regular expression +`````lower (char - [" + !'(),-.:;?[]{|}⟦⟧"])*````` + +AlphaIndex literals are recognized by the regular expression +`````{"α0"} | 'α' (digit - '0') digit*````` + + +===Reserved words and symbols=== +The set of reserved words is the set of terminals appearing in the grammar. Those reserved words that consist of non-letter characters are called symbols, and they are treated in a different way from those that are similar to identifiers. The lexer follows rules familiar from languages like Haskell, C, and Java, including longest match and spacing conventions. + +The reserved words used in Syntax are the following: + | ``Δ`` | ``Φ`` | ``λ`` | ``ν`` + | ``ξ`` | ``ρ`` | ``σ`` | ``φ`` + +The symbols used in Syntax are the following: + | { | } | ⊥ | ↦ + | ∅ | ⤍ | , | . + +===Comments=== +There are no single-line comments in the grammar.There are no multiple-line comments in the grammar. + +==The syntactic structure of Syntax== +Non-terminals are enclosed between < and >. +The symbols -> (production), **|** (union) +and **eps** (empty rule) belong to the BNF notation. +All other symbols are terminals. + + | //Program// | -> | ``{`` //[Binding]// ``}`` + | //Object// | -> | ``{`` //[Binding]// ``}`` + | | **|** | //AbstractObject// ``{`` //[Binding]// ``}`` //[Bindings]// + | | **|** | //Dispatch// + | | **|** | ``⊥`` + | //AbstractObject// | -> | ``{`` //[Binding]// ``}`` + | | **|** | //Dispatch// + | | **|** | ``⊥`` + | //DispatchedObject// | -> | ``{`` //[Binding]// ``}`` + | | **|** | ``⊥`` + | //Binding// | -> | //Attribute// ``↦`` //Object// + | | **|** | //Attribute// ``↦`` ``∅`` + | | **|** | ``Δ`` ``⤍`` //Bytes// + | | **|** | ``λ`` ``⤍`` + | //[Binding]// | -> | **eps** + | | **|** | //Binding// + | | **|** | //Binding// ``,`` //[Binding]// + | //Bindings// | -> | ``{`` //[Binding]// ``}`` + | //[Bindings]// | -> | **eps** + | | **|** | //Bindings// //[Bindings]// + | //Dispatch// | -> | //DispatchedObject// //[Bindings]// ``.`` //[Attribute]// //[Disp]// + | | **|** | ``Φ`` ``.`` //[Attribute]// //[Disp]// + | | **|** | ``ξ`` ``.`` //[Attribute]// //[Disp]// + | //Attribute// | -> | ``φ`` + | | **|** | ``ρ`` + | | **|** | ``σ`` + | | **|** | ``ν`` + | | **|** | //LabelId// + | | **|** | //AlphaIndex// + | //[Attribute]// | -> | //Attribute// + | | **|** | //Attribute// ``.`` //[Attribute]// + | //Disp// | -> | ``{`` //[Binding]// ``}`` //Bindings// ``.`` //[Attribute]// + | //[Disp]// | -> | **eps** + | | **|** | //Disp// //[Disp]// + + + +%% File generated by the BNF Converter (bnfc 2.9.5). diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt.bak b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt.bak new file mode 100644 index 000000000..4b884671a --- /dev/null +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt.bak @@ -0,0 +1,89 @@ +The Language Syntax +BNF Converter + + +%Process by txt2tags to generate html or latex + + + +This document was automatically generated by the //BNF-Converter//. It was generated together with the lexer, the parser, and the abstract syntax module, which guarantees that the document matches with the implementation of the language (provided no hand-hacking has taken place). + +==The lexical structure of Syntax== + +===Literals=== + + + + + +Bytes literals are recognized by the regular expression +`````{"--"} | ["0123456789ABCDEF"] ["0123456789ABCDEF"] ('-' ["0123456789ABCDEF"] ["0123456789ABCDEF"])* {"--"}````` + +Function literals are recognized by the regular expression +`````upper (char - [" + !'(),-.:;?[]{|}⟦⟧"])*````` + +LabelId literals are recognized by the regular expression +`````lower (char - [" + !'(),-.:;?[]{|}⟦⟧"])*````` + +AlphaIndex literals are recognized by the regular expression +`````{"α0"} | 'α' (digit - '0') digit*````` + + +===Reserved words and symbols=== +The set of reserved words is the set of terminals appearing in the grammar. Those reserved words that consist of non-letter characters are called symbols, and they are treated in a different way from those that are similar to identifiers. The lexer follows rules familiar from languages like Haskell, C, and Java, including longest match and spacing conventions. + +The reserved words used in Syntax are the following: + | ``Δ`` | ``Φ`` | ``λ`` | ``ν`` + | ``ξ`` | ``ρ`` | ``σ`` | ``φ`` + +The symbols used in Syntax are the following: + | { | } | ⊥ | ↦ + | ∅ | ⤍ | , | . + +===Comments=== +There are no single-line comments in the grammar.There are no multiple-line comments in the grammar. + +==The syntactic structure of Syntax== +Non-terminals are enclosed between < and >. +The symbols -> (production), **|** (union) +and **eps** (empty rule) belong to the BNF notation. +All other symbols are terminals. + + | //Program// | -> | ``{`` //[Binding]// ``}`` + | //Object// | -> | ``{`` //[Binding]// ``}`` + | | **|** | //AbstractObject// ``{`` //[Binding]// ``}`` //[Bindings]// + | | **|** | //Dispatch// + | | **|** | ``⊥`` + | //AbstractObject// | -> | ``{`` //[Binding]// ``}`` + | | **|** | //Dispatch// + | | **|** | ``⊥`` + | //DispatchedObject// | -> | ``{`` //[Binding]// ``}`` + | | **|** | ``⊥`` + | //Binding// | -> | //Attribute// ``↦`` ``∅`` + | | **|** | ``Δ`` ``⤍`` //Bytes// + | | **|** | ``λ`` ``⤍`` + | //[Binding]// | -> | **eps** + | | **|** | //Binding// + | | **|** | //Binding// ``,`` //[Binding]// + | //Bindings// | -> | ``{`` //[Binding]// ``}`` + | //[Bindings]// | -> | **eps** + | | **|** | //Bindings// //[Bindings]// + | //Dispatch// | -> | ``Φ`` ``.`` //[Attribute]// //[Disp]// + | | **|** | ``ξ`` ``.`` //[Attribute]// //[Disp]// + | //Attribute// | -> | ``φ`` + | | **|** | ``ρ`` + | | **|** | ``σ`` + | | **|** | ``ν`` + | | **|** | //LabelId// + | | **|** | //AlphaIndex// + | //[Attribute]// | -> | //Attribute// + | | **|** | //Attribute// ``.`` //[Attribute]// + | //Disp// | -> | ``{`` //[Binding]// ``}`` //Bindings// ``.`` //[Attribute]// + | //[Disp]// | -> | **eps** + | | **|** | //Disp// //[Disp]// + + + +%% File generated by the BNF Converter (bnfc 2.9.5). diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/ErrM.hs b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/ErrM.hs new file mode 100644 index 000000000..fb27b4f4c --- /dev/null +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/ErrM.hs @@ -0,0 +1,91 @@ +-- File generated by the BNF Converter (bnfc 2.9.5). + +{-# LANGUAGE CPP #-} + +#if __GLASGOW_HASKELL__ >= 708 +--------------------------------------------------------------------------- +-- Pattern synonyms exist since ghc 7.8. + +-- | BNF Converter: Error Monad. +-- +-- Module for backwards compatibility. +-- +-- The generated parser now uses @'Either' String@ as error monad. +-- This module defines a type synonym 'Err' and pattern synonyms +-- 'Bad' and 'Ok' for 'Left' and 'Right'. + +{-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE FlexibleInstances #-} + +module Language.EO.Phi.Syntax.ErrM where + +import Prelude (id, const, Either(..), String) + +import Control.Monad (MonadPlus(..)) +import Control.Applicative (Alternative(..)) +#if __GLASGOW_HASKELL__ >= 808 +import Control.Monad (MonadFail(..)) +#endif + +-- | Error monad with 'String' error messages. +type Err = Either String + +pattern Bad msg = Left msg +pattern Ok a = Right a + +#if __GLASGOW_HASKELL__ >= 808 +instance MonadFail Err where + fail = Bad +#endif + +instance Alternative Err where + empty = Left "Err.empty" + (<|>) Left{} = id + (<|>) x@Right{} = const x + +instance MonadPlus Err where + mzero = empty + mplus = (<|>) + +#else +--------------------------------------------------------------------------- +-- ghc 7.6 and before: use old definition as data type. + +-- | BNF Converter: Error Monad + +-- Copyright (C) 2004 Author: Aarne Ranta +-- This file comes with NO WARRANTY and may be used FOR ANY PURPOSE. + +module Language.EO.Phi.Syntax.ErrM where + +-- the Error monad: like Maybe type with error msgs + +import Control.Applicative (Applicative(..), Alternative(..)) +import Control.Monad (MonadPlus(..), liftM) + +data Err a = Ok a | Bad String + deriving (Read, Show, Eq, Ord) + +instance Monad Err where + return = Ok + Ok a >>= f = f a + Bad s >>= _ = Bad s + +instance Applicative Err where + pure = Ok + (Bad s) <*> _ = Bad s + (Ok f) <*> o = liftM f o + +instance Functor Err where + fmap = liftM + +instance MonadPlus Err where + mzero = Bad "Err.mzero" + mplus (Bad _) y = y + mplus x _ = x + +instance Alternative Err where + empty = mzero + (<|>) = mplus + +#endif diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/ErrM.hs.bak b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/ErrM.hs.bak new file mode 100644 index 000000000..c72618db5 --- /dev/null +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/ErrM.hs.bak @@ -0,0 +1,91 @@ +-- File generated by the BNF Converter (bnfc 2.9.6). + +{-# LANGUAGE CPP #-} + +#if __GLASGOW_HASKELL__ >= 708 +--------------------------------------------------------------------------- +-- Pattern synonyms exist since ghc 7.8. + +-- | BNF Converter: Error Monad. +-- +-- Module for backwards compatibility. +-- +-- The generated parser now uses @'Either' String@ as error monad. +-- This module defines a type synonym 'Err' and pattern synonyms +-- 'Bad' and 'Ok' for 'Left' and 'Right'. + +{-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE FlexibleInstances #-} + +module Language.EO.Phi.Syntax.ErrM where + +import Prelude (id, const, Either(..), String) + +import Control.Monad (MonadPlus(..)) +import Control.Applicative (Alternative(..)) +#if __GLASGOW_HASKELL__ >= 808 +import Control.Monad (MonadFail(..)) +#endif + +-- | Error monad with 'String' error messages. +type Err = Either String + +pattern Bad msg = Left msg +pattern Ok a = Right a + +#if __GLASGOW_HASKELL__ >= 808 +instance MonadFail Err where + fail = Bad +#endif + +instance Alternative Err where + empty = Left "Err.empty" + (<|>) Left{} = id + (<|>) x@Right{} = const x + +instance MonadPlus Err where + mzero = empty + mplus = (<|>) + +#else +--------------------------------------------------------------------------- +-- ghc 7.6 and before: use old definition as data type. + +-- | BNF Converter: Error Monad + +-- Copyright (C) 2004 Author: Aarne Ranta +-- This file comes with NO WARRANTY and may be used FOR ANY PURPOSE. + +module Language.EO.Phi.Syntax.ErrM where + +-- the Error monad: like Maybe type with error msgs + +import Control.Applicative (Applicative(..), Alternative(..)) +import Control.Monad (MonadPlus(..), liftM) + +data Err a = Ok a | Bad String + deriving (Read, Show, Eq, Ord) + +instance Monad Err where + return = Ok + Ok a >>= f = f a + Bad s >>= _ = Bad s + +instance Applicative Err where + pure = Ok + (Bad s) <*> _ = Bad s + (Ok f) <*> o = liftM f o + +instance Functor Err where + fmap = liftM + +instance MonadPlus Err where + mzero = Bad "Err.mzero" + mplus (Bad _) y = y + mplus x _ = x + +instance Alternative Err where + empty = mzero + (<|>) = mplus + +#endif diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.hs b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.hs new file mode 100644 index 000000000..873fa3a31 --- /dev/null +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.hs @@ -0,0 +1,6868 @@ +{-# OPTIONS_GHC -fno-warn-unused-binds -fno-warn-missing-signatures #-} +{-# LANGUAGE CPP #-} +{-# LINE 4 "Lex.x" #-} +{-# OPTIONS -fno-warn-incomplete-patterns #-} +{-# OPTIONS_GHC -w #-} + +{-# LANGUAGE PatternSynonyms #-} + +module Language.EO.Phi.Syntax.Lex where + +import Prelude + +import qualified Data.Bits +import Data.Char (ord) +import Data.Function (on) +import Data.Word (Word8) +#if __GLASGOW_HASKELL__ >= 603 +#include "ghcconfig.h" +#elif defined(__GLASGOW_HASKELL__) +#include "config.h" +#endif +#if __GLASGOW_HASKELL__ >= 503 +import Data.Array +#else +import Array +#endif +alex_tab_size :: Int +alex_tab_size = 8 +alex_base :: Array Int Int +alex_base = listArray (0 :: Int, 50) + [ -8 + , 0 + , 0 + , 76 + , -73 + , 140 + , -153 + , -159 + , 268 + , 332 + , 396 + , 460 + , 588 + , 844 + , 963 + , -39 + , 0 + , -23 + , 1091 + , 1235 + , 840 + , 50 + , -147 + , 0 + , 180 + , 0 + , -145 + , -120 + , -111 + , -79 + , 0 + , -22 + , -10 + , 983 + , 1010 + , 1367 + , 1612 + , 1857 + , 2093 + , 2349 + , 2350 + , 2478 + , -113 + , -108 + , 1303 + , 1549 + , 2591 + , 0 + , 0 + , 0 + , 2847 + ] + +alex_table :: Array Int Int +alex_table = listArray (0 :: Int, 3102) + [ 0 + , 24 + , 24 + , 24 + , 24 + , 24 + , 7 + , -1 + , -1 + , 16 + , 17 + , 17 + , 17 + , 17 + , 17 + , 17 + , 17 + , 17 + , 17 + , 25 + , 25 + , 25 + , 25 + , 30 + , 24 + , 17 + , 17 + , 17 + , 17 + , 17 + , 17 + , 17 + , 17 + , 17 + , 17 + , 34 + , 25 + , 31 + , 25 + , 0 + , 33 + , 33 + , 33 + , 33 + , 33 + , 33 + , 33 + , 33 + , 33 + , 33 + , 25 + , 42 + , 25 + , -1 + , -1 + , 25 + , 0 + , 36 + , 36 + , 36 + , 36 + , 36 + , 36 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 25 + , 0 + , 25 + , 5 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 0 + , 22 + , 0 + , 28 + , 8 + , 26 + , 24 + , 24 + , 24 + , 24 + , 24 + , 0 + , 0 + , 0 + , 0 + , 20 + , 29 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 24 + , 0 + , 27 + , 0 + , 0 + , 0 + , 21 + , 4 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 0 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 0 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 0 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 0 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 0 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 0 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 12 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 13 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 0 + , 0 + , -1 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 25 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , -1 + , -1 + , 0 + , 0 + , 0 + , 0 + , 0 + , -1 + , -1 + , -1 + , 0 + , 25 + , -1 + , -1 + , -1 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 15 + , 0 + , 0 + , 0 + , -1 + , -1 + , 0 + , 0 + , 0 + , -1 + , 25 + , 0 + , 25 + , 25 + , 32 + , 32 + , 32 + , 32 + , 32 + , 32 + , 32 + , 32 + , 32 + , 32 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 32 + , 32 + , 32 + , 32 + , 32 + , 32 + , -1 + , 30 + , -1 + , 0 + , 33 + , 33 + , 33 + , 33 + , 33 + , 33 + , 33 + , 33 + , 33 + , 33 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 33 + , 33 + , 33 + , 33 + , 33 + , 33 + , 0 + , 0 + , 0 + , 0 + , 0 + , -1 + , -1 + , -1 + , 0 + , 0 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 13 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 5 + , 12 + , 23 + , 6 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 4 + , 11 + , 1 + , 1 + , 1 + , 3 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 0 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 0 + , 0 + , 0 + , 0 + , 19 + , 0 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 19 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 0 + , 0 + , 38 + , 38 + , 0 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 0 + , 0 + , 38 + , 38 + , 38 + , 38 + , 38 + , 19 + , 0 + , 0 + , 38 + , 38 + , 0 + , 0 + , 0 + , 38 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 0 + , 0 + , 38 + , 38 + , 38 + , 18 + , 38 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 0 + , 38 + , 0 + , 38 + , 35 + , 38 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 0 + , 0 + , 0 + , 38 + , 38 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 0 + , 0 + , 39 + , 9 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 44 + , 40 + , 48 + , 43 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 45 + , 41 + , 49 + , 49 + , 49 + , 46 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 0 + , 0 + , 38 + , 38 + , 0 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 0 + , 0 + , 38 + , 38 + , 38 + , 38 + , 38 + , 19 + , 0 + , 0 + , 38 + , 38 + , 0 + , 0 + , 0 + , 38 + , 37 + , 37 + , 37 + , 37 + , 37 + , 37 + , 37 + , 37 + , 37 + , 37 + , 0 + , 0 + , 38 + , 38 + , 38 + , 0 + , 38 + , 37 + , 37 + , 37 + , 37 + , 37 + , 37 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 0 + , 38 + , 0 + , 38 + , 35 + , 38 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 0 + , 0 + , 0 + , 38 + , 38 + , 44 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 0 + , 39 + , 9 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 44 + , 40 + , 48 + , 43 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 45 + , 41 + , 49 + , 49 + , 49 + , 46 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 0 + , 0 + , 38 + , 38 + , 0 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 38 + , 0 + , 0 + , 38 + , 38 + , 38 + , 38 + , 38 + , 19 + , 0 + , 0 + , 38 + , 38 + , 0 + , 34 + , 0 + , 38 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 0 + , 0 + , 38 + , 38 + , 38 + , 0 + , 38 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 0 + , 38 + , 0 + , 38 + , 35 + , 38 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 35 + , 0 + , 0 + , 0 + , 38 + , 38 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 39 + , 9 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 44 + , 40 + , 48 + , 43 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 45 + , 41 + , 49 + , 49 + , 49 + , 46 + , -1 + , -1 + , 0 + , 0 + , -1 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , -1 + , -1 + , 0 + , 0 + , 0 + , 0 + , 0 + , -1 + , -1 + , -1 + , 0 + , 0 + , -1 + , -1 + , -1 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , -1 + , -1 + , 0 + , 0 + , 0 + , -1 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , -1 + , 0 + , -1 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , -1 + , -1 + , -1 + , 0 + , 0 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 39 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 44 + , 40 + , 48 + , 43 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 45 + , 41 + , 49 + , 49 + , 49 + , 46 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 0 + , 39 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 47 + , 40 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 48 + , 45 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 14 + , 14 + , 14 + , 14 + , 14 + , 14 + , 14 + , 14 + , 14 + , 0 + , 0 + , 14 + , 14 + , 0 + , 14 + , 14 + , 14 + , 14 + , 14 + , 14 + , 14 + , 14 + , 14 + , 14 + , 14 + , 14 + , 14 + , 14 + , 14 + , 14 + , 14 + , 14 + , 0 + , 0 + , 14 + , 14 + , 14 + , 14 + , 14 + , 19 + , 0 + , 0 + , 14 + , 14 + , 0 + , 0 + , 0 + , 14 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 0 + , 0 + , 14 + , 14 + , 14 + , 0 + , 14 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 0 + , 14 + , 0 + , 14 + , 50 + , 14 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 50 + , 0 + , 0 + , 0 + , 14 + , 14 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 13 + , 10 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 2 + , 5 + , 12 + , 23 + , 6 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 23 + , 4 + , 11 + , 1 + , 1 + , 1 + , 3 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + ] + +alex_check :: Array Int Int +alex_check = listArray (0 :: Int, 3102) + [ -1 + , 9 + , 10 + , 11 + , 12 + , 13 + , 159 + , 166 + , 167 + , 48 + , 49 + , 50 + , 51 + , 52 + , 53 + , 54 + , 55 + , 56 + , 57 + , 166 + , 165 + , 141 + , 133 + , 45 + , 32 + , 48 + , 49 + , 50 + , 51 + , 52 + , 53 + , 54 + , 55 + , 56 + , 57 + , 45 + , 44 + , 45 + , 46 + , -1 + , 48 + , 49 + , 50 + , 51 + , 52 + , 53 + , 54 + , 55 + , 56 + , 57 + , 129 + , 159 + , 131 + , 166 + , 167 + , 134 + , -1 + , 65 + , 66 + , 67 + , 68 + , 69 + , 70 + , 71 + , 72 + , 73 + , 74 + , 75 + , 76 + , 77 + , 78 + , 79 + , 80 + , 81 + , 82 + , 83 + , 84 + , 85 + , 86 + , 87 + , 88 + , 89 + , 90 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 97 + , 98 + , 99 + , 100 + , 101 + , 102 + , 103 + , 104 + , 105 + , 106 + , 107 + , 108 + , 109 + , 110 + , 111 + , 112 + , 113 + , 114 + , 115 + , 116 + , 117 + , 118 + , 119 + , 120 + , 121 + , 122 + , 123 + , -1 + , 125 + , 191 + , 192 + , 193 + , 194 + , 195 + , 196 + , 197 + , 198 + , 199 + , 200 + , 201 + , 202 + , 203 + , 204 + , 205 + , 206 + , 207 + , 208 + , 209 + , 210 + , 211 + , 212 + , 213 + , 214 + , 215 + , 216 + , 217 + , 218 + , 219 + , 220 + , 221 + , 222 + , 223 + , 224 + , 225 + , 226 + , 227 + , 228 + , 229 + , 230 + , 231 + , 232 + , 233 + , 234 + , 235 + , 236 + , 237 + , 238 + , 239 + , 240 + , 241 + , 242 + , 243 + , 244 + , 245 + , 246 + , 247 + , 248 + , 249 + , 250 + , 251 + , 252 + , 253 + , 254 + , 255 + , -1 + , 134 + , -1 + , 136 + , 195 + , 138 + , 9 + , 10 + , 11 + , 12 + , 13 + , -1 + , -1 + , -1 + , -1 + , 206 + , 207 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 32 + , -1 + , 164 + , -1 + , -1 + , -1 + , 226 + , 143 + , 144 + , 145 + , 146 + , 147 + , 148 + , 149 + , 150 + , 151 + , 152 + , 153 + , 154 + , 155 + , 156 + , 157 + , 158 + , 159 + , 160 + , 161 + , 162 + , 163 + , 164 + , 165 + , 166 + , 167 + , 168 + , 169 + , 170 + , 171 + , 172 + , 173 + , 174 + , 175 + , 176 + , 177 + , 178 + , 179 + , 180 + , 181 + , 182 + , 183 + , 184 + , 185 + , 186 + , 187 + , 188 + , 189 + , 190 + , 191 + , 192 + , 193 + , 194 + , 195 + , 196 + , 197 + , 198 + , 199 + , 200 + , 201 + , 202 + , 203 + , 204 + , 205 + , 206 + , 207 + , 208 + , 209 + , 210 + , 211 + , 212 + , 213 + , 214 + , 215 + , 216 + , 217 + , 218 + , 219 + , 220 + , 221 + , 222 + , 223 + , 224 + , 225 + , 226 + , 227 + , 228 + , 229 + , 230 + , 231 + , 232 + , 233 + , 234 + , 235 + , 236 + , 237 + , 238 + , 239 + , 240 + , 241 + , 242 + , 243 + , 244 + , 245 + , 246 + , 247 + , 248 + , 249 + , 250 + , 251 + , 252 + , 253 + , 254 + , 255 + , 192 + , 193 + , 194 + , 195 + , 196 + , 197 + , 198 + , 199 + , 200 + , 201 + , 202 + , 203 + , 204 + , 205 + , 206 + , 207 + , 208 + , 209 + , 210 + , 211 + , 212 + , 213 + , 214 + , 215 + , 216 + , 217 + , 218 + , 219 + , 220 + , 221 + , 222 + , 223 + , 224 + , 225 + , 226 + , 227 + , 228 + , 229 + , 230 + , 231 + , 232 + , 233 + , 234 + , 235 + , 236 + , 237 + , 238 + , 239 + , 240 + , 241 + , 242 + , 243 + , 244 + , 245 + , 246 + , 247 + , 248 + , 249 + , 250 + , 251 + , 252 + , 253 + , 254 + , 255 + , 128 + , 129 + , 130 + , 131 + , 132 + , 133 + , 134 + , 135 + , 136 + , 137 + , 138 + , 139 + , 140 + , 141 + , 142 + , 143 + , 144 + , 145 + , 146 + , 147 + , 148 + , 149 + , 150 + , -1 + , 152 + , 153 + , 154 + , 155 + , 156 + , 157 + , 158 + , 159 + , 160 + , 161 + , 162 + , 163 + , 164 + , 165 + , 166 + , 167 + , 168 + , 169 + , 170 + , 171 + , 172 + , 173 + , 174 + , 175 + , 176 + , 177 + , 178 + , 179 + , 180 + , 181 + , 182 + , -1 + , 184 + , 185 + , 186 + , 187 + , 188 + , 189 + , 190 + , 191 + , 128 + , 129 + , 130 + , 131 + , 132 + , 133 + , 134 + , 135 + , 136 + , 137 + , 138 + , 139 + , 140 + , 141 + , 142 + , 143 + , 144 + , 145 + , 146 + , 147 + , 148 + , 149 + , 150 + , -1 + , 152 + , 153 + , 154 + , 155 + , 156 + , 157 + , 158 + , 159 + , 160 + , 161 + , 162 + , 163 + , 164 + , 165 + , 166 + , 167 + , 168 + , 169 + , 170 + , 171 + , 172 + , 173 + , 174 + , 175 + , 176 + , 177 + , 178 + , 179 + , 180 + , 181 + , 182 + , -1 + , 184 + , 185 + , 186 + , 187 + , 188 + , 189 + , 190 + , 191 + , 128 + , 129 + , 130 + , 131 + , 132 + , 133 + , 134 + , 135 + , 136 + , 137 + , 138 + , 139 + , 140 + , 141 + , 142 + , 143 + , 144 + , 145 + , 146 + , 147 + , 148 + , 149 + , 150 + , -1 + , 152 + , 153 + , 154 + , 155 + , 156 + , 157 + , 158 + , 159 + , 160 + , 161 + , 162 + , 163 + , 164 + , 165 + , 166 + , 167 + , 168 + , 169 + , 170 + , 171 + , 172 + , 173 + , 174 + , 175 + , 176 + , 177 + , 178 + , 179 + , 180 + , 181 + , 182 + , -1 + , 184 + , 185 + , 186 + , 187 + , 188 + , 189 + , 190 + , 191 + , 128 + , 129 + , 130 + , 131 + , 132 + , 133 + , 134 + , 135 + , 136 + , 137 + , 138 + , 139 + , 140 + , 141 + , 142 + , 143 + , 144 + , 145 + , 146 + , 147 + , 148 + , 149 + , 150 + , 151 + , 152 + , 153 + , 154 + , 155 + , 156 + , 157 + , 158 + , 159 + , 160 + , 161 + , 162 + , 163 + , 164 + , 165 + , 166 + , 167 + , 168 + , 169 + , 170 + , 171 + , 172 + , 173 + , 174 + , 175 + , 176 + , 177 + , 178 + , 179 + , 180 + , 181 + , 182 + , 183 + , 184 + , 185 + , 186 + , 187 + , 188 + , 189 + , 190 + , 191 + , 192 + , 193 + , 194 + , 195 + , 196 + , 197 + , 198 + , 199 + , 200 + , 201 + , 202 + , 203 + , 204 + , 205 + , 206 + , 207 + , 208 + , 209 + , 210 + , 211 + , 212 + , 213 + , 214 + , 215 + , 216 + , 217 + , 218 + , 219 + , 220 + , 221 + , 222 + , 223 + , 224 + , 225 + , 226 + , 227 + , 228 + , 229 + , 230 + , 231 + , 232 + , 233 + , 234 + , 235 + , 236 + , 237 + , 238 + , 239 + , 240 + , 241 + , 242 + , 243 + , 244 + , 245 + , 246 + , 247 + , 248 + , 249 + , 250 + , 251 + , 252 + , 253 + , 254 + , 255 + , 128 + , 129 + , 130 + , 131 + , 132 + , 133 + , 134 + , 135 + , 136 + , 137 + , 138 + , 139 + , 140 + , 141 + , 142 + , 143 + , 144 + , 145 + , 146 + , 147 + , 148 + , 149 + , 150 + , 151 + , 152 + , 153 + , 154 + , 155 + , 156 + , 157 + , 158 + , 159 + , 160 + , 161 + , 162 + , 163 + , 164 + , 165 + , 166 + , 167 + , 168 + , 169 + , 170 + , 171 + , 172 + , 173 + , 174 + , 175 + , 176 + , 177 + , 178 + , 179 + , 180 + , 181 + , 182 + , 183 + , 184 + , 185 + , 186 + , 187 + , 188 + , 189 + , 190 + , 191 + , 192 + , 193 + , 194 + , 195 + , 196 + , 197 + , 198 + , 199 + , 200 + , 201 + , 202 + , 203 + , 204 + , 205 + , 206 + , 207 + , 208 + , 209 + , 210 + , 211 + , 212 + , 213 + , 214 + , 215 + , 216 + , 217 + , 218 + , 219 + , 220 + , 221 + , 222 + , 223 + , 224 + , 225 + , 226 + , 227 + , 228 + , 229 + , 230 + , 231 + , 232 + , 233 + , 234 + , 235 + , 236 + , 237 + , 238 + , 239 + , 240 + , 241 + , 242 + , 243 + , 244 + , 245 + , 246 + , 247 + , 248 + , 249 + , 250 + , 251 + , 252 + , 253 + , 254 + , 255 + , 0 + , 1 + , 2 + , 3 + , 4 + , 5 + , 6 + , 7 + , 8 + , 9 + , 10 + , 11 + , 12 + , 13 + , 14 + , 15 + , 16 + , 17 + , 18 + , 19 + , 20 + , 21 + , 22 + , 23 + , 24 + , 25 + , 26 + , 27 + , 28 + , 29 + , 30 + , 31 + , 32 + , 33 + , 34 + , 35 + , 36 + , 37 + , 38 + , 39 + , 40 + , 41 + , 42 + , 43 + , 44 + , 45 + , 46 + , 47 + , 48 + , 49 + , 50 + , 51 + , 52 + , 53 + , 54 + , 55 + , 56 + , 57 + , 58 + , 59 + , 60 + , 61 + , 62 + , 63 + , 64 + , 65 + , 66 + , 67 + , 68 + , 69 + , 70 + , 71 + , 72 + , 73 + , 74 + , 75 + , 76 + , 77 + , 78 + , 79 + , 80 + , 81 + , 82 + , 83 + , 84 + , 85 + , 86 + , 87 + , 88 + , 89 + , 90 + , 91 + , 92 + , 93 + , 94 + , 95 + , 96 + , 97 + , 98 + , 99 + , 100 + , 101 + , 102 + , 103 + , 104 + , 105 + , 106 + , 107 + , 108 + , 109 + , 110 + , 111 + , 112 + , 113 + , 114 + , 115 + , 116 + , 117 + , 118 + , 119 + , 120 + , 121 + , 122 + , 123 + , 124 + , 125 + , 126 + , 127 + , 9 + , 10 + , -1 + , -1 + , 13 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 148 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 32 + , 33 + , -1 + , -1 + , -1 + , -1 + , -1 + , 39 + , 40 + , 41 + , -1 + , 166 + , 44 + , 45 + , 46 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 177 + , -1 + , -1 + , -1 + , 58 + , 59 + , -1 + , -1 + , -1 + , 63 + , 187 + , -1 + , 189 + , 190 + , 48 + , 49 + , 50 + , 51 + , 52 + , 53 + , 54 + , 55 + , 56 + , 57 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 65 + , 66 + , 67 + , 68 + , 69 + , 70 + , 91 + , 45 + , 93 + , -1 + , 48 + , 49 + , 50 + , 51 + , 52 + , 53 + , 54 + , 55 + , 56 + , 57 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 65 + , 66 + , 67 + , 68 + , 69 + , 70 + , -1 + , -1 + , -1 + , -1 + , -1 + , 123 + , 124 + , 125 + , -1 + , -1 + , 128 + , 129 + , 130 + , 131 + , 132 + , 133 + , 134 + , 135 + , 136 + , 137 + , 138 + , 139 + , 140 + , 141 + , 142 + , 143 + , 144 + , 145 + , 146 + , 147 + , 148 + , 149 + , 150 + , 151 + , 152 + , 153 + , 154 + , 155 + , 156 + , 157 + , 158 + , 159 + , 160 + , 161 + , 162 + , 163 + , 164 + , 165 + , 166 + , 167 + , 168 + , 169 + , 170 + , 171 + , 172 + , 173 + , 174 + , 175 + , 176 + , 177 + , 178 + , 179 + , 180 + , 181 + , 182 + , 183 + , 184 + , 185 + , 186 + , 187 + , 188 + , 189 + , 190 + , 191 + , 192 + , 193 + , 194 + , 195 + , 196 + , 197 + , 198 + , 199 + , 200 + , 201 + , 202 + , 203 + , 204 + , 205 + , 206 + , 207 + , 208 + , 209 + , 210 + , 211 + , 212 + , 213 + , 214 + , 215 + , 216 + , 217 + , 218 + , 219 + , 220 + , 221 + , 222 + , 223 + , 224 + , 225 + , 226 + , 227 + , 228 + , 229 + , 230 + , 231 + , 232 + , 233 + , 234 + , 235 + , 236 + , 237 + , 238 + , 239 + , 240 + , 241 + , 242 + , 243 + , 244 + , 245 + , 246 + , 247 + , 248 + , 249 + , 250 + , 251 + , 252 + , 253 + , 254 + , 255 + , 128 + , 129 + , 130 + , 131 + , 132 + , 133 + , 134 + , 135 + , 136 + , 137 + , 138 + , 139 + , 140 + , 141 + , 142 + , 143 + , 144 + , 145 + , 146 + , 147 + , 148 + , 149 + , 150 + , -1 + , 152 + , 153 + , 154 + , 155 + , 156 + , 157 + , 158 + , 159 + , 160 + , 161 + , 162 + , 163 + , 164 + , 165 + , 166 + , 167 + , 168 + , 169 + , 170 + , 171 + , 172 + , 173 + , 174 + , 175 + , 176 + , 177 + , 178 + , 179 + , 180 + , 181 + , 182 + , 39 + , 184 + , 185 + , 186 + , 187 + , 188 + , 189 + , 190 + , 191 + , 48 + , 49 + , 50 + , 51 + , 52 + , 53 + , 54 + , 55 + , 56 + , 57 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 65 + , 66 + , 67 + , 68 + , 69 + , 70 + , 71 + , 72 + , 73 + , 74 + , 75 + , 76 + , 77 + , 78 + , 79 + , 80 + , 81 + , 82 + , 83 + , 84 + , 85 + , 86 + , 87 + , 88 + , 89 + , 90 + , -1 + , -1 + , -1 + , -1 + , 95 + , -1 + , 97 + , 98 + , 99 + , 100 + , 101 + , 102 + , 103 + , 104 + , 105 + , 106 + , 107 + , 108 + , 109 + , 110 + , 111 + , 112 + , 113 + , 114 + , 115 + , 116 + , 117 + , 118 + , 119 + , 120 + , 121 + , 122 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 0 + , 1 + , 2 + , 3 + , 4 + , 5 + , 6 + , 7 + , 8 + , -1 + , -1 + , 11 + , 12 + , -1 + , 14 + , 15 + , 16 + , 17 + , 18 + , 19 + , 20 + , 21 + , 22 + , 23 + , 24 + , 25 + , 26 + , 27 + , 28 + , 29 + , 30 + , 31 + , -1 + , -1 + , 34 + , 35 + , 36 + , 37 + , 38 + , 39 + , -1 + , -1 + , 42 + , 43 + , -1 + , -1 + , -1 + , 47 + , 48 + , 49 + , 50 + , 51 + , 52 + , 53 + , 54 + , 55 + , 56 + , 57 + , -1 + , -1 + , 60 + , 61 + , 62 + , 195 + , 64 + , 65 + , 66 + , 67 + , 68 + , 69 + , 70 + , 71 + , 72 + , 73 + , 74 + , 75 + , 76 + , 77 + , 78 + , 79 + , 80 + , 81 + , 82 + , 83 + , 84 + , 85 + , 86 + , 87 + , 88 + , 89 + , 90 + , -1 + , 92 + , -1 + , 94 + , 95 + , 96 + , 97 + , 98 + , 99 + , 100 + , 101 + , 102 + , 103 + , 104 + , 105 + , 106 + , 107 + , 108 + , 109 + , 110 + , 111 + , 112 + , 113 + , 114 + , 115 + , 116 + , 117 + , 118 + , 119 + , 120 + , 121 + , 122 + , -1 + , -1 + , -1 + , 126 + , 127 + , 192 + , 193 + , 194 + , 195 + , 196 + , 197 + , 198 + , 199 + , 200 + , 201 + , 202 + , 203 + , 204 + , 205 + , 206 + , 207 + , 208 + , 209 + , 210 + , 211 + , 212 + , 213 + , 214 + , 215 + , 216 + , 217 + , 218 + , 219 + , 220 + , 221 + , 222 + , 223 + , 224 + , 225 + , 226 + , 227 + , 228 + , 229 + , 230 + , 231 + , 232 + , 233 + , 234 + , 235 + , 236 + , 237 + , 238 + , 239 + , 240 + , 241 + , 242 + , 243 + , 244 + , 245 + , 246 + , 247 + , 248 + , 249 + , 250 + , 251 + , 252 + , 253 + , 254 + , 255 + , -1 + , -1 + , 194 + , 195 + , 196 + , 197 + , 198 + , 199 + , 200 + , 201 + , 202 + , 203 + , 204 + , 205 + , 206 + , 207 + , 208 + , 209 + , 210 + , 211 + , 212 + , 213 + , 214 + , 215 + , 216 + , 217 + , 218 + , 219 + , 220 + , 221 + , 222 + , 223 + , 224 + , 225 + , 226 + , 227 + , 228 + , 229 + , 230 + , 231 + , 232 + , 233 + , 234 + , 235 + , 236 + , 237 + , 238 + , 239 + , 240 + , 241 + , 242 + , 243 + , 244 + , 0 + , 1 + , 2 + , 3 + , 4 + , 5 + , 6 + , 7 + , 8 + , -1 + , -1 + , 11 + , 12 + , -1 + , 14 + , 15 + , 16 + , 17 + , 18 + , 19 + , 20 + , 21 + , 22 + , 23 + , 24 + , 25 + , 26 + , 27 + , 28 + , 29 + , 30 + , 31 + , -1 + , -1 + , 34 + , 35 + , 36 + , 37 + , 38 + , 39 + , -1 + , -1 + , 42 + , 43 + , -1 + , -1 + , -1 + , 47 + , 48 + , 49 + , 50 + , 51 + , 52 + , 53 + , 54 + , 55 + , 56 + , 57 + , -1 + , -1 + , 60 + , 61 + , 62 + , -1 + , 64 + , 65 + , 66 + , 67 + , 68 + , 69 + , 70 + , 71 + , 72 + , 73 + , 74 + , 75 + , 76 + , 77 + , 78 + , 79 + , 80 + , 81 + , 82 + , 83 + , 84 + , 85 + , 86 + , 87 + , 88 + , 89 + , 90 + , -1 + , 92 + , -1 + , 94 + , 95 + , 96 + , 97 + , 98 + , 99 + , 100 + , 101 + , 102 + , 103 + , 104 + , 105 + , 106 + , 107 + , 108 + , 109 + , 110 + , 111 + , 112 + , 113 + , 114 + , 115 + , 116 + , 117 + , 118 + , 119 + , 120 + , 121 + , 122 + , -1 + , -1 + , -1 + , 126 + , 127 + , 191 + , 192 + , 193 + , 194 + , 195 + , 196 + , 197 + , 198 + , 199 + , 200 + , 201 + , 202 + , 203 + , 204 + , 205 + , 206 + , 207 + , 208 + , 209 + , 210 + , 211 + , 212 + , 213 + , 214 + , 215 + , 216 + , 217 + , 218 + , 219 + , 220 + , 221 + , 222 + , 223 + , 224 + , 225 + , 226 + , 227 + , 228 + , 229 + , 230 + , 231 + , 232 + , 233 + , 234 + , 235 + , 236 + , 237 + , 238 + , 239 + , 240 + , 241 + , 242 + , 243 + , 244 + , 245 + , 246 + , 247 + , 248 + , 249 + , 250 + , 251 + , 252 + , 253 + , 254 + , 255 + , -1 + , 194 + , 195 + , 196 + , 197 + , 198 + , 199 + , 200 + , 201 + , 202 + , 203 + , 204 + , 205 + , 206 + , 207 + , 208 + , 209 + , 210 + , 211 + , 212 + , 213 + , 214 + , 215 + , 216 + , 217 + , 218 + , 219 + , 220 + , 221 + , 222 + , 223 + , 224 + , 225 + , 226 + , 227 + , 228 + , 229 + , 230 + , 231 + , 232 + , 233 + , 234 + , 235 + , 236 + , 237 + , 238 + , 239 + , 240 + , 241 + , 242 + , 243 + , 244 + , 0 + , 1 + , 2 + , 3 + , 4 + , 5 + , 6 + , 7 + , 8 + , -1 + , -1 + , 11 + , 12 + , -1 + , 14 + , 15 + , 16 + , 17 + , 18 + , 19 + , 20 + , 21 + , 22 + , 23 + , 24 + , 25 + , 26 + , 27 + , 28 + , 29 + , 30 + , 31 + , -1 + , -1 + , 34 + , 35 + , 36 + , 37 + , 38 + , 39 + , -1 + , -1 + , 42 + , 43 + , -1 + , 45 + , -1 + , 47 + , 48 + , 49 + , 50 + , 51 + , 52 + , 53 + , 54 + , 55 + , 56 + , 57 + , -1 + , -1 + , 60 + , 61 + , 62 + , -1 + , 64 + , 65 + , 66 + , 67 + , 68 + , 69 + , 70 + , 71 + , 72 + , 73 + , 74 + , 75 + , 76 + , 77 + , 78 + , 79 + , 80 + , 81 + , 82 + , 83 + , 84 + , 85 + , 86 + , 87 + , 88 + , 89 + , 90 + , -1 + , 92 + , -1 + , 94 + , 95 + , 96 + , 97 + , 98 + , 99 + , 100 + , 101 + , 102 + , 103 + , 104 + , 105 + , 106 + , 107 + , 108 + , 109 + , 110 + , 111 + , 112 + , 113 + , 114 + , 115 + , 116 + , 117 + , 118 + , 119 + , 120 + , 121 + , 122 + , -1 + , -1 + , -1 + , 126 + , 127 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 194 + , 195 + , 196 + , 197 + , 198 + , 199 + , 200 + , 201 + , 202 + , 203 + , 204 + , 205 + , 206 + , 207 + , 208 + , 209 + , 210 + , 211 + , 212 + , 213 + , 214 + , 215 + , 216 + , 217 + , 218 + , 219 + , 220 + , 221 + , 222 + , 223 + , 224 + , 225 + , 226 + , 227 + , 228 + , 229 + , 230 + , 231 + , 232 + , 233 + , 234 + , 235 + , 236 + , 237 + , 238 + , 239 + , 240 + , 241 + , 242 + , 243 + , 244 + , 9 + , 10 + , -1 + , -1 + , 13 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 32 + , 33 + , -1 + , -1 + , -1 + , -1 + , -1 + , 39 + , 40 + , 41 + , -1 + , -1 + , 44 + , 45 + , 46 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 58 + , 59 + , -1 + , -1 + , -1 + , 63 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 91 + , -1 + , 93 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 123 + , 124 + , 125 + , -1 + , -1 + , 128 + , 129 + , 130 + , 131 + , 132 + , 133 + , 134 + , 135 + , 136 + , 137 + , 138 + , 139 + , 140 + , 141 + , 142 + , 143 + , 144 + , 145 + , 146 + , 147 + , 148 + , 149 + , 150 + , 151 + , 152 + , 153 + , 154 + , 155 + , 156 + , 157 + , 158 + , 159 + , 160 + , 161 + , 162 + , 163 + , 164 + , 165 + , 166 + , 167 + , 168 + , 169 + , 170 + , 171 + , 172 + , 173 + , 174 + , 175 + , 176 + , 177 + , 178 + , 179 + , 180 + , 181 + , 182 + , 183 + , 184 + , 185 + , 186 + , 187 + , 188 + , 189 + , 190 + , 191 + , 192 + , 193 + , 194 + , 195 + , 196 + , 197 + , 198 + , 199 + , 200 + , 201 + , 202 + , 203 + , 204 + , 205 + , 206 + , 207 + , 208 + , 209 + , 210 + , 211 + , 212 + , 213 + , 214 + , 215 + , 216 + , 217 + , 218 + , 219 + , 220 + , 221 + , 222 + , 223 + , 224 + , 225 + , 226 + , 227 + , 228 + , 229 + , 230 + , 231 + , 232 + , 233 + , 234 + , 235 + , 236 + , 237 + , 238 + , 239 + , 240 + , 241 + , 242 + , 243 + , 244 + , 245 + , 246 + , 247 + , 248 + , 249 + , 250 + , 251 + , 252 + , 253 + , 254 + , 255 + , 0 + , 1 + , 2 + , 3 + , 4 + , 5 + , 6 + , 7 + , 8 + , 9 + , 10 + , 11 + , 12 + , 13 + , 14 + , 15 + , 16 + , 17 + , 18 + , 19 + , 20 + , 21 + , 22 + , 23 + , 24 + , 25 + , 26 + , 27 + , 28 + , 29 + , 30 + , 31 + , 32 + , 33 + , 34 + , 35 + , 36 + , 37 + , 38 + , 39 + , 40 + , 41 + , 42 + , 43 + , 44 + , 45 + , 46 + , 47 + , 48 + , 49 + , 50 + , 51 + , 52 + , 53 + , 54 + , 55 + , 56 + , 57 + , 58 + , 59 + , 60 + , 61 + , 62 + , 63 + , 64 + , 65 + , 66 + , 67 + , 68 + , 69 + , 70 + , 71 + , 72 + , 73 + , 74 + , 75 + , 76 + , 77 + , 78 + , 79 + , 80 + , 81 + , 82 + , 83 + , 84 + , 85 + , 86 + , 87 + , 88 + , 89 + , 90 + , 91 + , 92 + , 93 + , 94 + , 95 + , 96 + , 97 + , 98 + , 99 + , 100 + , 101 + , 102 + , 103 + , 104 + , 105 + , 106 + , 107 + , 108 + , 109 + , 110 + , 111 + , 112 + , 113 + , 114 + , 115 + , 116 + , 117 + , 118 + , 119 + , 120 + , 121 + , 122 + , 123 + , 124 + , 125 + , 126 + , 127 + , -1 + , 128 + , 129 + , 130 + , 131 + , 132 + , 133 + , 134 + , 135 + , 136 + , 137 + , 138 + , 139 + , 140 + , 141 + , 142 + , 143 + , 144 + , 145 + , 146 + , 147 + , 148 + , 149 + , 150 + , 151 + , 152 + , 153 + , 154 + , 155 + , 156 + , 157 + , 158 + , 159 + , 160 + , 161 + , 162 + , 163 + , 164 + , 165 + , 166 + , 167 + , 168 + , 169 + , 170 + , 171 + , 172 + , 173 + , 174 + , 175 + , 176 + , 177 + , 178 + , 179 + , 180 + , 181 + , 182 + , 183 + , 184 + , 185 + , 186 + , 187 + , 188 + , 189 + , 190 + , 191 + , 192 + , 193 + , 194 + , 195 + , 196 + , 197 + , 198 + , 199 + , 200 + , 201 + , 202 + , 203 + , 204 + , 205 + , 206 + , 207 + , 208 + , 209 + , 210 + , 211 + , 212 + , 213 + , 214 + , 215 + , 216 + , 217 + , 218 + , 219 + , 220 + , 221 + , 222 + , 223 + , 224 + , 225 + , 226 + , 227 + , 228 + , 229 + , 230 + , 231 + , 232 + , 233 + , 234 + , 235 + , 236 + , 237 + , 238 + , 239 + , 240 + , 241 + , 242 + , 243 + , 244 + , 245 + , 246 + , 247 + , 248 + , 249 + , 250 + , 251 + , 252 + , 253 + , 254 + , 255 + , 128 + , 129 + , 130 + , 131 + , 132 + , 133 + , 134 + , 135 + , 136 + , 137 + , 138 + , 139 + , 140 + , 141 + , 142 + , 143 + , 144 + , 145 + , 146 + , 147 + , 148 + , 149 + , 150 + , 151 + , 152 + , 153 + , 154 + , 155 + , 156 + , 157 + , 158 + , 159 + , 160 + , 161 + , 162 + , 163 + , 164 + , 165 + , 166 + , 167 + , 168 + , 169 + , 170 + , 171 + , 172 + , 173 + , 174 + , 175 + , 176 + , 177 + , 178 + , 179 + , 180 + , 181 + , 182 + , 183 + , 184 + , 185 + , 186 + , 187 + , 188 + , 189 + , 190 + , 191 + , 192 + , 193 + , 194 + , 195 + , 196 + , 197 + , 198 + , 199 + , 200 + , 201 + , 202 + , 203 + , 204 + , 205 + , 206 + , 207 + , 208 + , 209 + , 210 + , 211 + , 212 + , 213 + , 214 + , 215 + , 216 + , 217 + , 218 + , 219 + , 220 + , 221 + , 222 + , 223 + , 224 + , 225 + , 226 + , 227 + , 228 + , 229 + , 230 + , 231 + , 232 + , 233 + , 234 + , 235 + , 236 + , 237 + , 238 + , 239 + , 240 + , 241 + , 242 + , 243 + , 244 + , 245 + , 246 + , 247 + , 248 + , 249 + , 250 + , 251 + , 252 + , 253 + , 254 + , 255 + , 143 + , 144 + , 145 + , 146 + , 147 + , 148 + , 149 + , 150 + , 151 + , 152 + , 153 + , 154 + , 155 + , 156 + , 157 + , 158 + , 159 + , 160 + , 161 + , 162 + , 163 + , 164 + , 165 + , 166 + , 167 + , 168 + , 169 + , 170 + , 171 + , 172 + , 173 + , 174 + , 175 + , 176 + , 177 + , 178 + , 179 + , 180 + , 181 + , 182 + , 183 + , 184 + , 185 + , 186 + , 187 + , 188 + , 189 + , 190 + , 191 + , 192 + , 193 + , 194 + , 195 + , 196 + , 197 + , 198 + , 199 + , 200 + , 201 + , 202 + , 203 + , 204 + , 205 + , 206 + , 207 + , 208 + , 209 + , 210 + , 211 + , 212 + , 213 + , 214 + , 215 + , 216 + , 217 + , 218 + , 219 + , 220 + , 221 + , 222 + , 223 + , 224 + , 225 + , 226 + , 227 + , 228 + , 229 + , 230 + , 231 + , 232 + , 233 + , 234 + , 235 + , 236 + , 237 + , 238 + , 239 + , 240 + , 241 + , 242 + , 243 + , 244 + , 245 + , 246 + , 247 + , 248 + , 249 + , 250 + , 251 + , 252 + , 253 + , 254 + , 255 + , 0 + , 1 + , 2 + , 3 + , 4 + , 5 + , 6 + , 7 + , 8 + , -1 + , -1 + , 11 + , 12 + , -1 + , 14 + , 15 + , 16 + , 17 + , 18 + , 19 + , 20 + , 21 + , 22 + , 23 + , 24 + , 25 + , 26 + , 27 + , 28 + , 29 + , 30 + , 31 + , -1 + , -1 + , 34 + , 35 + , 36 + , 37 + , 38 + , 39 + , -1 + , -1 + , 42 + , 43 + , -1 + , -1 + , -1 + , 47 + , 48 + , 49 + , 50 + , 51 + , 52 + , 53 + , 54 + , 55 + , 56 + , 57 + , -1 + , -1 + , 60 + , 61 + , 62 + , -1 + , 64 + , 65 + , 66 + , 67 + , 68 + , 69 + , 70 + , 71 + , 72 + , 73 + , 74 + , 75 + , 76 + , 77 + , 78 + , 79 + , 80 + , 81 + , 82 + , 83 + , 84 + , 85 + , 86 + , 87 + , 88 + , 89 + , 90 + , -1 + , 92 + , -1 + , 94 + , 95 + , 96 + , 97 + , 98 + , 99 + , 100 + , 101 + , 102 + , 103 + , 104 + , 105 + , 106 + , 107 + , 108 + , 109 + , 110 + , 111 + , 112 + , 113 + , 114 + , 115 + , 116 + , 117 + , 118 + , 119 + , 120 + , 121 + , 122 + , -1 + , -1 + , -1 + , 126 + , 127 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 194 + , 195 + , 196 + , 197 + , 198 + , 199 + , 200 + , 201 + , 202 + , 203 + , 204 + , 205 + , 206 + , 207 + , 208 + , 209 + , 210 + , 211 + , 212 + , 213 + , 214 + , 215 + , 216 + , 217 + , 218 + , 219 + , 220 + , 221 + , 222 + , 223 + , 224 + , 225 + , 226 + , 227 + , 228 + , 229 + , 230 + , 231 + , 232 + , 233 + , 234 + , 235 + , 236 + , 237 + , 238 + , 239 + , 240 + , 241 + , 242 + , 243 + , 244 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + ] + +alex_deflt :: Array Int Int +alex_deflt = listArray (0 :: Int, 50) + [ -1 + , 23 + , 14 + , 23 + , 2 + , 14 + , 2 + , 14 + , -1 + , 38 + , 14 + , -1 + , -1 + , 14 + , 14 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 2 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 38 + , 38 + , -1 + , -1 + , 38 + , 47 + , 38 + , 47 + , 48 + , 38 + , 47 + , 48 + , -1 + ] + +alex_accept = listArray (0 :: Int, 50) + [ AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAcc 10 + , AlexAccNone + , AlexAcc 9 + , AlexAcc 8 + , AlexAccNone + , AlexAcc 7 + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccSkip + , AlexAcc 6 + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAcc 5 + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAcc 4 + , AlexAcc 3 + , AlexAcc 2 + , AlexAcc 1 + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAcc 0 + ] + +alex_actions = array (0 :: Int, 11) + [ (10,alex_action_4) + , (9,alex_action_5) + , (8,alex_action_5) + , (7,alex_action_6) + , (6,alex_action_1) + , (5,alex_action_2) + , (4,alex_action_3) + , (3,alex_action_3) + , (2,alex_action_3) + , (1,alex_action_3) + , (0,alex_action_4) + ] + +{-# LINE 62 "Lex.x" #-} +-- | Create a token with position. +tok :: (String -> Tok) -> (Posn -> String -> Token) +tok f p = PT p . f + +-- | Token without position. +data Tok + = TK {-# UNPACK #-} !TokSymbol -- ^ Reserved word or symbol. + | TL !String -- ^ String literal. + | TI !String -- ^ Integer literal. + | TV !String -- ^ Identifier. + | TD !String -- ^ Float literal. + | TC !String -- ^ Character literal. + | T_Bytes !String + | T_Function !String + | T_LabelId !String + | T_AlphaIndex !String + deriving (Eq, Show, Ord) + +-- | Smart constructor for 'Tok' for the sake of backwards compatibility. +pattern TS :: String -> Int -> Tok +pattern TS t i = TK (TokSymbol t i) + +-- | Keyword or symbol tokens have a unique ID. +data TokSymbol = TokSymbol + { tsText :: String + -- ^ Keyword or symbol text. + , tsID :: !Int + -- ^ Unique ID. + } deriving (Show) + +-- | Keyword/symbol equality is determined by the unique ID. +instance Eq TokSymbol where (==) = (==) `on` tsID + +-- | Keyword/symbol ordering is determined by the unique ID. +instance Ord TokSymbol where compare = compare `on` tsID + +-- | Token with position. +data Token + = PT Posn Tok + | Err Posn + deriving (Eq, Show, Ord) + +-- | Pretty print a position. +printPosn :: Posn -> String +printPosn (Pn _ l c) = "line " ++ show l ++ ", column " ++ show c + +-- | Pretty print the position of the first token in the list. +tokenPos :: [Token] -> String +tokenPos (t:_) = printPosn (tokenPosn t) +tokenPos [] = "end of file" + +-- | Get the position of a token. +tokenPosn :: Token -> Posn +tokenPosn (PT p _) = p +tokenPosn (Err p) = p + +-- | Get line and column of a token. +tokenLineCol :: Token -> (Int, Int) +tokenLineCol = posLineCol . tokenPosn + +-- | Get line and column of a position. +posLineCol :: Posn -> (Int, Int) +posLineCol (Pn _ l c) = (l,c) + +-- | Convert a token into "position token" form. +mkPosToken :: Token -> ((Int, Int), String) +mkPosToken t = (tokenLineCol t, tokenText t) + +-- | Convert a token to its text. +tokenText :: Token -> String +tokenText t = case t of + PT _ (TS s _) -> s + PT _ (TL s) -> show s + PT _ (TI s) -> s + PT _ (TV s) -> s + PT _ (TD s) -> s + PT _ (TC s) -> s + Err _ -> "#error" + PT _ (T_Bytes s) -> s + PT _ (T_Function s) -> s + PT _ (T_LabelId s) -> s + PT _ (T_AlphaIndex s) -> s + +-- | Convert a token to a string. +prToken :: Token -> String +prToken t = tokenText t + +-- | Finite map from text to token organized as binary search tree. +data BTree + = N -- ^ Nil (leaf). + | B String Tok BTree BTree + -- ^ Binary node. + deriving (Show) + +-- | Convert potential keyword into token or use fallback conversion. +eitherResIdent :: (String -> Tok) -> String -> Tok +eitherResIdent tv s = treeFind resWords + where + treeFind N = tv s + treeFind (B a t left right) = + case compare s a of + LT -> treeFind left + GT -> treeFind right + EQ -> t + +-- | The keywords and symbols of the language organized as binary search tree. +resWords :: BTree +resWords = + b "\958" 9 + (b "\916" 5 + (b "{" 3 (b "." 2 (b "," 1 N N) N) (b "}" 4 N N)) + (b "\955" 7 (b "\934" 6 N N) (b "\957" 8 N N))) + (b "\8614" 13 + (b "\963" 11 (b "\961" 10 N N) (b "\966" 12 N N)) + (b "\8869" 15 (b "\8709" 14 N N) (b "\10509" 16 N N))) + where + b s n = B bs (TS bs n) + where + bs = s + +-- | Unquote string literal. +unescapeInitTail :: String -> String +unescapeInitTail = id . unesc . tail . id + where + unesc s = case s of + '\\':c:cs | elem c ['\"', '\\', '\''] -> c : unesc cs + '\\':'n':cs -> '\n' : unesc cs + '\\':'t':cs -> '\t' : unesc cs + '\\':'r':cs -> '\r' : unesc cs + '\\':'f':cs -> '\f' : unesc cs + '"':[] -> [] + c:cs -> c : unesc cs + _ -> [] + +------------------------------------------------------------------- +-- Alex wrapper code. +-- A modified "posn" wrapper. +------------------------------------------------------------------- + +data Posn = Pn !Int !Int !Int + deriving (Eq, Show, Ord) + +alexStartPos :: Posn +alexStartPos = Pn 0 1 1 + +alexMove :: Posn -> Char -> Posn +alexMove (Pn a l c) '\t' = Pn (a+1) l (((c+7) `div` 8)*8+1) +alexMove (Pn a l c) '\n' = Pn (a+1) (l+1) 1 +alexMove (Pn a l c) _ = Pn (a+1) l (c+1) + +type Byte = Word8 + +type AlexInput = (Posn, -- current position, + Char, -- previous char + [Byte], -- pending bytes on the current char + String) -- current input string + +tokens :: String -> [Token] +tokens str = go (alexStartPos, '\n', [], str) + where + go :: AlexInput -> [Token] + go inp@(pos, _, _, str) = + case alexScan inp 0 of + AlexEOF -> [] + AlexError (pos, _, _, _) -> [Err pos] + AlexSkip inp' len -> go inp' + AlexToken inp' len act -> act pos (take len str) : (go inp') + +alexGetByte :: AlexInput -> Maybe (Byte,AlexInput) +alexGetByte (p, c, (b:bs), s) = Just (b, (p, c, bs, s)) +alexGetByte (p, _, [], s) = + case s of + [] -> Nothing + (c:s) -> + let p' = alexMove p c + (b:bs) = utf8Encode c + in p' `seq` Just (b, (p', c, bs, s)) + +alexInputPrevChar :: AlexInput -> Char +alexInputPrevChar (p, c, bs, s) = c + +-- | Encode a Haskell String to a list of Word8 values, in UTF8 format. +utf8Encode :: Char -> [Word8] +utf8Encode = map fromIntegral . go . ord + where + go oc + | oc <= 0x7f = [oc] + + | oc <= 0x7ff = [ 0xc0 + (oc `Data.Bits.shiftR` 6) + , 0x80 + oc Data.Bits..&. 0x3f + ] + + | oc <= 0xffff = [ 0xe0 + (oc `Data.Bits.shiftR` 12) + , 0x80 + ((oc `Data.Bits.shiftR` 6) Data.Bits..&. 0x3f) + , 0x80 + oc Data.Bits..&. 0x3f + ] + | otherwise = [ 0xf0 + (oc `Data.Bits.shiftR` 18) + , 0x80 + ((oc `Data.Bits.shiftR` 12) Data.Bits..&. 0x3f) + , 0x80 + ((oc `Data.Bits.shiftR` 6) Data.Bits..&. 0x3f) + , 0x80 + oc Data.Bits..&. 0x3f + ] +alex_action_1 = tok (eitherResIdent TV) +alex_action_2 = tok (eitherResIdent T_Bytes) +alex_action_3 = tok (eitherResIdent T_Function) +alex_action_4 = tok (eitherResIdent T_LabelId) +alex_action_5 = tok (eitherResIdent T_AlphaIndex) +alex_action_6 = tok (eitherResIdent TV) + +#define ALEX_NOPRED 1 +-- ----------------------------------------------------------------------------- +-- ALEX TEMPLATE +-- +-- This code is in the PUBLIC DOMAIN; you may copy it freely and use +-- it for any purpose whatsoever. + +-- ----------------------------------------------------------------------------- +-- INTERNALS and main scanner engine + +#ifdef ALEX_GHC +# define ILIT(n) n# +# define IBOX(n) (I# (n)) +# define FAST_INT Int# +-- Do not remove this comment. Required to fix CPP parsing when using GCC and a clang-compiled alex. +# if __GLASGOW_HASKELL__ > 706 +# define GTE(n,m) (tagToEnum# (n >=# m)) +# define EQ(n,m) (tagToEnum# (n ==# m)) +# else +# define GTE(n,m) (n >=# m) +# define EQ(n,m) (n ==# m) +# endif +# define PLUS(n,m) (n +# m) +# define MINUS(n,m) (n -# m) +# define TIMES(n,m) (n *# m) +# define NEGATE(n) (negateInt# (n)) +# define IF_GHC(x) (x) +#else +# define ILIT(n) (n) +# define IBOX(n) (n) +# define FAST_INT Int +# define GTE(n,m) (n >= m) +# define EQ(n,m) (n == m) +# define PLUS(n,m) (n + m) +# define MINUS(n,m) (n - m) +# define TIMES(n,m) (n * m) +# define NEGATE(n) (negate (n)) +# define IF_GHC(x) +#endif + +#ifdef ALEX_GHC +data AlexAddr = AlexA# Addr# +-- Do not remove this comment. Required to fix CPP parsing when using GCC and a clang-compiled alex. +#if __GLASGOW_HASKELL__ < 503 +uncheckedShiftL# = shiftL# +#endif + +{-# INLINE alexIndexInt16OffAddr #-} +alexIndexInt16OffAddr :: AlexAddr -> Int# -> Int# +alexIndexInt16OffAddr (AlexA# arr) off = +#ifdef WORDS_BIGENDIAN + narrow16Int# i + where + i = word2Int# ((high `uncheckedShiftL#` 8#) `or#` low) + high = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#))) + low = int2Word# (ord# (indexCharOffAddr# arr off')) + off' = off *# 2# +#else +#if __GLASGOW_HASKELL__ >= 901 + int16ToInt# +#endif + (indexInt16OffAddr# arr off) +#endif +#else +alexIndexInt16OffAddr arr off = arr ! off +#endif + +#ifdef ALEX_GHC +{-# INLINE alexIndexInt32OffAddr #-} +alexIndexInt32OffAddr :: AlexAddr -> Int# -> Int# +alexIndexInt32OffAddr (AlexA# arr) off = +#ifdef WORDS_BIGENDIAN + narrow32Int# i + where + i = word2Int# ((b3 `uncheckedShiftL#` 24#) `or#` + (b2 `uncheckedShiftL#` 16#) `or#` + (b1 `uncheckedShiftL#` 8#) `or#` b0) + b3 = int2Word# (ord# (indexCharOffAddr# arr (off' +# 3#))) + b2 = int2Word# (ord# (indexCharOffAddr# arr (off' +# 2#))) + b1 = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#))) + b0 = int2Word# (ord# (indexCharOffAddr# arr off')) + off' = off *# 4# +#else +#if __GLASGOW_HASKELL__ >= 901 + int32ToInt# +#endif + (indexInt32OffAddr# arr off) +#endif +#else +alexIndexInt32OffAddr arr off = arr ! off +#endif + +#ifdef ALEX_GHC + +#if __GLASGOW_HASKELL__ < 503 +quickIndex arr i = arr ! i +#else +-- GHC >= 503, unsafeAt is available from Data.Array.Base. +quickIndex = unsafeAt +#endif +#else +quickIndex arr i = arr ! i +#endif + +-- ----------------------------------------------------------------------------- +-- Main lexing routines + +data AlexReturn a + = AlexEOF + | AlexError !AlexInput + | AlexSkip !AlexInput !Int + | AlexToken !AlexInput !Int a + +-- alexScan :: AlexInput -> StartCode -> AlexReturn a +alexScan input__ IBOX(sc) + = alexScanUser undefined input__ IBOX(sc) + +alexScanUser user__ input__ IBOX(sc) + = case alex_scan_tkn user__ input__ ILIT(0) input__ sc AlexNone of + (AlexNone, input__') -> + case alexGetByte input__ of + Nothing -> +#ifdef ALEX_DEBUG + trace ("End of input.") $ +#endif + AlexEOF + Just _ -> +#ifdef ALEX_DEBUG + trace ("Error.") $ +#endif + AlexError input__' + + (AlexLastSkip input__'' len, _) -> +#ifdef ALEX_DEBUG + trace ("Skipping.") $ +#endif + AlexSkip input__'' len + + (AlexLastAcc k input__''' len, _) -> +#ifdef ALEX_DEBUG + trace ("Accept.") $ +#endif + AlexToken input__''' len (alex_actions ! k) + + +-- Push the input through the DFA, remembering the most recent accepting +-- state it encountered. + +alex_scan_tkn user__ orig_input len input__ s last_acc = + input__ `seq` -- strict in the input + let + new_acc = (check_accs (alex_accept `quickIndex` IBOX(s))) + in + new_acc `seq` + case alexGetByte input__ of + Nothing -> (new_acc, input__) + Just (c, new_input) -> +#ifdef ALEX_DEBUG + trace ("State: " ++ show IBOX(s) ++ ", char: " ++ show c) $ +#endif + case fromIntegral c of { IBOX(ord_c) -> + let + base = alexIndexInt32OffAddr alex_base s + offset = PLUS(base,ord_c) + check = alexIndexInt16OffAddr alex_check offset + + new_s = if GTE(offset,ILIT(0)) && EQ(check,ord_c) + then alexIndexInt16OffAddr alex_table offset + else alexIndexInt16OffAddr alex_deflt s + in + case new_s of + ILIT(-1) -> (new_acc, input__) + -- on an error, we want to keep the input *before* the + -- character that failed, not after. + _ -> alex_scan_tkn user__ orig_input +#ifdef ALEX_LATIN1 + PLUS(len,ILIT(1)) + -- issue 119: in the latin1 encoding, *each* byte is one character +#else + (if c < 0x80 || c >= 0xC0 then PLUS(len,ILIT(1)) else len) + -- note that the length is increased ONLY if this is the 1st byte in a char encoding) +#endif + new_input new_s new_acc + } + where + check_accs (AlexAccNone) = last_acc + check_accs (AlexAcc a ) = AlexLastAcc a input__ IBOX(len) + check_accs (AlexAccSkip) = AlexLastSkip input__ IBOX(len) +#ifndef ALEX_NOPRED + check_accs (AlexAccPred a predx rest) + | predx user__ orig_input IBOX(len) input__ + = AlexLastAcc a input__ IBOX(len) + | otherwise + = check_accs rest + check_accs (AlexAccSkipPred predx rest) + | predx user__ orig_input IBOX(len) input__ + = AlexLastSkip input__ IBOX(len) + | otherwise + = check_accs rest +#endif + +data AlexLastAcc + = AlexNone + | AlexLastAcc !Int !AlexInput !Int + | AlexLastSkip !AlexInput !Int + +data AlexAcc user + = AlexAccNone + | AlexAcc Int + | AlexAccSkip +#ifndef ALEX_NOPRED + | AlexAccPred Int (AlexAccPred user) (AlexAcc user) + | AlexAccSkipPred (AlexAccPred user) (AlexAcc user) + +type AlexAccPred user = user -> AlexInput -> Int -> AlexInput -> Bool + +-- ----------------------------------------------------------------------------- +-- Predicates on a rule + +alexAndPred p1 p2 user__ in1 len in2 + = p1 user__ in1 len in2 && p2 user__ in1 len in2 + +--alexPrevCharIsPred :: Char -> AlexAccPred _ +alexPrevCharIs c _ input__ _ _ = c == alexInputPrevChar input__ + +alexPrevCharMatches f _ input__ _ _ = f (alexInputPrevChar input__) + +--alexPrevCharIsOneOfPred :: Array Char Bool -> AlexAccPred _ +alexPrevCharIsOneOf arr _ input__ _ _ = arr ! alexInputPrevChar input__ + +--alexRightContext :: Int -> AlexAccPred _ +alexRightContext IBOX(sc) user__ _ _ input__ = + case alex_scan_tkn user__ input__ ILIT(0) input__ sc AlexNone of + (AlexNone, _) -> False + _ -> True + -- TODO: there's no need to find the longest + -- match when checking the right context, just + -- the first match will do. +#endif diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.x b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.x new file mode 100644 index 000000000..e36054bde --- /dev/null +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.x @@ -0,0 +1,264 @@ +-- -*- haskell -*- File generated by the BNF Converter (bnfc 2.9.5). + +-- Lexer definition for use with Alex 3 +{ +{-# OPTIONS -fno-warn-incomplete-patterns #-} +{-# OPTIONS_GHC -w #-} + +{-# LANGUAGE PatternSynonyms #-} + +module Language.EO.Phi.Syntax.Lex where + +import Prelude + +import qualified Data.Bits +import Data.Char (ord) +import Data.Function (on) +import Data.Word (Word8) +} + +-- Predefined character classes + +$c = [A-Z\192-\221] # [\215] -- capital isolatin1 letter (215 = \times) FIXME +$s = [a-z\222-\255] # [\247] -- small isolatin1 letter (247 = \div ) FIXME +$l = [$c $s] -- letter +$d = [0-9] -- digit +$i = [$l $d _ '] -- identifier character +$u = [. \n] -- universal: any character + +-- Symbols and non-identifier-like reserved words + +@rsyms = \Δ | \λ | \Φ | \ξ | \φ | \ρ | \σ | \ν | \{ | \} | \⊥ | \↦ | \∅ | \⤍ | \, | \. + +:- + +-- Whitespace (skipped) +$white+ ; + +-- Symbols +@rsyms + { tok (eitherResIdent TV) } + +-- token Bytes +\- \- | [0 1 2 3 4 5 6 7 8 9 A B C D E F][0 1 2 3 4 5 6 7 8 9 A B C D E F](\- [0 1 2 3 4 5 6 7 8 9 A B C D E F][0 1 2 3 4 5 6 7 8 9 A B C D E F]) * (\- \-) + { tok (eitherResIdent T_Bytes) } + +-- token Function +$c [$u # [\t \n \r \ \! \' \( \) \, \- \. \: \; \? \[ \] \{ \| \} \⟦ \⟧]] * + { tok (eitherResIdent T_Function) } + +-- token LabelId +$s [$u # [\t \n \r \ \! \' \( \) \, \- \. \: \; \? \[ \] \{ \| \} \⟦ \⟧]] * + { tok (eitherResIdent T_LabelId) } + +-- token AlphaIndex +α 0 | α [$d # 0]$d * + { tok (eitherResIdent T_AlphaIndex) } + +-- Keywords and Ident +$l $i* + { tok (eitherResIdent TV) } + +{ +-- | Create a token with position. +tok :: (String -> Tok) -> (Posn -> String -> Token) +tok f p = PT p . f + +-- | Token without position. +data Tok + = TK {-# UNPACK #-} !TokSymbol -- ^ Reserved word or symbol. + | TL !String -- ^ String literal. + | TI !String -- ^ Integer literal. + | TV !String -- ^ Identifier. + | TD !String -- ^ Float literal. + | TC !String -- ^ Character literal. + | T_Bytes !String + | T_Function !String + | T_LabelId !String + | T_AlphaIndex !String + deriving (Eq, Show, Ord) + +-- | Smart constructor for 'Tok' for the sake of backwards compatibility. +pattern TS :: String -> Int -> Tok +pattern TS t i = TK (TokSymbol t i) + +-- | Keyword or symbol tokens have a unique ID. +data TokSymbol = TokSymbol + { tsText :: String + -- ^ Keyword or symbol text. + , tsID :: !Int + -- ^ Unique ID. + } deriving (Show) + +-- | Keyword/symbol equality is determined by the unique ID. +instance Eq TokSymbol where (==) = (==) `on` tsID + +-- | Keyword/symbol ordering is determined by the unique ID. +instance Ord TokSymbol where compare = compare `on` tsID + +-- | Token with position. +data Token + = PT Posn Tok + | Err Posn + deriving (Eq, Show, Ord) + +-- | Pretty print a position. +printPosn :: Posn -> String +printPosn (Pn _ l c) = "line " ++ show l ++ ", column " ++ show c + +-- | Pretty print the position of the first token in the list. +tokenPos :: [Token] -> String +tokenPos (t:_) = printPosn (tokenPosn t) +tokenPos [] = "end of file" + +-- | Get the position of a token. +tokenPosn :: Token -> Posn +tokenPosn (PT p _) = p +tokenPosn (Err p) = p + +-- | Get line and column of a token. +tokenLineCol :: Token -> (Int, Int) +tokenLineCol = posLineCol . tokenPosn + +-- | Get line and column of a position. +posLineCol :: Posn -> (Int, Int) +posLineCol (Pn _ l c) = (l,c) + +-- | Convert a token into "position token" form. +mkPosToken :: Token -> ((Int, Int), String) +mkPosToken t = (tokenLineCol t, tokenText t) + +-- | Convert a token to its text. +tokenText :: Token -> String +tokenText t = case t of + PT _ (TS s _) -> s + PT _ (TL s) -> show s + PT _ (TI s) -> s + PT _ (TV s) -> s + PT _ (TD s) -> s + PT _ (TC s) -> s + Err _ -> "#error" + PT _ (T_Bytes s) -> s + PT _ (T_Function s) -> s + PT _ (T_LabelId s) -> s + PT _ (T_AlphaIndex s) -> s + +-- | Convert a token to a string. +prToken :: Token -> String +prToken t = tokenText t + +-- | Finite map from text to token organized as binary search tree. +data BTree + = N -- ^ Nil (leaf). + | B String Tok BTree BTree + -- ^ Binary node. + deriving (Show) + +-- | Convert potential keyword into token or use fallback conversion. +eitherResIdent :: (String -> Tok) -> String -> Tok +eitherResIdent tv s = treeFind resWords + where + treeFind N = tv s + treeFind (B a t left right) = + case compare s a of + LT -> treeFind left + GT -> treeFind right + EQ -> t + +-- | The keywords and symbols of the language organized as binary search tree. +resWords :: BTree +resWords = + b "\958" 9 + (b "\916" 5 + (b "{" 3 (b "." 2 (b "," 1 N N) N) (b "}" 4 N N)) + (b "\955" 7 (b "\934" 6 N N) (b "\957" 8 N N))) + (b "\8614" 13 + (b "\963" 11 (b "\961" 10 N N) (b "\966" 12 N N)) + (b "\8869" 15 (b "\8709" 14 N N) (b "\10509" 16 N N))) + where + b s n = B bs (TS bs n) + where + bs = s + +-- | Unquote string literal. +unescapeInitTail :: String -> String +unescapeInitTail = id . unesc . tail . id + where + unesc s = case s of + '\\':c:cs | elem c ['\"', '\\', '\''] -> c : unesc cs + '\\':'n':cs -> '\n' : unesc cs + '\\':'t':cs -> '\t' : unesc cs + '\\':'r':cs -> '\r' : unesc cs + '\\':'f':cs -> '\f' : unesc cs + '"':[] -> [] + c:cs -> c : unesc cs + _ -> [] + +------------------------------------------------------------------- +-- Alex wrapper code. +-- A modified "posn" wrapper. +------------------------------------------------------------------- + +data Posn = Pn !Int !Int !Int + deriving (Eq, Show, Ord) + +alexStartPos :: Posn +alexStartPos = Pn 0 1 1 + +alexMove :: Posn -> Char -> Posn +alexMove (Pn a l c) '\t' = Pn (a+1) l (((c+7) `div` 8)*8+1) +alexMove (Pn a l c) '\n' = Pn (a+1) (l+1) 1 +alexMove (Pn a l c) _ = Pn (a+1) l (c+1) + +type Byte = Word8 + +type AlexInput = (Posn, -- current position, + Char, -- previous char + [Byte], -- pending bytes on the current char + String) -- current input string + +tokens :: String -> [Token] +tokens str = go (alexStartPos, '\n', [], str) + where + go :: AlexInput -> [Token] + go inp@(pos, _, _, str) = + case alexScan inp 0 of + AlexEOF -> [] + AlexError (pos, _, _, _) -> [Err pos] + AlexSkip inp' len -> go inp' + AlexToken inp' len act -> act pos (take len str) : (go inp') + +alexGetByte :: AlexInput -> Maybe (Byte,AlexInput) +alexGetByte (p, c, (b:bs), s) = Just (b, (p, c, bs, s)) +alexGetByte (p, _, [], s) = + case s of + [] -> Nothing + (c:s) -> + let p' = alexMove p c + (b:bs) = utf8Encode c + in p' `seq` Just (b, (p', c, bs, s)) + +alexInputPrevChar :: AlexInput -> Char +alexInputPrevChar (p, c, bs, s) = c + +-- | Encode a Haskell String to a list of Word8 values, in UTF8 format. +utf8Encode :: Char -> [Word8] +utf8Encode = map fromIntegral . go . ord + where + go oc + | oc <= 0x7f = [oc] + + | oc <= 0x7ff = [ 0xc0 + (oc `Data.Bits.shiftR` 6) + , 0x80 + oc Data.Bits..&. 0x3f + ] + + | oc <= 0xffff = [ 0xe0 + (oc `Data.Bits.shiftR` 12) + , 0x80 + ((oc `Data.Bits.shiftR` 6) Data.Bits..&. 0x3f) + , 0x80 + oc Data.Bits..&. 0x3f + ] + | otherwise = [ 0xf0 + (oc `Data.Bits.shiftR` 18) + , 0x80 + ((oc `Data.Bits.shiftR` 12) Data.Bits..&. 0x3f) + , 0x80 + ((oc `Data.Bits.shiftR` 6) Data.Bits..&. 0x3f) + , 0x80 + oc Data.Bits..&. 0x3f + ] +} diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.x.bak b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.x.bak new file mode 100644 index 000000000..c120dbf30 --- /dev/null +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.x.bak @@ -0,0 +1,264 @@ +-- -*- haskell -*- File generated by the BNF Converter (bnfc 2.9.5). + +-- Lexer definition for use with Alex 3 +{ +{-# OPTIONS -fno-warn-incomplete-patterns #-} +{-# OPTIONS_GHC -w #-} + +{-# LANGUAGE PatternSynonyms #-} + +module Language.EO.Phi.Syntax.Lex where + +import Prelude + +import qualified Data.Bits +import Data.Char (ord) +import Data.Function (on) +import Data.Word (Word8) +} + +-- Predefined character classes + +$c = [A-Z\192-\221] # [\215] -- capital isolatin1 letter (215 = \times) FIXME +$s = [a-z\222-\255] # [\247] -- small isolatin1 letter (247 = \div ) FIXME +$l = [$c $s] -- letter +$d = [0-9] -- digit +$i = [$l $d _ '] -- identifier character +$u = [. \n] -- universal: any character + +-- Symbols and non-identifier-like reserved words + +@rsyms = \Δ | \λ | \Φ | \ξ | \φ | \ρ | \σ | \ν | \↦ | \∅ | \⤍ | \, | \{ | \} | \. + +:- + +-- Whitespace (skipped) +$white+ ; + +-- Symbols +@rsyms + { tok (eitherResIdent TV) } + +-- token Bytes +\- \- | [0 1 2 3 4 5 6 7 8 9 A B C D E F][0 1 2 3 4 5 6 7 8 9 A B C D E F](\- [0 1 2 3 4 5 6 7 8 9 A B C D E F][0 1 2 3 4 5 6 7 8 9 A B C D E F]) * (\- \-) + { tok (eitherResIdent T_Bytes) } + +-- token Function +$c [$u # [\t \n \r \ \! \' \( \) \, \- \. \: \; \? \[ \] \{ \| \} \⟦ \⟧]] * + { tok (eitherResIdent T_Function) } + +-- token LabelId +$s [$u # [\t \n \r \ \! \' \( \) \, \- \. \: \; \? \[ \] \{ \| \} \⟦ \⟧]] * + { tok (eitherResIdent T_LabelId) } + +-- token AlphaIndex +α 0 | α [$d # 0]$d * + { tok (eitherResIdent T_AlphaIndex) } + +-- Keywords and Ident +$l $i* + { tok (eitherResIdent TV) } + +{ +-- | Create a token with position. +tok :: (String -> Tok) -> (Posn -> String -> Token) +tok f p = PT p . f + +-- | Token without position. +data Tok + = TK {-# UNPACK #-} !TokSymbol -- ^ Reserved word or symbol. + | TL !String -- ^ String literal. + | TI !String -- ^ Integer literal. + | TV !String -- ^ Identifier. + | TD !String -- ^ Float literal. + | TC !String -- ^ Character literal. + | T_Bytes !String + | T_Function !String + | T_LabelId !String + | T_AlphaIndex !String + deriving (Eq, Show, Ord) + +-- | Smart constructor for 'Tok' for the sake of backwards compatibility. +pattern TS :: String -> Int -> Tok +pattern TS t i = TK (TokSymbol t i) + +-- | Keyword or symbol tokens have a unique ID. +data TokSymbol = TokSymbol + { tsText :: String + -- ^ Keyword or symbol text. + , tsID :: !Int + -- ^ Unique ID. + } deriving (Show) + +-- | Keyword/symbol equality is determined by the unique ID. +instance Eq TokSymbol where (==) = (==) `on` tsID + +-- | Keyword/symbol ordering is determined by the unique ID. +instance Ord TokSymbol where compare = compare `on` tsID + +-- | Token with position. +data Token + = PT Posn Tok + | Err Posn + deriving (Eq, Show, Ord) + +-- | Pretty print a position. +printPosn :: Posn -> String +printPosn (Pn _ l c) = "line " ++ show l ++ ", column " ++ show c + +-- | Pretty print the position of the first token in the list. +tokenPos :: [Token] -> String +tokenPos (t:_) = printPosn (tokenPosn t) +tokenPos [] = "end of file" + +-- | Get the position of a token. +tokenPosn :: Token -> Posn +tokenPosn (PT p _) = p +tokenPosn (Err p) = p + +-- | Get line and column of a token. +tokenLineCol :: Token -> (Int, Int) +tokenLineCol = posLineCol . tokenPosn + +-- | Get line and column of a position. +posLineCol :: Posn -> (Int, Int) +posLineCol (Pn _ l c) = (l,c) + +-- | Convert a token into "position token" form. +mkPosToken :: Token -> ((Int, Int), String) +mkPosToken t = (tokenLineCol t, tokenText t) + +-- | Convert a token to its text. +tokenText :: Token -> String +tokenText t = case t of + PT _ (TS s _) -> s + PT _ (TL s) -> show s + PT _ (TI s) -> s + PT _ (TV s) -> s + PT _ (TD s) -> s + PT _ (TC s) -> s + Err _ -> "#error" + PT _ (T_Bytes s) -> s + PT _ (T_Function s) -> s + PT _ (T_LabelId s) -> s + PT _ (T_AlphaIndex s) -> s + +-- | Convert a token to a string. +prToken :: Token -> String +prToken t = tokenText t + +-- | Finite map from text to token organized as binary search tree. +data BTree + = N -- ^ Nil (leaf). + | B String Tok BTree BTree + -- ^ Binary node. + deriving (Show) + +-- | Convert potential keyword into token or use fallback conversion. +eitherResIdent :: (String -> Tok) -> String -> Tok +eitherResIdent tv s = treeFind resWords + where + treeFind N = tv s + treeFind (B a t left right) = + case compare s a of + LT -> treeFind left + GT -> treeFind right + EQ -> t + +-- | The keywords and symbols of the language organized as binary search tree. +resWords :: BTree +resWords = + b "\957" 8 + (b "}" 4 + (b "." 2 (b "," 1 N N) (b "{" 3 N N)) + (b "\934" 6 (b "\916" 5 N N) (b "\955" 7 N N))) + (b "\966" 12 + (b "\961" 10 (b "\958" 9 N N) (b "\963" 11 N N)) + (b "\8709" 14 (b "\8614" 13 N N) (b "\10509" 15 N N))) + where + b s n = B bs (TS bs n) + where + bs = s + +-- | Unquote string literal. +unescapeInitTail :: String -> String +unescapeInitTail = id . unesc . tail . id + where + unesc s = case s of + '\\':c:cs | elem c ['\"', '\\', '\''] -> c : unesc cs + '\\':'n':cs -> '\n' : unesc cs + '\\':'t':cs -> '\t' : unesc cs + '\\':'r':cs -> '\r' : unesc cs + '\\':'f':cs -> '\f' : unesc cs + '"':[] -> [] + c:cs -> c : unesc cs + _ -> [] + +------------------------------------------------------------------- +-- Alex wrapper code. +-- A modified "posn" wrapper. +------------------------------------------------------------------- + +data Posn = Pn !Int !Int !Int + deriving (Eq, Show, Ord) + +alexStartPos :: Posn +alexStartPos = Pn 0 1 1 + +alexMove :: Posn -> Char -> Posn +alexMove (Pn a l c) '\t' = Pn (a+1) l (((c+7) `div` 8)*8+1) +alexMove (Pn a l c) '\n' = Pn (a+1) (l+1) 1 +alexMove (Pn a l c) _ = Pn (a+1) l (c+1) + +type Byte = Word8 + +type AlexInput = (Posn, -- current position, + Char, -- previous char + [Byte], -- pending bytes on the current char + String) -- current input string + +tokens :: String -> [Token] +tokens str = go (alexStartPos, '\n', [], str) + where + go :: AlexInput -> [Token] + go inp@(pos, _, _, str) = + case alexScan inp 0 of + AlexEOF -> [] + AlexError (pos, _, _, _) -> [Err pos] + AlexSkip inp' len -> go inp' + AlexToken inp' len act -> act pos (take len str) : (go inp') + +alexGetByte :: AlexInput -> Maybe (Byte,AlexInput) +alexGetByte (p, c, (b:bs), s) = Just (b, (p, c, bs, s)) +alexGetByte (p, _, [], s) = + case s of + [] -> Nothing + (c:s) -> + let p' = alexMove p c + (b:bs) = utf8Encode c + in p' `seq` Just (b, (p', c, bs, s)) + +alexInputPrevChar :: AlexInput -> Char +alexInputPrevChar (p, c, bs, s) = c + +-- | Encode a Haskell String to a list of Word8 values, in UTF8 format. +utf8Encode :: Char -> [Word8] +utf8Encode = map fromIntegral . go . ord + where + go oc + | oc <= 0x7f = [oc] + + | oc <= 0x7ff = [ 0xc0 + (oc `Data.Bits.shiftR` 6) + , 0x80 + oc Data.Bits..&. 0x3f + ] + + | oc <= 0xffff = [ 0xe0 + (oc `Data.Bits.shiftR` 12) + , 0x80 + ((oc `Data.Bits.shiftR` 6) Data.Bits..&. 0x3f) + , 0x80 + oc Data.Bits..&. 0x3f + ] + | otherwise = [ 0xf0 + (oc `Data.Bits.shiftR` 18) + , 0x80 + ((oc `Data.Bits.shiftR` 12) Data.Bits..&. 0x3f) + , 0x80 + ((oc `Data.Bits.shiftR` 6) Data.Bits..&. 0x3f) + , 0x80 + oc Data.Bits..&. 0x3f + ] +} diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.hs b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.hs new file mode 100644 index 000000000..3a7ccef30 --- /dev/null +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.hs @@ -0,0 +1,1523 @@ +{-# OPTIONS_GHC -w #-} +{-# OPTIONS_GHC -fno-warn-incomplete-patterns -fno-warn-overlapping-patterns #-} +{-# LANGUAGE PatternSynonyms #-} + +module Language.EO.Phi.Syntax.Par + ( happyError + , myLexer + , pProgram + , pObject + , pAbstractObject + , pDispatchedObject + , pBinding + , pListBinding + , pBindings + , pListBindings + , pDispatch + , pAttribute + , pListAttribute + , pDisp + , pListDisp + ) where + +import Prelude + +import qualified Language.EO.Phi.Syntax.Abs +import Language.EO.Phi.Syntax.Lex +import qualified Data.Array as Happy_Data_Array +import qualified Data.Bits as Bits +import Control.Applicative(Applicative(..)) +import Control.Monad (ap) + +-- parser produced by Happy Version 1.20.1.1 + +data HappyAbsSyn + = HappyTerminal (Token) + | HappyErrorToken Prelude.Int + | HappyAbsSyn16 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Bytes)) + | HappyAbsSyn17 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Function)) + | HappyAbsSyn18 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.LabelId)) + | HappyAbsSyn19 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.AlphaIndex)) + | HappyAbsSyn20 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Program)) + | HappyAbsSyn21 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Object)) + | HappyAbsSyn22 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.AbstractObject)) + | HappyAbsSyn23 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.DispatchedObject)) + | HappyAbsSyn24 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Binding)) + | HappyAbsSyn25 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, [Language.EO.Phi.Syntax.Abs.Binding])) + | HappyAbsSyn26 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Bindings)) + | HappyAbsSyn27 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, [Language.EO.Phi.Syntax.Abs.Bindings])) + | HappyAbsSyn28 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Dispatch)) + | HappyAbsSyn29 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Attribute)) + | HappyAbsSyn30 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, [Language.EO.Phi.Syntax.Abs.Attribute])) + | HappyAbsSyn31 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Disp)) + | HappyAbsSyn32 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, [Language.EO.Phi.Syntax.Abs.Disp])) + +{- to allow type-synonyms as our monads (likely + - with explicitly-specified bind and return) + - in Haskell98, it seems that with + - /type M a = .../, then /(HappyReduction M)/ + - is not allowed. But Happy is a + - code-generator that can just substitute it. +type HappyReduction m = + Prelude.Int + -> (Token) + -> HappyState (Token) (HappyStk HappyAbsSyn -> [(Token)] -> m HappyAbsSyn) + -> [HappyState (Token) (HappyStk HappyAbsSyn -> [(Token)] -> m HappyAbsSyn)] + -> HappyStk HappyAbsSyn + -> [(Token)] -> m HappyAbsSyn +-} + +action_0, + action_1, + action_2, + action_3, + action_4, + action_5, + action_6, + action_7, + action_8, + action_9, + action_10, + action_11, + action_12, + action_13, + action_14, + action_15, + action_16, + action_17, + action_18, + action_19, + action_20, + action_21, + action_22, + action_23, + action_24, + action_25, + action_26, + action_27, + action_28, + action_29, + action_30, + action_31, + action_32, + action_33, + action_34, + action_35, + action_36, + action_37, + action_38, + action_39, + action_40, + action_41, + action_42, + action_43, + action_44, + action_45, + action_46, + action_47, + action_48, + action_49, + action_50, + action_51, + action_52, + action_53, + action_54, + action_55, + action_56, + action_57, + action_58, + action_59, + action_60, + action_61, + action_62, + action_63, + action_64, + action_65, + action_66, + action_67, + action_68, + action_69, + action_70, + action_71, + action_72, + action_73, + action_74, + action_75, + action_76, + action_77, + action_78, + action_79, + action_80, + action_81, + action_82, + action_83, + action_84, + action_85, + action_86, + action_87, + action_88, + action_89, + action_90, + action_91, + action_92, + action_93, + action_94, + action_95, + action_96, + action_97, + action_98 :: () => Prelude.Int -> ({-HappyReduction (Err) = -} + Prelude.Int + -> (Token) + -> HappyState (Token) (HappyStk HappyAbsSyn -> [(Token)] -> (Err) HappyAbsSyn) + -> [HappyState (Token) (HappyStk HappyAbsSyn -> [(Token)] -> (Err) HappyAbsSyn)] + -> HappyStk HappyAbsSyn + -> [(Token)] -> (Err) HappyAbsSyn) + +happyReduce_13, + happyReduce_14, + happyReduce_15, + happyReduce_16, + happyReduce_17, + happyReduce_18, + happyReduce_19, + happyReduce_20, + happyReduce_21, + happyReduce_22, + happyReduce_23, + happyReduce_24, + happyReduce_25, + happyReduce_26, + happyReduce_27, + happyReduce_28, + happyReduce_29, + happyReduce_30, + happyReduce_31, + happyReduce_32, + happyReduce_33, + happyReduce_34, + happyReduce_35, + happyReduce_36, + happyReduce_37, + happyReduce_38, + happyReduce_39, + happyReduce_40, + happyReduce_41, + happyReduce_42, + happyReduce_43, + happyReduce_44, + happyReduce_45, + happyReduce_46, + happyReduce_47, + happyReduce_48, + happyReduce_49, + happyReduce_50 :: () => ({-HappyReduction (Err) = -} + Prelude.Int + -> (Token) + -> HappyState (Token) (HappyStk HappyAbsSyn -> [(Token)] -> (Err) HappyAbsSyn) + -> [HappyState (Token) (HappyStk HappyAbsSyn -> [(Token)] -> (Err) HappyAbsSyn)] + -> HappyStk HappyAbsSyn + -> [(Token)] -> (Err) HappyAbsSyn) + +happyExpList :: Happy_Data_Array.Array Prelude.Int Prelude.Int +happyExpList = Happy_Data_Array.listArray (0,215) ([0,0,4,0,0,9344,8,0,36864,260,0,0,8194,0,0,60672,192,0,40960,6173,0,0,1,0,0,32,0,0,9216,65,0,0,33232,1,0,14848,48,0,512,0,0,16384,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,55808,385,0,0,0,0,0,0,0,0,0,0,0,1024,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,256,0,0,0,0,0,0,3792,12,0,64,0,0,2048,0,0,0,0,0,0,64,0,0,0,0,0,0,948,3,0,0,0,0,256,0,0,0,0,0,0,16384,0,0,0,64,0,0,2048,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55808,385,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,948,3,0,0,0,0,0,0,0,0,33242,1,0,32,0,0,1024,0,0,0,49389,0,0,16,0,0,0,0,0,0,2048,0,0,24868,0,0,55808,385,0,8192,0,0,0,0,0,0,59392,192,0,0,6173,0,0,2,0,0,16,0,0,32768,3086,0,0,1,0,0,0,0,0,512,0,0,0,0,0,0,7424,24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,0,128,0,0,0,24692,0,0,0,0,0,0,0,0,0,0,0 + ]) + +{-# NOINLINE happyExpListPerState #-} +happyExpListPerState st = + token_strs_expected + where token_strs = ["error","%dummy","%start_pProgram_internal","%start_pObject_internal","%start_pAbstractObject_internal","%start_pDispatchedObject_internal","%start_pBinding_internal","%start_pListBinding_internal","%start_pBindings_internal","%start_pListBindings_internal","%start_pDispatch_internal","%start_pAttribute_internal","%start_pListAttribute_internal","%start_pDisp_internal","%start_pListDisp_internal","Bytes","Function","LabelId","AlphaIndex","Program","Object","AbstractObject","DispatchedObject","Binding","ListBinding","Bindings","ListBindings","Dispatch","Attribute","ListAttribute","Disp","ListDisp","','","'.'","'{'","'}'","'\916'","'\934'","'\955'","'\957'","'\958'","'\961'","'\963'","'\966'","'\8614'","'\8709'","'\8869'","'\10509'","L_Bytes","L_Function","L_LabelId","L_AlphaIndex","%eof"] + bit_start = st Prelude.* 53 + bit_end = (st Prelude.+ 1) Prelude.* 53 + read_bit = readArrayBit happyExpList + bits = Prelude.map read_bit [bit_start..bit_end Prelude.- 1] + bits_indexed = Prelude.zip bits [0..52] + token_strs_expected = Prelude.concatMap f bits_indexed + f (Prelude.False, _) = [] + f (Prelude.True, nr) = [token_strs Prelude.!! nr] + +action_0 (35) = happyShift action_57 +action_0 (20) = happyGoto action_56 +action_0 _ = happyFail (happyExpListPerState 0) + +action_1 (35) = happyShift action_54 +action_1 (38) = happyShift action_33 +action_1 (41) = happyShift action_34 +action_1 (47) = happyShift action_55 +action_1 (21) = happyGoto action_51 +action_1 (22) = happyGoto action_52 +action_1 (23) = happyGoto action_30 +action_1 (28) = happyGoto action_53 +action_1 _ = happyFail (happyExpListPerState 1) + +action_2 (35) = happyShift action_49 +action_2 (38) = happyShift action_33 +action_2 (41) = happyShift action_34 +action_2 (47) = happyShift action_50 +action_2 (22) = happyGoto action_47 +action_2 (23) = happyGoto action_30 +action_2 (28) = happyGoto action_48 +action_2 _ = happyFail (happyExpListPerState 2) + +action_3 (35) = happyShift action_32 +action_3 (47) = happyShift action_35 +action_3 (23) = happyGoto action_46 +action_3 _ = happyFail (happyExpListPerState 3) + +action_4 (37) = happyShift action_43 +action_4 (39) = happyShift action_44 +action_4 (40) = happyShift action_23 +action_4 (42) = happyShift action_24 +action_4 (43) = happyShift action_25 +action_4 (44) = happyShift action_26 +action_4 (51) = happyShift action_27 +action_4 (52) = happyShift action_28 +action_4 (18) = happyGoto action_19 +action_4 (19) = happyGoto action_20 +action_4 (24) = happyGoto action_45 +action_4 (29) = happyGoto action_42 +action_4 _ = happyFail (happyExpListPerState 4) + +action_5 (37) = happyShift action_43 +action_5 (39) = happyShift action_44 +action_5 (40) = happyShift action_23 +action_5 (42) = happyShift action_24 +action_5 (43) = happyShift action_25 +action_5 (44) = happyShift action_26 +action_5 (51) = happyShift action_27 +action_5 (52) = happyShift action_28 +action_5 (18) = happyGoto action_19 +action_5 (19) = happyGoto action_20 +action_5 (24) = happyGoto action_40 +action_5 (25) = happyGoto action_41 +action_5 (29) = happyGoto action_42 +action_5 _ = happyReduce_31 + +action_6 (35) = happyShift action_38 +action_6 (26) = happyGoto action_39 +action_6 _ = happyFail (happyExpListPerState 6) + +action_7 (35) = happyShift action_38 +action_7 (26) = happyGoto action_36 +action_7 (27) = happyGoto action_37 +action_7 _ = happyReduce_35 + +action_8 (35) = happyShift action_32 +action_8 (38) = happyShift action_33 +action_8 (41) = happyShift action_34 +action_8 (47) = happyShift action_35 +action_8 (23) = happyGoto action_30 +action_8 (28) = happyGoto action_31 +action_8 _ = happyFail (happyExpListPerState 8) + +action_9 (40) = happyShift action_23 +action_9 (42) = happyShift action_24 +action_9 (43) = happyShift action_25 +action_9 (44) = happyShift action_26 +action_9 (51) = happyShift action_27 +action_9 (52) = happyShift action_28 +action_9 (18) = happyGoto action_19 +action_9 (19) = happyGoto action_20 +action_9 (29) = happyGoto action_29 +action_9 _ = happyFail (happyExpListPerState 9) + +action_10 (40) = happyShift action_23 +action_10 (42) = happyShift action_24 +action_10 (43) = happyShift action_25 +action_10 (44) = happyShift action_26 +action_10 (51) = happyShift action_27 +action_10 (52) = happyShift action_28 +action_10 (18) = happyGoto action_19 +action_10 (19) = happyGoto action_20 +action_10 (29) = happyGoto action_21 +action_10 (30) = happyGoto action_22 +action_10 _ = happyFail (happyExpListPerState 10) + +action_11 (35) = happyShift action_17 +action_11 (31) = happyGoto action_18 +action_11 _ = happyFail (happyExpListPerState 11) + +action_12 (35) = happyShift action_17 +action_12 (31) = happyGoto action_15 +action_12 (32) = happyGoto action_16 +action_12 _ = happyReduce_49 + +action_13 (49) = happyShift action_14 +action_13 _ = happyFail (happyExpListPerState 13) + +action_14 _ = happyReduce_13 + +action_15 (35) = happyShift action_17 +action_15 (31) = happyGoto action_15 +action_15 (32) = happyGoto action_74 +action_15 _ = happyReduce_49 + +action_16 (53) = happyAccept +action_16 _ = happyFail (happyExpListPerState 16) + +action_17 (37) = happyShift action_43 +action_17 (39) = happyShift action_44 +action_17 (40) = happyShift action_23 +action_17 (42) = happyShift action_24 +action_17 (43) = happyShift action_25 +action_17 (44) = happyShift action_26 +action_17 (51) = happyShift action_27 +action_17 (52) = happyShift action_28 +action_17 (18) = happyGoto action_19 +action_17 (19) = happyGoto action_20 +action_17 (24) = happyGoto action_40 +action_17 (25) = happyGoto action_73 +action_17 (29) = happyGoto action_42 +action_17 _ = happyReduce_31 + +action_18 (53) = happyAccept +action_18 _ = happyFail (happyExpListPerState 18) + +action_19 _ = happyReduce_44 + +action_20 _ = happyReduce_45 + +action_21 (34) = happyShift action_72 +action_21 _ = happyReduce_46 + +action_22 (53) = happyAccept +action_22 _ = happyFail (happyExpListPerState 22) + +action_23 _ = happyReduce_43 + +action_24 _ = happyReduce_41 + +action_25 _ = happyReduce_42 + +action_26 _ = happyReduce_40 + +action_27 _ = happyReduce_15 + +action_28 _ = happyReduce_16 + +action_29 (53) = happyAccept +action_29 _ = happyFail (happyExpListPerState 29) + +action_30 (35) = happyShift action_38 +action_30 (26) = happyGoto action_36 +action_30 (27) = happyGoto action_71 +action_30 _ = happyReduce_35 + +action_31 (53) = happyAccept +action_31 _ = happyFail (happyExpListPerState 31) + +action_32 (37) = happyShift action_43 +action_32 (39) = happyShift action_44 +action_32 (40) = happyShift action_23 +action_32 (42) = happyShift action_24 +action_32 (43) = happyShift action_25 +action_32 (44) = happyShift action_26 +action_32 (51) = happyShift action_27 +action_32 (52) = happyShift action_28 +action_32 (18) = happyGoto action_19 +action_32 (19) = happyGoto action_20 +action_32 (24) = happyGoto action_40 +action_32 (25) = happyGoto action_70 +action_32 (29) = happyGoto action_42 +action_32 _ = happyReduce_31 + +action_33 (34) = happyShift action_69 +action_33 _ = happyFail (happyExpListPerState 33) + +action_34 (34) = happyShift action_68 +action_34 _ = happyFail (happyExpListPerState 34) + +action_35 _ = happyReduce_26 + +action_36 (35) = happyShift action_38 +action_36 (26) = happyGoto action_36 +action_36 (27) = happyGoto action_67 +action_36 _ = happyReduce_35 + +action_37 (53) = happyAccept +action_37 _ = happyFail (happyExpListPerState 37) + +action_38 (37) = happyShift action_43 +action_38 (39) = happyShift action_44 +action_38 (40) = happyShift action_23 +action_38 (42) = happyShift action_24 +action_38 (43) = happyShift action_25 +action_38 (44) = happyShift action_26 +action_38 (51) = happyShift action_27 +action_38 (52) = happyShift action_28 +action_38 (18) = happyGoto action_19 +action_38 (19) = happyGoto action_20 +action_38 (24) = happyGoto action_40 +action_38 (25) = happyGoto action_66 +action_38 (29) = happyGoto action_42 +action_38 _ = happyReduce_31 + +action_39 (53) = happyAccept +action_39 _ = happyFail (happyExpListPerState 39) + +action_40 (33) = happyShift action_65 +action_40 _ = happyReduce_32 + +action_41 (53) = happyAccept +action_41 _ = happyFail (happyExpListPerState 41) + +action_42 (45) = happyShift action_64 +action_42 _ = happyFail (happyExpListPerState 42) + +action_43 (48) = happyShift action_63 +action_43 _ = happyFail (happyExpListPerState 43) + +action_44 (48) = happyShift action_62 +action_44 _ = happyFail (happyExpListPerState 44) + +action_45 (53) = happyAccept +action_45 _ = happyFail (happyExpListPerState 45) + +action_46 (53) = happyAccept +action_46 _ = happyFail (happyExpListPerState 46) + +action_47 (53) = happyAccept +action_47 _ = happyFail (happyExpListPerState 47) + +action_48 _ = happyReduce_23 + +action_49 (37) = happyShift action_43 +action_49 (39) = happyShift action_44 +action_49 (40) = happyShift action_23 +action_49 (42) = happyShift action_24 +action_49 (43) = happyShift action_25 +action_49 (44) = happyShift action_26 +action_49 (51) = happyShift action_27 +action_49 (52) = happyShift action_28 +action_49 (18) = happyGoto action_19 +action_49 (19) = happyGoto action_20 +action_49 (24) = happyGoto action_40 +action_49 (25) = happyGoto action_61 +action_49 (29) = happyGoto action_42 +action_49 _ = happyReduce_31 + +action_50 (53) = happyReduce_24 +action_50 _ = happyReduce_26 + +action_51 (53) = happyAccept +action_51 _ = happyFail (happyExpListPerState 51) + +action_52 (35) = happyShift action_60 +action_52 _ = happyFail (happyExpListPerState 52) + +action_53 (35) = happyReduce_23 +action_53 _ = happyReduce_20 + +action_54 (37) = happyShift action_43 +action_54 (39) = happyShift action_44 +action_54 (40) = happyShift action_23 +action_54 (42) = happyShift action_24 +action_54 (43) = happyShift action_25 +action_54 (44) = happyShift action_26 +action_54 (51) = happyShift action_27 +action_54 (52) = happyShift action_28 +action_54 (18) = happyGoto action_19 +action_54 (19) = happyGoto action_20 +action_54 (24) = happyGoto action_40 +action_54 (25) = happyGoto action_59 +action_54 (29) = happyGoto action_42 +action_54 _ = happyReduce_31 + +action_55 (34) = happyReduce_26 +action_55 (35) = happyReduce_26 +action_55 _ = happyReduce_21 + +action_56 (53) = happyAccept +action_56 _ = happyFail (happyExpListPerState 56) + +action_57 (37) = happyShift action_43 +action_57 (39) = happyShift action_44 +action_57 (40) = happyShift action_23 +action_57 (42) = happyShift action_24 +action_57 (43) = happyShift action_25 +action_57 (44) = happyShift action_26 +action_57 (51) = happyShift action_27 +action_57 (52) = happyShift action_28 +action_57 (18) = happyGoto action_19 +action_57 (19) = happyGoto action_20 +action_57 (24) = happyGoto action_40 +action_57 (25) = happyGoto action_58 +action_57 (29) = happyGoto action_42 +action_57 _ = happyReduce_31 + +action_58 (36) = happyShift action_89 +action_58 _ = happyFail (happyExpListPerState 58) + +action_59 (36) = happyShift action_88 +action_59 _ = happyFail (happyExpListPerState 59) + +action_60 (37) = happyShift action_43 +action_60 (39) = happyShift action_44 +action_60 (40) = happyShift action_23 +action_60 (42) = happyShift action_24 +action_60 (43) = happyShift action_25 +action_60 (44) = happyShift action_26 +action_60 (51) = happyShift action_27 +action_60 (52) = happyShift action_28 +action_60 (18) = happyGoto action_19 +action_60 (19) = happyGoto action_20 +action_60 (24) = happyGoto action_40 +action_60 (25) = happyGoto action_87 +action_60 (29) = happyGoto action_42 +action_60 _ = happyReduce_31 + +action_61 (36) = happyShift action_86 +action_61 _ = happyFail (happyExpListPerState 61) + +action_62 _ = happyReduce_30 + +action_63 (49) = happyShift action_14 +action_63 (16) = happyGoto action_85 +action_63 _ = happyFail (happyExpListPerState 63) + +action_64 (35) = happyShift action_54 +action_64 (38) = happyShift action_33 +action_64 (41) = happyShift action_34 +action_64 (46) = happyShift action_84 +action_64 (47) = happyShift action_55 +action_64 (21) = happyGoto action_83 +action_64 (22) = happyGoto action_52 +action_64 (23) = happyGoto action_30 +action_64 (28) = happyGoto action_53 +action_64 _ = happyFail (happyExpListPerState 64) + +action_65 (37) = happyShift action_43 +action_65 (39) = happyShift action_44 +action_65 (40) = happyShift action_23 +action_65 (42) = happyShift action_24 +action_65 (43) = happyShift action_25 +action_65 (44) = happyShift action_26 +action_65 (51) = happyShift action_27 +action_65 (52) = happyShift action_28 +action_65 (18) = happyGoto action_19 +action_65 (19) = happyGoto action_20 +action_65 (24) = happyGoto action_40 +action_65 (25) = happyGoto action_82 +action_65 (29) = happyGoto action_42 +action_65 _ = happyReduce_31 + +action_66 (36) = happyShift action_81 +action_66 _ = happyFail (happyExpListPerState 66) + +action_67 _ = happyReduce_36 + +action_68 (40) = happyShift action_23 +action_68 (42) = happyShift action_24 +action_68 (43) = happyShift action_25 +action_68 (44) = happyShift action_26 +action_68 (51) = happyShift action_27 +action_68 (52) = happyShift action_28 +action_68 (18) = happyGoto action_19 +action_68 (19) = happyGoto action_20 +action_68 (29) = happyGoto action_21 +action_68 (30) = happyGoto action_80 +action_68 _ = happyFail (happyExpListPerState 68) + +action_69 (40) = happyShift action_23 +action_69 (42) = happyShift action_24 +action_69 (43) = happyShift action_25 +action_69 (44) = happyShift action_26 +action_69 (51) = happyShift action_27 +action_69 (52) = happyShift action_28 +action_69 (18) = happyGoto action_19 +action_69 (19) = happyGoto action_20 +action_69 (29) = happyGoto action_21 +action_69 (30) = happyGoto action_79 +action_69 _ = happyFail (happyExpListPerState 69) + +action_70 (36) = happyShift action_78 +action_70 _ = happyFail (happyExpListPerState 70) + +action_71 (34) = happyShift action_77 +action_71 _ = happyFail (happyExpListPerState 71) + +action_72 (40) = happyShift action_23 +action_72 (42) = happyShift action_24 +action_72 (43) = happyShift action_25 +action_72 (44) = happyShift action_26 +action_72 (51) = happyShift action_27 +action_72 (52) = happyShift action_28 +action_72 (18) = happyGoto action_19 +action_72 (19) = happyGoto action_20 +action_72 (29) = happyGoto action_21 +action_72 (30) = happyGoto action_76 +action_72 _ = happyFail (happyExpListPerState 72) + +action_73 (36) = happyShift action_75 +action_73 _ = happyFail (happyExpListPerState 73) + +action_74 _ = happyReduce_50 + +action_75 (35) = happyShift action_38 +action_75 (26) = happyGoto action_94 +action_75 _ = happyFail (happyExpListPerState 75) + +action_76 _ = happyReduce_47 + +action_77 (40) = happyShift action_23 +action_77 (42) = happyShift action_24 +action_77 (43) = happyShift action_25 +action_77 (44) = happyShift action_26 +action_77 (51) = happyShift action_27 +action_77 (52) = happyShift action_28 +action_77 (18) = happyGoto action_19 +action_77 (19) = happyGoto action_20 +action_77 (29) = happyGoto action_21 +action_77 (30) = happyGoto action_93 +action_77 _ = happyFail (happyExpListPerState 77) + +action_78 _ = happyReduce_25 + +action_79 (35) = happyShift action_17 +action_79 (31) = happyGoto action_15 +action_79 (32) = happyGoto action_92 +action_79 _ = happyReduce_49 + +action_80 (35) = happyShift action_17 +action_80 (31) = happyGoto action_15 +action_80 (32) = happyGoto action_91 +action_80 _ = happyReduce_49 + +action_81 _ = happyReduce_34 + +action_82 _ = happyReduce_33 + +action_83 _ = happyReduce_27 + +action_84 _ = happyReduce_28 + +action_85 _ = happyReduce_29 + +action_86 (53) = happyReduce_22 +action_86 _ = happyReduce_25 + +action_87 (36) = happyShift action_90 +action_87 _ = happyFail (happyExpListPerState 87) + +action_88 (34) = happyReduce_25 +action_88 (35) = happyReduce_25 +action_88 _ = happyReduce_18 + +action_89 _ = happyReduce_17 + +action_90 (35) = happyShift action_38 +action_90 (26) = happyGoto action_36 +action_90 (27) = happyGoto action_97 +action_90 _ = happyReduce_35 + +action_91 _ = happyReduce_39 + +action_92 _ = happyReduce_38 + +action_93 (35) = happyShift action_17 +action_93 (31) = happyGoto action_15 +action_93 (32) = happyGoto action_96 +action_93 _ = happyReduce_49 + +action_94 (34) = happyShift action_95 +action_94 _ = happyFail (happyExpListPerState 94) + +action_95 (40) = happyShift action_23 +action_95 (42) = happyShift action_24 +action_95 (43) = happyShift action_25 +action_95 (44) = happyShift action_26 +action_95 (51) = happyShift action_27 +action_95 (52) = happyShift action_28 +action_95 (18) = happyGoto action_19 +action_95 (19) = happyGoto action_20 +action_95 (29) = happyGoto action_21 +action_95 (30) = happyGoto action_98 +action_95 _ = happyFail (happyExpListPerState 95) + +action_96 _ = happyReduce_37 + +action_97 _ = happyReduce_19 + +action_98 _ = happyReduce_48 + +happyReduce_13 = happySpecReduce_1 16 happyReduction_13 +happyReduction_13 (HappyTerminal happy_var_1) + = HappyAbsSyn16 + ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.Bytes (tokenText happy_var_1)) + ) +happyReduction_13 _ = notHappyAtAll + +happyReduce_14 = happySpecReduce_1 17 happyReduction_14 +happyReduction_14 (HappyTerminal happy_var_1) + = HappyAbsSyn17 + ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.Function (tokenText happy_var_1)) + ) +happyReduction_14 _ = notHappyAtAll + +happyReduce_15 = happySpecReduce_1 18 happyReduction_15 +happyReduction_15 (HappyTerminal happy_var_1) + = HappyAbsSyn18 + ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.LabelId (tokenText happy_var_1)) + ) +happyReduction_15 _ = notHappyAtAll + +happyReduce_16 = happySpecReduce_1 19 happyReduction_16 +happyReduction_16 (HappyTerminal happy_var_1) + = HappyAbsSyn19 + ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.AlphaIndex (tokenText happy_var_1)) + ) +happyReduction_16 _ = notHappyAtAll + +happyReduce_17 = happySpecReduce_3 20 happyReduction_17 +happyReduction_17 _ + (HappyAbsSyn25 happy_var_2) + (HappyTerminal happy_var_1) + = HappyAbsSyn20 + ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.Program (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1)) (snd happy_var_2)) + ) +happyReduction_17 _ _ _ = notHappyAtAll + +happyReduce_18 = happySpecReduce_3 21 happyReduction_18 +happyReduction_18 _ + (HappyAbsSyn25 happy_var_2) + (HappyTerminal happy_var_1) + = HappyAbsSyn21 + ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.Formation (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1)) (snd happy_var_2)) + ) +happyReduction_18 _ _ _ = notHappyAtAll + +happyReduce_19 = happyReduce 5 21 happyReduction_19 +happyReduction_19 ((HappyAbsSyn27 happy_var_5) `HappyStk` + _ `HappyStk` + (HappyAbsSyn25 happy_var_3) `HappyStk` + _ `HappyStk` + (HappyAbsSyn22 happy_var_1) `HappyStk` + happyRest) + = HappyAbsSyn21 + ((fst happy_var_1, Language.EO.Phi.Syntax.Abs.Application (fst happy_var_1) (snd happy_var_1) (snd happy_var_3) (snd happy_var_5)) + ) `HappyStk` happyRest + +happyReduce_20 = happySpecReduce_1 21 happyReduction_20 +happyReduction_20 (HappyAbsSyn28 happy_var_1) + = HappyAbsSyn21 + ((fst happy_var_1, Language.EO.Phi.Syntax.Abs.Dispatch (fst happy_var_1) (snd happy_var_1)) + ) +happyReduction_20 _ = notHappyAtAll + +happyReduce_21 = happySpecReduce_1 21 happyReduction_21 +happyReduction_21 (HappyTerminal happy_var_1) + = HappyAbsSyn21 + ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.Termination (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1))) + ) +happyReduction_21 _ = notHappyAtAll + +happyReduce_22 = happySpecReduce_3 22 happyReduction_22 +happyReduction_22 _ + (HappyAbsSyn25 happy_var_2) + (HappyTerminal happy_var_1) + = HappyAbsSyn22 + ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.AbstractFormation (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1)) (snd happy_var_2)) + ) +happyReduction_22 _ _ _ = notHappyAtAll + +happyReduce_23 = happySpecReduce_1 22 happyReduction_23 +happyReduction_23 (HappyAbsSyn28 happy_var_1) + = HappyAbsSyn22 + ((fst happy_var_1, Language.EO.Phi.Syntax.Abs.AbstractDispatch (fst happy_var_1) (snd happy_var_1)) + ) +happyReduction_23 _ = notHappyAtAll + +happyReduce_24 = happySpecReduce_1 22 happyReduction_24 +happyReduction_24 (HappyTerminal happy_var_1) + = HappyAbsSyn22 + ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.AbstractTermination (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1))) + ) +happyReduction_24 _ = notHappyAtAll + +happyReduce_25 = happySpecReduce_3 23 happyReduction_25 +happyReduction_25 _ + (HappyAbsSyn25 happy_var_2) + (HappyTerminal happy_var_1) + = HappyAbsSyn23 + ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.DispatchedFormation (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1)) (snd happy_var_2)) + ) +happyReduction_25 _ _ _ = notHappyAtAll + +happyReduce_26 = happySpecReduce_1 23 happyReduction_26 +happyReduction_26 (HappyTerminal happy_var_1) + = HappyAbsSyn23 + ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.DispatchedTermination (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1))) + ) +happyReduction_26 _ = notHappyAtAll + +happyReduce_27 = happySpecReduce_3 24 happyReduction_27 +happyReduction_27 (HappyAbsSyn21 happy_var_3) + _ + (HappyAbsSyn29 happy_var_1) + = HappyAbsSyn24 + ((fst happy_var_1, Language.EO.Phi.Syntax.Abs.AlphaBinding (fst happy_var_1) (snd happy_var_1) (snd happy_var_3)) + ) +happyReduction_27 _ _ _ = notHappyAtAll + +happyReduce_28 = happySpecReduce_3 24 happyReduction_28 +happyReduction_28 _ + _ + (HappyAbsSyn29 happy_var_1) + = HappyAbsSyn24 + ((fst happy_var_1, Language.EO.Phi.Syntax.Abs.EmptyBinding (fst happy_var_1) (snd happy_var_1)) + ) +happyReduction_28 _ _ _ = notHappyAtAll + +happyReduce_29 = happySpecReduce_3 24 happyReduction_29 +happyReduction_29 (HappyAbsSyn16 happy_var_3) + _ + (HappyTerminal happy_var_1) + = HappyAbsSyn24 + ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.DeltaBinding (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1)) (snd happy_var_3)) + ) +happyReduction_29 _ _ _ = notHappyAtAll + +happyReduce_30 = happySpecReduce_2 24 happyReduction_30 +happyReduction_30 _ + (HappyTerminal happy_var_1) + = HappyAbsSyn24 + ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.LambdaBinding (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1))) + ) +happyReduction_30 _ _ = notHappyAtAll + +happyReduce_31 = happySpecReduce_0 25 happyReduction_31 +happyReduction_31 = HappyAbsSyn25 + ((Language.EO.Phi.Syntax.Abs.BNFC'NoPosition, []) + ) + +happyReduce_32 = happySpecReduce_1 25 happyReduction_32 +happyReduction_32 (HappyAbsSyn24 happy_var_1) + = HappyAbsSyn25 + ((fst happy_var_1, (:[]) (snd happy_var_1)) + ) +happyReduction_32 _ = notHappyAtAll + +happyReduce_33 = happySpecReduce_3 25 happyReduction_33 +happyReduction_33 (HappyAbsSyn25 happy_var_3) + _ + (HappyAbsSyn24 happy_var_1) + = HappyAbsSyn25 + ((fst happy_var_1, (:) (snd happy_var_1) (snd happy_var_3)) + ) +happyReduction_33 _ _ _ = notHappyAtAll + +happyReduce_34 = happySpecReduce_3 26 happyReduction_34 +happyReduction_34 _ + (HappyAbsSyn25 happy_var_2) + (HappyTerminal happy_var_1) + = HappyAbsSyn26 + ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.Bindings (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1)) (snd happy_var_2)) + ) +happyReduction_34 _ _ _ = notHappyAtAll + +happyReduce_35 = happySpecReduce_0 27 happyReduction_35 +happyReduction_35 = HappyAbsSyn27 + ((Language.EO.Phi.Syntax.Abs.BNFC'NoPosition, []) + ) + +happyReduce_36 = happySpecReduce_2 27 happyReduction_36 +happyReduction_36 (HappyAbsSyn27 happy_var_2) + (HappyAbsSyn26 happy_var_1) + = HappyAbsSyn27 + ((fst happy_var_1, (:) (snd happy_var_1) (snd happy_var_2)) + ) +happyReduction_36 _ _ = notHappyAtAll + +happyReduce_37 = happyReduce 5 28 happyReduction_37 +happyReduction_37 ((HappyAbsSyn32 happy_var_5) `HappyStk` + (HappyAbsSyn30 happy_var_4) `HappyStk` + _ `HappyStk` + (HappyAbsSyn27 happy_var_2) `HappyStk` + (HappyAbsSyn23 happy_var_1) `HappyStk` + happyRest) + = HappyAbsSyn28 + ((fst happy_var_1, Language.EO.Phi.Syntax.Abs.ObjectDispatch (fst happy_var_1) (snd happy_var_1) (snd happy_var_2) (snd happy_var_4) (snd happy_var_5)) + ) `HappyStk` happyRest + +happyReduce_38 = happyReduce 4 28 happyReduction_38 +happyReduction_38 ((HappyAbsSyn32 happy_var_4) `HappyStk` + (HappyAbsSyn30 happy_var_3) `HappyStk` + _ `HappyStk` + (HappyTerminal happy_var_1) `HappyStk` + happyRest) + = HappyAbsSyn28 + ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.HomeDispatch (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1)) (snd happy_var_3) (snd happy_var_4)) + ) `HappyStk` happyRest + +happyReduce_39 = happyReduce 4 28 happyReduction_39 +happyReduction_39 ((HappyAbsSyn32 happy_var_4) `HappyStk` + (HappyAbsSyn30 happy_var_3) `HappyStk` + _ `HappyStk` + (HappyTerminal happy_var_1) `HappyStk` + happyRest) + = HappyAbsSyn28 + ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.ThisDispatch (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1)) (snd happy_var_3) (snd happy_var_4)) + ) `HappyStk` happyRest + +happyReduce_40 = happySpecReduce_1 29 happyReduction_40 +happyReduction_40 (HappyTerminal happy_var_1) + = HappyAbsSyn29 + ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.Phi (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1))) + ) +happyReduction_40 _ = notHappyAtAll + +happyReduce_41 = happySpecReduce_1 29 happyReduction_41 +happyReduction_41 (HappyTerminal happy_var_1) + = HappyAbsSyn29 + ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.Rho (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1))) + ) +happyReduction_41 _ = notHappyAtAll + +happyReduce_42 = happySpecReduce_1 29 happyReduction_42 +happyReduction_42 (HappyTerminal happy_var_1) + = HappyAbsSyn29 + ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.Sigma (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1))) + ) +happyReduction_42 _ = notHappyAtAll + +happyReduce_43 = happySpecReduce_1 29 happyReduction_43 +happyReduction_43 (HappyTerminal happy_var_1) + = HappyAbsSyn29 + ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.VTX (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1))) + ) +happyReduction_43 _ = notHappyAtAll + +happyReduce_44 = happySpecReduce_1 29 happyReduction_44 +happyReduction_44 (HappyAbsSyn18 happy_var_1) + = HappyAbsSyn29 + ((fst happy_var_1, Language.EO.Phi.Syntax.Abs.Label (fst happy_var_1) (snd happy_var_1)) + ) +happyReduction_44 _ = notHappyAtAll + +happyReduce_45 = happySpecReduce_1 29 happyReduction_45 +happyReduction_45 (HappyAbsSyn19 happy_var_1) + = HappyAbsSyn29 + ((fst happy_var_1, Language.EO.Phi.Syntax.Abs.Alpha (fst happy_var_1) (snd happy_var_1)) + ) +happyReduction_45 _ = notHappyAtAll + +happyReduce_46 = happySpecReduce_1 30 happyReduction_46 +happyReduction_46 (HappyAbsSyn29 happy_var_1) + = HappyAbsSyn30 + ((fst happy_var_1, (:[]) (snd happy_var_1)) + ) +happyReduction_46 _ = notHappyAtAll + +happyReduce_47 = happySpecReduce_3 30 happyReduction_47 +happyReduction_47 (HappyAbsSyn30 happy_var_3) + _ + (HappyAbsSyn29 happy_var_1) + = HappyAbsSyn30 + ((fst happy_var_1, (:) (snd happy_var_1) (snd happy_var_3)) + ) +happyReduction_47 _ _ _ = notHappyAtAll + +happyReduce_48 = happyReduce 6 31 happyReduction_48 +happyReduction_48 ((HappyAbsSyn30 happy_var_6) `HappyStk` + _ `HappyStk` + (HappyAbsSyn26 happy_var_4) `HappyStk` + _ `HappyStk` + (HappyAbsSyn25 happy_var_2) `HappyStk` + (HappyTerminal happy_var_1) `HappyStk` + happyRest) + = HappyAbsSyn31 + ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.Disp (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1)) (snd happy_var_2) (snd happy_var_4) (snd happy_var_6)) + ) `HappyStk` happyRest + +happyReduce_49 = happySpecReduce_0 32 happyReduction_49 +happyReduction_49 = HappyAbsSyn32 + ((Language.EO.Phi.Syntax.Abs.BNFC'NoPosition, []) + ) + +happyReduce_50 = happySpecReduce_2 32 happyReduction_50 +happyReduction_50 (HappyAbsSyn32 happy_var_2) + (HappyAbsSyn31 happy_var_1) + = HappyAbsSyn32 + ((fst happy_var_1, (:) (snd happy_var_1) (snd happy_var_2)) + ) +happyReduction_50 _ _ = notHappyAtAll + +happyNewToken action sts stk [] = + action 53 53 notHappyAtAll (HappyState action) sts stk [] + +happyNewToken action sts stk (tk:tks) = + let cont i = action i i tk (HappyState action) sts stk tks in + case tk of { + PT _ (TS _ 1) -> cont 33; + PT _ (TS _ 2) -> cont 34; + PT _ (TS _ 3) -> cont 35; + PT _ (TS _ 4) -> cont 36; + PT _ (TS _ 5) -> cont 37; + PT _ (TS _ 6) -> cont 38; + PT _ (TS _ 7) -> cont 39; + PT _ (TS _ 8) -> cont 40; + PT _ (TS _ 9) -> cont 41; + PT _ (TS _ 10) -> cont 42; + PT _ (TS _ 11) -> cont 43; + PT _ (TS _ 12) -> cont 44; + PT _ (TS _ 13) -> cont 45; + PT _ (TS _ 14) -> cont 46; + PT _ (TS _ 15) -> cont 47; + PT _ (TS _ 16) -> cont 48; + PT _ (T_Bytes _) -> cont 49; + PT _ (T_Function _) -> cont 50; + PT _ (T_LabelId _) -> cont 51; + PT _ (T_AlphaIndex _) -> cont 52; + _ -> happyError' ((tk:tks), []) + } + +happyError_ explist 53 tk tks = happyError' (tks, explist) +happyError_ explist _ tk tks = happyError' ((tk:tks), explist) + +happyThen :: () => Err a -> (a -> Err b) -> Err b +happyThen = ((>>=)) +happyReturn :: () => a -> Err a +happyReturn = (return) +happyThen1 m k tks = ((>>=)) m (\a -> k a tks) +happyReturn1 :: () => a -> b -> Err a +happyReturn1 = \a tks -> (return) a +happyError' :: () => ([(Token)], [Prelude.String]) -> Err a +happyError' = (\(tokens, _) -> happyError tokens) +pProgram_internal tks = happySomeParser where + happySomeParser = happyThen (happyParse action_0 tks) (\x -> case x of {HappyAbsSyn20 z -> happyReturn z; _other -> notHappyAtAll }) + +pObject_internal tks = happySomeParser where + happySomeParser = happyThen (happyParse action_1 tks) (\x -> case x of {HappyAbsSyn21 z -> happyReturn z; _other -> notHappyAtAll }) + +pAbstractObject_internal tks = happySomeParser where + happySomeParser = happyThen (happyParse action_2 tks) (\x -> case x of {HappyAbsSyn22 z -> happyReturn z; _other -> notHappyAtAll }) + +pDispatchedObject_internal tks = happySomeParser where + happySomeParser = happyThen (happyParse action_3 tks) (\x -> case x of {HappyAbsSyn23 z -> happyReturn z; _other -> notHappyAtAll }) + +pBinding_internal tks = happySomeParser where + happySomeParser = happyThen (happyParse action_4 tks) (\x -> case x of {HappyAbsSyn24 z -> happyReturn z; _other -> notHappyAtAll }) + +pListBinding_internal tks = happySomeParser where + happySomeParser = happyThen (happyParse action_5 tks) (\x -> case x of {HappyAbsSyn25 z -> happyReturn z; _other -> notHappyAtAll }) + +pBindings_internal tks = happySomeParser where + happySomeParser = happyThen (happyParse action_6 tks) (\x -> case x of {HappyAbsSyn26 z -> happyReturn z; _other -> notHappyAtAll }) + +pListBindings_internal tks = happySomeParser where + happySomeParser = happyThen (happyParse action_7 tks) (\x -> case x of {HappyAbsSyn27 z -> happyReturn z; _other -> notHappyAtAll }) + +pDispatch_internal tks = happySomeParser where + happySomeParser = happyThen (happyParse action_8 tks) (\x -> case x of {HappyAbsSyn28 z -> happyReturn z; _other -> notHappyAtAll }) + +pAttribute_internal tks = happySomeParser where + happySomeParser = happyThen (happyParse action_9 tks) (\x -> case x of {HappyAbsSyn29 z -> happyReturn z; _other -> notHappyAtAll }) + +pListAttribute_internal tks = happySomeParser where + happySomeParser = happyThen (happyParse action_10 tks) (\x -> case x of {HappyAbsSyn30 z -> happyReturn z; _other -> notHappyAtAll }) + +pDisp_internal tks = happySomeParser where + happySomeParser = happyThen (happyParse action_11 tks) (\x -> case x of {HappyAbsSyn31 z -> happyReturn z; _other -> notHappyAtAll }) + +pListDisp_internal tks = happySomeParser where + happySomeParser = happyThen (happyParse action_12 tks) (\x -> case x of {HappyAbsSyn32 z -> happyReturn z; _other -> notHappyAtAll }) + +happySeq = happyDontSeq + + +type Err = Either String + +happyError :: [Token] -> Err a +happyError ts = Left $ + "syntax error at " ++ tokenPos ts ++ + case ts of + [] -> [] + [Err _] -> " due to lexer error" + t:_ -> " before `" ++ (prToken t) ++ "'" + +myLexer :: String -> [Token] +myLexer = tokens + +-- Entrypoints + +pProgram :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Program +pProgram = fmap snd . pProgram_internal + +pObject :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Object +pObject = fmap snd . pObject_internal + +pAbstractObject :: [Token] -> Err Language.EO.Phi.Syntax.Abs.AbstractObject +pAbstractObject = fmap snd . pAbstractObject_internal + +pDispatchedObject :: [Token] -> Err Language.EO.Phi.Syntax.Abs.DispatchedObject +pDispatchedObject = fmap snd . pDispatchedObject_internal + +pBinding :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Binding +pBinding = fmap snd . pBinding_internal + +pListBinding :: [Token] -> Err [Language.EO.Phi.Syntax.Abs.Binding] +pListBinding = fmap snd . pListBinding_internal + +pBindings :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Bindings +pBindings = fmap snd . pBindings_internal + +pListBindings :: [Token] -> Err [Language.EO.Phi.Syntax.Abs.Bindings] +pListBindings = fmap snd . pListBindings_internal + +pDispatch :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Dispatch +pDispatch = fmap snd . pDispatch_internal + +pAttribute :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Attribute +pAttribute = fmap snd . pAttribute_internal + +pListAttribute :: [Token] -> Err [Language.EO.Phi.Syntax.Abs.Attribute] +pListAttribute = fmap snd . pListAttribute_internal + +pDisp :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Disp +pDisp = fmap snd . pDisp_internal + +pListDisp :: [Token] -> Err [Language.EO.Phi.Syntax.Abs.Disp] +pListDisp = fmap snd . pListDisp_internal +{-# LINE 1 "templates/GenericTemplate.hs" #-} +-- $Id: GenericTemplate.hs,v 1.26 2005/01/14 14:47:22 simonmar Exp $ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +data Happy_IntList = HappyCons Prelude.Int Happy_IntList + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +infixr 9 `HappyStk` +data HappyStk a = HappyStk a (HappyStk a) + +----------------------------------------------------------------------------- +-- starting the parse + +happyParse start_state = happyNewToken start_state notHappyAtAll notHappyAtAll + +----------------------------------------------------------------------------- +-- Accepting the parse + +-- If the current token is ERROR_TOK, it means we've just accepted a partial +-- parse (a %partial parser). We must ignore the saved token on the top of +-- the stack in this case. +happyAccept (1) tk st sts (_ `HappyStk` ans `HappyStk` _) = + happyReturn1 ans +happyAccept j tk st sts (HappyStk ans _) = + (happyReturn1 ans) + +----------------------------------------------------------------------------- +-- Arrays only: do the next action + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +indexShortOffAddr arr off = arr Happy_Data_Array.! off + + +{-# INLINE happyLt #-} +happyLt x y = (x Prelude.< y) + + + + + + +readArrayBit arr bit = + Bits.testBit (indexShortOffAddr arr (bit `Prelude.div` 16)) (bit `Prelude.mod` 16) + + + + + + +----------------------------------------------------------------------------- +-- HappyState data type (not arrays) + + + +newtype HappyState b c = HappyState + (Prelude.Int -> -- token number + Prelude.Int -> -- token number (yes, again) + b -> -- token semantic value + HappyState b c -> -- current state + [HappyState b c] -> -- state stack + c) + + + +----------------------------------------------------------------------------- +-- Shifting a token + +happyShift new_state (1) tk st sts stk@(x `HappyStk` _) = + let i = (case x of { HappyErrorToken (i) -> i }) in +-- trace "shifting the error token" $ + new_state i i tk (HappyState (new_state)) ((st):(sts)) (stk) + +happyShift new_state i tk st sts stk = + happyNewToken new_state ((st):(sts)) ((HappyTerminal (tk))`HappyStk`stk) + +-- happyReduce is specialised for the common cases. + +happySpecReduce_0 i fn (1) tk st sts stk + = happyFail [] (1) tk st sts stk +happySpecReduce_0 nt fn j tk st@((HappyState (action))) sts stk + = action nt j tk st ((st):(sts)) (fn `HappyStk` stk) + +happySpecReduce_1 i fn (1) tk st sts stk + = happyFail [] (1) tk st sts stk +happySpecReduce_1 nt fn j tk _ sts@(((st@(HappyState (action))):(_))) (v1`HappyStk`stk') + = let r = fn v1 in + happySeq r (action nt j tk st sts (r `HappyStk` stk')) + +happySpecReduce_2 i fn (1) tk st sts stk + = happyFail [] (1) tk st sts stk +happySpecReduce_2 nt fn j tk _ ((_):(sts@(((st@(HappyState (action))):(_))))) (v1`HappyStk`v2`HappyStk`stk') + = let r = fn v1 v2 in + happySeq r (action nt j tk st sts (r `HappyStk` stk')) + +happySpecReduce_3 i fn (1) tk st sts stk + = happyFail [] (1) tk st sts stk +happySpecReduce_3 nt fn j tk _ ((_):(((_):(sts@(((st@(HappyState (action))):(_))))))) (v1`HappyStk`v2`HappyStk`v3`HappyStk`stk') + = let r = fn v1 v2 v3 in + happySeq r (action nt j tk st sts (r `HappyStk` stk')) + +happyReduce k i fn (1) tk st sts stk + = happyFail [] (1) tk st sts stk +happyReduce k nt fn j tk st sts stk + = case happyDrop (k Prelude.- ((1) :: Prelude.Int)) sts of + sts1@(((st1@(HappyState (action))):(_))) -> + let r = fn stk in -- it doesn't hurt to always seq here... + happyDoSeq r (action nt j tk st1 sts1 r) + +happyMonadReduce k nt fn (1) tk st sts stk + = happyFail [] (1) tk st sts stk +happyMonadReduce k nt fn j tk st sts stk = + case happyDrop k ((st):(sts)) of + sts1@(((st1@(HappyState (action))):(_))) -> + let drop_stk = happyDropStk k stk in + happyThen1 (fn stk tk) (\r -> action nt j tk st1 sts1 (r `HappyStk` drop_stk)) + +happyMonad2Reduce k nt fn (1) tk st sts stk + = happyFail [] (1) tk st sts stk +happyMonad2Reduce k nt fn j tk st sts stk = + case happyDrop k ((st):(sts)) of + sts1@(((st1@(HappyState (action))):(_))) -> + let drop_stk = happyDropStk k stk + + + + + + _ = nt :: Prelude.Int + new_state = action + + in + happyThen1 (fn stk tk) (\r -> happyNewToken new_state sts1 (r `HappyStk` drop_stk)) + +happyDrop (0) l = l +happyDrop n ((_):(t)) = happyDrop (n Prelude.- ((1) :: Prelude.Int)) t + +happyDropStk (0) l = l +happyDropStk n (x `HappyStk` xs) = happyDropStk (n Prelude.- ((1)::Prelude.Int)) xs + +----------------------------------------------------------------------------- +-- Moving to a new state after a reduction + + + + + + + + + +happyGoto action j tk st = action j j tk (HappyState action) + + +----------------------------------------------------------------------------- +-- Error recovery (ERROR_TOK is the error token) + +-- parse error if we are in recovery and we fail again +happyFail explist (1) tk old_st _ stk@(x `HappyStk` _) = + let i = (case x of { HappyErrorToken (i) -> i }) in +-- trace "failing" $ + happyError_ explist i tk + +{- We don't need state discarding for our restricted implementation of + "error". In fact, it can cause some bogus parses, so I've disabled it + for now --SDM + +-- discard a state +happyFail ERROR_TOK tk old_st CONS(HAPPYSTATE(action),sts) + (saved_tok `HappyStk` _ `HappyStk` stk) = +-- trace ("discarding state, depth " ++ show (length stk)) $ + DO_ACTION(action,ERROR_TOK,tk,sts,(saved_tok`HappyStk`stk)) +-} + +-- Enter error recovery: generate an error token, +-- save the old token and carry on. +happyFail explist i tk (HappyState (action)) sts stk = +-- trace "entering error recovery" $ + action (1) (1) tk (HappyState (action)) sts ((HappyErrorToken (i)) `HappyStk` stk) + +-- Internal happy errors: + +notHappyAtAll :: a +notHappyAtAll = Prelude.error "Internal Happy error\n" + +----------------------------------------------------------------------------- +-- Hack to get the typechecker to accept our action functions + + + + + + + +----------------------------------------------------------------------------- +-- Seq-ing. If the --strict flag is given, then Happy emits +-- happySeq = happyDoSeq +-- otherwise it emits +-- happySeq = happyDontSeq + +happyDoSeq, happyDontSeq :: a -> b -> b +happyDoSeq a b = a `Prelude.seq` b +happyDontSeq a b = b + +----------------------------------------------------------------------------- +-- Don't inline any functions from the template. GHC has a nasty habit +-- of deciding to inline happyGoto everywhere, which increases the size of +-- the generated parser quite a bit. + + + + + + + + + +{-# NOINLINE happyShift #-} +{-# NOINLINE happySpecReduce_0 #-} +{-# NOINLINE happySpecReduce_1 #-} +{-# NOINLINE happySpecReduce_2 #-} +{-# NOINLINE happySpecReduce_3 #-} +{-# NOINLINE happyReduce #-} +{-# NOINLINE happyMonadReduce #-} +{-# NOINLINE happyGoto #-} +{-# NOINLINE happyFail #-} + +-- end of Happy Template. diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.info b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.info new file mode 100644 index 000000000..145086b51 --- /dev/null +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.info @@ -0,0 +1,1227 @@ +----------------------------------------------------------------------------- +Info file generated by Happy Version 1.20.1.1 from Par.y +----------------------------------------------------------------------------- + +state 15 contains 1 shift/reduce conflicts. +state 55 contains 1 reduce/reduce conflicts. +state 79 contains 1 shift/reduce conflicts. +state 80 contains 1 shift/reduce conflicts. +state 88 contains 1 reduce/reduce conflicts. +state 93 contains 1 shift/reduce conflicts. + +rule 14 is unused + +terminal L_Function is unused + +----------------------------------------------------------------------------- +Grammar +----------------------------------------------------------------------------- + %start_pProgram_internal -> Program (0) + %start_pObject_internal -> Object (1) + %start_pAbstractObject_internal -> AbstractObject (2) + %start_pDispatchedObject_internal -> DispatchedObject (3) + %start_pBinding_internal -> Binding (4) + %start_pListBinding_internal -> ListBinding (5) + %start_pBindings_internal -> Bindings (6) + %start_pListBindings_internal -> ListBindings (7) + %start_pDispatch_internal -> Dispatch (8) + %start_pAttribute_internal -> Attribute (9) + %start_pListAttribute_internal -> ListAttribute (10) + %start_pDisp_internal -> Disp (11) + %start_pListDisp_internal -> ListDisp (12) + Bytes -> L_Bytes (13) + Function -> L_Function (14) + LabelId -> L_LabelId (15) + AlphaIndex -> L_AlphaIndex (16) + Program -> '{' ListBinding '}' (17) + Object -> '{' ListBinding '}' (18) + Object -> AbstractObject '{' ListBinding '}' ListBindings (19) + Object -> Dispatch (20) + Object -> '⊥' (21) + AbstractObject -> '{' ListBinding '}' (22) + AbstractObject -> Dispatch (23) + AbstractObject -> '⊥' (24) + DispatchedObject -> '{' ListBinding '}' (25) + DispatchedObject -> '⊥' (26) + Binding -> Attribute '↦' Object (27) + Binding -> Attribute '↦' '∅' (28) + Binding -> 'Δ' '⤍' Bytes (29) + Binding -> 'λ' '⤍' (30) + ListBinding -> (31) + ListBinding -> Binding (32) + ListBinding -> Binding ',' ListBinding (33) + Bindings -> '{' ListBinding '}' (34) + ListBindings -> (35) + ListBindings -> Bindings ListBindings (36) + Dispatch -> DispatchedObject ListBindings '.' ListAttribute ListDisp (37) + Dispatch -> 'Φ' '.' ListAttribute ListDisp (38) + Dispatch -> 'ξ' '.' ListAttribute ListDisp (39) + Attribute -> 'φ' (40) + Attribute -> 'ρ' (41) + Attribute -> 'σ' (42) + Attribute -> 'ν' (43) + Attribute -> LabelId (44) + Attribute -> AlphaIndex (45) + ListAttribute -> Attribute (46) + ListAttribute -> Attribute '.' ListAttribute (47) + Disp -> '{' ListBinding '}' Bindings '.' ListAttribute (48) + ListDisp -> (49) + ListDisp -> Disp ListDisp (50) + +----------------------------------------------------------------------------- +Terminals +----------------------------------------------------------------------------- + ',' { PT _ (TS _ 1) } + '.' { PT _ (TS _ 2) } + '{' { PT _ (TS _ 3) } + '}' { PT _ (TS _ 4) } + 'Δ' { PT _ (TS _ 5) } + 'Φ' { PT _ (TS _ 6) } + 'λ' { PT _ (TS _ 7) } + 'ν' { PT _ (TS _ 8) } + 'ξ' { PT _ (TS _ 9) } + 'ρ' { PT _ (TS _ 10) } + 'σ' { PT _ (TS _ 11) } + 'φ' { PT _ (TS _ 12) } + '↦' { PT _ (TS _ 13) } + '∅' { PT _ (TS _ 14) } + '⊥' { PT _ (TS _ 15) } + '⤍' { PT _ (TS _ 16) } + L_Bytes { PT _ (T_Bytes _) } + L_Function { PT _ (T_Function _) } + L_LabelId { PT _ (T_LabelId _) } + L_AlphaIndex { PT _ (T_AlphaIndex _) } + +----------------------------------------------------------------------------- +Non-terminals +----------------------------------------------------------------------------- + %start_pProgram_internal rule 0 + %start_pObject_internal rule 1 + %start_pAbstractObject_internal rule 2 + %start_pDispatchedObject_internal rule 3 + %start_pBinding_internal rule 4 + %start_pListBinding_internal rule 5 + %start_pBindings_internal rule 6 + %start_pListBindings_internal rule 7 + %start_pDispatch_internal rule 8 + %start_pAttribute_internal rule 9 + %start_pListAttribute_internal rule 10 + %start_pDisp_internal rule 11 + %start_pListDisp_internal rule 12 + Bytes rule 13 + Function rule 14 + LabelId rule 15 + AlphaIndex rule 16 + Program rule 17 + Object rules 18, 19, 20, 21 + AbstractObject rules 22, 23, 24 + DispatchedObject rules 25, 26 + Binding rules 27, 28, 29, 30 + ListBinding rules 31, 32, 33 + Bindings rule 34 + ListBindings rules 35, 36 + Dispatch rules 37, 38, 39 + Attribute rules 40, 41, 42, 43, 44, 45 + ListAttribute rules 46, 47 + Disp rule 48 + ListDisp rules 49, 50 + +----------------------------------------------------------------------------- +States +----------------------------------------------------------------------------- +State 0 + + %start_pProgram_internal -> . Program (rule 0) + + '{' shift, and enter state 57 + + Program goto state 56 + +State 1 + + %start_pObject_internal -> . Object (rule 1) + + '{' shift, and enter state 54 + 'Φ' shift, and enter state 33 + 'ξ' shift, and enter state 34 + '⊥' shift, and enter state 55 + + Object goto state 51 + AbstractObject goto state 52 + DispatchedObjectgoto state 30 + Dispatch goto state 53 + +State 2 + + %start_pAbstractObject_internal -> . AbstractObject (rule 2) + + '{' shift, and enter state 49 + 'Φ' shift, and enter state 33 + 'ξ' shift, and enter state 34 + '⊥' shift, and enter state 50 + + AbstractObject goto state 47 + DispatchedObjectgoto state 30 + Dispatch goto state 48 + +State 3 + + %start_pDispatchedObject_internal -> . DispatchedObject (rule 3) + + '{' shift, and enter state 32 + '⊥' shift, and enter state 35 + + DispatchedObjectgoto state 46 + +State 4 + + %start_pBinding_internal -> . Binding (rule 4) + + 'Δ' shift, and enter state 43 + 'λ' shift, and enter state 44 + 'ν' shift, and enter state 23 + 'ρ' shift, and enter state 24 + 'σ' shift, and enter state 25 + 'φ' shift, and enter state 26 + L_LabelId shift, and enter state 27 + L_AlphaIndex shift, and enter state 28 + + LabelId goto state 19 + AlphaIndex goto state 20 + Binding goto state 45 + Attribute goto state 42 + +State 5 + + %start_pListBinding_internal -> . ListBinding (rule 5) + + 'Δ' shift, and enter state 43 + 'λ' shift, and enter state 44 + 'ν' shift, and enter state 23 + 'ρ' shift, and enter state 24 + 'σ' shift, and enter state 25 + 'φ' shift, and enter state 26 + L_LabelId shift, and enter state 27 + L_AlphaIndex shift, and enter state 28 + %eof reduce using rule 31 + + LabelId goto state 19 + AlphaIndex goto state 20 + Binding goto state 40 + ListBinding goto state 41 + Attribute goto state 42 + +State 6 + + %start_pBindings_internal -> . Bindings (rule 6) + + '{' shift, and enter state 38 + + Bindings goto state 39 + +State 7 + + %start_pListBindings_internal -> . ListBindings (rule 7) + + '{' shift, and enter state 38 + %eof reduce using rule 35 + + Bindings goto state 36 + ListBindings goto state 37 + +State 8 + + %start_pDispatch_internal -> . Dispatch (rule 8) + + '{' shift, and enter state 32 + 'Φ' shift, and enter state 33 + 'ξ' shift, and enter state 34 + '⊥' shift, and enter state 35 + + DispatchedObjectgoto state 30 + Dispatch goto state 31 + +State 9 + + %start_pAttribute_internal -> . Attribute (rule 9) + + 'ν' shift, and enter state 23 + 'ρ' shift, and enter state 24 + 'σ' shift, and enter state 25 + 'φ' shift, and enter state 26 + L_LabelId shift, and enter state 27 + L_AlphaIndex shift, and enter state 28 + + LabelId goto state 19 + AlphaIndex goto state 20 + Attribute goto state 29 + +State 10 + + %start_pListAttribute_internal -> . ListAttribute (rule 10) + + 'ν' shift, and enter state 23 + 'ρ' shift, and enter state 24 + 'σ' shift, and enter state 25 + 'φ' shift, and enter state 26 + L_LabelId shift, and enter state 27 + L_AlphaIndex shift, and enter state 28 + + LabelId goto state 19 + AlphaIndex goto state 20 + Attribute goto state 21 + ListAttribute goto state 22 + +State 11 + + %start_pDisp_internal -> . Disp (rule 11) + + '{' shift, and enter state 17 + + Disp goto state 18 + +State 12 + + %start_pListDisp_internal -> . ListDisp (rule 12) + + '{' shift, and enter state 17 + %eof reduce using rule 49 + + Disp goto state 15 + ListDisp goto state 16 + +State 13 + + Bytes -> . L_Bytes (rule 13) + + L_Bytes shift, and enter state 14 + + +State 14 + + Bytes -> L_Bytes . (rule 13) + + ',' reduce using rule 13 + '}' reduce using rule 13 + %eof reduce using rule 13 + + +State 15 + + ListDisp -> Disp . ListDisp (rule 50) + + ',' reduce using rule 49 + '{' shift, and enter state 17 + (reduce using rule 49) + + '}' reduce using rule 49 + %eof reduce using rule 49 + + Disp goto state 15 + ListDisp goto state 74 + +State 16 + + %start_pListDisp_internal -> ListDisp . (rule 12) + + %eof accept + + +State 17 + + Disp -> '{' . ListBinding '}' Bindings '.' ListAttribute (rule 48) + + '}' reduce using rule 31 + 'Δ' shift, and enter state 43 + 'λ' shift, and enter state 44 + 'ν' shift, and enter state 23 + 'ρ' shift, and enter state 24 + 'σ' shift, and enter state 25 + 'φ' shift, and enter state 26 + L_LabelId shift, and enter state 27 + L_AlphaIndex shift, and enter state 28 + + LabelId goto state 19 + AlphaIndex goto state 20 + Binding goto state 40 + ListBinding goto state 73 + Attribute goto state 42 + +State 18 + + %start_pDisp_internal -> Disp . (rule 11) + + %eof accept + + +State 19 + + Attribute -> LabelId . (rule 44) + + ',' reduce using rule 44 + '.' reduce using rule 44 + '{' reduce using rule 44 + '}' reduce using rule 44 + '↦' reduce using rule 44 + %eof reduce using rule 44 + + +State 20 + + Attribute -> AlphaIndex . (rule 45) + + ',' reduce using rule 45 + '.' reduce using rule 45 + '{' reduce using rule 45 + '}' reduce using rule 45 + '↦' reduce using rule 45 + %eof reduce using rule 45 + + +State 21 + + ListAttribute -> Attribute . (rule 46) + ListAttribute -> Attribute . '.' ListAttribute (rule 47) + + ',' reduce using rule 46 + '.' shift, and enter state 72 + '{' reduce using rule 46 + '}' reduce using rule 46 + %eof reduce using rule 46 + + +State 22 + + %start_pListAttribute_internal -> ListAttribute . (rule 10) + + %eof accept + + +State 23 + + Attribute -> 'ν' . (rule 43) + + ',' reduce using rule 43 + '.' reduce using rule 43 + '{' reduce using rule 43 + '}' reduce using rule 43 + '↦' reduce using rule 43 + %eof reduce using rule 43 + + +State 24 + + Attribute -> 'ρ' . (rule 41) + + ',' reduce using rule 41 + '.' reduce using rule 41 + '{' reduce using rule 41 + '}' reduce using rule 41 + '↦' reduce using rule 41 + %eof reduce using rule 41 + + +State 25 + + Attribute -> 'σ' . (rule 42) + + ',' reduce using rule 42 + '.' reduce using rule 42 + '{' reduce using rule 42 + '}' reduce using rule 42 + '↦' reduce using rule 42 + %eof reduce using rule 42 + + +State 26 + + Attribute -> 'φ' . (rule 40) + + ',' reduce using rule 40 + '.' reduce using rule 40 + '{' reduce using rule 40 + '}' reduce using rule 40 + '↦' reduce using rule 40 + %eof reduce using rule 40 + + +State 27 + + LabelId -> L_LabelId . (rule 15) + + ',' reduce using rule 15 + '.' reduce using rule 15 + '{' reduce using rule 15 + '}' reduce using rule 15 + '↦' reduce using rule 15 + %eof reduce using rule 15 + + +State 28 + + AlphaIndex -> L_AlphaIndex . (rule 16) + + ',' reduce using rule 16 + '.' reduce using rule 16 + '{' reduce using rule 16 + '}' reduce using rule 16 + '↦' reduce using rule 16 + %eof reduce using rule 16 + + +State 29 + + %start_pAttribute_internal -> Attribute . (rule 9) + + %eof accept + + +State 30 + + Dispatch -> DispatchedObject . ListBindings '.' ListAttribute ListDisp (rule 37) + + '.' reduce using rule 35 + '{' shift, and enter state 38 + + Bindings goto state 36 + ListBindings goto state 71 + +State 31 + + %start_pDispatch_internal -> Dispatch . (rule 8) + + %eof accept + + +State 32 + + DispatchedObject -> '{' . ListBinding '}' (rule 25) + + '}' reduce using rule 31 + 'Δ' shift, and enter state 43 + 'λ' shift, and enter state 44 + 'ν' shift, and enter state 23 + 'ρ' shift, and enter state 24 + 'σ' shift, and enter state 25 + 'φ' shift, and enter state 26 + L_LabelId shift, and enter state 27 + L_AlphaIndex shift, and enter state 28 + + LabelId goto state 19 + AlphaIndex goto state 20 + Binding goto state 40 + ListBinding goto state 70 + Attribute goto state 42 + +State 33 + + Dispatch -> 'Φ' . '.' ListAttribute ListDisp (rule 38) + + '.' shift, and enter state 69 + + +State 34 + + Dispatch -> 'ξ' . '.' ListAttribute ListDisp (rule 39) + + '.' shift, and enter state 68 + + +State 35 + + DispatchedObject -> '⊥' . (rule 26) + + '.' reduce using rule 26 + '{' reduce using rule 26 + %eof reduce using rule 26 + + +State 36 + + ListBindings -> Bindings . ListBindings (rule 36) + + ',' reduce using rule 35 + '.' reduce using rule 35 + '{' shift, and enter state 38 + '}' reduce using rule 35 + %eof reduce using rule 35 + + Bindings goto state 36 + ListBindings goto state 67 + +State 37 + + %start_pListBindings_internal -> ListBindings . (rule 7) + + %eof accept + + +State 38 + + Bindings -> '{' . ListBinding '}' (rule 34) + + '}' reduce using rule 31 + 'Δ' shift, and enter state 43 + 'λ' shift, and enter state 44 + 'ν' shift, and enter state 23 + 'ρ' shift, and enter state 24 + 'σ' shift, and enter state 25 + 'φ' shift, and enter state 26 + L_LabelId shift, and enter state 27 + L_AlphaIndex shift, and enter state 28 + + LabelId goto state 19 + AlphaIndex goto state 20 + Binding goto state 40 + ListBinding goto state 66 + Attribute goto state 42 + +State 39 + + %start_pBindings_internal -> Bindings . (rule 6) + + %eof accept + + +State 40 + + ListBinding -> Binding . (rule 32) + ListBinding -> Binding . ',' ListBinding (rule 33) + + ',' shift, and enter state 65 + '}' reduce using rule 32 + %eof reduce using rule 32 + + +State 41 + + %start_pListBinding_internal -> ListBinding . (rule 5) + + %eof accept + + +State 42 + + Binding -> Attribute . '↦' Object (rule 27) + Binding -> Attribute . '↦' '∅' (rule 28) + + '↦' shift, and enter state 64 + + +State 43 + + Binding -> 'Δ' . '⤍' Bytes (rule 29) + + '⤍' shift, and enter state 63 + + +State 44 + + Binding -> 'λ' . '⤍' (rule 30) + + '⤍' shift, and enter state 62 + + +State 45 + + %start_pBinding_internal -> Binding . (rule 4) + + %eof accept + + +State 46 + + %start_pDispatchedObject_internal -> DispatchedObject . (rule 3) + + %eof accept + + +State 47 + + %start_pAbstractObject_internal -> AbstractObject . (rule 2) + + %eof accept + + +State 48 + + AbstractObject -> Dispatch . (rule 23) + + %eof reduce using rule 23 + + +State 49 + + AbstractObject -> '{' . ListBinding '}' (rule 22) + DispatchedObject -> '{' . ListBinding '}' (rule 25) + + '}' reduce using rule 31 + 'Δ' shift, and enter state 43 + 'λ' shift, and enter state 44 + 'ν' shift, and enter state 23 + 'ρ' shift, and enter state 24 + 'σ' shift, and enter state 25 + 'φ' shift, and enter state 26 + L_LabelId shift, and enter state 27 + L_AlphaIndex shift, and enter state 28 + + LabelId goto state 19 + AlphaIndex goto state 20 + Binding goto state 40 + ListBinding goto state 61 + Attribute goto state 42 + +State 50 + + AbstractObject -> '⊥' . (rule 24) + DispatchedObject -> '⊥' . (rule 26) + + '.' reduce using rule 26 + '{' reduce using rule 26 + %eof reduce using rule 24 + + +State 51 + + %start_pObject_internal -> Object . (rule 1) + + %eof accept + + +State 52 + + Object -> AbstractObject . '{' ListBinding '}' ListBindings (rule 19) + + '{' shift, and enter state 60 + + +State 53 + + Object -> Dispatch . (rule 20) + AbstractObject -> Dispatch . (rule 23) + + ',' reduce using rule 20 + '{' reduce using rule 23 + '}' reduce using rule 20 + %eof reduce using rule 20 + + +State 54 + + Object -> '{' . ListBinding '}' (rule 18) + AbstractObject -> '{' . ListBinding '}' (rule 22) + DispatchedObject -> '{' . ListBinding '}' (rule 25) + + '}' reduce using rule 31 + 'Δ' shift, and enter state 43 + 'λ' shift, and enter state 44 + 'ν' shift, and enter state 23 + 'ρ' shift, and enter state 24 + 'σ' shift, and enter state 25 + 'φ' shift, and enter state 26 + L_LabelId shift, and enter state 27 + L_AlphaIndex shift, and enter state 28 + + LabelId goto state 19 + AlphaIndex goto state 20 + Binding goto state 40 + ListBinding goto state 59 + Attribute goto state 42 + +State 55 + + Object -> '⊥' . (rule 21) + AbstractObject -> '⊥' . (rule 24) + DispatchedObject -> '⊥' . (rule 26) + + ',' reduce using rule 21 + '.' reduce using rule 26 + '{' reduce using rule 26 + (reduce using rule 24) + + '}' reduce using rule 21 + %eof reduce using rule 21 + + +State 56 + + %start_pProgram_internal -> Program . (rule 0) + + %eof accept + + +State 57 + + Program -> '{' . ListBinding '}' (rule 17) + + '}' reduce using rule 31 + 'Δ' shift, and enter state 43 + 'λ' shift, and enter state 44 + 'ν' shift, and enter state 23 + 'ρ' shift, and enter state 24 + 'σ' shift, and enter state 25 + 'φ' shift, and enter state 26 + L_LabelId shift, and enter state 27 + L_AlphaIndex shift, and enter state 28 + + LabelId goto state 19 + AlphaIndex goto state 20 + Binding goto state 40 + ListBinding goto state 58 + Attribute goto state 42 + +State 58 + + Program -> '{' ListBinding . '}' (rule 17) + + '}' shift, and enter state 89 + + +State 59 + + Object -> '{' ListBinding . '}' (rule 18) + AbstractObject -> '{' ListBinding . '}' (rule 22) + DispatchedObject -> '{' ListBinding . '}' (rule 25) + + '}' shift, and enter state 88 + + +State 60 + + Object -> AbstractObject '{' . ListBinding '}' ListBindings (rule 19) + + '}' reduce using rule 31 + 'Δ' shift, and enter state 43 + 'λ' shift, and enter state 44 + 'ν' shift, and enter state 23 + 'ρ' shift, and enter state 24 + 'σ' shift, and enter state 25 + 'φ' shift, and enter state 26 + L_LabelId shift, and enter state 27 + L_AlphaIndex shift, and enter state 28 + + LabelId goto state 19 + AlphaIndex goto state 20 + Binding goto state 40 + ListBinding goto state 87 + Attribute goto state 42 + +State 61 + + AbstractObject -> '{' ListBinding . '}' (rule 22) + DispatchedObject -> '{' ListBinding . '}' (rule 25) + + '}' shift, and enter state 86 + + +State 62 + + Binding -> 'λ' '⤍' . (rule 30) + + ',' reduce using rule 30 + '}' reduce using rule 30 + %eof reduce using rule 30 + + +State 63 + + Binding -> 'Δ' '⤍' . Bytes (rule 29) + + L_Bytes shift, and enter state 14 + + Bytes goto state 85 + +State 64 + + Binding -> Attribute '↦' . Object (rule 27) + Binding -> Attribute '↦' . '∅' (rule 28) + + '{' shift, and enter state 54 + 'Φ' shift, and enter state 33 + 'ξ' shift, and enter state 34 + '∅' shift, and enter state 84 + '⊥' shift, and enter state 55 + + Object goto state 83 + AbstractObject goto state 52 + DispatchedObjectgoto state 30 + Dispatch goto state 53 + +State 65 + + ListBinding -> Binding ',' . ListBinding (rule 33) + + '}' reduce using rule 31 + 'Δ' shift, and enter state 43 + 'λ' shift, and enter state 44 + 'ν' shift, and enter state 23 + 'ρ' shift, and enter state 24 + 'σ' shift, and enter state 25 + 'φ' shift, and enter state 26 + L_LabelId shift, and enter state 27 + L_AlphaIndex shift, and enter state 28 + %eof reduce using rule 31 + + LabelId goto state 19 + AlphaIndex goto state 20 + Binding goto state 40 + ListBinding goto state 82 + Attribute goto state 42 + +State 66 + + Bindings -> '{' ListBinding . '}' (rule 34) + + '}' shift, and enter state 81 + + +State 67 + + ListBindings -> Bindings ListBindings . (rule 36) + + ',' reduce using rule 36 + '.' reduce using rule 36 + '}' reduce using rule 36 + %eof reduce using rule 36 + + +State 68 + + Dispatch -> 'ξ' '.' . ListAttribute ListDisp (rule 39) + + 'ν' shift, and enter state 23 + 'ρ' shift, and enter state 24 + 'σ' shift, and enter state 25 + 'φ' shift, and enter state 26 + L_LabelId shift, and enter state 27 + L_AlphaIndex shift, and enter state 28 + + LabelId goto state 19 + AlphaIndex goto state 20 + Attribute goto state 21 + ListAttribute goto state 80 + +State 69 + + Dispatch -> 'Φ' '.' . ListAttribute ListDisp (rule 38) + + 'ν' shift, and enter state 23 + 'ρ' shift, and enter state 24 + 'σ' shift, and enter state 25 + 'φ' shift, and enter state 26 + L_LabelId shift, and enter state 27 + L_AlphaIndex shift, and enter state 28 + + LabelId goto state 19 + AlphaIndex goto state 20 + Attribute goto state 21 + ListAttribute goto state 79 + +State 70 + + DispatchedObject -> '{' ListBinding . '}' (rule 25) + + '}' shift, and enter state 78 + + +State 71 + + Dispatch -> DispatchedObject ListBindings . '.' ListAttribute ListDisp (rule 37) + + '.' shift, and enter state 77 + + +State 72 + + ListAttribute -> Attribute '.' . ListAttribute (rule 47) + + 'ν' shift, and enter state 23 + 'ρ' shift, and enter state 24 + 'σ' shift, and enter state 25 + 'φ' shift, and enter state 26 + L_LabelId shift, and enter state 27 + L_AlphaIndex shift, and enter state 28 + + LabelId goto state 19 + AlphaIndex goto state 20 + Attribute goto state 21 + ListAttribute goto state 76 + +State 73 + + Disp -> '{' ListBinding . '}' Bindings '.' ListAttribute (rule 48) + + '}' shift, and enter state 75 + + +State 74 + + ListDisp -> Disp ListDisp . (rule 50) + + ',' reduce using rule 50 + '{' reduce using rule 50 + '}' reduce using rule 50 + %eof reduce using rule 50 + + +State 75 + + Disp -> '{' ListBinding '}' . Bindings '.' ListAttribute (rule 48) + + '{' shift, and enter state 38 + + Bindings goto state 94 + +State 76 + + ListAttribute -> Attribute '.' ListAttribute . (rule 47) + + ',' reduce using rule 47 + '{' reduce using rule 47 + '}' reduce using rule 47 + %eof reduce using rule 47 + + +State 77 + + Dispatch -> DispatchedObject ListBindings '.' . ListAttribute ListDisp (rule 37) + + 'ν' shift, and enter state 23 + 'ρ' shift, and enter state 24 + 'σ' shift, and enter state 25 + 'φ' shift, and enter state 26 + L_LabelId shift, and enter state 27 + L_AlphaIndex shift, and enter state 28 + + LabelId goto state 19 + AlphaIndex goto state 20 + Attribute goto state 21 + ListAttribute goto state 93 + +State 78 + + DispatchedObject -> '{' ListBinding '}' . (rule 25) + + '.' reduce using rule 25 + '{' reduce using rule 25 + %eof reduce using rule 25 + + +State 79 + + Dispatch -> 'Φ' '.' ListAttribute . ListDisp (rule 38) + + ',' reduce using rule 49 + '{' shift, and enter state 17 + (reduce using rule 49) + + '}' reduce using rule 49 + %eof reduce using rule 49 + + Disp goto state 15 + ListDisp goto state 92 + +State 80 + + Dispatch -> 'ξ' '.' ListAttribute . ListDisp (rule 39) + + ',' reduce using rule 49 + '{' shift, and enter state 17 + (reduce using rule 49) + + '}' reduce using rule 49 + %eof reduce using rule 49 + + Disp goto state 15 + ListDisp goto state 91 + +State 81 + + Bindings -> '{' ListBinding '}' . (rule 34) + + ',' reduce using rule 34 + '.' reduce using rule 34 + '{' reduce using rule 34 + '}' reduce using rule 34 + %eof reduce using rule 34 + + +State 82 + + ListBinding -> Binding ',' ListBinding . (rule 33) + + '}' reduce using rule 33 + %eof reduce using rule 33 + + +State 83 + + Binding -> Attribute '↦' Object . (rule 27) + + ',' reduce using rule 27 + '}' reduce using rule 27 + %eof reduce using rule 27 + + +State 84 + + Binding -> Attribute '↦' '∅' . (rule 28) + + ',' reduce using rule 28 + '}' reduce using rule 28 + %eof reduce using rule 28 + + +State 85 + + Binding -> 'Δ' '⤍' Bytes . (rule 29) + + ',' reduce using rule 29 + '}' reduce using rule 29 + %eof reduce using rule 29 + + +State 86 + + AbstractObject -> '{' ListBinding '}' . (rule 22) + DispatchedObject -> '{' ListBinding '}' . (rule 25) + + '.' reduce using rule 25 + '{' reduce using rule 25 + %eof reduce using rule 22 + + +State 87 + + Object -> AbstractObject '{' ListBinding . '}' ListBindings (rule 19) + + '}' shift, and enter state 90 + + +State 88 + + Object -> '{' ListBinding '}' . (rule 18) + AbstractObject -> '{' ListBinding '}' . (rule 22) + DispatchedObject -> '{' ListBinding '}' . (rule 25) + + ',' reduce using rule 18 + '.' reduce using rule 25 + '{' reduce using rule 25 + (reduce using rule 22) + + '}' reduce using rule 18 + %eof reduce using rule 18 + + +State 89 + + Program -> '{' ListBinding '}' . (rule 17) + + %eof reduce using rule 17 + + +State 90 + + Object -> AbstractObject '{' ListBinding '}' . ListBindings (rule 19) + + ',' reduce using rule 35 + '{' shift, and enter state 38 + '}' reduce using rule 35 + %eof reduce using rule 35 + + Bindings goto state 36 + ListBindings goto state 97 + +State 91 + + Dispatch -> 'ξ' '.' ListAttribute ListDisp . (rule 39) + + ',' reduce using rule 39 + '{' reduce using rule 39 + '}' reduce using rule 39 + %eof reduce using rule 39 + + +State 92 + + Dispatch -> 'Φ' '.' ListAttribute ListDisp . (rule 38) + + ',' reduce using rule 38 + '{' reduce using rule 38 + '}' reduce using rule 38 + %eof reduce using rule 38 + + +State 93 + + Dispatch -> DispatchedObject ListBindings '.' ListAttribute . ListDisp (rule 37) + + ',' reduce using rule 49 + '{' shift, and enter state 17 + (reduce using rule 49) + + '}' reduce using rule 49 + %eof reduce using rule 49 + + Disp goto state 15 + ListDisp goto state 96 + +State 94 + + Disp -> '{' ListBinding '}' Bindings . '.' ListAttribute (rule 48) + + '.' shift, and enter state 95 + + +State 95 + + Disp -> '{' ListBinding '}' Bindings '.' . ListAttribute (rule 48) + + 'ν' shift, and enter state 23 + 'ρ' shift, and enter state 24 + 'σ' shift, and enter state 25 + 'φ' shift, and enter state 26 + L_LabelId shift, and enter state 27 + L_AlphaIndex shift, and enter state 28 + + LabelId goto state 19 + AlphaIndex goto state 20 + Attribute goto state 21 + ListAttribute goto state 98 + +State 96 + + Dispatch -> DispatchedObject ListBindings '.' ListAttribute ListDisp . (rule 37) + + ',' reduce using rule 37 + '{' reduce using rule 37 + '}' reduce using rule 37 + %eof reduce using rule 37 + + +State 97 + + Object -> AbstractObject '{' ListBinding '}' ListBindings . (rule 19) + + ',' reduce using rule 19 + '}' reduce using rule 19 + %eof reduce using rule 19 + + +State 98 + + Disp -> '{' ListBinding '}' Bindings '.' ListAttribute . (rule 48) + + ',' reduce using rule 48 + '{' reduce using rule 48 + '}' reduce using rule 48 + %eof reduce using rule 48 + + +----------------------------------------------------------------------------- +Grammar Totals +----------------------------------------------------------------------------- +Number of rules: 51 +Number of terminals: 20 +Number of non-terminals: 30 +Number of states: 99 diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y new file mode 100644 index 000000000..382664649 --- /dev/null +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y @@ -0,0 +1,214 @@ +-- -*- haskell -*- File generated by the BNF Converter (bnfc 2.9.5). + +-- Parser definition for use with Happy +{ +{-# OPTIONS_GHC -fno-warn-incomplete-patterns -fno-warn-overlapping-patterns #-} +{-# LANGUAGE PatternSynonyms #-} + +module Language.EO.Phi.Syntax.Par + ( happyError + , myLexer + , pProgram + , pObject + , pAbstractObject + , pDispatchedObject + , pBinding + , pListBinding + , pBindings + , pListBindings + , pDispatch + , pAttribute + , pListAttribute + , pDisp + , pListDisp + ) where + +import Prelude + +import qualified Language.EO.Phi.Syntax.Abs +import Language.EO.Phi.Syntax.Lex + +} + +%name pProgram_internal Program +%name pObject_internal Object +%name pAbstractObject_internal AbstractObject +%name pDispatchedObject_internal DispatchedObject +%name pBinding_internal Binding +%name pListBinding_internal ListBinding +%name pBindings_internal Bindings +%name pListBindings_internal ListBindings +%name pDispatch_internal Dispatch +%name pAttribute_internal Attribute +%name pListAttribute_internal ListAttribute +%name pDisp_internal Disp +%name pListDisp_internal ListDisp +-- no lexer declaration +%monad { Err } { (>>=) } { return } +%tokentype {Token} +%token + ',' { PT _ (TS _ 1) } + '.' { PT _ (TS _ 2) } + '{' { PT _ (TS _ 3) } + '}' { PT _ (TS _ 4) } + 'Δ' { PT _ (TS _ 5) } + 'Φ' { PT _ (TS _ 6) } + 'λ' { PT _ (TS _ 7) } + 'ν' { PT _ (TS _ 8) } + 'ξ' { PT _ (TS _ 9) } + 'ρ' { PT _ (TS _ 10) } + 'σ' { PT _ (TS _ 11) } + 'φ' { PT _ (TS _ 12) } + '↦' { PT _ (TS _ 13) } + '∅' { PT _ (TS _ 14) } + '⊥' { PT _ (TS _ 15) } + '⤍' { PT _ (TS _ 16) } + L_Bytes { PT _ (T_Bytes _) } + L_Function { PT _ (T_Function _) } + L_LabelId { PT _ (T_LabelId _) } + L_AlphaIndex { PT _ (T_AlphaIndex _) } + +%% + +Bytes :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Bytes) } +Bytes : L_Bytes { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Bytes (tokenText $1)) } + +Function :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Function) } +Function : L_Function { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Function (tokenText $1)) } + +LabelId :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.LabelId) } +LabelId : L_LabelId { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.LabelId (tokenText $1)) } + +AlphaIndex :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.AlphaIndex) } +AlphaIndex : L_AlphaIndex { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.AlphaIndex (tokenText $1)) } + +Program :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Program) } +Program + : '{' ListBinding '}' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Program (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $2)) } + +Object :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Object) } +Object + : '{' ListBinding '}' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Formation (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $2)) } + | AbstractObject '{' ListBinding '}' ListBindings { (fst $1, Language.EO.Phi.Syntax.Abs.Application (fst $1) (snd $1) (snd $3) (snd $5)) } + | Dispatch { (fst $1, Language.EO.Phi.Syntax.Abs.Dispatch (fst $1) (snd $1)) } + | '⊥' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Termination (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } + +AbstractObject :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.AbstractObject) } +AbstractObject + : '{' ListBinding '}' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.AbstractFormation (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $2)) } + | Dispatch { (fst $1, Language.EO.Phi.Syntax.Abs.AbstractDispatch (fst $1) (snd $1)) } + | '⊥' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.AbstractTermination (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } + +DispatchedObject :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.DispatchedObject) } +DispatchedObject + : '{' ListBinding '}' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.DispatchedFormation (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $2)) } + | '⊥' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.DispatchedTermination (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } + +Binding :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Binding) } +Binding + : Attribute '↦' Object { (fst $1, Language.EO.Phi.Syntax.Abs.AlphaBinding (fst $1) (snd $1) (snd $3)) } + | Attribute '↦' '∅' { (fst $1, Language.EO.Phi.Syntax.Abs.EmptyBinding (fst $1) (snd $1)) } + | 'Δ' '⤍' Bytes { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.DeltaBinding (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $3)) } + | 'λ' '⤍' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.LambdaBinding (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } + +ListBinding :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, [Language.EO.Phi.Syntax.Abs.Binding]) } +ListBinding + : {- empty -} { (Language.EO.Phi.Syntax.Abs.BNFC'NoPosition, []) } + | Binding { (fst $1, (:[]) (snd $1)) } + | Binding ',' ListBinding { (fst $1, (:) (snd $1) (snd $3)) } + +Bindings :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Bindings) } +Bindings + : '{' ListBinding '}' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Bindings (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $2)) } + +ListBindings :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, [Language.EO.Phi.Syntax.Abs.Bindings]) } +ListBindings + : {- empty -} { (Language.EO.Phi.Syntax.Abs.BNFC'NoPosition, []) } + | Bindings ListBindings { (fst $1, (:) (snd $1) (snd $2)) } + +Dispatch :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Dispatch) } +Dispatch + : DispatchedObject ListBindings '.' ListAttribute ListDisp { (fst $1, Language.EO.Phi.Syntax.Abs.ObjectDispatch (fst $1) (snd $1) (snd $2) (snd $4) (snd $5)) } + | 'Φ' '.' ListAttribute ListDisp { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.HomeDispatch (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $3) (snd $4)) } + | 'ξ' '.' ListAttribute ListDisp { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.ThisDispatch (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $3) (snd $4)) } + +Attribute :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Attribute) } +Attribute + : 'φ' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Phi (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } + | 'ρ' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Rho (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } + | 'σ' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Sigma (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } + | 'ν' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.VTX (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } + | LabelId { (fst $1, Language.EO.Phi.Syntax.Abs.Label (fst $1) (snd $1)) } + | AlphaIndex { (fst $1, Language.EO.Phi.Syntax.Abs.Alpha (fst $1) (snd $1)) } + +ListAttribute :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, [Language.EO.Phi.Syntax.Abs.Attribute]) } +ListAttribute + : Attribute { (fst $1, (:[]) (snd $1)) } + | Attribute '.' ListAttribute { (fst $1, (:) (snd $1) (snd $3)) } + +Disp :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Disp) } +Disp + : '{' ListBinding '}' Bindings '.' ListAttribute { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Disp (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $2) (snd $4) (snd $6)) } + +ListDisp :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, [Language.EO.Phi.Syntax.Abs.Disp]) } +ListDisp + : {- empty -} { (Language.EO.Phi.Syntax.Abs.BNFC'NoPosition, []) } + | Disp ListDisp { (fst $1, (:) (snd $1) (snd $2)) } + +{ + +type Err = Either String + +happyError :: [Token] -> Err a +happyError ts = Left $ + "syntax error at " ++ tokenPos ts ++ + case ts of + [] -> [] + [Err _] -> " due to lexer error" + t:_ -> " before `" ++ (prToken t) ++ "'" + +myLexer :: String -> [Token] +myLexer = tokens + +-- Entrypoints + +pProgram :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Program +pProgram = fmap snd . pProgram_internal + +pObject :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Object +pObject = fmap snd . pObject_internal + +pAbstractObject :: [Token] -> Err Language.EO.Phi.Syntax.Abs.AbstractObject +pAbstractObject = fmap snd . pAbstractObject_internal + +pDispatchedObject :: [Token] -> Err Language.EO.Phi.Syntax.Abs.DispatchedObject +pDispatchedObject = fmap snd . pDispatchedObject_internal + +pBinding :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Binding +pBinding = fmap snd . pBinding_internal + +pListBinding :: [Token] -> Err [Language.EO.Phi.Syntax.Abs.Binding] +pListBinding = fmap snd . pListBinding_internal + +pBindings :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Bindings +pBindings = fmap snd . pBindings_internal + +pListBindings :: [Token] -> Err [Language.EO.Phi.Syntax.Abs.Bindings] +pListBindings = fmap snd . pListBindings_internal + +pDispatch :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Dispatch +pDispatch = fmap snd . pDispatch_internal + +pAttribute :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Attribute +pAttribute = fmap snd . pAttribute_internal + +pListAttribute :: [Token] -> Err [Language.EO.Phi.Syntax.Abs.Attribute] +pListAttribute = fmap snd . pListAttribute_internal + +pDisp :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Disp +pDisp = fmap snd . pDisp_internal + +pListDisp :: [Token] -> Err [Language.EO.Phi.Syntax.Abs.Disp] +pListDisp = fmap snd . pListDisp_internal +} + diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y.bak b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y.bak new file mode 100644 index 000000000..0a687f005 --- /dev/null +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y.bak @@ -0,0 +1,212 @@ +-- -*- haskell -*- File generated by the BNF Converter (bnfc 2.9.5). + +-- Parser definition for use with Happy +{ +{-# OPTIONS_GHC -fno-warn-incomplete-patterns -fno-warn-overlapping-patterns #-} +{-# LANGUAGE PatternSynonyms #-} + +module Language.EO.Phi.Syntax.Par + ( happyError + , myLexer + , pProgram + , pObject + , pAbstractObject + , pDispatchedObject + , pBinding + , pListBinding + , pBindings + , pListBindings + , pDispatch + , pAttribute + , pListAttribute + , pDisp + , pListDisp + ) where + +import Prelude + +import qualified Language.EO.Phi.Syntax.Abs +import Language.EO.Phi.Syntax.Lex + +} + +%name pProgram_internal Program +%name pObject_internal Object +%name pAbstractObject_internal AbstractObject +%name pDispatchedObject_internal DispatchedObject +%name pBinding_internal Binding +%name pListBinding_internal ListBinding +%name pBindings_internal Bindings +%name pListBindings_internal ListBindings +%name pDispatch_internal Dispatch +%name pAttribute_internal Attribute +%name pListAttribute_internal ListAttribute +%name pDisp_internal Disp +%name pListDisp_internal ListDisp +-- no lexer declaration +%monad { Err } { (>>=) } { return } +%tokentype {Token} +%token + ',' { PT _ (TS _ 1) } + '.' { PT _ (TS _ 2) } + '{' { PT _ (TS _ 3) } + '}' { PT _ (TS _ 4) } + 'Δ' { PT _ (TS _ 5) } + 'Φ' { PT _ (TS _ 6) } + 'λ' { PT _ (TS _ 7) } + 'ν' { PT _ (TS _ 8) } + 'ξ' { PT _ (TS _ 9) } + 'ρ' { PT _ (TS _ 10) } + 'σ' { PT _ (TS _ 11) } + 'φ' { PT _ (TS _ 12) } + '↦' { PT _ (TS _ 13) } + '∅' { PT _ (TS _ 14) } + '⊥' { PT _ (TS _ 15) } + '⤍' { PT _ (TS _ 16) } + L_Bytes { PT _ (T_Bytes _) } + L_Function { PT _ (T_Function _) } + L_LabelId { PT _ (T_LabelId _) } + L_AlphaIndex { PT _ (T_AlphaIndex _) } + +%% + +Bytes :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Bytes) } +Bytes : L_Bytes { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Bytes (tokenText $1)) } + +Function :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Function) } +Function : L_Function { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Function (tokenText $1)) } + +LabelId :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.LabelId) } +LabelId : L_LabelId { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.LabelId (tokenText $1)) } + +AlphaIndex :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.AlphaIndex) } +AlphaIndex : L_AlphaIndex { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.AlphaIndex (tokenText $1)) } + +Program :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Program) } +Program + : '{' ListBinding '}' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Program (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $2)) } + +Object :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Object) } +Object + : '{' ListBinding '}' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Formation (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $2)) } + | AbstractObject '{' ListBinding '}' ListBindings { (fst $1, Language.EO.Phi.Syntax.Abs.Application (fst $1) (snd $1) (snd $3) (snd $5)) } + | Dispatch { (fst $1, Language.EO.Phi.Syntax.Abs.Dispatch (fst $1) (snd $1)) } + | '⊥' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Termination (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } + +AbstractObject :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.AbstractObject) } +AbstractObject + : '{' ListBinding '}' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.AbstractFormation (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $2)) } + | Dispatch { (fst $1, Language.EO.Phi.Syntax.Abs.AbstractDispatch (fst $1) (snd $1)) } + | '⊥' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.AbstractTermination (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } + +DispatchedObject :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.DispatchedObject) } +DispatchedObject + : '{' ListBinding '}' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.DispatchedFormation (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $2)) } + | '⊥' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.DispatchedTermination (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } + +Binding :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Binding) } +Binding + : Attribute '↦' '∅' { (fst $1, Language.EO.Phi.Syntax.Abs.EmptyBinding (fst $1) (snd $1)) } + | 'Δ' '⤍' Bytes { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.DeltaBinding (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $3)) } + | 'λ' '⤍' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.LambdaBinding (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } + +ListBinding :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, [Language.EO.Phi.Syntax.Abs.Binding]) } +ListBinding + : {- empty -} { (Language.EO.Phi.Syntax.Abs.BNFC'NoPosition, []) } + | Binding { (fst $1, (:[]) (snd $1)) } + | Binding ',' ListBinding { (fst $1, (:) (snd $1) (snd $3)) } + +Bindings :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Bindings) } +Bindings + : '{' ListBinding '}' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Bindings (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $2)) } + +ListBindings :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, [Language.EO.Phi.Syntax.Abs.Bindings]) } +ListBindings + : {- empty -} { (Language.EO.Phi.Syntax.Abs.BNFC'NoPosition, []) } + | Bindings ListBindings { (fst $1, (:) (snd $1) (snd $2)) } + +Dispatch :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Dispatch) } +Dispatch + : 'Φ' '.' ListAttribute ListDisp { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.HomeDispatch (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $3) (snd $4)) } + | 'ξ' '.' ListAttribute ListDisp { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.ThisDispatch (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $3) (snd $4)) } + +Attribute :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Attribute) } +Attribute + : 'φ' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Phi (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } + | 'ρ' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Rho (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } + | 'σ' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Sigma (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } + | 'ν' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.VTX (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } + | LabelId { (fst $1, Language.EO.Phi.Syntax.Abs.Label (fst $1) (snd $1)) } + | AlphaIndex { (fst $1, Language.EO.Phi.Syntax.Abs.Alpha (fst $1) (snd $1)) } + +ListAttribute :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, [Language.EO.Phi.Syntax.Abs.Attribute]) } +ListAttribute + : Attribute { (fst $1, (:[]) (snd $1)) } + | Attribute '.' ListAttribute { (fst $1, (:) (snd $1) (snd $3)) } + +Disp :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Disp) } +Disp + : '{' ListBinding '}' Bindings '.' ListAttribute { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Disp (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $2) (snd $4) (snd $6)) } + +ListDisp :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, [Language.EO.Phi.Syntax.Abs.Disp]) } +ListDisp + : {- empty -} { (Language.EO.Phi.Syntax.Abs.BNFC'NoPosition, []) } + | Disp ListDisp { (fst $1, (:) (snd $1) (snd $2)) } + +{ + +type Err = Either String + +happyError :: [Token] -> Err a +happyError ts = Left $ + "syntax error at " ++ tokenPos ts ++ + case ts of + [] -> [] + [Err _] -> " due to lexer error" + t:_ -> " before `" ++ (prToken t) ++ "'" + +myLexer :: String -> [Token] +myLexer = tokens + +-- Entrypoints + +pProgram :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Program +pProgram = fmap snd . pProgram_internal + +pObject :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Object +pObject = fmap snd . pObject_internal + +pAbstractObject :: [Token] -> Err Language.EO.Phi.Syntax.Abs.AbstractObject +pAbstractObject = fmap snd . pAbstractObject_internal + +pDispatchedObject :: [Token] -> Err Language.EO.Phi.Syntax.Abs.DispatchedObject +pDispatchedObject = fmap snd . pDispatchedObject_internal + +pBinding :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Binding +pBinding = fmap snd . pBinding_internal + +pListBinding :: [Token] -> Err [Language.EO.Phi.Syntax.Abs.Binding] +pListBinding = fmap snd . pListBinding_internal + +pBindings :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Bindings +pBindings = fmap snd . pBindings_internal + +pListBindings :: [Token] -> Err [Language.EO.Phi.Syntax.Abs.Bindings] +pListBindings = fmap snd . pListBindings_internal + +pDispatch :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Dispatch +pDispatch = fmap snd . pDispatch_internal + +pAttribute :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Attribute +pAttribute = fmap snd . pAttribute_internal + +pListAttribute :: [Token] -> Err [Language.EO.Phi.Syntax.Abs.Attribute] +pListAttribute = fmap snd . pListAttribute_internal + +pDisp :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Disp +pDisp = fmap snd . pDisp_internal + +pListDisp :: [Token] -> Err [Language.EO.Phi.Syntax.Abs.Disp] +pListDisp = fmap snd . pListDisp_internal +} + diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs new file mode 100644 index 000000000..8be1ef5c4 --- /dev/null +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs @@ -0,0 +1,216 @@ +-- File generated by the BNF Converter (bnfc 2.9.5). + +{-# LANGUAGE CPP #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE LambdaCase #-} +#if __GLASGOW_HASKELL__ <= 708 +{-# LANGUAGE OverlappingInstances #-} +#endif + +-- | Pretty-printer for Language. + +module Language.EO.Phi.Syntax.Print where + +import Prelude + ( ($), (.) + , Bool(..), (==), (<) + , Int, Integer, Double, (+), (-), (*) + , String, (++) + , ShowS, showChar, showString + , all, elem, foldr, id, map, null, replicate, shows, span + ) +import Data.Char ( Char, isSpace ) +import qualified Language.EO.Phi.Syntax.Abs + +-- | The top-level printing method. + +printTree :: Print a => a -> String +printTree = render . prt 0 + +type Doc = [ShowS] -> [ShowS] + +doc :: ShowS -> Doc +doc = (:) + +render :: Doc -> String +render d = rend 0 False (map ($ "") $ d []) "" + where + rend + :: Int -- ^ Indentation level. + -> Bool -- ^ Pending indentation to be output before next character? + -> [String] + -> ShowS + rend i p = \case + "[" :ts -> char '[' . rend i False ts + "(" :ts -> char '(' . rend i False ts + "{" :ts -> onNewLine i p . showChar '{' . new (i+1) ts + "}" : ";":ts -> onNewLine (i-1) p . showString "};" . new (i-1) ts + "}" :ts -> onNewLine (i-1) p . showChar '}' . new (i-1) ts + [";"] -> char ';' + ";" :ts -> char ';' . new i ts + t : ts@(s:_) | closingOrPunctuation s + -> pending . showString t . rend i False ts + t :ts -> pending . space t . rend i False ts + [] -> id + where + -- Output character after pending indentation. + char :: Char -> ShowS + char c = pending . showChar c + + -- Output pending indentation. + pending :: ShowS + pending = if p then indent i else id + + -- Indentation (spaces) for given indentation level. + indent :: Int -> ShowS + indent i = replicateS (2*i) (showChar ' ') + + -- Continue rendering in new line with new indentation. + new :: Int -> [String] -> ShowS + new j ts = showChar '\n' . rend j True ts + + -- Make sure we are on a fresh line. + onNewLine :: Int -> Bool -> ShowS + onNewLine i p = (if p then id else showChar '\n') . indent i + + -- Separate given string from following text by a space (if needed). + space :: String -> ShowS + space t s = + case (all isSpace t, null spc, null rest) of + (True , _ , True ) -> [] -- remove trailing space + (False, _ , True ) -> t -- remove trailing space + (False, True, False) -> t ++ ' ' : s -- add space if none + _ -> t ++ s + where + (spc, rest) = span isSpace s + + closingOrPunctuation :: String -> Bool + closingOrPunctuation [c] = c `elem` closerOrPunct + closingOrPunctuation _ = False + + closerOrPunct :: String + closerOrPunct = ")],;" + +parenth :: Doc -> Doc +parenth ss = doc (showChar '(') . ss . doc (showChar ')') + +concatS :: [ShowS] -> ShowS +concatS = foldr (.) id + +concatD :: [Doc] -> Doc +concatD = foldr (.) id + +replicateS :: Int -> ShowS -> ShowS +replicateS n f = concatS (replicate n f) + +-- | The printer class does the job. + +class Print a where + prt :: Int -> a -> Doc + +instance {-# OVERLAPPABLE #-} Print a => Print [a] where + prt i = concatD . map (prt i) + +instance Print Char where + prt _ c = doc (showChar '\'' . mkEsc '\'' c . showChar '\'') + +instance Print String where + prt _ = printString + +printString :: String -> Doc +printString s = doc (showChar '"' . concatS (map (mkEsc '"') s) . showChar '"') + +mkEsc :: Char -> Char -> ShowS +mkEsc q = \case + s | s == q -> showChar '\\' . showChar s + '\\' -> showString "\\\\" + '\n' -> showString "\\n" + '\t' -> showString "\\t" + s -> showChar s + +prPrec :: Int -> Int -> Doc -> Doc +prPrec i j = if j < i then parenth else id + +instance Print Integer where + prt _ x = doc (shows x) + +instance Print Double where + prt _ x = doc (shows x) + +instance Print Language.EO.Phi.Syntax.Abs.Bytes where + prt _ (Language.EO.Phi.Syntax.Abs.Bytes i) = doc $ showString i +instance Print Language.EO.Phi.Syntax.Abs.Function where + prt _ (Language.EO.Phi.Syntax.Abs.Function i) = doc $ showString i +instance Print Language.EO.Phi.Syntax.Abs.LabelId where + prt _ (Language.EO.Phi.Syntax.Abs.LabelId i) = doc $ showString i +instance Print Language.EO.Phi.Syntax.Abs.AlphaIndex where + prt _ (Language.EO.Phi.Syntax.Abs.AlphaIndex i) = doc $ showString i +instance Print (Language.EO.Phi.Syntax.Abs.Program' a) where + prt i = \case + Language.EO.Phi.Syntax.Abs.Program _ bindings -> prPrec i 0 (concatD [doc (showString "{"), prt 0 bindings, doc (showString "}")]) + +instance Print (Language.EO.Phi.Syntax.Abs.Object' a) where + prt i = \case + Language.EO.Phi.Syntax.Abs.Formation _ bindings -> prPrec i 0 (concatD [doc (showString "{"), prt 0 bindings, doc (showString "}")]) + Language.EO.Phi.Syntax.Abs.Application _ abstractobject bindings bindingss -> prPrec i 0 (concatD [prt 0 abstractobject, doc (showString "{"), prt 0 bindings, doc (showString "}"), prt 0 bindingss]) + Language.EO.Phi.Syntax.Abs.Dispatch _ dispatch -> prPrec i 0 (concatD [prt 0 dispatch]) + Language.EO.Phi.Syntax.Abs.Termination _ -> prPrec i 0 (concatD [doc (showString "\8869")]) + +instance Print (Language.EO.Phi.Syntax.Abs.AbstractObject' a) where + prt i = \case + Language.EO.Phi.Syntax.Abs.AbstractFormation _ bindings -> prPrec i 0 (concatD [doc (showString "{"), prt 0 bindings, doc (showString "}")]) + Language.EO.Phi.Syntax.Abs.AbstractDispatch _ dispatch -> prPrec i 0 (concatD [prt 0 dispatch]) + Language.EO.Phi.Syntax.Abs.AbstractTermination _ -> prPrec i 0 (concatD [doc (showString "\8869")]) + +instance Print (Language.EO.Phi.Syntax.Abs.DispatchedObject' a) where + prt i = \case + Language.EO.Phi.Syntax.Abs.DispatchedFormation _ bindings -> prPrec i 0 (concatD [doc (showString "{"), prt 0 bindings, doc (showString "}")]) + Language.EO.Phi.Syntax.Abs.DispatchedTermination _ -> prPrec i 0 (concatD [doc (showString "\8869")]) + +instance Print (Language.EO.Phi.Syntax.Abs.Binding' a) where + prt i = \case + Language.EO.Phi.Syntax.Abs.AlphaBinding _ attribute object -> prPrec i 0 (concatD [prt 0 attribute, doc (showString "\8614"), prt 0 object]) + Language.EO.Phi.Syntax.Abs.EmptyBinding _ attribute -> prPrec i 0 (concatD [prt 0 attribute, doc (showString "\8614"), doc (showString "\8709")]) + Language.EO.Phi.Syntax.Abs.DeltaBinding _ bytes -> prPrec i 0 (concatD [doc (showString "\916"), doc (showString "\10509"), prt 0 bytes]) + Language.EO.Phi.Syntax.Abs.LambdaBinding _ -> prPrec i 0 (concatD [doc (showString "\955"), doc (showString "\10509")]) + +instance Print [Language.EO.Phi.Syntax.Abs.Binding' a] where + prt _ [] = concatD [] + prt _ [x] = concatD [prt 0 x] + prt _ (x:xs) = concatD [prt 0 x, doc (showString ","), prt 0 xs] + +instance Print (Language.EO.Phi.Syntax.Abs.Bindings' a) where + prt i = \case + Language.EO.Phi.Syntax.Abs.Bindings _ bindings -> prPrec i 0 (concatD [doc (showString "{"), prt 0 bindings, doc (showString "}")]) + +instance Print [Language.EO.Phi.Syntax.Abs.Bindings' a] where + prt _ [] = concatD [] + prt _ (x:xs) = concatD [prt 0 x, prt 0 xs] + +instance Print (Language.EO.Phi.Syntax.Abs.Dispatch' a) where + prt i = \case + Language.EO.Phi.Syntax.Abs.ObjectDispatch _ dispatchedobject bindingss attributes disps -> prPrec i 0 (concatD [prt 0 dispatchedobject, prt 0 bindingss, doc (showString "."), prt 0 attributes, prt 0 disps]) + Language.EO.Phi.Syntax.Abs.HomeDispatch _ attributes disps -> prPrec i 0 (concatD [doc (showString "\934"), doc (showString "."), prt 0 attributes, prt 0 disps]) + Language.EO.Phi.Syntax.Abs.ThisDispatch _ attributes disps -> prPrec i 0 (concatD [doc (showString "\958"), doc (showString "."), prt 0 attributes, prt 0 disps]) + +instance Print (Language.EO.Phi.Syntax.Abs.Attribute' a) where + prt i = \case + Language.EO.Phi.Syntax.Abs.Phi _ -> prPrec i 0 (concatD [doc (showString "\966")]) + Language.EO.Phi.Syntax.Abs.Rho _ -> prPrec i 0 (concatD [doc (showString "\961")]) + Language.EO.Phi.Syntax.Abs.Sigma _ -> prPrec i 0 (concatD [doc (showString "\963")]) + Language.EO.Phi.Syntax.Abs.VTX _ -> prPrec i 0 (concatD [doc (showString "\957")]) + Language.EO.Phi.Syntax.Abs.Label _ labelid -> prPrec i 0 (concatD [prt 0 labelid]) + Language.EO.Phi.Syntax.Abs.Alpha _ alphaindex -> prPrec i 0 (concatD [prt 0 alphaindex]) + +instance Print [Language.EO.Phi.Syntax.Abs.Attribute' a] where + prt _ [] = concatD [] + prt _ [x] = concatD [prt 0 x] + prt _ (x:xs) = concatD [prt 0 x, doc (showString "."), prt 0 xs] + +instance Print (Language.EO.Phi.Syntax.Abs.Disp' a) where + prt i = \case + Language.EO.Phi.Syntax.Abs.Disp _ bindings1 bindings2 attributes -> prPrec i 0 (concatD [doc (showString "{"), prt 0 bindings1, doc (showString "}"), prt 0 bindings2, doc (showString "."), prt 0 attributes]) + +instance Print [Language.EO.Phi.Syntax.Abs.Disp' a] where + prt _ [] = concatD [] + prt _ (x:xs) = concatD [prt 0 x, prt 0 xs] diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs.bak b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs.bak new file mode 100644 index 000000000..53893f89d --- /dev/null +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs.bak @@ -0,0 +1,214 @@ +-- File generated by the BNF Converter (bnfc 2.9.5). + +{-# LANGUAGE CPP #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE LambdaCase #-} +#if __GLASGOW_HASKELL__ <= 708 +{-# LANGUAGE OverlappingInstances #-} +#endif + +-- | Pretty-printer for Language. + +module Language.EO.Phi.Syntax.Print where + +import Prelude + ( ($), (.) + , Bool(..), (==), (<) + , Int, Integer, Double, (+), (-), (*) + , String, (++) + , ShowS, showChar, showString + , all, elem, foldr, id, map, null, replicate, shows, span + ) +import Data.Char ( Char, isSpace ) +import qualified Language.EO.Phi.Syntax.Abs + +-- | The top-level printing method. + +printTree :: Print a => a -> String +printTree = render . prt 0 + +type Doc = [ShowS] -> [ShowS] + +doc :: ShowS -> Doc +doc = (:) + +render :: Doc -> String +render d = rend 0 False (map ($ "") $ d []) "" + where + rend + :: Int -- ^ Indentation level. + -> Bool -- ^ Pending indentation to be output before next character? + -> [String] + -> ShowS + rend i p = \case + "[" :ts -> char '[' . rend i False ts + "(" :ts -> char '(' . rend i False ts + "{" :ts -> onNewLine i p . showChar '{' . new (i+1) ts + "}" : ";":ts -> onNewLine (i-1) p . showString "};" . new (i-1) ts + "}" :ts -> onNewLine (i-1) p . showChar '}' . new (i-1) ts + [";"] -> char ';' + ";" :ts -> char ';' . new i ts + t : ts@(s:_) | closingOrPunctuation s + -> pending . showString t . rend i False ts + t :ts -> pending . space t . rend i False ts + [] -> id + where + -- Output character after pending indentation. + char :: Char -> ShowS + char c = pending . showChar c + + -- Output pending indentation. + pending :: ShowS + pending = if p then indent i else id + + -- Indentation (spaces) for given indentation level. + indent :: Int -> ShowS + indent i = replicateS (2*i) (showChar ' ') + + -- Continue rendering in new line with new indentation. + new :: Int -> [String] -> ShowS + new j ts = showChar '\n' . rend j True ts + + -- Make sure we are on a fresh line. + onNewLine :: Int -> Bool -> ShowS + onNewLine i p = (if p then id else showChar '\n') . indent i + + -- Separate given string from following text by a space (if needed). + space :: String -> ShowS + space t s = + case (all isSpace t, null spc, null rest) of + (True , _ , True ) -> [] -- remove trailing space + (False, _ , True ) -> t -- remove trailing space + (False, True, False) -> t ++ ' ' : s -- add space if none + _ -> t ++ s + where + (spc, rest) = span isSpace s + + closingOrPunctuation :: String -> Bool + closingOrPunctuation [c] = c `elem` closerOrPunct + closingOrPunctuation _ = False + + closerOrPunct :: String + closerOrPunct = ")],;" + +parenth :: Doc -> Doc +parenth ss = doc (showChar '(') . ss . doc (showChar ')') + +concatS :: [ShowS] -> ShowS +concatS = foldr (.) id + +concatD :: [Doc] -> Doc +concatD = foldr (.) id + +replicateS :: Int -> ShowS -> ShowS +replicateS n f = concatS (replicate n f) + +-- | The printer class does the job. + +class Print a where + prt :: Int -> a -> Doc + +instance {-# OVERLAPPABLE #-} Print a => Print [a] where + prt i = concatD . map (prt i) + +instance Print Char where + prt _ c = doc (showChar '\'' . mkEsc '\'' c . showChar '\'') + +instance Print String where + prt _ = printString + +printString :: String -> Doc +printString s = doc (showChar '"' . concatS (map (mkEsc '"') s) . showChar '"') + +mkEsc :: Char -> Char -> ShowS +mkEsc q = \case + s | s == q -> showChar '\\' . showChar s + '\\' -> showString "\\\\" + '\n' -> showString "\\n" + '\t' -> showString "\\t" + s -> showChar s + +prPrec :: Int -> Int -> Doc -> Doc +prPrec i j = if j < i then parenth else id + +instance Print Integer where + prt _ x = doc (shows x) + +instance Print Double where + prt _ x = doc (shows x) + +instance Print Language.EO.Phi.Syntax.Abs.Bytes where + prt _ (Language.EO.Phi.Syntax.Abs.Bytes i) = doc $ showString i +instance Print Language.EO.Phi.Syntax.Abs.Function where + prt _ (Language.EO.Phi.Syntax.Abs.Function i) = doc $ showString i +instance Print Language.EO.Phi.Syntax.Abs.LabelId where + prt _ (Language.EO.Phi.Syntax.Abs.LabelId i) = doc $ showString i +instance Print Language.EO.Phi.Syntax.Abs.AlphaIndex where + prt _ (Language.EO.Phi.Syntax.Abs.AlphaIndex i) = doc $ showString i +instance Print (Language.EO.Phi.Syntax.Abs.Program' a) where + prt i = \case + Language.EO.Phi.Syntax.Abs.Program _ bindings -> prPrec i 0 (concatD [doc (showString "{"), prt 0 bindings, doc (showString "}")]) + +instance Print (Language.EO.Phi.Syntax.Abs.Object' a) where + prt i = \case + Language.EO.Phi.Syntax.Abs.Formation _ bindings -> prPrec i 0 (concatD [doc (showString "{"), prt 0 bindings, doc (showString "}")]) + Language.EO.Phi.Syntax.Abs.Application _ abstractobject bindings bindingss -> prPrec i 0 (concatD [prt 0 abstractobject, doc (showString "{"), prt 0 bindings, doc (showString "}"), prt 0 bindingss]) + Language.EO.Phi.Syntax.Abs.Dispatch _ dispatch -> prPrec i 0 (concatD [prt 0 dispatch]) + Language.EO.Phi.Syntax.Abs.Termination _ -> prPrec i 0 (concatD [doc (showString "\8869")]) + +instance Print (Language.EO.Phi.Syntax.Abs.AbstractObject' a) where + prt i = \case + Language.EO.Phi.Syntax.Abs.AbstractFormation _ bindings -> prPrec i 0 (concatD [doc (showString "{"), prt 0 bindings, doc (showString "}")]) + Language.EO.Phi.Syntax.Abs.AbstractDispatch _ dispatch -> prPrec i 0 (concatD [prt 0 dispatch]) + Language.EO.Phi.Syntax.Abs.AbstractTermination _ -> prPrec i 0 (concatD [doc (showString "\8869")]) + +instance Print (Language.EO.Phi.Syntax.Abs.DispatchedObject' a) where + prt i = \case + Language.EO.Phi.Syntax.Abs.DispatchedFormation _ bindings -> prPrec i 0 (concatD [doc (showString "{"), prt 0 bindings, doc (showString "}")]) + Language.EO.Phi.Syntax.Abs.DispatchedTermination _ -> prPrec i 0 (concatD [doc (showString "\8869")]) + +instance Print (Language.EO.Phi.Syntax.Abs.Binding' a) where + prt i = \case + Language.EO.Phi.Syntax.Abs.EmptyBinding _ attribute -> prPrec i 0 (concatD [prt 0 attribute, doc (showString "\8614"), doc (showString "\8709")]) + Language.EO.Phi.Syntax.Abs.DeltaBinding _ bytes -> prPrec i 0 (concatD [doc (showString "\916"), doc (showString "\10509"), prt 0 bytes]) + Language.EO.Phi.Syntax.Abs.LambdaBinding _ -> prPrec i 0 (concatD [doc (showString "\955"), doc (showString "\10509")]) + +instance Print [Language.EO.Phi.Syntax.Abs.Binding' a] where + prt _ [] = concatD [] + prt _ [x] = concatD [prt 0 x] + prt _ (x:xs) = concatD [prt 0 x, doc (showString ","), prt 0 xs] + +instance Print (Language.EO.Phi.Syntax.Abs.Bindings' a) where + prt i = \case + Language.EO.Phi.Syntax.Abs.Bindings _ bindings -> prPrec i 0 (concatD [doc (showString "{"), prt 0 bindings, doc (showString "}")]) + +instance Print [Language.EO.Phi.Syntax.Abs.Bindings' a] where + prt _ [] = concatD [] + prt _ (x:xs) = concatD [prt 0 x, prt 0 xs] + +instance Print (Language.EO.Phi.Syntax.Abs.Dispatch' a) where + prt i = \case + Language.EO.Phi.Syntax.Abs.HomeDispatch _ attributes disps -> prPrec i 0 (concatD [doc (showString "\934"), doc (showString "."), prt 0 attributes, prt 0 disps]) + Language.EO.Phi.Syntax.Abs.ThisDispatch _ attributes disps -> prPrec i 0 (concatD [doc (showString "\958"), doc (showString "."), prt 0 attributes, prt 0 disps]) + +instance Print (Language.EO.Phi.Syntax.Abs.Attribute' a) where + prt i = \case + Language.EO.Phi.Syntax.Abs.Phi _ -> prPrec i 0 (concatD [doc (showString "\966")]) + Language.EO.Phi.Syntax.Abs.Rho _ -> prPrec i 0 (concatD [doc (showString "\961")]) + Language.EO.Phi.Syntax.Abs.Sigma _ -> prPrec i 0 (concatD [doc (showString "\963")]) + Language.EO.Phi.Syntax.Abs.VTX _ -> prPrec i 0 (concatD [doc (showString "\957")]) + Language.EO.Phi.Syntax.Abs.Label _ labelid -> prPrec i 0 (concatD [prt 0 labelid]) + Language.EO.Phi.Syntax.Abs.Alpha _ alphaindex -> prPrec i 0 (concatD [prt 0 alphaindex]) + +instance Print [Language.EO.Phi.Syntax.Abs.Attribute' a] where + prt _ [] = concatD [] + prt _ [x] = concatD [prt 0 x] + prt _ (x:xs) = concatD [prt 0 x, doc (showString "."), prt 0 xs] + +instance Print (Language.EO.Phi.Syntax.Abs.Disp' a) where + prt i = \case + Language.EO.Phi.Syntax.Abs.Disp _ bindings1 bindings2 attributes -> prPrec i 0 (concatD [doc (showString "{"), prt 0 bindings1, doc (showString "}"), prt 0 bindings2, doc (showString "."), prt 0 attributes]) + +instance Print [Language.EO.Phi.Syntax.Abs.Disp' a] where + prt _ [] = concatD [] + prt _ (x:xs) = concatD [prt 0 x, prt 0 xs] diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Skel.hs b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Skel.hs new file mode 100644 index 000000000..735fb29e0 --- /dev/null +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Skel.hs @@ -0,0 +1,84 @@ +-- File generated by the BNF Converter (bnfc 2.9.5). + +-- Templates for pattern matching on abstract syntax + +{-# OPTIONS_GHC -fno-warn-unused-matches #-} + +module Language.EO.Phi.Syntax.Skel where + +import Prelude (($), Either(..), String, (++), Show, show) +import qualified Language.EO.Phi.Syntax.Abs + +type Err = Either String +type Result = Err String + +failure :: Show a => a -> Result +failure x = Left $ "Undefined case: " ++ show x + +transBytes :: Language.EO.Phi.Syntax.Abs.Bytes -> Result +transBytes x = case x of + Language.EO.Phi.Syntax.Abs.Bytes string -> failure x + +transFunction :: Language.EO.Phi.Syntax.Abs.Function -> Result +transFunction x = case x of + Language.EO.Phi.Syntax.Abs.Function string -> failure x + +transLabelId :: Language.EO.Phi.Syntax.Abs.LabelId -> Result +transLabelId x = case x of + Language.EO.Phi.Syntax.Abs.LabelId string -> failure x + +transAlphaIndex :: Language.EO.Phi.Syntax.Abs.AlphaIndex -> Result +transAlphaIndex x = case x of + Language.EO.Phi.Syntax.Abs.AlphaIndex string -> failure x + +transProgram :: Show a => Language.EO.Phi.Syntax.Abs.Program' a -> Result +transProgram x = case x of + Language.EO.Phi.Syntax.Abs.Program _ bindings -> failure x + +transObject :: Show a => Language.EO.Phi.Syntax.Abs.Object' a -> Result +transObject x = case x of + Language.EO.Phi.Syntax.Abs.Formation _ bindings -> failure x + Language.EO.Phi.Syntax.Abs.Application _ abstractobject bindings bindingss -> failure x + Language.EO.Phi.Syntax.Abs.Dispatch _ dispatch -> failure x + Language.EO.Phi.Syntax.Abs.Termination _ -> failure x + +transAbstractObject :: Show a => Language.EO.Phi.Syntax.Abs.AbstractObject' a -> Result +transAbstractObject x = case x of + Language.EO.Phi.Syntax.Abs.AbstractFormation _ bindings -> failure x + Language.EO.Phi.Syntax.Abs.AbstractDispatch _ dispatch -> failure x + Language.EO.Phi.Syntax.Abs.AbstractTermination _ -> failure x + +transDispatchedObject :: Show a => Language.EO.Phi.Syntax.Abs.DispatchedObject' a -> Result +transDispatchedObject x = case x of + Language.EO.Phi.Syntax.Abs.DispatchedFormation _ bindings -> failure x + Language.EO.Phi.Syntax.Abs.DispatchedTermination _ -> failure x + +transBinding :: Show a => Language.EO.Phi.Syntax.Abs.Binding' a -> Result +transBinding x = case x of + Language.EO.Phi.Syntax.Abs.AlphaBinding _ attribute object -> failure x + Language.EO.Phi.Syntax.Abs.EmptyBinding _ attribute -> failure x + Language.EO.Phi.Syntax.Abs.DeltaBinding _ bytes -> failure x + Language.EO.Phi.Syntax.Abs.LambdaBinding _ -> failure x + +transBindings :: Show a => Language.EO.Phi.Syntax.Abs.Bindings' a -> Result +transBindings x = case x of + Language.EO.Phi.Syntax.Abs.Bindings _ bindings -> failure x + +transDispatch :: Show a => Language.EO.Phi.Syntax.Abs.Dispatch' a -> Result +transDispatch x = case x of + Language.EO.Phi.Syntax.Abs.ObjectDispatch _ dispatchedobject bindingss attributes disps -> failure x + Language.EO.Phi.Syntax.Abs.HomeDispatch _ attributes disps -> failure x + Language.EO.Phi.Syntax.Abs.ThisDispatch _ attributes disps -> failure x + +transAttribute :: Show a => Language.EO.Phi.Syntax.Abs.Attribute' a -> Result +transAttribute x = case x of + Language.EO.Phi.Syntax.Abs.Phi _ -> failure x + Language.EO.Phi.Syntax.Abs.Rho _ -> failure x + Language.EO.Phi.Syntax.Abs.Sigma _ -> failure x + Language.EO.Phi.Syntax.Abs.VTX _ -> failure x + Language.EO.Phi.Syntax.Abs.Label _ labelid -> failure x + Language.EO.Phi.Syntax.Abs.Alpha _ alphaindex -> failure x + +transDisp :: Show a => Language.EO.Phi.Syntax.Abs.Disp' a -> Result +transDisp x = case x of + Language.EO.Phi.Syntax.Abs.Disp _ bindings1 bindings2 attributes -> failure x diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Skel.hs.bak b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Skel.hs.bak new file mode 100644 index 000000000..5c0ec9611 --- /dev/null +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Skel.hs.bak @@ -0,0 +1,82 @@ +-- File generated by the BNF Converter (bnfc 2.9.5). + +-- Templates for pattern matching on abstract syntax + +{-# OPTIONS_GHC -fno-warn-unused-matches #-} + +module Language.EO.Phi.Syntax.Skel where + +import Prelude (($), Either(..), String, (++), Show, show) +import qualified Language.EO.Phi.Syntax.Abs + +type Err = Either String +type Result = Err String + +failure :: Show a => a -> Result +failure x = Left $ "Undefined case: " ++ show x + +transBytes :: Language.EO.Phi.Syntax.Abs.Bytes -> Result +transBytes x = case x of + Language.EO.Phi.Syntax.Abs.Bytes string -> failure x + +transFunction :: Language.EO.Phi.Syntax.Abs.Function -> Result +transFunction x = case x of + Language.EO.Phi.Syntax.Abs.Function string -> failure x + +transLabelId :: Language.EO.Phi.Syntax.Abs.LabelId -> Result +transLabelId x = case x of + Language.EO.Phi.Syntax.Abs.LabelId string -> failure x + +transAlphaIndex :: Language.EO.Phi.Syntax.Abs.AlphaIndex -> Result +transAlphaIndex x = case x of + Language.EO.Phi.Syntax.Abs.AlphaIndex string -> failure x + +transProgram :: Show a => Language.EO.Phi.Syntax.Abs.Program' a -> Result +transProgram x = case x of + Language.EO.Phi.Syntax.Abs.Program _ bindings -> failure x + +transObject :: Show a => Language.EO.Phi.Syntax.Abs.Object' a -> Result +transObject x = case x of + Language.EO.Phi.Syntax.Abs.Formation _ bindings -> failure x + Language.EO.Phi.Syntax.Abs.Application _ abstractobject bindings bindingss -> failure x + Language.EO.Phi.Syntax.Abs.Dispatch _ dispatch -> failure x + Language.EO.Phi.Syntax.Abs.Termination _ -> failure x + +transAbstractObject :: Show a => Language.EO.Phi.Syntax.Abs.AbstractObject' a -> Result +transAbstractObject x = case x of + Language.EO.Phi.Syntax.Abs.AbstractFormation _ bindings -> failure x + Language.EO.Phi.Syntax.Abs.AbstractDispatch _ dispatch -> failure x + Language.EO.Phi.Syntax.Abs.AbstractTermination _ -> failure x + +transDispatchedObject :: Show a => Language.EO.Phi.Syntax.Abs.DispatchedObject' a -> Result +transDispatchedObject x = case x of + Language.EO.Phi.Syntax.Abs.DispatchedFormation _ bindings -> failure x + Language.EO.Phi.Syntax.Abs.DispatchedTermination _ -> failure x + +transBinding :: Show a => Language.EO.Phi.Syntax.Abs.Binding' a -> Result +transBinding x = case x of + Language.EO.Phi.Syntax.Abs.EmptyBinding _ attribute -> failure x + Language.EO.Phi.Syntax.Abs.DeltaBinding _ bytes -> failure x + Language.EO.Phi.Syntax.Abs.LambdaBinding _ -> failure x + +transBindings :: Show a => Language.EO.Phi.Syntax.Abs.Bindings' a -> Result +transBindings x = case x of + Language.EO.Phi.Syntax.Abs.Bindings _ bindings -> failure x + +transDispatch :: Show a => Language.EO.Phi.Syntax.Abs.Dispatch' a -> Result +transDispatch x = case x of + Language.EO.Phi.Syntax.Abs.HomeDispatch _ attributes disps -> failure x + Language.EO.Phi.Syntax.Abs.ThisDispatch _ attributes disps -> failure x + +transAttribute :: Show a => Language.EO.Phi.Syntax.Abs.Attribute' a -> Result +transAttribute x = case x of + Language.EO.Phi.Syntax.Abs.Phi _ -> failure x + Language.EO.Phi.Syntax.Abs.Rho _ -> failure x + Language.EO.Phi.Syntax.Abs.Sigma _ -> failure x + Language.EO.Phi.Syntax.Abs.VTX _ -> failure x + Language.EO.Phi.Syntax.Abs.Label _ labelid -> failure x + Language.EO.Phi.Syntax.Abs.Alpha _ alphaindex -> failure x + +transDisp :: Show a => Language.EO.Phi.Syntax.Abs.Disp' a -> Result +transDisp x = case x of + Language.EO.Phi.Syntax.Abs.Disp _ bindings1 bindings2 attributes -> failure x diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Test.hs b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Test.hs new file mode 100644 index 000000000..1e846af00 --- /dev/null +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Test.hs @@ -0,0 +1,76 @@ +-- File generated by the BNF Converter (bnfc 2.9.5). + +-- | Program to test parser. + +module Main where + +import Prelude + ( ($), (.) + , Either(..) + , Int, (>) + , String, (++), concat, unlines + , Show, show + , IO, (>>), (>>=), mapM_, putStrLn + , FilePath + , getContents, readFile + ) +import System.Environment ( getArgs ) +import System.Exit ( exitFailure ) +import Control.Monad ( when ) + +import Language.EO.Phi.Syntax.Abs () +import Language.EO.Phi.Syntax.Lex ( Token, mkPosToken ) +import Language.EO.Phi.Syntax.Par ( pProgram, myLexer ) +import Language.EO.Phi.Syntax.Print ( Print, printTree ) +import Language.EO.Phi.Syntax.Skel () + +type Err = Either String +type ParseFun a = [Token] -> Err a +type Verbosity = Int + +putStrV :: Verbosity -> String -> IO () +putStrV v s = when (v > 1) $ putStrLn s + +runFile :: (Print a, Show a) => Verbosity -> ParseFun a -> FilePath -> IO () +runFile v p f = putStrLn f >> readFile f >>= run v p + +run :: (Print a, Show a) => Verbosity -> ParseFun a -> String -> IO () +run v p s = + case p ts of + Left err -> do + putStrLn "\nParse Failed...\n" + putStrV v "Tokens:" + mapM_ (putStrV v . showPosToken . mkPosToken) ts + putStrLn err + exitFailure + Right tree -> do + putStrLn "\nParse Successful!" + showTree v tree + where + ts = myLexer s + showPosToken ((l,c),t) = concat [ show l, ":", show c, "\t", show t ] + +showTree :: (Show a, Print a) => Int -> a -> IO () +showTree v tree = do + putStrV v $ "\n[Abstract Syntax]\n\n" ++ show tree + putStrV v $ "\n[Linearized tree]\n\n" ++ printTree tree + +usage :: IO () +usage = do + putStrLn $ unlines + [ "usage: Call with one of the following argument combinations:" + , " --help Display this help message." + , " (no arguments) Parse stdin verbosely." + , " (files) Parse content of files verbosely." + , " -s (files) Silent mode. Parse content of files silently." + ] + +main :: IO () +main = do + args <- getArgs + case args of + ["--help"] -> usage + [] -> getContents >>= run 2 pProgram + "-s":fs -> mapM_ (runFile 0 pProgram) fs + fs -> mapM_ (runFile 2 pProgram) fs + diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Test.hs.bak b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Test.hs.bak new file mode 100644 index 000000000..b93523a56 --- /dev/null +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Test.hs.bak @@ -0,0 +1,76 @@ +-- File generated by the BNF Converter (bnfc 2.9.5). + +-- | Program to test parser. + +module Main where + +import Prelude + ( ($), (.) + , Either(..) + , Int, (>) + , String, (++), concat, unlines + , Show, show + , IO, (>>), (>>=), mapM_, putStrLn + , FilePath + , getContents, readFile + ) +import System.Environment ( getArgs ) +import System.Exit ( exitFailure ) +import Control.Monad ( when ) + +import Language.EO.Phi.Syntax.Abs () +import Language.EO.Phi.Syntax.Lex ( Token, mkPosToken ) +import Language.EO.Phi.Syntax.Par ( pAbstractObject, myLexer ) +import Language.EO.Phi.Syntax.Print ( Print, printTree ) +import Language.EO.Phi.Syntax.Skel () + +type Err = Either String +type ParseFun a = [Token] -> Err a +type Verbosity = Int + +putStrV :: Verbosity -> String -> IO () +putStrV v s = when (v > 1) $ putStrLn s + +runFile :: (Print a, Show a) => Verbosity -> ParseFun a -> FilePath -> IO () +runFile v p f = putStrLn f >> readFile f >>= run v p + +run :: (Print a, Show a) => Verbosity -> ParseFun a -> String -> IO () +run v p s = + case p ts of + Left err -> do + putStrLn "\nParse Failed...\n" + putStrV v "Tokens:" + mapM_ (putStrV v . showPosToken . mkPosToken) ts + putStrLn err + exitFailure + Right tree -> do + putStrLn "\nParse Successful!" + showTree v tree + where + ts = myLexer s + showPosToken ((l,c),t) = concat [ show l, ":", show c, "\t", show t ] + +showTree :: (Show a, Print a) => Int -> a -> IO () +showTree v tree = do + putStrV v $ "\n[Abstract Syntax]\n\n" ++ show tree + putStrV v $ "\n[Linearized tree]\n\n" ++ printTree tree + +usage :: IO () +usage = do + putStrLn $ unlines + [ "usage: Call with one of the following argument combinations:" + , " --help Display this help message." + , " (no arguments) Parse stdin verbosely." + , " (files) Parse content of files verbosely." + , " -s (files) Silent mode. Parse content of files silently." + ] + +main :: IO () +main = do + args <- getArgs + case args of + ["--help"] -> usage + [] -> getContents >>= run 2 pAbstractObject + "-s":fs -> mapM_ (runFile 0 pAbstractObject) fs + fs -> mapM_ (runFile 2 pAbstractObject) fs + diff --git a/eo-phi-normalizer/test/Language/EO/PhiSpec.hs b/eo-phi-normalizer/test/Language/EO/PhiSpec.hs new file mode 100644 index 000000000..d02fca5ab --- /dev/null +++ b/eo-phi-normalizer/test/Language/EO/PhiSpec.hs @@ -0,0 +1,26 @@ +module Language.EO.PhiSpec where + +import Test.Hspec +import qualified Language.EO.Phi as Phi + +unsafeParseProgramFromFile :: FilePath -> IO Phi.Program +unsafeParseProgramFromFile path = + Phi.unsafeParseProgram <$> readFile path + +normalizesTo :: FilePath -> FilePath -> Expectation +normalizesTo beforePath afterPath = do + beforeProgram <- unsafeParseProgramFromFile beforePath + afterProgram <- unsafeParseProgramFromFile afterPath + Phi.normalize beforeProgram `shouldBe` afterProgram + +normalizesCorrectly :: FilePath -> Expectation +normalizesCorrectly baseName = beforePath `normalizesTo` afterPath + where + beforePath = "test/eo/phi/" <> baseName + afterPath = "test/eo/phi/" <> baseName <> ".normalized" + +spec :: Spec +spec = do + describe "Normalizer" $ do + it "Normalizes static attribute references" $ do + normalizesCorrectly "test.phi" diff --git a/eo-phi-normalizer/test/Spec.hs b/eo-phi-normalizer/test/Spec.hs new file mode 100644 index 000000000..a824f8c30 --- /dev/null +++ b/eo-phi-normalizer/test/Spec.hs @@ -0,0 +1 @@ +{-# OPTIONS_GHC -F -pgmF hspec-discover #-} diff --git a/eo-phi-normalizer/test/eo/phi/test.phi b/eo-phi-normalizer/test/eo/phi/test.phi new file mode 100644 index 000000000..1681ebf92 --- /dev/null +++ b/eo-phi-normalizer/test/eo/phi/test.phi @@ -0,0 +1,4 @@ +{ + φ ↦ {}, + a ↦ ξ.a +} diff --git a/eo-phi-normalizer/test/eo/phi/test.phi.normalized b/eo-phi-normalizer/test/eo/phi/test.phi.normalized new file mode 100644 index 000000000..dfc1350a5 --- /dev/null +++ b/eo-phi-normalizer/test/eo/phi/test.phi.normalized @@ -0,0 +1,4 @@ +{ + φ ↦ {}, + a ↦ {} +} diff --git a/eo-phi-normalizer/test/eo/phi/test.phi.pretty b/eo-phi-normalizer/test/eo/phi/test.phi.pretty new file mode 100644 index 000000000..1681ebf92 --- /dev/null +++ b/eo-phi-normalizer/test/eo/phi/test.phi.pretty @@ -0,0 +1,4 @@ +{ + φ ↦ {}, + a ↦ ξ.a +} diff --git a/hie.yaml b/hie.yaml new file mode 100644 index 000000000..debcb134c --- /dev/null +++ b/hie.yaml @@ -0,0 +1,10 @@ +cradle: + stack: + - path: "eo-phi-normalizer/src" + component: "eo-phi-normalizer:lib" + + - path: "eo-phi-normalizer/app/Main.hs" + component: "eo-phi-normalizer:exe:normalize-phi" + + - path: "eo-phi-normalizer/test" + component: "eo-phi-normalizer:test:eo-phi-normalizer-test" diff --git a/stack.yaml b/stack.yaml new file mode 100644 index 000000000..4516c0fc7 --- /dev/null +++ b/stack.yaml @@ -0,0 +1,3 @@ +resolver: nightly-2023-12-14 +packages: +- eo-phi-normalizer diff --git a/stack.yaml.lock b/stack.yaml.lock new file mode 100644 index 000000000..3c83e0b56 --- /dev/null +++ b/stack.yaml.lock @@ -0,0 +1,12 @@ +# This file was autogenerated by Stack. +# You should not edit this file by hand. +# For more information, please see the documentation at: +# https://docs.haskellstack.org/en/stable/lock_files + +packages: [] +snapshots: +- completed: + size: 712805 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/nightly/2023/12/14.yaml + sha256: db71f776c40adadc1bdf39a7901e2d7f270d0bec2b80f99dd4ea352b80fb9ad1 + original: nightly-2023-12-14 From a8df765b37329bdd60a339e258fdc0e196d90d8f Mon Sep 17 00:00:00 2001 From: Nikolai Kudasov Date: Fri, 22 Dec 2023 00:01:37 +0300 Subject: [PATCH 02/15] Call normalizer in defaultMain --- eo-phi-normalizer/src/Language/EO/Phi.hs | 2 +- eo-phi-normalizer/test/eo/phi/test.yaml | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 eo-phi-normalizer/test/eo/phi/test.yaml diff --git a/eo-phi-normalizer/src/Language/EO/Phi.hs b/eo-phi-normalizer/src/Language/EO/Phi.hs index c8467ba9f..60a32dec9 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi.hs +++ b/eo-phi-normalizer/src/Language/EO/Phi.hs @@ -57,4 +57,4 @@ defaultMain = do putStrLn parseError exitFailure Right program -> do - putStrLn (printTree program) + putStrLn (printTree (normalize program)) diff --git a/eo-phi-normalizer/test/eo/phi/test.yaml b/eo-phi-normalizer/test/eo/phi/test.yaml new file mode 100644 index 000000000..a881517ef --- /dev/null +++ b/eo-phi-normalizer/test/eo/phi/test.yaml @@ -0,0 +1,12 @@ +input: | + { φ ↦ { } , a ↦ ξ.a } +normalized: | + { + φ ↦ {}, + a ↦ {} + } +prettified: | + { + φ ↦ {}, + a ↦ ξ.a + } From c9a8f4cc980f1bed23f538c2841cae025f1bc01c Mon Sep 17 00:00:00 2001 From: Nikolai Kudasov Date: Fri, 22 Dec 2023 00:01:53 +0300 Subject: [PATCH 03/15] Add GHC built-test-haddock workflow --- .github/workflows/ghc.yml | 61 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/workflows/ghc.yml diff --git a/.github/workflows/ghc.yml b/.github/workflows/ghc.yml new file mode 100644 index 000000000..b3f835862 --- /dev/null +++ b/.github/workflows/ghc.yml @@ -0,0 +1,61 @@ +name: GHC (build, test, haddock) + +# Controls when the workflow will run +on: + push: + branches: [master] + tags: [v*] + pull_request: + branches: [master] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +permissions: + contents: write # to submit Haddock documentation to GitHub Pages + +jobs: + build: + name: "Build and test with GHC" + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + + steps: + - name: 📥 Checkout repository + uses: actions/checkout@v3 + + - name: 🧰 Setup Stack + uses: freckle/stack-action@v4 + with: + fast: ${{ github.ref_name != 'master' }} + + haddock: + needs: [build] + if: ${{ github.ref_name == 'master' }} + name: "Build and upload Haddock documentation (master)" + runs-on: ubuntu-latest + + steps: + - name: 📥 Checkout repository + uses: actions/checkout@v3 + + - name: 🧰 Setup Stack + uses: freckle/stack-action@v4 + with: + test: false + + - name: 🔨 Build Haddock Documentation (with Stack) + run: | + stack haddock + mkdir -p dist/haddock + mv $(stack path --local-doc-root)/* dist/haddock + + - name: 🚀 Publish Haddock Documentation + uses: JamesIves/github-pages-deploy-action@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + folder: dist/haddock + target-folder: haddock + single-commit: true From 9bdd23a97e9561bfaed1e753122cf2e6ab6f0918 Mon Sep 17 00:00:00 2001 From: Nikolai Kudasov Date: Fri, 22 Dec 2023 00:46:54 +0300 Subject: [PATCH 04/15] Convert tests to YAML files --- eo-phi-normalizer/test/eo/phi/normal-1.yaml | 7 +++++++ eo-phi-normalizer/test/eo/phi/normal-2.yaml | 7 +++++++ eo-phi-normalizer/test/eo/phi/test.phi | 4 ---- eo-phi-normalizer/test/eo/phi/test.phi.normalized | 4 ---- eo-phi-normalizer/test/eo/phi/test.phi.pretty | 4 ---- eo-phi-normalizer/test/eo/phi/test.yaml | 6 ++---- 6 files changed, 16 insertions(+), 16 deletions(-) create mode 100644 eo-phi-normalizer/test/eo/phi/normal-1.yaml create mode 100644 eo-phi-normalizer/test/eo/phi/normal-2.yaml delete mode 100644 eo-phi-normalizer/test/eo/phi/test.phi delete mode 100644 eo-phi-normalizer/test/eo/phi/test.phi.normalized delete mode 100644 eo-phi-normalizer/test/eo/phi/test.phi.pretty diff --git a/eo-phi-normalizer/test/eo/phi/normal-1.yaml b/eo-phi-normalizer/test/eo/phi/normal-1.yaml new file mode 100644 index 000000000..758437236 --- /dev/null +++ b/eo-phi-normalizer/test/eo/phi/normal-1.yaml @@ -0,0 +1,7 @@ +name: "Program in normal form (1)" +input: | + {} +normalized: | + {} +prettified: | + { } diff --git a/eo-phi-normalizer/test/eo/phi/normal-2.yaml b/eo-phi-normalizer/test/eo/phi/normal-2.yaml new file mode 100644 index 000000000..2420abe2f --- /dev/null +++ b/eo-phi-normalizer/test/eo/phi/normal-2.yaml @@ -0,0 +1,7 @@ +name: "Program in normal form (2)" +input: | + { φ ↦ { φ ↦ { φ ↦ { } } } } +normalized: | + { φ ↦ { φ ↦ { φ ↦ { } } } } +prettified: | + { φ ↦ { φ ↦ { φ ↦ { } } } } diff --git a/eo-phi-normalizer/test/eo/phi/test.phi b/eo-phi-normalizer/test/eo/phi/test.phi deleted file mode 100644 index 1681ebf92..000000000 --- a/eo-phi-normalizer/test/eo/phi/test.phi +++ /dev/null @@ -1,4 +0,0 @@ -{ - φ ↦ {}, - a ↦ ξ.a -} diff --git a/eo-phi-normalizer/test/eo/phi/test.phi.normalized b/eo-phi-normalizer/test/eo/phi/test.phi.normalized deleted file mode 100644 index dfc1350a5..000000000 --- a/eo-phi-normalizer/test/eo/phi/test.phi.normalized +++ /dev/null @@ -1,4 +0,0 @@ -{ - φ ↦ {}, - a ↦ {} -} diff --git a/eo-phi-normalizer/test/eo/phi/test.phi.pretty b/eo-phi-normalizer/test/eo/phi/test.phi.pretty deleted file mode 100644 index 1681ebf92..000000000 --- a/eo-phi-normalizer/test/eo/phi/test.phi.pretty +++ /dev/null @@ -1,4 +0,0 @@ -{ - φ ↦ {}, - a ↦ ξ.a -} diff --git a/eo-phi-normalizer/test/eo/phi/test.yaml b/eo-phi-normalizer/test/eo/phi/test.yaml index a881517ef..08bc44244 100644 --- a/eo-phi-normalizer/test/eo/phi/test.yaml +++ b/eo-phi-normalizer/test/eo/phi/test.yaml @@ -1,3 +1,4 @@ +name: "Simple static attribute reference" input: | { φ ↦ { } , a ↦ ξ.a } normalized: | @@ -6,7 +7,4 @@ normalized: | a ↦ {} } prettified: | - { - φ ↦ {}, - a ↦ ξ.a - } + { φ ↦ { }, a ↦ ξ.a } From 773e022f896af96270ac91d6f35812dd62e21b43 Mon Sep 17 00:00:00 2001 From: Nikolai Kudasov Date: Fri, 22 Dec 2023 00:47:35 +0300 Subject: [PATCH 05/15] Discover and run all tests in test/eo/phi/*.yaml --- eo-phi-normalizer/test/Language/EO/PhiSpec.hs | 34 ++++++++---------- eo-phi-normalizer/test/Test/EO/Phi.hs | 35 +++++++++++++++++++ 2 files changed, 50 insertions(+), 19 deletions(-) create mode 100644 eo-phi-normalizer/test/Test/EO/Phi.hs diff --git a/eo-phi-normalizer/test/Language/EO/PhiSpec.hs b/eo-phi-normalizer/test/Language/EO/PhiSpec.hs index d02fca5ab..32516b737 100644 --- a/eo-phi-normalizer/test/Language/EO/PhiSpec.hs +++ b/eo-phi-normalizer/test/Language/EO/PhiSpec.hs @@ -1,26 +1,22 @@ +{-# LANGUAGE RecordWildCards #-} module Language.EO.PhiSpec where -import Test.Hspec -import qualified Language.EO.Phi as Phi - -unsafeParseProgramFromFile :: FilePath -> IO Phi.Program -unsafeParseProgramFromFile path = - Phi.unsafeParseProgram <$> readFile path +import Test.Hspec +import Control.Monad (forM_) +import Data.List (dropWhileEnd) +import Data.Char (isSpace) -normalizesTo :: FilePath -> FilePath -> Expectation -normalizesTo beforePath afterPath = do - beforeProgram <- unsafeParseProgramFromFile beforePath - afterProgram <- unsafeParseProgramFromFile afterPath - Phi.normalize beforeProgram `shouldBe` afterProgram - -normalizesCorrectly :: FilePath -> Expectation -normalizesCorrectly baseName = beforePath `normalizesTo` afterPath - where - beforePath = "test/eo/phi/" <> baseName - afterPath = "test/eo/phi/" <> baseName <> ".normalized" +import qualified Language.EO.Phi as Phi +import Test.EO.Phi spec :: Spec spec = do + tests <- runIO (allPhiTests "test/eo/phi/") describe "Normalizer" $ do - it "Normalizes static attribute references" $ do - normalizesCorrectly "test.phi" + forM_ tests $ \PhiTest{..} -> do + it name $ do + Phi.printTree (Phi.normalize input) `shouldBe` Phi.printTree normalized + describe "Prettify" $ do + forM_ tests $ \PhiTest{..} -> do + it name $ do + Phi.printTree input `shouldBe` dropWhileEnd isSpace prettified diff --git a/eo-phi-normalizer/test/Test/EO/Phi.hs b/eo-phi-normalizer/test/Test/EO/Phi.hs new file mode 100644 index 000000000..0fa874462 --- /dev/null +++ b/eo-phi-normalizer/test/Test/EO/Phi.hs @@ -0,0 +1,35 @@ +{-# OPTIONS_GHC -Wno-orphans #-} +{-# LANGUAGE DeriveAnyClass #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE DeriveGeneric #-} +module Test.EO.Phi where + +import Data.Aeson (FromJSON(..)) +import qualified Data.Yaml as Yaml +import System.Directory (listDirectory) +import System.FilePath (()) +import GHC.Generics (Generic) +import Control.Monad (forM) + +import qualified Language.EO.Phi as Phi +import Language.EO.Phi (unsafeParseProgram) +import Data.List (sort) + +data PhiTest = PhiTest + { name :: String + , input :: Phi.Program + , normalized :: Phi.Program + , prettified :: String + } deriving (Generic, FromJSON) + +allPhiTests :: FilePath -> IO [PhiTest] +allPhiTests dir = do + paths <- listDirectory dir + forM (sort paths) $ \path -> + Yaml.decodeFileThrow (dir path) + +-- * Orphan instances + +-- | Parsing a $\varphi$-program from a JSON string. +instance FromJSON Phi.Program where + parseJSON = fmap unsafeParseProgram . parseJSON From 513782bb3556753697e24f6e64c61b2c0030c3ca Mon Sep 17 00:00:00 2001 From: Nikolai Kudasov Date: Fri, 22 Dec 2023 00:48:24 +0300 Subject: [PATCH 06/15] Update pretty-printing and package.yaml --- eo-phi-normalizer/eo-phi-normalizer.cabal | 25 +++++-- eo-phi-normalizer/package.yaml | 5 ++ eo-phi-normalizer/src/Language/EO/Phi.hs | 87 +++++++++++++++++++---- 3 files changed, 98 insertions(+), 19 deletions(-) diff --git a/eo-phi-normalizer/eo-phi-normalizer.cabal b/eo-phi-normalizer/eo-phi-normalizer.cabal index aa9d021fc..95d392901 100644 --- a/eo-phi-normalizer/eo-phi-normalizer.cabal +++ b/eo-phi-normalizer/eo-phi-normalizer.cabal @@ -43,15 +43,19 @@ library Paths_eo_phi_normalizer hs-source-dirs: src - ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints + ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -Wno-missing-export-lists build-tools: alex >=3.2.4 , happy >=1.19.9 build-tool-depends: BNFC:bnfc >=2.9.4.1 build-depends: - array >=0.5.5.0 + aeson + , array >=0.5.5.0 , base >=4.7 && <5 + , directory + , filepath + , yaml default-language: Haskell2010 executable normalize-phi @@ -62,16 +66,20 @@ executable normalize-phi Paths_eo_phi_normalizer hs-source-dirs: app - ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N + ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -Wno-missing-export-lists -threaded -rtsopts -with-rtsopts=-N build-tools: alex >=3.2.4 , happy >=1.19.9 build-tool-depends: BNFC:bnfc >=2.9.4.1 build-depends: - array >=0.5.5.0 + aeson + , array >=0.5.5.0 , base >=4.7 && <5 + , directory , eo-phi-normalizer + , filepath + , yaml default-language: Haskell2010 test-suite eo-phi-normalizer-test @@ -79,21 +87,26 @@ test-suite eo-phi-normalizer-test main-is: Spec.hs other-modules: Language.EO.PhiSpec + Test.EO.Phi Paths_eo_phi_normalizer autogen-modules: Paths_eo_phi_normalizer hs-source-dirs: test - ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N + ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -Wno-missing-export-lists -threaded -rtsopts -with-rtsopts=-N build-tools: alex >=3.2.4 , happy >=1.19.9 build-tool-depends: BNFC:bnfc >=2.9.4.1 build-depends: - array >=0.5.5.0 + aeson + , array >=0.5.5.0 , base >=4.7 && <5 + , directory , eo-phi-normalizer + , filepath , hspec , hspec-discover + , yaml default-language: Haskell2010 diff --git a/eo-phi-normalizer/package.yaml b/eo-phi-normalizer/package.yaml index ebe96c897..ebd89229c 100644 --- a/eo-phi-normalizer/package.yaml +++ b/eo-phi-normalizer/package.yaml @@ -33,7 +33,11 @@ build-tools: dependencies: - base >= 4.7 && < 5 +- aeson - array >= 0.5.5.0 +- directory +- filepath +- yaml ghc-options: - -Wall @@ -45,6 +49,7 @@ ghc-options: - -Wmissing-home-modules - -Wpartial-fields - -Wredundant-constraints +- -Wno-missing-export-lists library: source-dirs: src diff --git a/eo-phi-normalizer/src/Language/EO/Phi.hs b/eo-phi-normalizer/src/Language/EO/Phi.hs index 60a32dec9..1545471ec 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi.hs +++ b/eo-phi-normalizer/src/Language/EO/Phi.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE LambdaCase #-} module Language.EO.Phi ( defaultMain, normalize, @@ -7,6 +8,8 @@ module Language.EO.Phi ( module Language.EO.Phi.Syntax.Abs, ) where + +import Data.Char (isSpace) import System.Exit (exitFailure) import qualified Language.EO.Phi.Syntax.Par as Phi @@ -32,19 +35,6 @@ unsafeParseProgram input = Left parseError -> error parseError Right program -> program --- | Like 'Phi.printTree', but without spaces around dots. -printTree :: Phi.Print a => a -> String -printTree = shrinkDots . Phi.printTree - --- | Remove spaces around dots. --- --- >>> putStrLn (shrinkDots "a ↦ ξ . a") --- a ↦ ξ.a -shrinkDots :: String -> String -shrinkDots [] = [] -shrinkDots (' ':'.':' ':cs) = '.':shrinkDots cs -shrinkDots (c:cs) = c : shrinkDots cs - -- | Default entry point. -- Parses a 𝜑-program from standard input, normalizes, -- then pretty-prints the result to standard output. @@ -58,3 +48,74 @@ defaultMain = do exitFailure Right program -> do putStrLn (printTree (normalize program)) + +-- * Overriding generated pretty-printer + +-- | Like 'Phi.printTree', but without spaces around dots and no indentation for curly braces. +printTree :: Phi.Print a => a -> String +printTree = shrinkDots . render . Phi.prt 0 + +-- | Remove spaces around dots. +-- +-- >>> putStrLn (shrinkDots "a ↦ ξ . a") +-- a ↦ ξ.a +shrinkDots :: String -> String +shrinkDots [] = [] +shrinkDots (' ':'.':' ':cs) = '.':shrinkDots cs +shrinkDots (c:cs) = c : shrinkDots cs + +-- | Copy of 'Phi.render', except no indentation is made for curly braces. +render :: Phi.Doc -> String +render d = rend 0 False (map ($ "") $ d []) "" + where + rend + :: Int -- ^ Indentation level. + -> Bool -- ^ Pending indentation to be output before next character? + -> [String] + -> ShowS + rend i p = \case + "[" :ts -> char '[' . rend i False ts + "(" :ts -> char '(' . rend i False ts + -- "{" :ts -> onNewLine i p . showChar '{' . new (i+1) ts + -- "}" : ";":ts -> onNewLine (i-1) p . showString "};" . new (i-1) ts + -- "}" :ts -> onNewLine (i-1) p . showChar '}' . new (i-1) ts + [";"] -> char ';' + ";" :ts -> char ';' . new i ts + t : ts@(s:_) | closingOrPunctuation s + -> pending . showString t . rend i False ts + t :ts -> pending . space t . rend i False ts + [] -> id + where + -- Output character after pending indentation. + char :: Char -> ShowS + char c = pending . showChar c + + -- Output pending indentation. + pending :: ShowS + pending = if p then indent i else id + + -- Indentation (spaces) for given indentation level. + indent :: Int -> ShowS + indent i = Phi.replicateS (2*i) (showChar ' ') + + -- Continue rendering in new line with new indentation. + new :: Int -> [String] -> ShowS + new j ts = showChar '\n' . rend j True ts + + -- Separate given string from following text by a space (if needed). + space :: String -> ShowS + space t s = + case (all isSpace t, null spc, null rest) of + (True , _ , True ) -> [] -- remove trailing space + (False, _ , True ) -> t -- remove trailing space + (False, True, False) -> t ++ ' ' : s -- add space if none + _ -> t ++ s + where + (spc, rest) = span isSpace s + + closingOrPunctuation :: String -> Bool + closingOrPunctuation [c] = c `elem` closerOrPunct + closingOrPunctuation _ = False + + closerOrPunct :: String + closerOrPunct = ")],;" From 5090c9d68af7de14a9a638138f0eaf35c611880b Mon Sep 17 00:00:00 2001 From: Nikolai Kudasov Date: Fri, 22 Dec 2023 00:49:10 +0300 Subject: [PATCH 07/15] Update LICENSE --- eo-phi-normalizer/LICENSE | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eo-phi-normalizer/LICENSE b/eo-phi-normalizer/LICENSE index c5b6c1669..317da7f3d 100644 --- a/eo-phi-normalizer/LICENSE +++ b/eo-phi-normalizer/LICENSE @@ -1,4 +1,4 @@ -Copyright Author name here (c) 2023 +Copyright EO/Polystat Development Team (c) 2023 All rights reserved. @@ -13,7 +13,7 @@ modification, are permitted provided that the following conditions are met: disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Author name here nor the names of other + * Neither the name of EO/Polystat Development Team nor the names of other contributors may be used to endorse or promote products derived from this software without specific prior written permission. From a253508c09f22cd3a85bc13a3595fb463ff4d4c7 Mon Sep 17 00:00:00 2001 From: Nikolai Kudasov Date: Fri, 22 Dec 2023 00:50:47 +0300 Subject: [PATCH 08/15] Update README --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fb3b23ab0..c522d0d01 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,14 @@ normalize-phi < FILE The output should be a 𝜑-term after normalization. +```sh +echo "{ φ ↦ {}, a ↦ ξ.a }" | normalize-phi +``` + +``` +{ φ ↦ { }, a ↦ { } } +``` + ## Development The project is developed with the [Stack tool](https://docs.haskellstack.org/en/stable/README/). @@ -59,5 +67,3 @@ To run (all) tests, simply use ```sh stack test ``` - -[^1]: From fd6c7ccd8586d633d15e2be3c67fd1634febcc2f Mon Sep 17 00:00:00 2001 From: Nikolai Kudasov Date: Fri, 22 Dec 2023 00:56:16 +0300 Subject: [PATCH 09/15] Remove and ignore backup and unnecessary(?) generated BNFC files --- .gitignore | 7 + .../src/Language/EO/Phi/Syntax/Abs.hs.bak | 157 - .../src/Language/EO/Phi/Syntax/Doc.txt.bak | 89 - .../src/Language/EO/Phi/Syntax/ErrM.hs.bak | 91 - .../src/Language/EO/Phi/Syntax/Lex.hs | 6868 ----------------- .../src/Language/EO/Phi/Syntax/Lex.x.bak | 264 - .../src/Language/EO/Phi/Syntax/Par.hs | 1523 ---- .../src/Language/EO/Phi/Syntax/Par.info | 1227 --- .../src/Language/EO/Phi/Syntax/Par.y.bak | 212 - .../src/Language/EO/Phi/Syntax/Print.hs.bak | 214 - .../src/Language/EO/Phi/Syntax/Skel.hs.bak | 82 - .../src/Language/EO/Phi/Syntax/Test.hs.bak | 76 - 12 files changed, 7 insertions(+), 10803 deletions(-) delete mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Syntax/Abs.hs.bak delete mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt.bak delete mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Syntax/ErrM.hs.bak delete mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.hs delete mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.x.bak delete mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.hs delete mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.info delete mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y.bak delete mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs.bak delete mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Syntax/Skel.hs.bak delete mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Syntax/Test.hs.bak diff --git a/.gitignore b/.gitignore index 4d1733fd7..fc587c5eb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,10 @@ +*.bak +eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.hs +eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.hs +eo-phi-normalizer/src/Language/EO/Phi/Syntax/ErrM.hs +eo-phi-normalizer/src/Language/EO/Phi/Syntax/Skel.hs +eo-phi-normalizer/src/Language/EO/Phi/Syntax/Test.hs +eo-phi-normalizer/src/Language/EO/Phi/Syntax/Test .cache/ .DS_Store dist diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Abs.hs.bak b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Abs.hs.bak deleted file mode 100644 index f38a2ccac..000000000 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Abs.hs.bak +++ /dev/null @@ -1,157 +0,0 @@ --- File generated by the BNF Converter (bnfc 2.9.5). - -{-# LANGUAGE DeriveDataTypeable #-} -{-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE DeriveTraversable #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE PatternSynonyms #-} - --- | The abstract syntax of language Syntax. - -module Language.EO.Phi.Syntax.Abs where - -import Prelude (String) -import qualified Prelude as C - ( Eq, Ord, Show, Read - , Functor, Foldable, Traversable - , Int, Maybe(..) - ) -import qualified Data.String - -import qualified Data.Data as C (Data, Typeable) -import qualified GHC.Generics as C (Generic) - -type Program = Program' BNFC'Position -data Program' a = Program a [Binding' a] - deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) - -type Object = Object' BNFC'Position -data Object' a - = Formation a [Binding' a] - | Application a (AbstractObject' a) [Binding' a] [Bindings' a] - | Dispatch a (Dispatch' a) - | Termination a - deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) - -type AbstractObject = AbstractObject' BNFC'Position -data AbstractObject' a - = AbstractFormation a [Binding' a] - | AbstractDispatch a (Dispatch' a) - | AbstractTermination a - deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) - -type DispatchedObject = DispatchedObject' BNFC'Position -data DispatchedObject' a - = DispatchedFormation a [Binding' a] | DispatchedTermination a - deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) - -type Binding = Binding' BNFC'Position -data Binding' a - = EmptyBinding a (Attribute' a) - | DeltaBinding a Bytes - | LambdaBinding a - deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) - -type Bindings = Bindings' BNFC'Position -data Bindings' a = Bindings a [Binding' a] - deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) - -type Dispatch = Dispatch' BNFC'Position -data Dispatch' a - = HomeDispatch a [Attribute' a] [Disp' a] - | ThisDispatch a [Attribute' a] [Disp' a] - deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) - -type Attribute = Attribute' BNFC'Position -data Attribute' a - = Phi a - | Rho a - | Sigma a - | VTX a - | Label a LabelId - | Alpha a AlphaIndex - deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) - -type Disp = Disp' BNFC'Position -data Disp' a = Disp a [Binding' a] (Bindings' a) [Attribute' a] - deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) - -newtype Bytes = Bytes String - deriving (C.Eq, C.Ord, C.Show, C.Read, C.Data, C.Typeable, C.Generic, Data.String.IsString) - -newtype Function = Function String - deriving (C.Eq, C.Ord, C.Show, C.Read, C.Data, C.Typeable, C.Generic, Data.String.IsString) - -newtype LabelId = LabelId String - deriving (C.Eq, C.Ord, C.Show, C.Read, C.Data, C.Typeable, C.Generic, Data.String.IsString) - -newtype AlphaIndex = AlphaIndex String - deriving (C.Eq, C.Ord, C.Show, C.Read, C.Data, C.Typeable, C.Generic, Data.String.IsString) - --- | Start position (line, column) of something. - -type BNFC'Position = C.Maybe (C.Int, C.Int) - -pattern BNFC'NoPosition :: BNFC'Position -pattern BNFC'NoPosition = C.Nothing - -pattern BNFC'Position :: C.Int -> C.Int -> BNFC'Position -pattern BNFC'Position line col = C.Just (line, col) - --- | Get the start position of something. - -class HasPosition a where - hasPosition :: a -> BNFC'Position - -instance HasPosition Program where - hasPosition = \case - Program p _ -> p - -instance HasPosition Object where - hasPosition = \case - Formation p _ -> p - Application p _ _ _ -> p - Dispatch p _ -> p - Termination p -> p - -instance HasPosition AbstractObject where - hasPosition = \case - AbstractFormation p _ -> p - AbstractDispatch p _ -> p - AbstractTermination p -> p - -instance HasPosition DispatchedObject where - hasPosition = \case - DispatchedFormation p _ -> p - DispatchedTermination p -> p - -instance HasPosition Binding where - hasPosition = \case - EmptyBinding p _ -> p - DeltaBinding p _ -> p - LambdaBinding p -> p - -instance HasPosition Bindings where - hasPosition = \case - Bindings p _ -> p - -instance HasPosition Dispatch where - hasPosition = \case - HomeDispatch p _ _ -> p - ThisDispatch p _ _ -> p - -instance HasPosition Attribute where - hasPosition = \case - Phi p -> p - Rho p -> p - Sigma p -> p - VTX p -> p - Label p _ -> p - Alpha p _ -> p - -instance HasPosition Disp where - hasPosition = \case - Disp p _ _ _ -> p - diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt.bak b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt.bak deleted file mode 100644 index 4b884671a..000000000 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt.bak +++ /dev/null @@ -1,89 +0,0 @@ -The Language Syntax -BNF Converter - - -%Process by txt2tags to generate html or latex - - - -This document was automatically generated by the //BNF-Converter//. It was generated together with the lexer, the parser, and the abstract syntax module, which guarantees that the document matches with the implementation of the language (provided no hand-hacking has taken place). - -==The lexical structure of Syntax== - -===Literals=== - - - - - -Bytes literals are recognized by the regular expression -`````{"--"} | ["0123456789ABCDEF"] ["0123456789ABCDEF"] ('-' ["0123456789ABCDEF"] ["0123456789ABCDEF"])* {"--"}````` - -Function literals are recognized by the regular expression -`````upper (char - [" - !'(),-.:;?[]{|}⟦⟧"])*````` - -LabelId literals are recognized by the regular expression -`````lower (char - [" - !'(),-.:;?[]{|}⟦⟧"])*````` - -AlphaIndex literals are recognized by the regular expression -`````{"α0"} | 'α' (digit - '0') digit*````` - - -===Reserved words and symbols=== -The set of reserved words is the set of terminals appearing in the grammar. Those reserved words that consist of non-letter characters are called symbols, and they are treated in a different way from those that are similar to identifiers. The lexer follows rules familiar from languages like Haskell, C, and Java, including longest match and spacing conventions. - -The reserved words used in Syntax are the following: - | ``Δ`` | ``Φ`` | ``λ`` | ``ν`` - | ``ξ`` | ``ρ`` | ``σ`` | ``φ`` - -The symbols used in Syntax are the following: - | { | } | ⊥ | ↦ - | ∅ | ⤍ | , | . - -===Comments=== -There are no single-line comments in the grammar.There are no multiple-line comments in the grammar. - -==The syntactic structure of Syntax== -Non-terminals are enclosed between < and >. -The symbols -> (production), **|** (union) -and **eps** (empty rule) belong to the BNF notation. -All other symbols are terminals. - - | //Program// | -> | ``{`` //[Binding]// ``}`` - | //Object// | -> | ``{`` //[Binding]// ``}`` - | | **|** | //AbstractObject// ``{`` //[Binding]// ``}`` //[Bindings]// - | | **|** | //Dispatch// - | | **|** | ``⊥`` - | //AbstractObject// | -> | ``{`` //[Binding]// ``}`` - | | **|** | //Dispatch// - | | **|** | ``⊥`` - | //DispatchedObject// | -> | ``{`` //[Binding]// ``}`` - | | **|** | ``⊥`` - | //Binding// | -> | //Attribute// ``↦`` ``∅`` - | | **|** | ``Δ`` ``⤍`` //Bytes// - | | **|** | ``λ`` ``⤍`` - | //[Binding]// | -> | **eps** - | | **|** | //Binding// - | | **|** | //Binding// ``,`` //[Binding]// - | //Bindings// | -> | ``{`` //[Binding]// ``}`` - | //[Bindings]// | -> | **eps** - | | **|** | //Bindings// //[Bindings]// - | //Dispatch// | -> | ``Φ`` ``.`` //[Attribute]// //[Disp]// - | | **|** | ``ξ`` ``.`` //[Attribute]// //[Disp]// - | //Attribute// | -> | ``φ`` - | | **|** | ``ρ`` - | | **|** | ``σ`` - | | **|** | ``ν`` - | | **|** | //LabelId// - | | **|** | //AlphaIndex// - | //[Attribute]// | -> | //Attribute// - | | **|** | //Attribute// ``.`` //[Attribute]// - | //Disp// | -> | ``{`` //[Binding]// ``}`` //Bindings// ``.`` //[Attribute]// - | //[Disp]// | -> | **eps** - | | **|** | //Disp// //[Disp]// - - - -%% File generated by the BNF Converter (bnfc 2.9.5). diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/ErrM.hs.bak b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/ErrM.hs.bak deleted file mode 100644 index c72618db5..000000000 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/ErrM.hs.bak +++ /dev/null @@ -1,91 +0,0 @@ --- File generated by the BNF Converter (bnfc 2.9.6). - -{-# LANGUAGE CPP #-} - -#if __GLASGOW_HASKELL__ >= 708 ---------------------------------------------------------------------------- --- Pattern synonyms exist since ghc 7.8. - --- | BNF Converter: Error Monad. --- --- Module for backwards compatibility. --- --- The generated parser now uses @'Either' String@ as error monad. --- This module defines a type synonym 'Err' and pattern synonyms --- 'Bad' and 'Ok' for 'Left' and 'Right'. - -{-# LANGUAGE PatternSynonyms #-} -{-# LANGUAGE FlexibleInstances #-} - -module Language.EO.Phi.Syntax.ErrM where - -import Prelude (id, const, Either(..), String) - -import Control.Monad (MonadPlus(..)) -import Control.Applicative (Alternative(..)) -#if __GLASGOW_HASKELL__ >= 808 -import Control.Monad (MonadFail(..)) -#endif - --- | Error monad with 'String' error messages. -type Err = Either String - -pattern Bad msg = Left msg -pattern Ok a = Right a - -#if __GLASGOW_HASKELL__ >= 808 -instance MonadFail Err where - fail = Bad -#endif - -instance Alternative Err where - empty = Left "Err.empty" - (<|>) Left{} = id - (<|>) x@Right{} = const x - -instance MonadPlus Err where - mzero = empty - mplus = (<|>) - -#else ---------------------------------------------------------------------------- --- ghc 7.6 and before: use old definition as data type. - --- | BNF Converter: Error Monad - --- Copyright (C) 2004 Author: Aarne Ranta --- This file comes with NO WARRANTY and may be used FOR ANY PURPOSE. - -module Language.EO.Phi.Syntax.ErrM where - --- the Error monad: like Maybe type with error msgs - -import Control.Applicative (Applicative(..), Alternative(..)) -import Control.Monad (MonadPlus(..), liftM) - -data Err a = Ok a | Bad String - deriving (Read, Show, Eq, Ord) - -instance Monad Err where - return = Ok - Ok a >>= f = f a - Bad s >>= _ = Bad s - -instance Applicative Err where - pure = Ok - (Bad s) <*> _ = Bad s - (Ok f) <*> o = liftM f o - -instance Functor Err where - fmap = liftM - -instance MonadPlus Err where - mzero = Bad "Err.mzero" - mplus (Bad _) y = y - mplus x _ = x - -instance Alternative Err where - empty = mzero - (<|>) = mplus - -#endif diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.hs b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.hs deleted file mode 100644 index 873fa3a31..000000000 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.hs +++ /dev/null @@ -1,6868 +0,0 @@ -{-# OPTIONS_GHC -fno-warn-unused-binds -fno-warn-missing-signatures #-} -{-# LANGUAGE CPP #-} -{-# LINE 4 "Lex.x" #-} -{-# OPTIONS -fno-warn-incomplete-patterns #-} -{-# OPTIONS_GHC -w #-} - -{-# LANGUAGE PatternSynonyms #-} - -module Language.EO.Phi.Syntax.Lex where - -import Prelude - -import qualified Data.Bits -import Data.Char (ord) -import Data.Function (on) -import Data.Word (Word8) -#if __GLASGOW_HASKELL__ >= 603 -#include "ghcconfig.h" -#elif defined(__GLASGOW_HASKELL__) -#include "config.h" -#endif -#if __GLASGOW_HASKELL__ >= 503 -import Data.Array -#else -import Array -#endif -alex_tab_size :: Int -alex_tab_size = 8 -alex_base :: Array Int Int -alex_base = listArray (0 :: Int, 50) - [ -8 - , 0 - , 0 - , 76 - , -73 - , 140 - , -153 - , -159 - , 268 - , 332 - , 396 - , 460 - , 588 - , 844 - , 963 - , -39 - , 0 - , -23 - , 1091 - , 1235 - , 840 - , 50 - , -147 - , 0 - , 180 - , 0 - , -145 - , -120 - , -111 - , -79 - , 0 - , -22 - , -10 - , 983 - , 1010 - , 1367 - , 1612 - , 1857 - , 2093 - , 2349 - , 2350 - , 2478 - , -113 - , -108 - , 1303 - , 1549 - , 2591 - , 0 - , 0 - , 0 - , 2847 - ] - -alex_table :: Array Int Int -alex_table = listArray (0 :: Int, 3102) - [ 0 - , 24 - , 24 - , 24 - , 24 - , 24 - , 7 - , -1 - , -1 - , 16 - , 17 - , 17 - , 17 - , 17 - , 17 - , 17 - , 17 - , 17 - , 17 - , 25 - , 25 - , 25 - , 25 - , 30 - , 24 - , 17 - , 17 - , 17 - , 17 - , 17 - , 17 - , 17 - , 17 - , 17 - , 17 - , 34 - , 25 - , 31 - , 25 - , 0 - , 33 - , 33 - , 33 - , 33 - , 33 - , 33 - , 33 - , 33 - , 33 - , 33 - , 25 - , 42 - , 25 - , -1 - , -1 - , 25 - , 0 - , 36 - , 36 - , 36 - , 36 - , 36 - , 36 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 25 - , 0 - , 25 - , 5 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , 0 - , 22 - , 0 - , 28 - , 8 - , 26 - , 24 - , 24 - , 24 - , 24 - , 24 - , 0 - , 0 - , 0 - , 0 - , 20 - , 29 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 24 - , 0 - , 27 - , 0 - , 0 - , 0 - , 21 - , 4 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 0 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 0 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 0 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 0 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 0 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 0 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 12 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 13 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , 0 - , 0 - , -1 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 25 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , -1 - , -1 - , 0 - , 0 - , 0 - , 0 - , 0 - , -1 - , -1 - , -1 - , 0 - , 25 - , -1 - , -1 - , -1 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 15 - , 0 - , 0 - , 0 - , -1 - , -1 - , 0 - , 0 - , 0 - , -1 - , 25 - , 0 - , 25 - , 25 - , 32 - , 32 - , 32 - , 32 - , 32 - , 32 - , 32 - , 32 - , 32 - , 32 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 32 - , 32 - , 32 - , 32 - , 32 - , 32 - , -1 - , 30 - , -1 - , 0 - , 33 - , 33 - , 33 - , 33 - , 33 - , 33 - , 33 - , 33 - , 33 - , 33 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 33 - , 33 - , 33 - , 33 - , 33 - , 33 - , 0 - , 0 - , 0 - , 0 - , 0 - , -1 - , -1 - , -1 - , 0 - , 0 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , 13 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 5 - , 12 - , 23 - , 6 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 4 - , 11 - , 1 - , 1 - , 1 - , 3 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 0 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 0 - , 0 - , 0 - , 0 - , 19 - , 0 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 19 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 0 - , 0 - , 38 - , 38 - , 0 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 0 - , 0 - , 38 - , 38 - , 38 - , 38 - , 38 - , 19 - , 0 - , 0 - , 38 - , 38 - , 0 - , 0 - , 0 - , 38 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 0 - , 0 - , 38 - , 38 - , 38 - , 18 - , 38 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 0 - , 38 - , 0 - , 38 - , 35 - , 38 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 0 - , 0 - , 0 - , 38 - , 38 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , 0 - , 0 - , 39 - , 9 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 44 - , 40 - , 48 - , 43 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 45 - , 41 - , 49 - , 49 - , 49 - , 46 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 0 - , 0 - , 38 - , 38 - , 0 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 0 - , 0 - , 38 - , 38 - , 38 - , 38 - , 38 - , 19 - , 0 - , 0 - , 38 - , 38 - , 0 - , 0 - , 0 - , 38 - , 37 - , 37 - , 37 - , 37 - , 37 - , 37 - , 37 - , 37 - , 37 - , 37 - , 0 - , 0 - , 38 - , 38 - , 38 - , 0 - , 38 - , 37 - , 37 - , 37 - , 37 - , 37 - , 37 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 0 - , 38 - , 0 - , 38 - , 35 - , 38 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 0 - , 0 - , 0 - , 38 - , 38 - , 44 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , 0 - , 39 - , 9 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 44 - , 40 - , 48 - , 43 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 45 - , 41 - , 49 - , 49 - , 49 - , 46 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 0 - , 0 - , 38 - , 38 - , 0 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 38 - , 0 - , 0 - , 38 - , 38 - , 38 - , 38 - , 38 - , 19 - , 0 - , 0 - , 38 - , 38 - , 0 - , 34 - , 0 - , 38 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 0 - , 0 - , 38 - , 38 - , 38 - , 0 - , 38 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 0 - , 38 - , 0 - , 38 - , 35 - , 38 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 35 - , 0 - , 0 - , 0 - , 38 - , 38 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 39 - , 9 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 44 - , 40 - , 48 - , 43 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 45 - , 41 - , 49 - , 49 - , 49 - , 46 - , -1 - , -1 - , 0 - , 0 - , -1 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , -1 - , -1 - , 0 - , 0 - , 0 - , 0 - , 0 - , -1 - , -1 - , -1 - , 0 - , 0 - , -1 - , -1 - , -1 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , -1 - , -1 - , 0 - , 0 - , 0 - , -1 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , -1 - , 0 - , -1 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , -1 - , -1 - , -1 - , 0 - , 0 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , 39 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 44 - , 40 - , 48 - , 43 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 45 - , 41 - , 49 - , 49 - , 49 - , 46 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , 0 - , 39 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 47 - , 40 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 48 - , 45 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , 14 - , 14 - , 14 - , 14 - , 14 - , 14 - , 14 - , 14 - , 14 - , 0 - , 0 - , 14 - , 14 - , 0 - , 14 - , 14 - , 14 - , 14 - , 14 - , 14 - , 14 - , 14 - , 14 - , 14 - , 14 - , 14 - , 14 - , 14 - , 14 - , 14 - , 14 - , 14 - , 0 - , 0 - , 14 - , 14 - , 14 - , 14 - , 14 - , 19 - , 0 - , 0 - , 14 - , 14 - , 0 - , 0 - , 0 - , 14 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 0 - , 0 - , 14 - , 14 - , 14 - , 0 - , 14 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 0 - , 14 - , 0 - , 14 - , 50 - , 14 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 50 - , 0 - , 0 - , 0 - , 14 - , 14 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 13 - , 10 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 2 - , 5 - , 12 - , 23 - , 6 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 23 - , 4 - , 11 - , 1 - , 1 - , 1 - , 3 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - , 0 - ] - -alex_check :: Array Int Int -alex_check = listArray (0 :: Int, 3102) - [ -1 - , 9 - , 10 - , 11 - , 12 - , 13 - , 159 - , 166 - , 167 - , 48 - , 49 - , 50 - , 51 - , 52 - , 53 - , 54 - , 55 - , 56 - , 57 - , 166 - , 165 - , 141 - , 133 - , 45 - , 32 - , 48 - , 49 - , 50 - , 51 - , 52 - , 53 - , 54 - , 55 - , 56 - , 57 - , 45 - , 44 - , 45 - , 46 - , -1 - , 48 - , 49 - , 50 - , 51 - , 52 - , 53 - , 54 - , 55 - , 56 - , 57 - , 129 - , 159 - , 131 - , 166 - , 167 - , 134 - , -1 - , 65 - , 66 - , 67 - , 68 - , 69 - , 70 - , 71 - , 72 - , 73 - , 74 - , 75 - , 76 - , 77 - , 78 - , 79 - , 80 - , 81 - , 82 - , 83 - , 84 - , 85 - , 86 - , 87 - , 88 - , 89 - , 90 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , 97 - , 98 - , 99 - , 100 - , 101 - , 102 - , 103 - , 104 - , 105 - , 106 - , 107 - , 108 - , 109 - , 110 - , 111 - , 112 - , 113 - , 114 - , 115 - , 116 - , 117 - , 118 - , 119 - , 120 - , 121 - , 122 - , 123 - , -1 - , 125 - , 191 - , 192 - , 193 - , 194 - , 195 - , 196 - , 197 - , 198 - , 199 - , 200 - , 201 - , 202 - , 203 - , 204 - , 205 - , 206 - , 207 - , 208 - , 209 - , 210 - , 211 - , 212 - , 213 - , 214 - , 215 - , 216 - , 217 - , 218 - , 219 - , 220 - , 221 - , 222 - , 223 - , 224 - , 225 - , 226 - , 227 - , 228 - , 229 - , 230 - , 231 - , 232 - , 233 - , 234 - , 235 - , 236 - , 237 - , 238 - , 239 - , 240 - , 241 - , 242 - , 243 - , 244 - , 245 - , 246 - , 247 - , 248 - , 249 - , 250 - , 251 - , 252 - , 253 - , 254 - , 255 - , -1 - , 134 - , -1 - , 136 - , 195 - , 138 - , 9 - , 10 - , 11 - , 12 - , 13 - , -1 - , -1 - , -1 - , -1 - , 206 - , 207 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , 32 - , -1 - , 164 - , -1 - , -1 - , -1 - , 226 - , 143 - , 144 - , 145 - , 146 - , 147 - , 148 - , 149 - , 150 - , 151 - , 152 - , 153 - , 154 - , 155 - , 156 - , 157 - , 158 - , 159 - , 160 - , 161 - , 162 - , 163 - , 164 - , 165 - , 166 - , 167 - , 168 - , 169 - , 170 - , 171 - , 172 - , 173 - , 174 - , 175 - , 176 - , 177 - , 178 - , 179 - , 180 - , 181 - , 182 - , 183 - , 184 - , 185 - , 186 - , 187 - , 188 - , 189 - , 190 - , 191 - , 192 - , 193 - , 194 - , 195 - , 196 - , 197 - , 198 - , 199 - , 200 - , 201 - , 202 - , 203 - , 204 - , 205 - , 206 - , 207 - , 208 - , 209 - , 210 - , 211 - , 212 - , 213 - , 214 - , 215 - , 216 - , 217 - , 218 - , 219 - , 220 - , 221 - , 222 - , 223 - , 224 - , 225 - , 226 - , 227 - , 228 - , 229 - , 230 - , 231 - , 232 - , 233 - , 234 - , 235 - , 236 - , 237 - , 238 - , 239 - , 240 - , 241 - , 242 - , 243 - , 244 - , 245 - , 246 - , 247 - , 248 - , 249 - , 250 - , 251 - , 252 - , 253 - , 254 - , 255 - , 192 - , 193 - , 194 - , 195 - , 196 - , 197 - , 198 - , 199 - , 200 - , 201 - , 202 - , 203 - , 204 - , 205 - , 206 - , 207 - , 208 - , 209 - , 210 - , 211 - , 212 - , 213 - , 214 - , 215 - , 216 - , 217 - , 218 - , 219 - , 220 - , 221 - , 222 - , 223 - , 224 - , 225 - , 226 - , 227 - , 228 - , 229 - , 230 - , 231 - , 232 - , 233 - , 234 - , 235 - , 236 - , 237 - , 238 - , 239 - , 240 - , 241 - , 242 - , 243 - , 244 - , 245 - , 246 - , 247 - , 248 - , 249 - , 250 - , 251 - , 252 - , 253 - , 254 - , 255 - , 128 - , 129 - , 130 - , 131 - , 132 - , 133 - , 134 - , 135 - , 136 - , 137 - , 138 - , 139 - , 140 - , 141 - , 142 - , 143 - , 144 - , 145 - , 146 - , 147 - , 148 - , 149 - , 150 - , -1 - , 152 - , 153 - , 154 - , 155 - , 156 - , 157 - , 158 - , 159 - , 160 - , 161 - , 162 - , 163 - , 164 - , 165 - , 166 - , 167 - , 168 - , 169 - , 170 - , 171 - , 172 - , 173 - , 174 - , 175 - , 176 - , 177 - , 178 - , 179 - , 180 - , 181 - , 182 - , -1 - , 184 - , 185 - , 186 - , 187 - , 188 - , 189 - , 190 - , 191 - , 128 - , 129 - , 130 - , 131 - , 132 - , 133 - , 134 - , 135 - , 136 - , 137 - , 138 - , 139 - , 140 - , 141 - , 142 - , 143 - , 144 - , 145 - , 146 - , 147 - , 148 - , 149 - , 150 - , -1 - , 152 - , 153 - , 154 - , 155 - , 156 - , 157 - , 158 - , 159 - , 160 - , 161 - , 162 - , 163 - , 164 - , 165 - , 166 - , 167 - , 168 - , 169 - , 170 - , 171 - , 172 - , 173 - , 174 - , 175 - , 176 - , 177 - , 178 - , 179 - , 180 - , 181 - , 182 - , -1 - , 184 - , 185 - , 186 - , 187 - , 188 - , 189 - , 190 - , 191 - , 128 - , 129 - , 130 - , 131 - , 132 - , 133 - , 134 - , 135 - , 136 - , 137 - , 138 - , 139 - , 140 - , 141 - , 142 - , 143 - , 144 - , 145 - , 146 - , 147 - , 148 - , 149 - , 150 - , -1 - , 152 - , 153 - , 154 - , 155 - , 156 - , 157 - , 158 - , 159 - , 160 - , 161 - , 162 - , 163 - , 164 - , 165 - , 166 - , 167 - , 168 - , 169 - , 170 - , 171 - , 172 - , 173 - , 174 - , 175 - , 176 - , 177 - , 178 - , 179 - , 180 - , 181 - , 182 - , -1 - , 184 - , 185 - , 186 - , 187 - , 188 - , 189 - , 190 - , 191 - , 128 - , 129 - , 130 - , 131 - , 132 - , 133 - , 134 - , 135 - , 136 - , 137 - , 138 - , 139 - , 140 - , 141 - , 142 - , 143 - , 144 - , 145 - , 146 - , 147 - , 148 - , 149 - , 150 - , 151 - , 152 - , 153 - , 154 - , 155 - , 156 - , 157 - , 158 - , 159 - , 160 - , 161 - , 162 - , 163 - , 164 - , 165 - , 166 - , 167 - , 168 - , 169 - , 170 - , 171 - , 172 - , 173 - , 174 - , 175 - , 176 - , 177 - , 178 - , 179 - , 180 - , 181 - , 182 - , 183 - , 184 - , 185 - , 186 - , 187 - , 188 - , 189 - , 190 - , 191 - , 192 - , 193 - , 194 - , 195 - , 196 - , 197 - , 198 - , 199 - , 200 - , 201 - , 202 - , 203 - , 204 - , 205 - , 206 - , 207 - , 208 - , 209 - , 210 - , 211 - , 212 - , 213 - , 214 - , 215 - , 216 - , 217 - , 218 - , 219 - , 220 - , 221 - , 222 - , 223 - , 224 - , 225 - , 226 - , 227 - , 228 - , 229 - , 230 - , 231 - , 232 - , 233 - , 234 - , 235 - , 236 - , 237 - , 238 - , 239 - , 240 - , 241 - , 242 - , 243 - , 244 - , 245 - , 246 - , 247 - , 248 - , 249 - , 250 - , 251 - , 252 - , 253 - , 254 - , 255 - , 128 - , 129 - , 130 - , 131 - , 132 - , 133 - , 134 - , 135 - , 136 - , 137 - , 138 - , 139 - , 140 - , 141 - , 142 - , 143 - , 144 - , 145 - , 146 - , 147 - , 148 - , 149 - , 150 - , 151 - , 152 - , 153 - , 154 - , 155 - , 156 - , 157 - , 158 - , 159 - , 160 - , 161 - , 162 - , 163 - , 164 - , 165 - , 166 - , 167 - , 168 - , 169 - , 170 - , 171 - , 172 - , 173 - , 174 - , 175 - , 176 - , 177 - , 178 - , 179 - , 180 - , 181 - , 182 - , 183 - , 184 - , 185 - , 186 - , 187 - , 188 - , 189 - , 190 - , 191 - , 192 - , 193 - , 194 - , 195 - , 196 - , 197 - , 198 - , 199 - , 200 - , 201 - , 202 - , 203 - , 204 - , 205 - , 206 - , 207 - , 208 - , 209 - , 210 - , 211 - , 212 - , 213 - , 214 - , 215 - , 216 - , 217 - , 218 - , 219 - , 220 - , 221 - , 222 - , 223 - , 224 - , 225 - , 226 - , 227 - , 228 - , 229 - , 230 - , 231 - , 232 - , 233 - , 234 - , 235 - , 236 - , 237 - , 238 - , 239 - , 240 - , 241 - , 242 - , 243 - , 244 - , 245 - , 246 - , 247 - , 248 - , 249 - , 250 - , 251 - , 252 - , 253 - , 254 - , 255 - , 0 - , 1 - , 2 - , 3 - , 4 - , 5 - , 6 - , 7 - , 8 - , 9 - , 10 - , 11 - , 12 - , 13 - , 14 - , 15 - , 16 - , 17 - , 18 - , 19 - , 20 - , 21 - , 22 - , 23 - , 24 - , 25 - , 26 - , 27 - , 28 - , 29 - , 30 - , 31 - , 32 - , 33 - , 34 - , 35 - , 36 - , 37 - , 38 - , 39 - , 40 - , 41 - , 42 - , 43 - , 44 - , 45 - , 46 - , 47 - , 48 - , 49 - , 50 - , 51 - , 52 - , 53 - , 54 - , 55 - , 56 - , 57 - , 58 - , 59 - , 60 - , 61 - , 62 - , 63 - , 64 - , 65 - , 66 - , 67 - , 68 - , 69 - , 70 - , 71 - , 72 - , 73 - , 74 - , 75 - , 76 - , 77 - , 78 - , 79 - , 80 - , 81 - , 82 - , 83 - , 84 - , 85 - , 86 - , 87 - , 88 - , 89 - , 90 - , 91 - , 92 - , 93 - , 94 - , 95 - , 96 - , 97 - , 98 - , 99 - , 100 - , 101 - , 102 - , 103 - , 104 - , 105 - , 106 - , 107 - , 108 - , 109 - , 110 - , 111 - , 112 - , 113 - , 114 - , 115 - , 116 - , 117 - , 118 - , 119 - , 120 - , 121 - , 122 - , 123 - , 124 - , 125 - , 126 - , 127 - , 9 - , 10 - , -1 - , -1 - , 13 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , 148 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , 32 - , 33 - , -1 - , -1 - , -1 - , -1 - , -1 - , 39 - , 40 - , 41 - , -1 - , 166 - , 44 - , 45 - , 46 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , 177 - , -1 - , -1 - , -1 - , 58 - , 59 - , -1 - , -1 - , -1 - , 63 - , 187 - , -1 - , 189 - , 190 - , 48 - , 49 - , 50 - , 51 - , 52 - , 53 - , 54 - , 55 - , 56 - , 57 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , 65 - , 66 - , 67 - , 68 - , 69 - , 70 - , 91 - , 45 - , 93 - , -1 - , 48 - , 49 - , 50 - , 51 - , 52 - , 53 - , 54 - , 55 - , 56 - , 57 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , 65 - , 66 - , 67 - , 68 - , 69 - , 70 - , -1 - , -1 - , -1 - , -1 - , -1 - , 123 - , 124 - , 125 - , -1 - , -1 - , 128 - , 129 - , 130 - , 131 - , 132 - , 133 - , 134 - , 135 - , 136 - , 137 - , 138 - , 139 - , 140 - , 141 - , 142 - , 143 - , 144 - , 145 - , 146 - , 147 - , 148 - , 149 - , 150 - , 151 - , 152 - , 153 - , 154 - , 155 - , 156 - , 157 - , 158 - , 159 - , 160 - , 161 - , 162 - , 163 - , 164 - , 165 - , 166 - , 167 - , 168 - , 169 - , 170 - , 171 - , 172 - , 173 - , 174 - , 175 - , 176 - , 177 - , 178 - , 179 - , 180 - , 181 - , 182 - , 183 - , 184 - , 185 - , 186 - , 187 - , 188 - , 189 - , 190 - , 191 - , 192 - , 193 - , 194 - , 195 - , 196 - , 197 - , 198 - , 199 - , 200 - , 201 - , 202 - , 203 - , 204 - , 205 - , 206 - , 207 - , 208 - , 209 - , 210 - , 211 - , 212 - , 213 - , 214 - , 215 - , 216 - , 217 - , 218 - , 219 - , 220 - , 221 - , 222 - , 223 - , 224 - , 225 - , 226 - , 227 - , 228 - , 229 - , 230 - , 231 - , 232 - , 233 - , 234 - , 235 - , 236 - , 237 - , 238 - , 239 - , 240 - , 241 - , 242 - , 243 - , 244 - , 245 - , 246 - , 247 - , 248 - , 249 - , 250 - , 251 - , 252 - , 253 - , 254 - , 255 - , 128 - , 129 - , 130 - , 131 - , 132 - , 133 - , 134 - , 135 - , 136 - , 137 - , 138 - , 139 - , 140 - , 141 - , 142 - , 143 - , 144 - , 145 - , 146 - , 147 - , 148 - , 149 - , 150 - , -1 - , 152 - , 153 - , 154 - , 155 - , 156 - , 157 - , 158 - , 159 - , 160 - , 161 - , 162 - , 163 - , 164 - , 165 - , 166 - , 167 - , 168 - , 169 - , 170 - , 171 - , 172 - , 173 - , 174 - , 175 - , 176 - , 177 - , 178 - , 179 - , 180 - , 181 - , 182 - , 39 - , 184 - , 185 - , 186 - , 187 - , 188 - , 189 - , 190 - , 191 - , 48 - , 49 - , 50 - , 51 - , 52 - , 53 - , 54 - , 55 - , 56 - , 57 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , 65 - , 66 - , 67 - , 68 - , 69 - , 70 - , 71 - , 72 - , 73 - , 74 - , 75 - , 76 - , 77 - , 78 - , 79 - , 80 - , 81 - , 82 - , 83 - , 84 - , 85 - , 86 - , 87 - , 88 - , 89 - , 90 - , -1 - , -1 - , -1 - , -1 - , 95 - , -1 - , 97 - , 98 - , 99 - , 100 - , 101 - , 102 - , 103 - , 104 - , 105 - , 106 - , 107 - , 108 - , 109 - , 110 - , 111 - , 112 - , 113 - , 114 - , 115 - , 116 - , 117 - , 118 - , 119 - , 120 - , 121 - , 122 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , 0 - , 1 - , 2 - , 3 - , 4 - , 5 - , 6 - , 7 - , 8 - , -1 - , -1 - , 11 - , 12 - , -1 - , 14 - , 15 - , 16 - , 17 - , 18 - , 19 - , 20 - , 21 - , 22 - , 23 - , 24 - , 25 - , 26 - , 27 - , 28 - , 29 - , 30 - , 31 - , -1 - , -1 - , 34 - , 35 - , 36 - , 37 - , 38 - , 39 - , -1 - , -1 - , 42 - , 43 - , -1 - , -1 - , -1 - , 47 - , 48 - , 49 - , 50 - , 51 - , 52 - , 53 - , 54 - , 55 - , 56 - , 57 - , -1 - , -1 - , 60 - , 61 - , 62 - , 195 - , 64 - , 65 - , 66 - , 67 - , 68 - , 69 - , 70 - , 71 - , 72 - , 73 - , 74 - , 75 - , 76 - , 77 - , 78 - , 79 - , 80 - , 81 - , 82 - , 83 - , 84 - , 85 - , 86 - , 87 - , 88 - , 89 - , 90 - , -1 - , 92 - , -1 - , 94 - , 95 - , 96 - , 97 - , 98 - , 99 - , 100 - , 101 - , 102 - , 103 - , 104 - , 105 - , 106 - , 107 - , 108 - , 109 - , 110 - , 111 - , 112 - , 113 - , 114 - , 115 - , 116 - , 117 - , 118 - , 119 - , 120 - , 121 - , 122 - , -1 - , -1 - , -1 - , 126 - , 127 - , 192 - , 193 - , 194 - , 195 - , 196 - , 197 - , 198 - , 199 - , 200 - , 201 - , 202 - , 203 - , 204 - , 205 - , 206 - , 207 - , 208 - , 209 - , 210 - , 211 - , 212 - , 213 - , 214 - , 215 - , 216 - , 217 - , 218 - , 219 - , 220 - , 221 - , 222 - , 223 - , 224 - , 225 - , 226 - , 227 - , 228 - , 229 - , 230 - , 231 - , 232 - , 233 - , 234 - , 235 - , 236 - , 237 - , 238 - , 239 - , 240 - , 241 - , 242 - , 243 - , 244 - , 245 - , 246 - , 247 - , 248 - , 249 - , 250 - , 251 - , 252 - , 253 - , 254 - , 255 - , -1 - , -1 - , 194 - , 195 - , 196 - , 197 - , 198 - , 199 - , 200 - , 201 - , 202 - , 203 - , 204 - , 205 - , 206 - , 207 - , 208 - , 209 - , 210 - , 211 - , 212 - , 213 - , 214 - , 215 - , 216 - , 217 - , 218 - , 219 - , 220 - , 221 - , 222 - , 223 - , 224 - , 225 - , 226 - , 227 - , 228 - , 229 - , 230 - , 231 - , 232 - , 233 - , 234 - , 235 - , 236 - , 237 - , 238 - , 239 - , 240 - , 241 - , 242 - , 243 - , 244 - , 0 - , 1 - , 2 - , 3 - , 4 - , 5 - , 6 - , 7 - , 8 - , -1 - , -1 - , 11 - , 12 - , -1 - , 14 - , 15 - , 16 - , 17 - , 18 - , 19 - , 20 - , 21 - , 22 - , 23 - , 24 - , 25 - , 26 - , 27 - , 28 - , 29 - , 30 - , 31 - , -1 - , -1 - , 34 - , 35 - , 36 - , 37 - , 38 - , 39 - , -1 - , -1 - , 42 - , 43 - , -1 - , -1 - , -1 - , 47 - , 48 - , 49 - , 50 - , 51 - , 52 - , 53 - , 54 - , 55 - , 56 - , 57 - , -1 - , -1 - , 60 - , 61 - , 62 - , -1 - , 64 - , 65 - , 66 - , 67 - , 68 - , 69 - , 70 - , 71 - , 72 - , 73 - , 74 - , 75 - , 76 - , 77 - , 78 - , 79 - , 80 - , 81 - , 82 - , 83 - , 84 - , 85 - , 86 - , 87 - , 88 - , 89 - , 90 - , -1 - , 92 - , -1 - , 94 - , 95 - , 96 - , 97 - , 98 - , 99 - , 100 - , 101 - , 102 - , 103 - , 104 - , 105 - , 106 - , 107 - , 108 - , 109 - , 110 - , 111 - , 112 - , 113 - , 114 - , 115 - , 116 - , 117 - , 118 - , 119 - , 120 - , 121 - , 122 - , -1 - , -1 - , -1 - , 126 - , 127 - , 191 - , 192 - , 193 - , 194 - , 195 - , 196 - , 197 - , 198 - , 199 - , 200 - , 201 - , 202 - , 203 - , 204 - , 205 - , 206 - , 207 - , 208 - , 209 - , 210 - , 211 - , 212 - , 213 - , 214 - , 215 - , 216 - , 217 - , 218 - , 219 - , 220 - , 221 - , 222 - , 223 - , 224 - , 225 - , 226 - , 227 - , 228 - , 229 - , 230 - , 231 - , 232 - , 233 - , 234 - , 235 - , 236 - , 237 - , 238 - , 239 - , 240 - , 241 - , 242 - , 243 - , 244 - , 245 - , 246 - , 247 - , 248 - , 249 - , 250 - , 251 - , 252 - , 253 - , 254 - , 255 - , -1 - , 194 - , 195 - , 196 - , 197 - , 198 - , 199 - , 200 - , 201 - , 202 - , 203 - , 204 - , 205 - , 206 - , 207 - , 208 - , 209 - , 210 - , 211 - , 212 - , 213 - , 214 - , 215 - , 216 - , 217 - , 218 - , 219 - , 220 - , 221 - , 222 - , 223 - , 224 - , 225 - , 226 - , 227 - , 228 - , 229 - , 230 - , 231 - , 232 - , 233 - , 234 - , 235 - , 236 - , 237 - , 238 - , 239 - , 240 - , 241 - , 242 - , 243 - , 244 - , 0 - , 1 - , 2 - , 3 - , 4 - , 5 - , 6 - , 7 - , 8 - , -1 - , -1 - , 11 - , 12 - , -1 - , 14 - , 15 - , 16 - , 17 - , 18 - , 19 - , 20 - , 21 - , 22 - , 23 - , 24 - , 25 - , 26 - , 27 - , 28 - , 29 - , 30 - , 31 - , -1 - , -1 - , 34 - , 35 - , 36 - , 37 - , 38 - , 39 - , -1 - , -1 - , 42 - , 43 - , -1 - , 45 - , -1 - , 47 - , 48 - , 49 - , 50 - , 51 - , 52 - , 53 - , 54 - , 55 - , 56 - , 57 - , -1 - , -1 - , 60 - , 61 - , 62 - , -1 - , 64 - , 65 - , 66 - , 67 - , 68 - , 69 - , 70 - , 71 - , 72 - , 73 - , 74 - , 75 - , 76 - , 77 - , 78 - , 79 - , 80 - , 81 - , 82 - , 83 - , 84 - , 85 - , 86 - , 87 - , 88 - , 89 - , 90 - , -1 - , 92 - , -1 - , 94 - , 95 - , 96 - , 97 - , 98 - , 99 - , 100 - , 101 - , 102 - , 103 - , 104 - , 105 - , 106 - , 107 - , 108 - , 109 - , 110 - , 111 - , 112 - , 113 - , 114 - , 115 - , 116 - , 117 - , 118 - , 119 - , 120 - , 121 - , 122 - , -1 - , -1 - , -1 - , 126 - , 127 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , 194 - , 195 - , 196 - , 197 - , 198 - , 199 - , 200 - , 201 - , 202 - , 203 - , 204 - , 205 - , 206 - , 207 - , 208 - , 209 - , 210 - , 211 - , 212 - , 213 - , 214 - , 215 - , 216 - , 217 - , 218 - , 219 - , 220 - , 221 - , 222 - , 223 - , 224 - , 225 - , 226 - , 227 - , 228 - , 229 - , 230 - , 231 - , 232 - , 233 - , 234 - , 235 - , 236 - , 237 - , 238 - , 239 - , 240 - , 241 - , 242 - , 243 - , 244 - , 9 - , 10 - , -1 - , -1 - , 13 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , 32 - , 33 - , -1 - , -1 - , -1 - , -1 - , -1 - , 39 - , 40 - , 41 - , -1 - , -1 - , 44 - , 45 - , 46 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , 58 - , 59 - , -1 - , -1 - , -1 - , 63 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , 91 - , -1 - , 93 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , 123 - , 124 - , 125 - , -1 - , -1 - , 128 - , 129 - , 130 - , 131 - , 132 - , 133 - , 134 - , 135 - , 136 - , 137 - , 138 - , 139 - , 140 - , 141 - , 142 - , 143 - , 144 - , 145 - , 146 - , 147 - , 148 - , 149 - , 150 - , 151 - , 152 - , 153 - , 154 - , 155 - , 156 - , 157 - , 158 - , 159 - , 160 - , 161 - , 162 - , 163 - , 164 - , 165 - , 166 - , 167 - , 168 - , 169 - , 170 - , 171 - , 172 - , 173 - , 174 - , 175 - , 176 - , 177 - , 178 - , 179 - , 180 - , 181 - , 182 - , 183 - , 184 - , 185 - , 186 - , 187 - , 188 - , 189 - , 190 - , 191 - , 192 - , 193 - , 194 - , 195 - , 196 - , 197 - , 198 - , 199 - , 200 - , 201 - , 202 - , 203 - , 204 - , 205 - , 206 - , 207 - , 208 - , 209 - , 210 - , 211 - , 212 - , 213 - , 214 - , 215 - , 216 - , 217 - , 218 - , 219 - , 220 - , 221 - , 222 - , 223 - , 224 - , 225 - , 226 - , 227 - , 228 - , 229 - , 230 - , 231 - , 232 - , 233 - , 234 - , 235 - , 236 - , 237 - , 238 - , 239 - , 240 - , 241 - , 242 - , 243 - , 244 - , 245 - , 246 - , 247 - , 248 - , 249 - , 250 - , 251 - , 252 - , 253 - , 254 - , 255 - , 0 - , 1 - , 2 - , 3 - , 4 - , 5 - , 6 - , 7 - , 8 - , 9 - , 10 - , 11 - , 12 - , 13 - , 14 - , 15 - , 16 - , 17 - , 18 - , 19 - , 20 - , 21 - , 22 - , 23 - , 24 - , 25 - , 26 - , 27 - , 28 - , 29 - , 30 - , 31 - , 32 - , 33 - , 34 - , 35 - , 36 - , 37 - , 38 - , 39 - , 40 - , 41 - , 42 - , 43 - , 44 - , 45 - , 46 - , 47 - , 48 - , 49 - , 50 - , 51 - , 52 - , 53 - , 54 - , 55 - , 56 - , 57 - , 58 - , 59 - , 60 - , 61 - , 62 - , 63 - , 64 - , 65 - , 66 - , 67 - , 68 - , 69 - , 70 - , 71 - , 72 - , 73 - , 74 - , 75 - , 76 - , 77 - , 78 - , 79 - , 80 - , 81 - , 82 - , 83 - , 84 - , 85 - , 86 - , 87 - , 88 - , 89 - , 90 - , 91 - , 92 - , 93 - , 94 - , 95 - , 96 - , 97 - , 98 - , 99 - , 100 - , 101 - , 102 - , 103 - , 104 - , 105 - , 106 - , 107 - , 108 - , 109 - , 110 - , 111 - , 112 - , 113 - , 114 - , 115 - , 116 - , 117 - , 118 - , 119 - , 120 - , 121 - , 122 - , 123 - , 124 - , 125 - , 126 - , 127 - , -1 - , 128 - , 129 - , 130 - , 131 - , 132 - , 133 - , 134 - , 135 - , 136 - , 137 - , 138 - , 139 - , 140 - , 141 - , 142 - , 143 - , 144 - , 145 - , 146 - , 147 - , 148 - , 149 - , 150 - , 151 - , 152 - , 153 - , 154 - , 155 - , 156 - , 157 - , 158 - , 159 - , 160 - , 161 - , 162 - , 163 - , 164 - , 165 - , 166 - , 167 - , 168 - , 169 - , 170 - , 171 - , 172 - , 173 - , 174 - , 175 - , 176 - , 177 - , 178 - , 179 - , 180 - , 181 - , 182 - , 183 - , 184 - , 185 - , 186 - , 187 - , 188 - , 189 - , 190 - , 191 - , 192 - , 193 - , 194 - , 195 - , 196 - , 197 - , 198 - , 199 - , 200 - , 201 - , 202 - , 203 - , 204 - , 205 - , 206 - , 207 - , 208 - , 209 - , 210 - , 211 - , 212 - , 213 - , 214 - , 215 - , 216 - , 217 - , 218 - , 219 - , 220 - , 221 - , 222 - , 223 - , 224 - , 225 - , 226 - , 227 - , 228 - , 229 - , 230 - , 231 - , 232 - , 233 - , 234 - , 235 - , 236 - , 237 - , 238 - , 239 - , 240 - , 241 - , 242 - , 243 - , 244 - , 245 - , 246 - , 247 - , 248 - , 249 - , 250 - , 251 - , 252 - , 253 - , 254 - , 255 - , 128 - , 129 - , 130 - , 131 - , 132 - , 133 - , 134 - , 135 - , 136 - , 137 - , 138 - , 139 - , 140 - , 141 - , 142 - , 143 - , 144 - , 145 - , 146 - , 147 - , 148 - , 149 - , 150 - , 151 - , 152 - , 153 - , 154 - , 155 - , 156 - , 157 - , 158 - , 159 - , 160 - , 161 - , 162 - , 163 - , 164 - , 165 - , 166 - , 167 - , 168 - , 169 - , 170 - , 171 - , 172 - , 173 - , 174 - , 175 - , 176 - , 177 - , 178 - , 179 - , 180 - , 181 - , 182 - , 183 - , 184 - , 185 - , 186 - , 187 - , 188 - , 189 - , 190 - , 191 - , 192 - , 193 - , 194 - , 195 - , 196 - , 197 - , 198 - , 199 - , 200 - , 201 - , 202 - , 203 - , 204 - , 205 - , 206 - , 207 - , 208 - , 209 - , 210 - , 211 - , 212 - , 213 - , 214 - , 215 - , 216 - , 217 - , 218 - , 219 - , 220 - , 221 - , 222 - , 223 - , 224 - , 225 - , 226 - , 227 - , 228 - , 229 - , 230 - , 231 - , 232 - , 233 - , 234 - , 235 - , 236 - , 237 - , 238 - , 239 - , 240 - , 241 - , 242 - , 243 - , 244 - , 245 - , 246 - , 247 - , 248 - , 249 - , 250 - , 251 - , 252 - , 253 - , 254 - , 255 - , 143 - , 144 - , 145 - , 146 - , 147 - , 148 - , 149 - , 150 - , 151 - , 152 - , 153 - , 154 - , 155 - , 156 - , 157 - , 158 - , 159 - , 160 - , 161 - , 162 - , 163 - , 164 - , 165 - , 166 - , 167 - , 168 - , 169 - , 170 - , 171 - , 172 - , 173 - , 174 - , 175 - , 176 - , 177 - , 178 - , 179 - , 180 - , 181 - , 182 - , 183 - , 184 - , 185 - , 186 - , 187 - , 188 - , 189 - , 190 - , 191 - , 192 - , 193 - , 194 - , 195 - , 196 - , 197 - , 198 - , 199 - , 200 - , 201 - , 202 - , 203 - , 204 - , 205 - , 206 - , 207 - , 208 - , 209 - , 210 - , 211 - , 212 - , 213 - , 214 - , 215 - , 216 - , 217 - , 218 - , 219 - , 220 - , 221 - , 222 - , 223 - , 224 - , 225 - , 226 - , 227 - , 228 - , 229 - , 230 - , 231 - , 232 - , 233 - , 234 - , 235 - , 236 - , 237 - , 238 - , 239 - , 240 - , 241 - , 242 - , 243 - , 244 - , 245 - , 246 - , 247 - , 248 - , 249 - , 250 - , 251 - , 252 - , 253 - , 254 - , 255 - , 0 - , 1 - , 2 - , 3 - , 4 - , 5 - , 6 - , 7 - , 8 - , -1 - , -1 - , 11 - , 12 - , -1 - , 14 - , 15 - , 16 - , 17 - , 18 - , 19 - , 20 - , 21 - , 22 - , 23 - , 24 - , 25 - , 26 - , 27 - , 28 - , 29 - , 30 - , 31 - , -1 - , -1 - , 34 - , 35 - , 36 - , 37 - , 38 - , 39 - , -1 - , -1 - , 42 - , 43 - , -1 - , -1 - , -1 - , 47 - , 48 - , 49 - , 50 - , 51 - , 52 - , 53 - , 54 - , 55 - , 56 - , 57 - , -1 - , -1 - , 60 - , 61 - , 62 - , -1 - , 64 - , 65 - , 66 - , 67 - , 68 - , 69 - , 70 - , 71 - , 72 - , 73 - , 74 - , 75 - , 76 - , 77 - , 78 - , 79 - , 80 - , 81 - , 82 - , 83 - , 84 - , 85 - , 86 - , 87 - , 88 - , 89 - , 90 - , -1 - , 92 - , -1 - , 94 - , 95 - , 96 - , 97 - , 98 - , 99 - , 100 - , 101 - , 102 - , 103 - , 104 - , 105 - , 106 - , 107 - , 108 - , 109 - , 110 - , 111 - , 112 - , 113 - , 114 - , 115 - , 116 - , 117 - , 118 - , 119 - , 120 - , 121 - , 122 - , -1 - , -1 - , -1 - , 126 - , 127 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , 194 - , 195 - , 196 - , 197 - , 198 - , 199 - , 200 - , 201 - , 202 - , 203 - , 204 - , 205 - , 206 - , 207 - , 208 - , 209 - , 210 - , 211 - , 212 - , 213 - , 214 - , 215 - , 216 - , 217 - , 218 - , 219 - , 220 - , 221 - , 222 - , 223 - , 224 - , 225 - , 226 - , 227 - , 228 - , 229 - , 230 - , 231 - , 232 - , 233 - , 234 - , 235 - , 236 - , 237 - , 238 - , 239 - , 240 - , 241 - , 242 - , 243 - , 244 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - ] - -alex_deflt :: Array Int Int -alex_deflt = listArray (0 :: Int, 50) - [ -1 - , 23 - , 14 - , 23 - , 2 - , 14 - , 2 - , 14 - , -1 - , 38 - , 14 - , -1 - , -1 - , 14 - , 14 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , 2 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , -1 - , 38 - , 38 - , -1 - , -1 - , 38 - , 47 - , 38 - , 47 - , 48 - , 38 - , 47 - , 48 - , -1 - ] - -alex_accept = listArray (0 :: Int, 50) - [ AlexAccNone - , AlexAccNone - , AlexAccNone - , AlexAccNone - , AlexAccNone - , AlexAccNone - , AlexAccNone - , AlexAccNone - , AlexAccNone - , AlexAccNone - , AlexAccNone - , AlexAccNone - , AlexAccNone - , AlexAccNone - , AlexAcc 10 - , AlexAccNone - , AlexAcc 9 - , AlexAcc 8 - , AlexAccNone - , AlexAcc 7 - , AlexAccNone - , AlexAccNone - , AlexAccNone - , AlexAccNone - , AlexAccSkip - , AlexAcc 6 - , AlexAccNone - , AlexAccNone - , AlexAccNone - , AlexAccNone - , AlexAcc 5 - , AlexAccNone - , AlexAccNone - , AlexAccNone - , AlexAccNone - , AlexAcc 4 - , AlexAcc 3 - , AlexAcc 2 - , AlexAcc 1 - , AlexAccNone - , AlexAccNone - , AlexAccNone - , AlexAccNone - , AlexAccNone - , AlexAccNone - , AlexAccNone - , AlexAccNone - , AlexAccNone - , AlexAccNone - , AlexAccNone - , AlexAcc 0 - ] - -alex_actions = array (0 :: Int, 11) - [ (10,alex_action_4) - , (9,alex_action_5) - , (8,alex_action_5) - , (7,alex_action_6) - , (6,alex_action_1) - , (5,alex_action_2) - , (4,alex_action_3) - , (3,alex_action_3) - , (2,alex_action_3) - , (1,alex_action_3) - , (0,alex_action_4) - ] - -{-# LINE 62 "Lex.x" #-} --- | Create a token with position. -tok :: (String -> Tok) -> (Posn -> String -> Token) -tok f p = PT p . f - --- | Token without position. -data Tok - = TK {-# UNPACK #-} !TokSymbol -- ^ Reserved word or symbol. - | TL !String -- ^ String literal. - | TI !String -- ^ Integer literal. - | TV !String -- ^ Identifier. - | TD !String -- ^ Float literal. - | TC !String -- ^ Character literal. - | T_Bytes !String - | T_Function !String - | T_LabelId !String - | T_AlphaIndex !String - deriving (Eq, Show, Ord) - --- | Smart constructor for 'Tok' for the sake of backwards compatibility. -pattern TS :: String -> Int -> Tok -pattern TS t i = TK (TokSymbol t i) - --- | Keyword or symbol tokens have a unique ID. -data TokSymbol = TokSymbol - { tsText :: String - -- ^ Keyword or symbol text. - , tsID :: !Int - -- ^ Unique ID. - } deriving (Show) - --- | Keyword/symbol equality is determined by the unique ID. -instance Eq TokSymbol where (==) = (==) `on` tsID - --- | Keyword/symbol ordering is determined by the unique ID. -instance Ord TokSymbol where compare = compare `on` tsID - --- | Token with position. -data Token - = PT Posn Tok - | Err Posn - deriving (Eq, Show, Ord) - --- | Pretty print a position. -printPosn :: Posn -> String -printPosn (Pn _ l c) = "line " ++ show l ++ ", column " ++ show c - --- | Pretty print the position of the first token in the list. -tokenPos :: [Token] -> String -tokenPos (t:_) = printPosn (tokenPosn t) -tokenPos [] = "end of file" - --- | Get the position of a token. -tokenPosn :: Token -> Posn -tokenPosn (PT p _) = p -tokenPosn (Err p) = p - --- | Get line and column of a token. -tokenLineCol :: Token -> (Int, Int) -tokenLineCol = posLineCol . tokenPosn - --- | Get line and column of a position. -posLineCol :: Posn -> (Int, Int) -posLineCol (Pn _ l c) = (l,c) - --- | Convert a token into "position token" form. -mkPosToken :: Token -> ((Int, Int), String) -mkPosToken t = (tokenLineCol t, tokenText t) - --- | Convert a token to its text. -tokenText :: Token -> String -tokenText t = case t of - PT _ (TS s _) -> s - PT _ (TL s) -> show s - PT _ (TI s) -> s - PT _ (TV s) -> s - PT _ (TD s) -> s - PT _ (TC s) -> s - Err _ -> "#error" - PT _ (T_Bytes s) -> s - PT _ (T_Function s) -> s - PT _ (T_LabelId s) -> s - PT _ (T_AlphaIndex s) -> s - --- | Convert a token to a string. -prToken :: Token -> String -prToken t = tokenText t - --- | Finite map from text to token organized as binary search tree. -data BTree - = N -- ^ Nil (leaf). - | B String Tok BTree BTree - -- ^ Binary node. - deriving (Show) - --- | Convert potential keyword into token or use fallback conversion. -eitherResIdent :: (String -> Tok) -> String -> Tok -eitherResIdent tv s = treeFind resWords - where - treeFind N = tv s - treeFind (B a t left right) = - case compare s a of - LT -> treeFind left - GT -> treeFind right - EQ -> t - --- | The keywords and symbols of the language organized as binary search tree. -resWords :: BTree -resWords = - b "\958" 9 - (b "\916" 5 - (b "{" 3 (b "." 2 (b "," 1 N N) N) (b "}" 4 N N)) - (b "\955" 7 (b "\934" 6 N N) (b "\957" 8 N N))) - (b "\8614" 13 - (b "\963" 11 (b "\961" 10 N N) (b "\966" 12 N N)) - (b "\8869" 15 (b "\8709" 14 N N) (b "\10509" 16 N N))) - where - b s n = B bs (TS bs n) - where - bs = s - --- | Unquote string literal. -unescapeInitTail :: String -> String -unescapeInitTail = id . unesc . tail . id - where - unesc s = case s of - '\\':c:cs | elem c ['\"', '\\', '\''] -> c : unesc cs - '\\':'n':cs -> '\n' : unesc cs - '\\':'t':cs -> '\t' : unesc cs - '\\':'r':cs -> '\r' : unesc cs - '\\':'f':cs -> '\f' : unesc cs - '"':[] -> [] - c:cs -> c : unesc cs - _ -> [] - -------------------------------------------------------------------- --- Alex wrapper code. --- A modified "posn" wrapper. -------------------------------------------------------------------- - -data Posn = Pn !Int !Int !Int - deriving (Eq, Show, Ord) - -alexStartPos :: Posn -alexStartPos = Pn 0 1 1 - -alexMove :: Posn -> Char -> Posn -alexMove (Pn a l c) '\t' = Pn (a+1) l (((c+7) `div` 8)*8+1) -alexMove (Pn a l c) '\n' = Pn (a+1) (l+1) 1 -alexMove (Pn a l c) _ = Pn (a+1) l (c+1) - -type Byte = Word8 - -type AlexInput = (Posn, -- current position, - Char, -- previous char - [Byte], -- pending bytes on the current char - String) -- current input string - -tokens :: String -> [Token] -tokens str = go (alexStartPos, '\n', [], str) - where - go :: AlexInput -> [Token] - go inp@(pos, _, _, str) = - case alexScan inp 0 of - AlexEOF -> [] - AlexError (pos, _, _, _) -> [Err pos] - AlexSkip inp' len -> go inp' - AlexToken inp' len act -> act pos (take len str) : (go inp') - -alexGetByte :: AlexInput -> Maybe (Byte,AlexInput) -alexGetByte (p, c, (b:bs), s) = Just (b, (p, c, bs, s)) -alexGetByte (p, _, [], s) = - case s of - [] -> Nothing - (c:s) -> - let p' = alexMove p c - (b:bs) = utf8Encode c - in p' `seq` Just (b, (p', c, bs, s)) - -alexInputPrevChar :: AlexInput -> Char -alexInputPrevChar (p, c, bs, s) = c - --- | Encode a Haskell String to a list of Word8 values, in UTF8 format. -utf8Encode :: Char -> [Word8] -utf8Encode = map fromIntegral . go . ord - where - go oc - | oc <= 0x7f = [oc] - - | oc <= 0x7ff = [ 0xc0 + (oc `Data.Bits.shiftR` 6) - , 0x80 + oc Data.Bits..&. 0x3f - ] - - | oc <= 0xffff = [ 0xe0 + (oc `Data.Bits.shiftR` 12) - , 0x80 + ((oc `Data.Bits.shiftR` 6) Data.Bits..&. 0x3f) - , 0x80 + oc Data.Bits..&. 0x3f - ] - | otherwise = [ 0xf0 + (oc `Data.Bits.shiftR` 18) - , 0x80 + ((oc `Data.Bits.shiftR` 12) Data.Bits..&. 0x3f) - , 0x80 + ((oc `Data.Bits.shiftR` 6) Data.Bits..&. 0x3f) - , 0x80 + oc Data.Bits..&. 0x3f - ] -alex_action_1 = tok (eitherResIdent TV) -alex_action_2 = tok (eitherResIdent T_Bytes) -alex_action_3 = tok (eitherResIdent T_Function) -alex_action_4 = tok (eitherResIdent T_LabelId) -alex_action_5 = tok (eitherResIdent T_AlphaIndex) -alex_action_6 = tok (eitherResIdent TV) - -#define ALEX_NOPRED 1 --- ----------------------------------------------------------------------------- --- ALEX TEMPLATE --- --- This code is in the PUBLIC DOMAIN; you may copy it freely and use --- it for any purpose whatsoever. - --- ----------------------------------------------------------------------------- --- INTERNALS and main scanner engine - -#ifdef ALEX_GHC -# define ILIT(n) n# -# define IBOX(n) (I# (n)) -# define FAST_INT Int# --- Do not remove this comment. Required to fix CPP parsing when using GCC and a clang-compiled alex. -# if __GLASGOW_HASKELL__ > 706 -# define GTE(n,m) (tagToEnum# (n >=# m)) -# define EQ(n,m) (tagToEnum# (n ==# m)) -# else -# define GTE(n,m) (n >=# m) -# define EQ(n,m) (n ==# m) -# endif -# define PLUS(n,m) (n +# m) -# define MINUS(n,m) (n -# m) -# define TIMES(n,m) (n *# m) -# define NEGATE(n) (negateInt# (n)) -# define IF_GHC(x) (x) -#else -# define ILIT(n) (n) -# define IBOX(n) (n) -# define FAST_INT Int -# define GTE(n,m) (n >= m) -# define EQ(n,m) (n == m) -# define PLUS(n,m) (n + m) -# define MINUS(n,m) (n - m) -# define TIMES(n,m) (n * m) -# define NEGATE(n) (negate (n)) -# define IF_GHC(x) -#endif - -#ifdef ALEX_GHC -data AlexAddr = AlexA# Addr# --- Do not remove this comment. Required to fix CPP parsing when using GCC and a clang-compiled alex. -#if __GLASGOW_HASKELL__ < 503 -uncheckedShiftL# = shiftL# -#endif - -{-# INLINE alexIndexInt16OffAddr #-} -alexIndexInt16OffAddr :: AlexAddr -> Int# -> Int# -alexIndexInt16OffAddr (AlexA# arr) off = -#ifdef WORDS_BIGENDIAN - narrow16Int# i - where - i = word2Int# ((high `uncheckedShiftL#` 8#) `or#` low) - high = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#))) - low = int2Word# (ord# (indexCharOffAddr# arr off')) - off' = off *# 2# -#else -#if __GLASGOW_HASKELL__ >= 901 - int16ToInt# -#endif - (indexInt16OffAddr# arr off) -#endif -#else -alexIndexInt16OffAddr arr off = arr ! off -#endif - -#ifdef ALEX_GHC -{-# INLINE alexIndexInt32OffAddr #-} -alexIndexInt32OffAddr :: AlexAddr -> Int# -> Int# -alexIndexInt32OffAddr (AlexA# arr) off = -#ifdef WORDS_BIGENDIAN - narrow32Int# i - where - i = word2Int# ((b3 `uncheckedShiftL#` 24#) `or#` - (b2 `uncheckedShiftL#` 16#) `or#` - (b1 `uncheckedShiftL#` 8#) `or#` b0) - b3 = int2Word# (ord# (indexCharOffAddr# arr (off' +# 3#))) - b2 = int2Word# (ord# (indexCharOffAddr# arr (off' +# 2#))) - b1 = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#))) - b0 = int2Word# (ord# (indexCharOffAddr# arr off')) - off' = off *# 4# -#else -#if __GLASGOW_HASKELL__ >= 901 - int32ToInt# -#endif - (indexInt32OffAddr# arr off) -#endif -#else -alexIndexInt32OffAddr arr off = arr ! off -#endif - -#ifdef ALEX_GHC - -#if __GLASGOW_HASKELL__ < 503 -quickIndex arr i = arr ! i -#else --- GHC >= 503, unsafeAt is available from Data.Array.Base. -quickIndex = unsafeAt -#endif -#else -quickIndex arr i = arr ! i -#endif - --- ----------------------------------------------------------------------------- --- Main lexing routines - -data AlexReturn a - = AlexEOF - | AlexError !AlexInput - | AlexSkip !AlexInput !Int - | AlexToken !AlexInput !Int a - --- alexScan :: AlexInput -> StartCode -> AlexReturn a -alexScan input__ IBOX(sc) - = alexScanUser undefined input__ IBOX(sc) - -alexScanUser user__ input__ IBOX(sc) - = case alex_scan_tkn user__ input__ ILIT(0) input__ sc AlexNone of - (AlexNone, input__') -> - case alexGetByte input__ of - Nothing -> -#ifdef ALEX_DEBUG - trace ("End of input.") $ -#endif - AlexEOF - Just _ -> -#ifdef ALEX_DEBUG - trace ("Error.") $ -#endif - AlexError input__' - - (AlexLastSkip input__'' len, _) -> -#ifdef ALEX_DEBUG - trace ("Skipping.") $ -#endif - AlexSkip input__'' len - - (AlexLastAcc k input__''' len, _) -> -#ifdef ALEX_DEBUG - trace ("Accept.") $ -#endif - AlexToken input__''' len (alex_actions ! k) - - --- Push the input through the DFA, remembering the most recent accepting --- state it encountered. - -alex_scan_tkn user__ orig_input len input__ s last_acc = - input__ `seq` -- strict in the input - let - new_acc = (check_accs (alex_accept `quickIndex` IBOX(s))) - in - new_acc `seq` - case alexGetByte input__ of - Nothing -> (new_acc, input__) - Just (c, new_input) -> -#ifdef ALEX_DEBUG - trace ("State: " ++ show IBOX(s) ++ ", char: " ++ show c) $ -#endif - case fromIntegral c of { IBOX(ord_c) -> - let - base = alexIndexInt32OffAddr alex_base s - offset = PLUS(base,ord_c) - check = alexIndexInt16OffAddr alex_check offset - - new_s = if GTE(offset,ILIT(0)) && EQ(check,ord_c) - then alexIndexInt16OffAddr alex_table offset - else alexIndexInt16OffAddr alex_deflt s - in - case new_s of - ILIT(-1) -> (new_acc, input__) - -- on an error, we want to keep the input *before* the - -- character that failed, not after. - _ -> alex_scan_tkn user__ orig_input -#ifdef ALEX_LATIN1 - PLUS(len,ILIT(1)) - -- issue 119: in the latin1 encoding, *each* byte is one character -#else - (if c < 0x80 || c >= 0xC0 then PLUS(len,ILIT(1)) else len) - -- note that the length is increased ONLY if this is the 1st byte in a char encoding) -#endif - new_input new_s new_acc - } - where - check_accs (AlexAccNone) = last_acc - check_accs (AlexAcc a ) = AlexLastAcc a input__ IBOX(len) - check_accs (AlexAccSkip) = AlexLastSkip input__ IBOX(len) -#ifndef ALEX_NOPRED - check_accs (AlexAccPred a predx rest) - | predx user__ orig_input IBOX(len) input__ - = AlexLastAcc a input__ IBOX(len) - | otherwise - = check_accs rest - check_accs (AlexAccSkipPred predx rest) - | predx user__ orig_input IBOX(len) input__ - = AlexLastSkip input__ IBOX(len) - | otherwise - = check_accs rest -#endif - -data AlexLastAcc - = AlexNone - | AlexLastAcc !Int !AlexInput !Int - | AlexLastSkip !AlexInput !Int - -data AlexAcc user - = AlexAccNone - | AlexAcc Int - | AlexAccSkip -#ifndef ALEX_NOPRED - | AlexAccPred Int (AlexAccPred user) (AlexAcc user) - | AlexAccSkipPred (AlexAccPred user) (AlexAcc user) - -type AlexAccPred user = user -> AlexInput -> Int -> AlexInput -> Bool - --- ----------------------------------------------------------------------------- --- Predicates on a rule - -alexAndPred p1 p2 user__ in1 len in2 - = p1 user__ in1 len in2 && p2 user__ in1 len in2 - ---alexPrevCharIsPred :: Char -> AlexAccPred _ -alexPrevCharIs c _ input__ _ _ = c == alexInputPrevChar input__ - -alexPrevCharMatches f _ input__ _ _ = f (alexInputPrevChar input__) - ---alexPrevCharIsOneOfPred :: Array Char Bool -> AlexAccPred _ -alexPrevCharIsOneOf arr _ input__ _ _ = arr ! alexInputPrevChar input__ - ---alexRightContext :: Int -> AlexAccPred _ -alexRightContext IBOX(sc) user__ _ _ input__ = - case alex_scan_tkn user__ input__ ILIT(0) input__ sc AlexNone of - (AlexNone, _) -> False - _ -> True - -- TODO: there's no need to find the longest - -- match when checking the right context, just - -- the first match will do. -#endif diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.x.bak b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.x.bak deleted file mode 100644 index c120dbf30..000000000 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.x.bak +++ /dev/null @@ -1,264 +0,0 @@ --- -*- haskell -*- File generated by the BNF Converter (bnfc 2.9.5). - --- Lexer definition for use with Alex 3 -{ -{-# OPTIONS -fno-warn-incomplete-patterns #-} -{-# OPTIONS_GHC -w #-} - -{-# LANGUAGE PatternSynonyms #-} - -module Language.EO.Phi.Syntax.Lex where - -import Prelude - -import qualified Data.Bits -import Data.Char (ord) -import Data.Function (on) -import Data.Word (Word8) -} - --- Predefined character classes - -$c = [A-Z\192-\221] # [\215] -- capital isolatin1 letter (215 = \times) FIXME -$s = [a-z\222-\255] # [\247] -- small isolatin1 letter (247 = \div ) FIXME -$l = [$c $s] -- letter -$d = [0-9] -- digit -$i = [$l $d _ '] -- identifier character -$u = [. \n] -- universal: any character - --- Symbols and non-identifier-like reserved words - -@rsyms = \Δ | \λ | \Φ | \ξ | \φ | \ρ | \σ | \ν | \↦ | \∅ | \⤍ | \, | \{ | \} | \. - -:- - --- Whitespace (skipped) -$white+ ; - --- Symbols -@rsyms - { tok (eitherResIdent TV) } - --- token Bytes -\- \- | [0 1 2 3 4 5 6 7 8 9 A B C D E F][0 1 2 3 4 5 6 7 8 9 A B C D E F](\- [0 1 2 3 4 5 6 7 8 9 A B C D E F][0 1 2 3 4 5 6 7 8 9 A B C D E F]) * (\- \-) - { tok (eitherResIdent T_Bytes) } - --- token Function -$c [$u # [\t \n \r \ \! \' \( \) \, \- \. \: \; \? \[ \] \{ \| \} \⟦ \⟧]] * - { tok (eitherResIdent T_Function) } - --- token LabelId -$s [$u # [\t \n \r \ \! \' \( \) \, \- \. \: \; \? \[ \] \{ \| \} \⟦ \⟧]] * - { tok (eitherResIdent T_LabelId) } - --- token AlphaIndex -α 0 | α [$d # 0]$d * - { tok (eitherResIdent T_AlphaIndex) } - --- Keywords and Ident -$l $i* - { tok (eitherResIdent TV) } - -{ --- | Create a token with position. -tok :: (String -> Tok) -> (Posn -> String -> Token) -tok f p = PT p . f - --- | Token without position. -data Tok - = TK {-# UNPACK #-} !TokSymbol -- ^ Reserved word or symbol. - | TL !String -- ^ String literal. - | TI !String -- ^ Integer literal. - | TV !String -- ^ Identifier. - | TD !String -- ^ Float literal. - | TC !String -- ^ Character literal. - | T_Bytes !String - | T_Function !String - | T_LabelId !String - | T_AlphaIndex !String - deriving (Eq, Show, Ord) - --- | Smart constructor for 'Tok' for the sake of backwards compatibility. -pattern TS :: String -> Int -> Tok -pattern TS t i = TK (TokSymbol t i) - --- | Keyword or symbol tokens have a unique ID. -data TokSymbol = TokSymbol - { tsText :: String - -- ^ Keyword or symbol text. - , tsID :: !Int - -- ^ Unique ID. - } deriving (Show) - --- | Keyword/symbol equality is determined by the unique ID. -instance Eq TokSymbol where (==) = (==) `on` tsID - --- | Keyword/symbol ordering is determined by the unique ID. -instance Ord TokSymbol where compare = compare `on` tsID - --- | Token with position. -data Token - = PT Posn Tok - | Err Posn - deriving (Eq, Show, Ord) - --- | Pretty print a position. -printPosn :: Posn -> String -printPosn (Pn _ l c) = "line " ++ show l ++ ", column " ++ show c - --- | Pretty print the position of the first token in the list. -tokenPos :: [Token] -> String -tokenPos (t:_) = printPosn (tokenPosn t) -tokenPos [] = "end of file" - --- | Get the position of a token. -tokenPosn :: Token -> Posn -tokenPosn (PT p _) = p -tokenPosn (Err p) = p - --- | Get line and column of a token. -tokenLineCol :: Token -> (Int, Int) -tokenLineCol = posLineCol . tokenPosn - --- | Get line and column of a position. -posLineCol :: Posn -> (Int, Int) -posLineCol (Pn _ l c) = (l,c) - --- | Convert a token into "position token" form. -mkPosToken :: Token -> ((Int, Int), String) -mkPosToken t = (tokenLineCol t, tokenText t) - --- | Convert a token to its text. -tokenText :: Token -> String -tokenText t = case t of - PT _ (TS s _) -> s - PT _ (TL s) -> show s - PT _ (TI s) -> s - PT _ (TV s) -> s - PT _ (TD s) -> s - PT _ (TC s) -> s - Err _ -> "#error" - PT _ (T_Bytes s) -> s - PT _ (T_Function s) -> s - PT _ (T_LabelId s) -> s - PT _ (T_AlphaIndex s) -> s - --- | Convert a token to a string. -prToken :: Token -> String -prToken t = tokenText t - --- | Finite map from text to token organized as binary search tree. -data BTree - = N -- ^ Nil (leaf). - | B String Tok BTree BTree - -- ^ Binary node. - deriving (Show) - --- | Convert potential keyword into token or use fallback conversion. -eitherResIdent :: (String -> Tok) -> String -> Tok -eitherResIdent tv s = treeFind resWords - where - treeFind N = tv s - treeFind (B a t left right) = - case compare s a of - LT -> treeFind left - GT -> treeFind right - EQ -> t - --- | The keywords and symbols of the language organized as binary search tree. -resWords :: BTree -resWords = - b "\957" 8 - (b "}" 4 - (b "." 2 (b "," 1 N N) (b "{" 3 N N)) - (b "\934" 6 (b "\916" 5 N N) (b "\955" 7 N N))) - (b "\966" 12 - (b "\961" 10 (b "\958" 9 N N) (b "\963" 11 N N)) - (b "\8709" 14 (b "\8614" 13 N N) (b "\10509" 15 N N))) - where - b s n = B bs (TS bs n) - where - bs = s - --- | Unquote string literal. -unescapeInitTail :: String -> String -unescapeInitTail = id . unesc . tail . id - where - unesc s = case s of - '\\':c:cs | elem c ['\"', '\\', '\''] -> c : unesc cs - '\\':'n':cs -> '\n' : unesc cs - '\\':'t':cs -> '\t' : unesc cs - '\\':'r':cs -> '\r' : unesc cs - '\\':'f':cs -> '\f' : unesc cs - '"':[] -> [] - c:cs -> c : unesc cs - _ -> [] - -------------------------------------------------------------------- --- Alex wrapper code. --- A modified "posn" wrapper. -------------------------------------------------------------------- - -data Posn = Pn !Int !Int !Int - deriving (Eq, Show, Ord) - -alexStartPos :: Posn -alexStartPos = Pn 0 1 1 - -alexMove :: Posn -> Char -> Posn -alexMove (Pn a l c) '\t' = Pn (a+1) l (((c+7) `div` 8)*8+1) -alexMove (Pn a l c) '\n' = Pn (a+1) (l+1) 1 -alexMove (Pn a l c) _ = Pn (a+1) l (c+1) - -type Byte = Word8 - -type AlexInput = (Posn, -- current position, - Char, -- previous char - [Byte], -- pending bytes on the current char - String) -- current input string - -tokens :: String -> [Token] -tokens str = go (alexStartPos, '\n', [], str) - where - go :: AlexInput -> [Token] - go inp@(pos, _, _, str) = - case alexScan inp 0 of - AlexEOF -> [] - AlexError (pos, _, _, _) -> [Err pos] - AlexSkip inp' len -> go inp' - AlexToken inp' len act -> act pos (take len str) : (go inp') - -alexGetByte :: AlexInput -> Maybe (Byte,AlexInput) -alexGetByte (p, c, (b:bs), s) = Just (b, (p, c, bs, s)) -alexGetByte (p, _, [], s) = - case s of - [] -> Nothing - (c:s) -> - let p' = alexMove p c - (b:bs) = utf8Encode c - in p' `seq` Just (b, (p', c, bs, s)) - -alexInputPrevChar :: AlexInput -> Char -alexInputPrevChar (p, c, bs, s) = c - --- | Encode a Haskell String to a list of Word8 values, in UTF8 format. -utf8Encode :: Char -> [Word8] -utf8Encode = map fromIntegral . go . ord - where - go oc - | oc <= 0x7f = [oc] - - | oc <= 0x7ff = [ 0xc0 + (oc `Data.Bits.shiftR` 6) - , 0x80 + oc Data.Bits..&. 0x3f - ] - - | oc <= 0xffff = [ 0xe0 + (oc `Data.Bits.shiftR` 12) - , 0x80 + ((oc `Data.Bits.shiftR` 6) Data.Bits..&. 0x3f) - , 0x80 + oc Data.Bits..&. 0x3f - ] - | otherwise = [ 0xf0 + (oc `Data.Bits.shiftR` 18) - , 0x80 + ((oc `Data.Bits.shiftR` 12) Data.Bits..&. 0x3f) - , 0x80 + ((oc `Data.Bits.shiftR` 6) Data.Bits..&. 0x3f) - , 0x80 + oc Data.Bits..&. 0x3f - ] -} diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.hs b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.hs deleted file mode 100644 index 3a7ccef30..000000000 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.hs +++ /dev/null @@ -1,1523 +0,0 @@ -{-# OPTIONS_GHC -w #-} -{-# OPTIONS_GHC -fno-warn-incomplete-patterns -fno-warn-overlapping-patterns #-} -{-# LANGUAGE PatternSynonyms #-} - -module Language.EO.Phi.Syntax.Par - ( happyError - , myLexer - , pProgram - , pObject - , pAbstractObject - , pDispatchedObject - , pBinding - , pListBinding - , pBindings - , pListBindings - , pDispatch - , pAttribute - , pListAttribute - , pDisp - , pListDisp - ) where - -import Prelude - -import qualified Language.EO.Phi.Syntax.Abs -import Language.EO.Phi.Syntax.Lex -import qualified Data.Array as Happy_Data_Array -import qualified Data.Bits as Bits -import Control.Applicative(Applicative(..)) -import Control.Monad (ap) - --- parser produced by Happy Version 1.20.1.1 - -data HappyAbsSyn - = HappyTerminal (Token) - | HappyErrorToken Prelude.Int - | HappyAbsSyn16 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Bytes)) - | HappyAbsSyn17 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Function)) - | HappyAbsSyn18 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.LabelId)) - | HappyAbsSyn19 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.AlphaIndex)) - | HappyAbsSyn20 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Program)) - | HappyAbsSyn21 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Object)) - | HappyAbsSyn22 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.AbstractObject)) - | HappyAbsSyn23 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.DispatchedObject)) - | HappyAbsSyn24 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Binding)) - | HappyAbsSyn25 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, [Language.EO.Phi.Syntax.Abs.Binding])) - | HappyAbsSyn26 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Bindings)) - | HappyAbsSyn27 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, [Language.EO.Phi.Syntax.Abs.Bindings])) - | HappyAbsSyn28 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Dispatch)) - | HappyAbsSyn29 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Attribute)) - | HappyAbsSyn30 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, [Language.EO.Phi.Syntax.Abs.Attribute])) - | HappyAbsSyn31 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Disp)) - | HappyAbsSyn32 ((Language.EO.Phi.Syntax.Abs.BNFC'Position, [Language.EO.Phi.Syntax.Abs.Disp])) - -{- to allow type-synonyms as our monads (likely - - with explicitly-specified bind and return) - - in Haskell98, it seems that with - - /type M a = .../, then /(HappyReduction M)/ - - is not allowed. But Happy is a - - code-generator that can just substitute it. -type HappyReduction m = - Prelude.Int - -> (Token) - -> HappyState (Token) (HappyStk HappyAbsSyn -> [(Token)] -> m HappyAbsSyn) - -> [HappyState (Token) (HappyStk HappyAbsSyn -> [(Token)] -> m HappyAbsSyn)] - -> HappyStk HappyAbsSyn - -> [(Token)] -> m HappyAbsSyn --} - -action_0, - action_1, - action_2, - action_3, - action_4, - action_5, - action_6, - action_7, - action_8, - action_9, - action_10, - action_11, - action_12, - action_13, - action_14, - action_15, - action_16, - action_17, - action_18, - action_19, - action_20, - action_21, - action_22, - action_23, - action_24, - action_25, - action_26, - action_27, - action_28, - action_29, - action_30, - action_31, - action_32, - action_33, - action_34, - action_35, - action_36, - action_37, - action_38, - action_39, - action_40, - action_41, - action_42, - action_43, - action_44, - action_45, - action_46, - action_47, - action_48, - action_49, - action_50, - action_51, - action_52, - action_53, - action_54, - action_55, - action_56, - action_57, - action_58, - action_59, - action_60, - action_61, - action_62, - action_63, - action_64, - action_65, - action_66, - action_67, - action_68, - action_69, - action_70, - action_71, - action_72, - action_73, - action_74, - action_75, - action_76, - action_77, - action_78, - action_79, - action_80, - action_81, - action_82, - action_83, - action_84, - action_85, - action_86, - action_87, - action_88, - action_89, - action_90, - action_91, - action_92, - action_93, - action_94, - action_95, - action_96, - action_97, - action_98 :: () => Prelude.Int -> ({-HappyReduction (Err) = -} - Prelude.Int - -> (Token) - -> HappyState (Token) (HappyStk HappyAbsSyn -> [(Token)] -> (Err) HappyAbsSyn) - -> [HappyState (Token) (HappyStk HappyAbsSyn -> [(Token)] -> (Err) HappyAbsSyn)] - -> HappyStk HappyAbsSyn - -> [(Token)] -> (Err) HappyAbsSyn) - -happyReduce_13, - happyReduce_14, - happyReduce_15, - happyReduce_16, - happyReduce_17, - happyReduce_18, - happyReduce_19, - happyReduce_20, - happyReduce_21, - happyReduce_22, - happyReduce_23, - happyReduce_24, - happyReduce_25, - happyReduce_26, - happyReduce_27, - happyReduce_28, - happyReduce_29, - happyReduce_30, - happyReduce_31, - happyReduce_32, - happyReduce_33, - happyReduce_34, - happyReduce_35, - happyReduce_36, - happyReduce_37, - happyReduce_38, - happyReduce_39, - happyReduce_40, - happyReduce_41, - happyReduce_42, - happyReduce_43, - happyReduce_44, - happyReduce_45, - happyReduce_46, - happyReduce_47, - happyReduce_48, - happyReduce_49, - happyReduce_50 :: () => ({-HappyReduction (Err) = -} - Prelude.Int - -> (Token) - -> HappyState (Token) (HappyStk HappyAbsSyn -> [(Token)] -> (Err) HappyAbsSyn) - -> [HappyState (Token) (HappyStk HappyAbsSyn -> [(Token)] -> (Err) HappyAbsSyn)] - -> HappyStk HappyAbsSyn - -> [(Token)] -> (Err) HappyAbsSyn) - -happyExpList :: Happy_Data_Array.Array Prelude.Int Prelude.Int -happyExpList = Happy_Data_Array.listArray (0,215) ([0,0,4,0,0,9344,8,0,36864,260,0,0,8194,0,0,60672,192,0,40960,6173,0,0,1,0,0,32,0,0,9216,65,0,0,33232,1,0,14848,48,0,512,0,0,16384,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,55808,385,0,0,0,0,0,0,0,0,0,0,0,1024,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,256,0,0,0,0,0,0,3792,12,0,64,0,0,2048,0,0,0,0,0,0,64,0,0,0,0,0,0,948,3,0,0,0,0,256,0,0,0,0,0,0,16384,0,0,0,64,0,0,2048,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55808,385,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,948,3,0,0,0,0,0,0,0,0,33242,1,0,32,0,0,1024,0,0,0,49389,0,0,16,0,0,0,0,0,0,2048,0,0,24868,0,0,55808,385,0,8192,0,0,0,0,0,0,59392,192,0,0,6173,0,0,2,0,0,16,0,0,32768,3086,0,0,1,0,0,0,0,0,512,0,0,0,0,0,0,7424,24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,0,128,0,0,0,24692,0,0,0,0,0,0,0,0,0,0,0 - ]) - -{-# NOINLINE happyExpListPerState #-} -happyExpListPerState st = - token_strs_expected - where token_strs = ["error","%dummy","%start_pProgram_internal","%start_pObject_internal","%start_pAbstractObject_internal","%start_pDispatchedObject_internal","%start_pBinding_internal","%start_pListBinding_internal","%start_pBindings_internal","%start_pListBindings_internal","%start_pDispatch_internal","%start_pAttribute_internal","%start_pListAttribute_internal","%start_pDisp_internal","%start_pListDisp_internal","Bytes","Function","LabelId","AlphaIndex","Program","Object","AbstractObject","DispatchedObject","Binding","ListBinding","Bindings","ListBindings","Dispatch","Attribute","ListAttribute","Disp","ListDisp","','","'.'","'{'","'}'","'\916'","'\934'","'\955'","'\957'","'\958'","'\961'","'\963'","'\966'","'\8614'","'\8709'","'\8869'","'\10509'","L_Bytes","L_Function","L_LabelId","L_AlphaIndex","%eof"] - bit_start = st Prelude.* 53 - bit_end = (st Prelude.+ 1) Prelude.* 53 - read_bit = readArrayBit happyExpList - bits = Prelude.map read_bit [bit_start..bit_end Prelude.- 1] - bits_indexed = Prelude.zip bits [0..52] - token_strs_expected = Prelude.concatMap f bits_indexed - f (Prelude.False, _) = [] - f (Prelude.True, nr) = [token_strs Prelude.!! nr] - -action_0 (35) = happyShift action_57 -action_0 (20) = happyGoto action_56 -action_0 _ = happyFail (happyExpListPerState 0) - -action_1 (35) = happyShift action_54 -action_1 (38) = happyShift action_33 -action_1 (41) = happyShift action_34 -action_1 (47) = happyShift action_55 -action_1 (21) = happyGoto action_51 -action_1 (22) = happyGoto action_52 -action_1 (23) = happyGoto action_30 -action_1 (28) = happyGoto action_53 -action_1 _ = happyFail (happyExpListPerState 1) - -action_2 (35) = happyShift action_49 -action_2 (38) = happyShift action_33 -action_2 (41) = happyShift action_34 -action_2 (47) = happyShift action_50 -action_2 (22) = happyGoto action_47 -action_2 (23) = happyGoto action_30 -action_2 (28) = happyGoto action_48 -action_2 _ = happyFail (happyExpListPerState 2) - -action_3 (35) = happyShift action_32 -action_3 (47) = happyShift action_35 -action_3 (23) = happyGoto action_46 -action_3 _ = happyFail (happyExpListPerState 3) - -action_4 (37) = happyShift action_43 -action_4 (39) = happyShift action_44 -action_4 (40) = happyShift action_23 -action_4 (42) = happyShift action_24 -action_4 (43) = happyShift action_25 -action_4 (44) = happyShift action_26 -action_4 (51) = happyShift action_27 -action_4 (52) = happyShift action_28 -action_4 (18) = happyGoto action_19 -action_4 (19) = happyGoto action_20 -action_4 (24) = happyGoto action_45 -action_4 (29) = happyGoto action_42 -action_4 _ = happyFail (happyExpListPerState 4) - -action_5 (37) = happyShift action_43 -action_5 (39) = happyShift action_44 -action_5 (40) = happyShift action_23 -action_5 (42) = happyShift action_24 -action_5 (43) = happyShift action_25 -action_5 (44) = happyShift action_26 -action_5 (51) = happyShift action_27 -action_5 (52) = happyShift action_28 -action_5 (18) = happyGoto action_19 -action_5 (19) = happyGoto action_20 -action_5 (24) = happyGoto action_40 -action_5 (25) = happyGoto action_41 -action_5 (29) = happyGoto action_42 -action_5 _ = happyReduce_31 - -action_6 (35) = happyShift action_38 -action_6 (26) = happyGoto action_39 -action_6 _ = happyFail (happyExpListPerState 6) - -action_7 (35) = happyShift action_38 -action_7 (26) = happyGoto action_36 -action_7 (27) = happyGoto action_37 -action_7 _ = happyReduce_35 - -action_8 (35) = happyShift action_32 -action_8 (38) = happyShift action_33 -action_8 (41) = happyShift action_34 -action_8 (47) = happyShift action_35 -action_8 (23) = happyGoto action_30 -action_8 (28) = happyGoto action_31 -action_8 _ = happyFail (happyExpListPerState 8) - -action_9 (40) = happyShift action_23 -action_9 (42) = happyShift action_24 -action_9 (43) = happyShift action_25 -action_9 (44) = happyShift action_26 -action_9 (51) = happyShift action_27 -action_9 (52) = happyShift action_28 -action_9 (18) = happyGoto action_19 -action_9 (19) = happyGoto action_20 -action_9 (29) = happyGoto action_29 -action_9 _ = happyFail (happyExpListPerState 9) - -action_10 (40) = happyShift action_23 -action_10 (42) = happyShift action_24 -action_10 (43) = happyShift action_25 -action_10 (44) = happyShift action_26 -action_10 (51) = happyShift action_27 -action_10 (52) = happyShift action_28 -action_10 (18) = happyGoto action_19 -action_10 (19) = happyGoto action_20 -action_10 (29) = happyGoto action_21 -action_10 (30) = happyGoto action_22 -action_10 _ = happyFail (happyExpListPerState 10) - -action_11 (35) = happyShift action_17 -action_11 (31) = happyGoto action_18 -action_11 _ = happyFail (happyExpListPerState 11) - -action_12 (35) = happyShift action_17 -action_12 (31) = happyGoto action_15 -action_12 (32) = happyGoto action_16 -action_12 _ = happyReduce_49 - -action_13 (49) = happyShift action_14 -action_13 _ = happyFail (happyExpListPerState 13) - -action_14 _ = happyReduce_13 - -action_15 (35) = happyShift action_17 -action_15 (31) = happyGoto action_15 -action_15 (32) = happyGoto action_74 -action_15 _ = happyReduce_49 - -action_16 (53) = happyAccept -action_16 _ = happyFail (happyExpListPerState 16) - -action_17 (37) = happyShift action_43 -action_17 (39) = happyShift action_44 -action_17 (40) = happyShift action_23 -action_17 (42) = happyShift action_24 -action_17 (43) = happyShift action_25 -action_17 (44) = happyShift action_26 -action_17 (51) = happyShift action_27 -action_17 (52) = happyShift action_28 -action_17 (18) = happyGoto action_19 -action_17 (19) = happyGoto action_20 -action_17 (24) = happyGoto action_40 -action_17 (25) = happyGoto action_73 -action_17 (29) = happyGoto action_42 -action_17 _ = happyReduce_31 - -action_18 (53) = happyAccept -action_18 _ = happyFail (happyExpListPerState 18) - -action_19 _ = happyReduce_44 - -action_20 _ = happyReduce_45 - -action_21 (34) = happyShift action_72 -action_21 _ = happyReduce_46 - -action_22 (53) = happyAccept -action_22 _ = happyFail (happyExpListPerState 22) - -action_23 _ = happyReduce_43 - -action_24 _ = happyReduce_41 - -action_25 _ = happyReduce_42 - -action_26 _ = happyReduce_40 - -action_27 _ = happyReduce_15 - -action_28 _ = happyReduce_16 - -action_29 (53) = happyAccept -action_29 _ = happyFail (happyExpListPerState 29) - -action_30 (35) = happyShift action_38 -action_30 (26) = happyGoto action_36 -action_30 (27) = happyGoto action_71 -action_30 _ = happyReduce_35 - -action_31 (53) = happyAccept -action_31 _ = happyFail (happyExpListPerState 31) - -action_32 (37) = happyShift action_43 -action_32 (39) = happyShift action_44 -action_32 (40) = happyShift action_23 -action_32 (42) = happyShift action_24 -action_32 (43) = happyShift action_25 -action_32 (44) = happyShift action_26 -action_32 (51) = happyShift action_27 -action_32 (52) = happyShift action_28 -action_32 (18) = happyGoto action_19 -action_32 (19) = happyGoto action_20 -action_32 (24) = happyGoto action_40 -action_32 (25) = happyGoto action_70 -action_32 (29) = happyGoto action_42 -action_32 _ = happyReduce_31 - -action_33 (34) = happyShift action_69 -action_33 _ = happyFail (happyExpListPerState 33) - -action_34 (34) = happyShift action_68 -action_34 _ = happyFail (happyExpListPerState 34) - -action_35 _ = happyReduce_26 - -action_36 (35) = happyShift action_38 -action_36 (26) = happyGoto action_36 -action_36 (27) = happyGoto action_67 -action_36 _ = happyReduce_35 - -action_37 (53) = happyAccept -action_37 _ = happyFail (happyExpListPerState 37) - -action_38 (37) = happyShift action_43 -action_38 (39) = happyShift action_44 -action_38 (40) = happyShift action_23 -action_38 (42) = happyShift action_24 -action_38 (43) = happyShift action_25 -action_38 (44) = happyShift action_26 -action_38 (51) = happyShift action_27 -action_38 (52) = happyShift action_28 -action_38 (18) = happyGoto action_19 -action_38 (19) = happyGoto action_20 -action_38 (24) = happyGoto action_40 -action_38 (25) = happyGoto action_66 -action_38 (29) = happyGoto action_42 -action_38 _ = happyReduce_31 - -action_39 (53) = happyAccept -action_39 _ = happyFail (happyExpListPerState 39) - -action_40 (33) = happyShift action_65 -action_40 _ = happyReduce_32 - -action_41 (53) = happyAccept -action_41 _ = happyFail (happyExpListPerState 41) - -action_42 (45) = happyShift action_64 -action_42 _ = happyFail (happyExpListPerState 42) - -action_43 (48) = happyShift action_63 -action_43 _ = happyFail (happyExpListPerState 43) - -action_44 (48) = happyShift action_62 -action_44 _ = happyFail (happyExpListPerState 44) - -action_45 (53) = happyAccept -action_45 _ = happyFail (happyExpListPerState 45) - -action_46 (53) = happyAccept -action_46 _ = happyFail (happyExpListPerState 46) - -action_47 (53) = happyAccept -action_47 _ = happyFail (happyExpListPerState 47) - -action_48 _ = happyReduce_23 - -action_49 (37) = happyShift action_43 -action_49 (39) = happyShift action_44 -action_49 (40) = happyShift action_23 -action_49 (42) = happyShift action_24 -action_49 (43) = happyShift action_25 -action_49 (44) = happyShift action_26 -action_49 (51) = happyShift action_27 -action_49 (52) = happyShift action_28 -action_49 (18) = happyGoto action_19 -action_49 (19) = happyGoto action_20 -action_49 (24) = happyGoto action_40 -action_49 (25) = happyGoto action_61 -action_49 (29) = happyGoto action_42 -action_49 _ = happyReduce_31 - -action_50 (53) = happyReduce_24 -action_50 _ = happyReduce_26 - -action_51 (53) = happyAccept -action_51 _ = happyFail (happyExpListPerState 51) - -action_52 (35) = happyShift action_60 -action_52 _ = happyFail (happyExpListPerState 52) - -action_53 (35) = happyReduce_23 -action_53 _ = happyReduce_20 - -action_54 (37) = happyShift action_43 -action_54 (39) = happyShift action_44 -action_54 (40) = happyShift action_23 -action_54 (42) = happyShift action_24 -action_54 (43) = happyShift action_25 -action_54 (44) = happyShift action_26 -action_54 (51) = happyShift action_27 -action_54 (52) = happyShift action_28 -action_54 (18) = happyGoto action_19 -action_54 (19) = happyGoto action_20 -action_54 (24) = happyGoto action_40 -action_54 (25) = happyGoto action_59 -action_54 (29) = happyGoto action_42 -action_54 _ = happyReduce_31 - -action_55 (34) = happyReduce_26 -action_55 (35) = happyReduce_26 -action_55 _ = happyReduce_21 - -action_56 (53) = happyAccept -action_56 _ = happyFail (happyExpListPerState 56) - -action_57 (37) = happyShift action_43 -action_57 (39) = happyShift action_44 -action_57 (40) = happyShift action_23 -action_57 (42) = happyShift action_24 -action_57 (43) = happyShift action_25 -action_57 (44) = happyShift action_26 -action_57 (51) = happyShift action_27 -action_57 (52) = happyShift action_28 -action_57 (18) = happyGoto action_19 -action_57 (19) = happyGoto action_20 -action_57 (24) = happyGoto action_40 -action_57 (25) = happyGoto action_58 -action_57 (29) = happyGoto action_42 -action_57 _ = happyReduce_31 - -action_58 (36) = happyShift action_89 -action_58 _ = happyFail (happyExpListPerState 58) - -action_59 (36) = happyShift action_88 -action_59 _ = happyFail (happyExpListPerState 59) - -action_60 (37) = happyShift action_43 -action_60 (39) = happyShift action_44 -action_60 (40) = happyShift action_23 -action_60 (42) = happyShift action_24 -action_60 (43) = happyShift action_25 -action_60 (44) = happyShift action_26 -action_60 (51) = happyShift action_27 -action_60 (52) = happyShift action_28 -action_60 (18) = happyGoto action_19 -action_60 (19) = happyGoto action_20 -action_60 (24) = happyGoto action_40 -action_60 (25) = happyGoto action_87 -action_60 (29) = happyGoto action_42 -action_60 _ = happyReduce_31 - -action_61 (36) = happyShift action_86 -action_61 _ = happyFail (happyExpListPerState 61) - -action_62 _ = happyReduce_30 - -action_63 (49) = happyShift action_14 -action_63 (16) = happyGoto action_85 -action_63 _ = happyFail (happyExpListPerState 63) - -action_64 (35) = happyShift action_54 -action_64 (38) = happyShift action_33 -action_64 (41) = happyShift action_34 -action_64 (46) = happyShift action_84 -action_64 (47) = happyShift action_55 -action_64 (21) = happyGoto action_83 -action_64 (22) = happyGoto action_52 -action_64 (23) = happyGoto action_30 -action_64 (28) = happyGoto action_53 -action_64 _ = happyFail (happyExpListPerState 64) - -action_65 (37) = happyShift action_43 -action_65 (39) = happyShift action_44 -action_65 (40) = happyShift action_23 -action_65 (42) = happyShift action_24 -action_65 (43) = happyShift action_25 -action_65 (44) = happyShift action_26 -action_65 (51) = happyShift action_27 -action_65 (52) = happyShift action_28 -action_65 (18) = happyGoto action_19 -action_65 (19) = happyGoto action_20 -action_65 (24) = happyGoto action_40 -action_65 (25) = happyGoto action_82 -action_65 (29) = happyGoto action_42 -action_65 _ = happyReduce_31 - -action_66 (36) = happyShift action_81 -action_66 _ = happyFail (happyExpListPerState 66) - -action_67 _ = happyReduce_36 - -action_68 (40) = happyShift action_23 -action_68 (42) = happyShift action_24 -action_68 (43) = happyShift action_25 -action_68 (44) = happyShift action_26 -action_68 (51) = happyShift action_27 -action_68 (52) = happyShift action_28 -action_68 (18) = happyGoto action_19 -action_68 (19) = happyGoto action_20 -action_68 (29) = happyGoto action_21 -action_68 (30) = happyGoto action_80 -action_68 _ = happyFail (happyExpListPerState 68) - -action_69 (40) = happyShift action_23 -action_69 (42) = happyShift action_24 -action_69 (43) = happyShift action_25 -action_69 (44) = happyShift action_26 -action_69 (51) = happyShift action_27 -action_69 (52) = happyShift action_28 -action_69 (18) = happyGoto action_19 -action_69 (19) = happyGoto action_20 -action_69 (29) = happyGoto action_21 -action_69 (30) = happyGoto action_79 -action_69 _ = happyFail (happyExpListPerState 69) - -action_70 (36) = happyShift action_78 -action_70 _ = happyFail (happyExpListPerState 70) - -action_71 (34) = happyShift action_77 -action_71 _ = happyFail (happyExpListPerState 71) - -action_72 (40) = happyShift action_23 -action_72 (42) = happyShift action_24 -action_72 (43) = happyShift action_25 -action_72 (44) = happyShift action_26 -action_72 (51) = happyShift action_27 -action_72 (52) = happyShift action_28 -action_72 (18) = happyGoto action_19 -action_72 (19) = happyGoto action_20 -action_72 (29) = happyGoto action_21 -action_72 (30) = happyGoto action_76 -action_72 _ = happyFail (happyExpListPerState 72) - -action_73 (36) = happyShift action_75 -action_73 _ = happyFail (happyExpListPerState 73) - -action_74 _ = happyReduce_50 - -action_75 (35) = happyShift action_38 -action_75 (26) = happyGoto action_94 -action_75 _ = happyFail (happyExpListPerState 75) - -action_76 _ = happyReduce_47 - -action_77 (40) = happyShift action_23 -action_77 (42) = happyShift action_24 -action_77 (43) = happyShift action_25 -action_77 (44) = happyShift action_26 -action_77 (51) = happyShift action_27 -action_77 (52) = happyShift action_28 -action_77 (18) = happyGoto action_19 -action_77 (19) = happyGoto action_20 -action_77 (29) = happyGoto action_21 -action_77 (30) = happyGoto action_93 -action_77 _ = happyFail (happyExpListPerState 77) - -action_78 _ = happyReduce_25 - -action_79 (35) = happyShift action_17 -action_79 (31) = happyGoto action_15 -action_79 (32) = happyGoto action_92 -action_79 _ = happyReduce_49 - -action_80 (35) = happyShift action_17 -action_80 (31) = happyGoto action_15 -action_80 (32) = happyGoto action_91 -action_80 _ = happyReduce_49 - -action_81 _ = happyReduce_34 - -action_82 _ = happyReduce_33 - -action_83 _ = happyReduce_27 - -action_84 _ = happyReduce_28 - -action_85 _ = happyReduce_29 - -action_86 (53) = happyReduce_22 -action_86 _ = happyReduce_25 - -action_87 (36) = happyShift action_90 -action_87 _ = happyFail (happyExpListPerState 87) - -action_88 (34) = happyReduce_25 -action_88 (35) = happyReduce_25 -action_88 _ = happyReduce_18 - -action_89 _ = happyReduce_17 - -action_90 (35) = happyShift action_38 -action_90 (26) = happyGoto action_36 -action_90 (27) = happyGoto action_97 -action_90 _ = happyReduce_35 - -action_91 _ = happyReduce_39 - -action_92 _ = happyReduce_38 - -action_93 (35) = happyShift action_17 -action_93 (31) = happyGoto action_15 -action_93 (32) = happyGoto action_96 -action_93 _ = happyReduce_49 - -action_94 (34) = happyShift action_95 -action_94 _ = happyFail (happyExpListPerState 94) - -action_95 (40) = happyShift action_23 -action_95 (42) = happyShift action_24 -action_95 (43) = happyShift action_25 -action_95 (44) = happyShift action_26 -action_95 (51) = happyShift action_27 -action_95 (52) = happyShift action_28 -action_95 (18) = happyGoto action_19 -action_95 (19) = happyGoto action_20 -action_95 (29) = happyGoto action_21 -action_95 (30) = happyGoto action_98 -action_95 _ = happyFail (happyExpListPerState 95) - -action_96 _ = happyReduce_37 - -action_97 _ = happyReduce_19 - -action_98 _ = happyReduce_48 - -happyReduce_13 = happySpecReduce_1 16 happyReduction_13 -happyReduction_13 (HappyTerminal happy_var_1) - = HappyAbsSyn16 - ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.Bytes (tokenText happy_var_1)) - ) -happyReduction_13 _ = notHappyAtAll - -happyReduce_14 = happySpecReduce_1 17 happyReduction_14 -happyReduction_14 (HappyTerminal happy_var_1) - = HappyAbsSyn17 - ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.Function (tokenText happy_var_1)) - ) -happyReduction_14 _ = notHappyAtAll - -happyReduce_15 = happySpecReduce_1 18 happyReduction_15 -happyReduction_15 (HappyTerminal happy_var_1) - = HappyAbsSyn18 - ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.LabelId (tokenText happy_var_1)) - ) -happyReduction_15 _ = notHappyAtAll - -happyReduce_16 = happySpecReduce_1 19 happyReduction_16 -happyReduction_16 (HappyTerminal happy_var_1) - = HappyAbsSyn19 - ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.AlphaIndex (tokenText happy_var_1)) - ) -happyReduction_16 _ = notHappyAtAll - -happyReduce_17 = happySpecReduce_3 20 happyReduction_17 -happyReduction_17 _ - (HappyAbsSyn25 happy_var_2) - (HappyTerminal happy_var_1) - = HappyAbsSyn20 - ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.Program (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1)) (snd happy_var_2)) - ) -happyReduction_17 _ _ _ = notHappyAtAll - -happyReduce_18 = happySpecReduce_3 21 happyReduction_18 -happyReduction_18 _ - (HappyAbsSyn25 happy_var_2) - (HappyTerminal happy_var_1) - = HappyAbsSyn21 - ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.Formation (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1)) (snd happy_var_2)) - ) -happyReduction_18 _ _ _ = notHappyAtAll - -happyReduce_19 = happyReduce 5 21 happyReduction_19 -happyReduction_19 ((HappyAbsSyn27 happy_var_5) `HappyStk` - _ `HappyStk` - (HappyAbsSyn25 happy_var_3) `HappyStk` - _ `HappyStk` - (HappyAbsSyn22 happy_var_1) `HappyStk` - happyRest) - = HappyAbsSyn21 - ((fst happy_var_1, Language.EO.Phi.Syntax.Abs.Application (fst happy_var_1) (snd happy_var_1) (snd happy_var_3) (snd happy_var_5)) - ) `HappyStk` happyRest - -happyReduce_20 = happySpecReduce_1 21 happyReduction_20 -happyReduction_20 (HappyAbsSyn28 happy_var_1) - = HappyAbsSyn21 - ((fst happy_var_1, Language.EO.Phi.Syntax.Abs.Dispatch (fst happy_var_1) (snd happy_var_1)) - ) -happyReduction_20 _ = notHappyAtAll - -happyReduce_21 = happySpecReduce_1 21 happyReduction_21 -happyReduction_21 (HappyTerminal happy_var_1) - = HappyAbsSyn21 - ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.Termination (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1))) - ) -happyReduction_21 _ = notHappyAtAll - -happyReduce_22 = happySpecReduce_3 22 happyReduction_22 -happyReduction_22 _ - (HappyAbsSyn25 happy_var_2) - (HappyTerminal happy_var_1) - = HappyAbsSyn22 - ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.AbstractFormation (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1)) (snd happy_var_2)) - ) -happyReduction_22 _ _ _ = notHappyAtAll - -happyReduce_23 = happySpecReduce_1 22 happyReduction_23 -happyReduction_23 (HappyAbsSyn28 happy_var_1) - = HappyAbsSyn22 - ((fst happy_var_1, Language.EO.Phi.Syntax.Abs.AbstractDispatch (fst happy_var_1) (snd happy_var_1)) - ) -happyReduction_23 _ = notHappyAtAll - -happyReduce_24 = happySpecReduce_1 22 happyReduction_24 -happyReduction_24 (HappyTerminal happy_var_1) - = HappyAbsSyn22 - ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.AbstractTermination (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1))) - ) -happyReduction_24 _ = notHappyAtAll - -happyReduce_25 = happySpecReduce_3 23 happyReduction_25 -happyReduction_25 _ - (HappyAbsSyn25 happy_var_2) - (HappyTerminal happy_var_1) - = HappyAbsSyn23 - ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.DispatchedFormation (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1)) (snd happy_var_2)) - ) -happyReduction_25 _ _ _ = notHappyAtAll - -happyReduce_26 = happySpecReduce_1 23 happyReduction_26 -happyReduction_26 (HappyTerminal happy_var_1) - = HappyAbsSyn23 - ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.DispatchedTermination (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1))) - ) -happyReduction_26 _ = notHappyAtAll - -happyReduce_27 = happySpecReduce_3 24 happyReduction_27 -happyReduction_27 (HappyAbsSyn21 happy_var_3) - _ - (HappyAbsSyn29 happy_var_1) - = HappyAbsSyn24 - ((fst happy_var_1, Language.EO.Phi.Syntax.Abs.AlphaBinding (fst happy_var_1) (snd happy_var_1) (snd happy_var_3)) - ) -happyReduction_27 _ _ _ = notHappyAtAll - -happyReduce_28 = happySpecReduce_3 24 happyReduction_28 -happyReduction_28 _ - _ - (HappyAbsSyn29 happy_var_1) - = HappyAbsSyn24 - ((fst happy_var_1, Language.EO.Phi.Syntax.Abs.EmptyBinding (fst happy_var_1) (snd happy_var_1)) - ) -happyReduction_28 _ _ _ = notHappyAtAll - -happyReduce_29 = happySpecReduce_3 24 happyReduction_29 -happyReduction_29 (HappyAbsSyn16 happy_var_3) - _ - (HappyTerminal happy_var_1) - = HappyAbsSyn24 - ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.DeltaBinding (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1)) (snd happy_var_3)) - ) -happyReduction_29 _ _ _ = notHappyAtAll - -happyReduce_30 = happySpecReduce_2 24 happyReduction_30 -happyReduction_30 _ - (HappyTerminal happy_var_1) - = HappyAbsSyn24 - ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.LambdaBinding (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1))) - ) -happyReduction_30 _ _ = notHappyAtAll - -happyReduce_31 = happySpecReduce_0 25 happyReduction_31 -happyReduction_31 = HappyAbsSyn25 - ((Language.EO.Phi.Syntax.Abs.BNFC'NoPosition, []) - ) - -happyReduce_32 = happySpecReduce_1 25 happyReduction_32 -happyReduction_32 (HappyAbsSyn24 happy_var_1) - = HappyAbsSyn25 - ((fst happy_var_1, (:[]) (snd happy_var_1)) - ) -happyReduction_32 _ = notHappyAtAll - -happyReduce_33 = happySpecReduce_3 25 happyReduction_33 -happyReduction_33 (HappyAbsSyn25 happy_var_3) - _ - (HappyAbsSyn24 happy_var_1) - = HappyAbsSyn25 - ((fst happy_var_1, (:) (snd happy_var_1) (snd happy_var_3)) - ) -happyReduction_33 _ _ _ = notHappyAtAll - -happyReduce_34 = happySpecReduce_3 26 happyReduction_34 -happyReduction_34 _ - (HappyAbsSyn25 happy_var_2) - (HappyTerminal happy_var_1) - = HappyAbsSyn26 - ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.Bindings (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1)) (snd happy_var_2)) - ) -happyReduction_34 _ _ _ = notHappyAtAll - -happyReduce_35 = happySpecReduce_0 27 happyReduction_35 -happyReduction_35 = HappyAbsSyn27 - ((Language.EO.Phi.Syntax.Abs.BNFC'NoPosition, []) - ) - -happyReduce_36 = happySpecReduce_2 27 happyReduction_36 -happyReduction_36 (HappyAbsSyn27 happy_var_2) - (HappyAbsSyn26 happy_var_1) - = HappyAbsSyn27 - ((fst happy_var_1, (:) (snd happy_var_1) (snd happy_var_2)) - ) -happyReduction_36 _ _ = notHappyAtAll - -happyReduce_37 = happyReduce 5 28 happyReduction_37 -happyReduction_37 ((HappyAbsSyn32 happy_var_5) `HappyStk` - (HappyAbsSyn30 happy_var_4) `HappyStk` - _ `HappyStk` - (HappyAbsSyn27 happy_var_2) `HappyStk` - (HappyAbsSyn23 happy_var_1) `HappyStk` - happyRest) - = HappyAbsSyn28 - ((fst happy_var_1, Language.EO.Phi.Syntax.Abs.ObjectDispatch (fst happy_var_1) (snd happy_var_1) (snd happy_var_2) (snd happy_var_4) (snd happy_var_5)) - ) `HappyStk` happyRest - -happyReduce_38 = happyReduce 4 28 happyReduction_38 -happyReduction_38 ((HappyAbsSyn32 happy_var_4) `HappyStk` - (HappyAbsSyn30 happy_var_3) `HappyStk` - _ `HappyStk` - (HappyTerminal happy_var_1) `HappyStk` - happyRest) - = HappyAbsSyn28 - ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.HomeDispatch (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1)) (snd happy_var_3) (snd happy_var_4)) - ) `HappyStk` happyRest - -happyReduce_39 = happyReduce 4 28 happyReduction_39 -happyReduction_39 ((HappyAbsSyn32 happy_var_4) `HappyStk` - (HappyAbsSyn30 happy_var_3) `HappyStk` - _ `HappyStk` - (HappyTerminal happy_var_1) `HappyStk` - happyRest) - = HappyAbsSyn28 - ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.ThisDispatch (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1)) (snd happy_var_3) (snd happy_var_4)) - ) `HappyStk` happyRest - -happyReduce_40 = happySpecReduce_1 29 happyReduction_40 -happyReduction_40 (HappyTerminal happy_var_1) - = HappyAbsSyn29 - ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.Phi (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1))) - ) -happyReduction_40 _ = notHappyAtAll - -happyReduce_41 = happySpecReduce_1 29 happyReduction_41 -happyReduction_41 (HappyTerminal happy_var_1) - = HappyAbsSyn29 - ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.Rho (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1))) - ) -happyReduction_41 _ = notHappyAtAll - -happyReduce_42 = happySpecReduce_1 29 happyReduction_42 -happyReduction_42 (HappyTerminal happy_var_1) - = HappyAbsSyn29 - ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.Sigma (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1))) - ) -happyReduction_42 _ = notHappyAtAll - -happyReduce_43 = happySpecReduce_1 29 happyReduction_43 -happyReduction_43 (HappyTerminal happy_var_1) - = HappyAbsSyn29 - ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.VTX (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1))) - ) -happyReduction_43 _ = notHappyAtAll - -happyReduce_44 = happySpecReduce_1 29 happyReduction_44 -happyReduction_44 (HappyAbsSyn18 happy_var_1) - = HappyAbsSyn29 - ((fst happy_var_1, Language.EO.Phi.Syntax.Abs.Label (fst happy_var_1) (snd happy_var_1)) - ) -happyReduction_44 _ = notHappyAtAll - -happyReduce_45 = happySpecReduce_1 29 happyReduction_45 -happyReduction_45 (HappyAbsSyn19 happy_var_1) - = HappyAbsSyn29 - ((fst happy_var_1, Language.EO.Phi.Syntax.Abs.Alpha (fst happy_var_1) (snd happy_var_1)) - ) -happyReduction_45 _ = notHappyAtAll - -happyReduce_46 = happySpecReduce_1 30 happyReduction_46 -happyReduction_46 (HappyAbsSyn29 happy_var_1) - = HappyAbsSyn30 - ((fst happy_var_1, (:[]) (snd happy_var_1)) - ) -happyReduction_46 _ = notHappyAtAll - -happyReduce_47 = happySpecReduce_3 30 happyReduction_47 -happyReduction_47 (HappyAbsSyn30 happy_var_3) - _ - (HappyAbsSyn29 happy_var_1) - = HappyAbsSyn30 - ((fst happy_var_1, (:) (snd happy_var_1) (snd happy_var_3)) - ) -happyReduction_47 _ _ _ = notHappyAtAll - -happyReduce_48 = happyReduce 6 31 happyReduction_48 -happyReduction_48 ((HappyAbsSyn30 happy_var_6) `HappyStk` - _ `HappyStk` - (HappyAbsSyn26 happy_var_4) `HappyStk` - _ `HappyStk` - (HappyAbsSyn25 happy_var_2) `HappyStk` - (HappyTerminal happy_var_1) `HappyStk` - happyRest) - = HappyAbsSyn31 - ((uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1), Language.EO.Phi.Syntax.Abs.Disp (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol happy_var_1)) (snd happy_var_2) (snd happy_var_4) (snd happy_var_6)) - ) `HappyStk` happyRest - -happyReduce_49 = happySpecReduce_0 32 happyReduction_49 -happyReduction_49 = HappyAbsSyn32 - ((Language.EO.Phi.Syntax.Abs.BNFC'NoPosition, []) - ) - -happyReduce_50 = happySpecReduce_2 32 happyReduction_50 -happyReduction_50 (HappyAbsSyn32 happy_var_2) - (HappyAbsSyn31 happy_var_1) - = HappyAbsSyn32 - ((fst happy_var_1, (:) (snd happy_var_1) (snd happy_var_2)) - ) -happyReduction_50 _ _ = notHappyAtAll - -happyNewToken action sts stk [] = - action 53 53 notHappyAtAll (HappyState action) sts stk [] - -happyNewToken action sts stk (tk:tks) = - let cont i = action i i tk (HappyState action) sts stk tks in - case tk of { - PT _ (TS _ 1) -> cont 33; - PT _ (TS _ 2) -> cont 34; - PT _ (TS _ 3) -> cont 35; - PT _ (TS _ 4) -> cont 36; - PT _ (TS _ 5) -> cont 37; - PT _ (TS _ 6) -> cont 38; - PT _ (TS _ 7) -> cont 39; - PT _ (TS _ 8) -> cont 40; - PT _ (TS _ 9) -> cont 41; - PT _ (TS _ 10) -> cont 42; - PT _ (TS _ 11) -> cont 43; - PT _ (TS _ 12) -> cont 44; - PT _ (TS _ 13) -> cont 45; - PT _ (TS _ 14) -> cont 46; - PT _ (TS _ 15) -> cont 47; - PT _ (TS _ 16) -> cont 48; - PT _ (T_Bytes _) -> cont 49; - PT _ (T_Function _) -> cont 50; - PT _ (T_LabelId _) -> cont 51; - PT _ (T_AlphaIndex _) -> cont 52; - _ -> happyError' ((tk:tks), []) - } - -happyError_ explist 53 tk tks = happyError' (tks, explist) -happyError_ explist _ tk tks = happyError' ((tk:tks), explist) - -happyThen :: () => Err a -> (a -> Err b) -> Err b -happyThen = ((>>=)) -happyReturn :: () => a -> Err a -happyReturn = (return) -happyThen1 m k tks = ((>>=)) m (\a -> k a tks) -happyReturn1 :: () => a -> b -> Err a -happyReturn1 = \a tks -> (return) a -happyError' :: () => ([(Token)], [Prelude.String]) -> Err a -happyError' = (\(tokens, _) -> happyError tokens) -pProgram_internal tks = happySomeParser where - happySomeParser = happyThen (happyParse action_0 tks) (\x -> case x of {HappyAbsSyn20 z -> happyReturn z; _other -> notHappyAtAll }) - -pObject_internal tks = happySomeParser where - happySomeParser = happyThen (happyParse action_1 tks) (\x -> case x of {HappyAbsSyn21 z -> happyReturn z; _other -> notHappyAtAll }) - -pAbstractObject_internal tks = happySomeParser where - happySomeParser = happyThen (happyParse action_2 tks) (\x -> case x of {HappyAbsSyn22 z -> happyReturn z; _other -> notHappyAtAll }) - -pDispatchedObject_internal tks = happySomeParser where - happySomeParser = happyThen (happyParse action_3 tks) (\x -> case x of {HappyAbsSyn23 z -> happyReturn z; _other -> notHappyAtAll }) - -pBinding_internal tks = happySomeParser where - happySomeParser = happyThen (happyParse action_4 tks) (\x -> case x of {HappyAbsSyn24 z -> happyReturn z; _other -> notHappyAtAll }) - -pListBinding_internal tks = happySomeParser where - happySomeParser = happyThen (happyParse action_5 tks) (\x -> case x of {HappyAbsSyn25 z -> happyReturn z; _other -> notHappyAtAll }) - -pBindings_internal tks = happySomeParser where - happySomeParser = happyThen (happyParse action_6 tks) (\x -> case x of {HappyAbsSyn26 z -> happyReturn z; _other -> notHappyAtAll }) - -pListBindings_internal tks = happySomeParser where - happySomeParser = happyThen (happyParse action_7 tks) (\x -> case x of {HappyAbsSyn27 z -> happyReturn z; _other -> notHappyAtAll }) - -pDispatch_internal tks = happySomeParser where - happySomeParser = happyThen (happyParse action_8 tks) (\x -> case x of {HappyAbsSyn28 z -> happyReturn z; _other -> notHappyAtAll }) - -pAttribute_internal tks = happySomeParser where - happySomeParser = happyThen (happyParse action_9 tks) (\x -> case x of {HappyAbsSyn29 z -> happyReturn z; _other -> notHappyAtAll }) - -pListAttribute_internal tks = happySomeParser where - happySomeParser = happyThen (happyParse action_10 tks) (\x -> case x of {HappyAbsSyn30 z -> happyReturn z; _other -> notHappyAtAll }) - -pDisp_internal tks = happySomeParser where - happySomeParser = happyThen (happyParse action_11 tks) (\x -> case x of {HappyAbsSyn31 z -> happyReturn z; _other -> notHappyAtAll }) - -pListDisp_internal tks = happySomeParser where - happySomeParser = happyThen (happyParse action_12 tks) (\x -> case x of {HappyAbsSyn32 z -> happyReturn z; _other -> notHappyAtAll }) - -happySeq = happyDontSeq - - -type Err = Either String - -happyError :: [Token] -> Err a -happyError ts = Left $ - "syntax error at " ++ tokenPos ts ++ - case ts of - [] -> [] - [Err _] -> " due to lexer error" - t:_ -> " before `" ++ (prToken t) ++ "'" - -myLexer :: String -> [Token] -myLexer = tokens - --- Entrypoints - -pProgram :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Program -pProgram = fmap snd . pProgram_internal - -pObject :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Object -pObject = fmap snd . pObject_internal - -pAbstractObject :: [Token] -> Err Language.EO.Phi.Syntax.Abs.AbstractObject -pAbstractObject = fmap snd . pAbstractObject_internal - -pDispatchedObject :: [Token] -> Err Language.EO.Phi.Syntax.Abs.DispatchedObject -pDispatchedObject = fmap snd . pDispatchedObject_internal - -pBinding :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Binding -pBinding = fmap snd . pBinding_internal - -pListBinding :: [Token] -> Err [Language.EO.Phi.Syntax.Abs.Binding] -pListBinding = fmap snd . pListBinding_internal - -pBindings :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Bindings -pBindings = fmap snd . pBindings_internal - -pListBindings :: [Token] -> Err [Language.EO.Phi.Syntax.Abs.Bindings] -pListBindings = fmap snd . pListBindings_internal - -pDispatch :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Dispatch -pDispatch = fmap snd . pDispatch_internal - -pAttribute :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Attribute -pAttribute = fmap snd . pAttribute_internal - -pListAttribute :: [Token] -> Err [Language.EO.Phi.Syntax.Abs.Attribute] -pListAttribute = fmap snd . pListAttribute_internal - -pDisp :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Disp -pDisp = fmap snd . pDisp_internal - -pListDisp :: [Token] -> Err [Language.EO.Phi.Syntax.Abs.Disp] -pListDisp = fmap snd . pListDisp_internal -{-# LINE 1 "templates/GenericTemplate.hs" #-} --- $Id: GenericTemplate.hs,v 1.26 2005/01/14 14:47:22 simonmar Exp $ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -data Happy_IntList = HappyCons Prelude.Int Happy_IntList - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -infixr 9 `HappyStk` -data HappyStk a = HappyStk a (HappyStk a) - ------------------------------------------------------------------------------ --- starting the parse - -happyParse start_state = happyNewToken start_state notHappyAtAll notHappyAtAll - ------------------------------------------------------------------------------ --- Accepting the parse - --- If the current token is ERROR_TOK, it means we've just accepted a partial --- parse (a %partial parser). We must ignore the saved token on the top of --- the stack in this case. -happyAccept (1) tk st sts (_ `HappyStk` ans `HappyStk` _) = - happyReturn1 ans -happyAccept j tk st sts (HappyStk ans _) = - (happyReturn1 ans) - ------------------------------------------------------------------------------ --- Arrays only: do the next action - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -indexShortOffAddr arr off = arr Happy_Data_Array.! off - - -{-# INLINE happyLt #-} -happyLt x y = (x Prelude.< y) - - - - - - -readArrayBit arr bit = - Bits.testBit (indexShortOffAddr arr (bit `Prelude.div` 16)) (bit `Prelude.mod` 16) - - - - - - ------------------------------------------------------------------------------ --- HappyState data type (not arrays) - - - -newtype HappyState b c = HappyState - (Prelude.Int -> -- token number - Prelude.Int -> -- token number (yes, again) - b -> -- token semantic value - HappyState b c -> -- current state - [HappyState b c] -> -- state stack - c) - - - ------------------------------------------------------------------------------ --- Shifting a token - -happyShift new_state (1) tk st sts stk@(x `HappyStk` _) = - let i = (case x of { HappyErrorToken (i) -> i }) in --- trace "shifting the error token" $ - new_state i i tk (HappyState (new_state)) ((st):(sts)) (stk) - -happyShift new_state i tk st sts stk = - happyNewToken new_state ((st):(sts)) ((HappyTerminal (tk))`HappyStk`stk) - --- happyReduce is specialised for the common cases. - -happySpecReduce_0 i fn (1) tk st sts stk - = happyFail [] (1) tk st sts stk -happySpecReduce_0 nt fn j tk st@((HappyState (action))) sts stk - = action nt j tk st ((st):(sts)) (fn `HappyStk` stk) - -happySpecReduce_1 i fn (1) tk st sts stk - = happyFail [] (1) tk st sts stk -happySpecReduce_1 nt fn j tk _ sts@(((st@(HappyState (action))):(_))) (v1`HappyStk`stk') - = let r = fn v1 in - happySeq r (action nt j tk st sts (r `HappyStk` stk')) - -happySpecReduce_2 i fn (1) tk st sts stk - = happyFail [] (1) tk st sts stk -happySpecReduce_2 nt fn j tk _ ((_):(sts@(((st@(HappyState (action))):(_))))) (v1`HappyStk`v2`HappyStk`stk') - = let r = fn v1 v2 in - happySeq r (action nt j tk st sts (r `HappyStk` stk')) - -happySpecReduce_3 i fn (1) tk st sts stk - = happyFail [] (1) tk st sts stk -happySpecReduce_3 nt fn j tk _ ((_):(((_):(sts@(((st@(HappyState (action))):(_))))))) (v1`HappyStk`v2`HappyStk`v3`HappyStk`stk') - = let r = fn v1 v2 v3 in - happySeq r (action nt j tk st sts (r `HappyStk` stk')) - -happyReduce k i fn (1) tk st sts stk - = happyFail [] (1) tk st sts stk -happyReduce k nt fn j tk st sts stk - = case happyDrop (k Prelude.- ((1) :: Prelude.Int)) sts of - sts1@(((st1@(HappyState (action))):(_))) -> - let r = fn stk in -- it doesn't hurt to always seq here... - happyDoSeq r (action nt j tk st1 sts1 r) - -happyMonadReduce k nt fn (1) tk st sts stk - = happyFail [] (1) tk st sts stk -happyMonadReduce k nt fn j tk st sts stk = - case happyDrop k ((st):(sts)) of - sts1@(((st1@(HappyState (action))):(_))) -> - let drop_stk = happyDropStk k stk in - happyThen1 (fn stk tk) (\r -> action nt j tk st1 sts1 (r `HappyStk` drop_stk)) - -happyMonad2Reduce k nt fn (1) tk st sts stk - = happyFail [] (1) tk st sts stk -happyMonad2Reduce k nt fn j tk st sts stk = - case happyDrop k ((st):(sts)) of - sts1@(((st1@(HappyState (action))):(_))) -> - let drop_stk = happyDropStk k stk - - - - - - _ = nt :: Prelude.Int - new_state = action - - in - happyThen1 (fn stk tk) (\r -> happyNewToken new_state sts1 (r `HappyStk` drop_stk)) - -happyDrop (0) l = l -happyDrop n ((_):(t)) = happyDrop (n Prelude.- ((1) :: Prelude.Int)) t - -happyDropStk (0) l = l -happyDropStk n (x `HappyStk` xs) = happyDropStk (n Prelude.- ((1)::Prelude.Int)) xs - ------------------------------------------------------------------------------ --- Moving to a new state after a reduction - - - - - - - - - -happyGoto action j tk st = action j j tk (HappyState action) - - ------------------------------------------------------------------------------ --- Error recovery (ERROR_TOK is the error token) - --- parse error if we are in recovery and we fail again -happyFail explist (1) tk old_st _ stk@(x `HappyStk` _) = - let i = (case x of { HappyErrorToken (i) -> i }) in --- trace "failing" $ - happyError_ explist i tk - -{- We don't need state discarding for our restricted implementation of - "error". In fact, it can cause some bogus parses, so I've disabled it - for now --SDM - --- discard a state -happyFail ERROR_TOK tk old_st CONS(HAPPYSTATE(action),sts) - (saved_tok `HappyStk` _ `HappyStk` stk) = --- trace ("discarding state, depth " ++ show (length stk)) $ - DO_ACTION(action,ERROR_TOK,tk,sts,(saved_tok`HappyStk`stk)) --} - --- Enter error recovery: generate an error token, --- save the old token and carry on. -happyFail explist i tk (HappyState (action)) sts stk = --- trace "entering error recovery" $ - action (1) (1) tk (HappyState (action)) sts ((HappyErrorToken (i)) `HappyStk` stk) - --- Internal happy errors: - -notHappyAtAll :: a -notHappyAtAll = Prelude.error "Internal Happy error\n" - ------------------------------------------------------------------------------ --- Hack to get the typechecker to accept our action functions - - - - - - - ------------------------------------------------------------------------------ --- Seq-ing. If the --strict flag is given, then Happy emits --- happySeq = happyDoSeq --- otherwise it emits --- happySeq = happyDontSeq - -happyDoSeq, happyDontSeq :: a -> b -> b -happyDoSeq a b = a `Prelude.seq` b -happyDontSeq a b = b - ------------------------------------------------------------------------------ --- Don't inline any functions from the template. GHC has a nasty habit --- of deciding to inline happyGoto everywhere, which increases the size of --- the generated parser quite a bit. - - - - - - - - - -{-# NOINLINE happyShift #-} -{-# NOINLINE happySpecReduce_0 #-} -{-# NOINLINE happySpecReduce_1 #-} -{-# NOINLINE happySpecReduce_2 #-} -{-# NOINLINE happySpecReduce_3 #-} -{-# NOINLINE happyReduce #-} -{-# NOINLINE happyMonadReduce #-} -{-# NOINLINE happyGoto #-} -{-# NOINLINE happyFail #-} - --- end of Happy Template. diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.info b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.info deleted file mode 100644 index 145086b51..000000000 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.info +++ /dev/null @@ -1,1227 +0,0 @@ ------------------------------------------------------------------------------ -Info file generated by Happy Version 1.20.1.1 from Par.y ------------------------------------------------------------------------------ - -state 15 contains 1 shift/reduce conflicts. -state 55 contains 1 reduce/reduce conflicts. -state 79 contains 1 shift/reduce conflicts. -state 80 contains 1 shift/reduce conflicts. -state 88 contains 1 reduce/reduce conflicts. -state 93 contains 1 shift/reduce conflicts. - -rule 14 is unused - -terminal L_Function is unused - ------------------------------------------------------------------------------ -Grammar ------------------------------------------------------------------------------ - %start_pProgram_internal -> Program (0) - %start_pObject_internal -> Object (1) - %start_pAbstractObject_internal -> AbstractObject (2) - %start_pDispatchedObject_internal -> DispatchedObject (3) - %start_pBinding_internal -> Binding (4) - %start_pListBinding_internal -> ListBinding (5) - %start_pBindings_internal -> Bindings (6) - %start_pListBindings_internal -> ListBindings (7) - %start_pDispatch_internal -> Dispatch (8) - %start_pAttribute_internal -> Attribute (9) - %start_pListAttribute_internal -> ListAttribute (10) - %start_pDisp_internal -> Disp (11) - %start_pListDisp_internal -> ListDisp (12) - Bytes -> L_Bytes (13) - Function -> L_Function (14) - LabelId -> L_LabelId (15) - AlphaIndex -> L_AlphaIndex (16) - Program -> '{' ListBinding '}' (17) - Object -> '{' ListBinding '}' (18) - Object -> AbstractObject '{' ListBinding '}' ListBindings (19) - Object -> Dispatch (20) - Object -> '⊥' (21) - AbstractObject -> '{' ListBinding '}' (22) - AbstractObject -> Dispatch (23) - AbstractObject -> '⊥' (24) - DispatchedObject -> '{' ListBinding '}' (25) - DispatchedObject -> '⊥' (26) - Binding -> Attribute '↦' Object (27) - Binding -> Attribute '↦' '∅' (28) - Binding -> 'Δ' '⤍' Bytes (29) - Binding -> 'λ' '⤍' (30) - ListBinding -> (31) - ListBinding -> Binding (32) - ListBinding -> Binding ',' ListBinding (33) - Bindings -> '{' ListBinding '}' (34) - ListBindings -> (35) - ListBindings -> Bindings ListBindings (36) - Dispatch -> DispatchedObject ListBindings '.' ListAttribute ListDisp (37) - Dispatch -> 'Φ' '.' ListAttribute ListDisp (38) - Dispatch -> 'ξ' '.' ListAttribute ListDisp (39) - Attribute -> 'φ' (40) - Attribute -> 'ρ' (41) - Attribute -> 'σ' (42) - Attribute -> 'ν' (43) - Attribute -> LabelId (44) - Attribute -> AlphaIndex (45) - ListAttribute -> Attribute (46) - ListAttribute -> Attribute '.' ListAttribute (47) - Disp -> '{' ListBinding '}' Bindings '.' ListAttribute (48) - ListDisp -> (49) - ListDisp -> Disp ListDisp (50) - ------------------------------------------------------------------------------ -Terminals ------------------------------------------------------------------------------ - ',' { PT _ (TS _ 1) } - '.' { PT _ (TS _ 2) } - '{' { PT _ (TS _ 3) } - '}' { PT _ (TS _ 4) } - 'Δ' { PT _ (TS _ 5) } - 'Φ' { PT _ (TS _ 6) } - 'λ' { PT _ (TS _ 7) } - 'ν' { PT _ (TS _ 8) } - 'ξ' { PT _ (TS _ 9) } - 'ρ' { PT _ (TS _ 10) } - 'σ' { PT _ (TS _ 11) } - 'φ' { PT _ (TS _ 12) } - '↦' { PT _ (TS _ 13) } - '∅' { PT _ (TS _ 14) } - '⊥' { PT _ (TS _ 15) } - '⤍' { PT _ (TS _ 16) } - L_Bytes { PT _ (T_Bytes _) } - L_Function { PT _ (T_Function _) } - L_LabelId { PT _ (T_LabelId _) } - L_AlphaIndex { PT _ (T_AlphaIndex _) } - ------------------------------------------------------------------------------ -Non-terminals ------------------------------------------------------------------------------ - %start_pProgram_internal rule 0 - %start_pObject_internal rule 1 - %start_pAbstractObject_internal rule 2 - %start_pDispatchedObject_internal rule 3 - %start_pBinding_internal rule 4 - %start_pListBinding_internal rule 5 - %start_pBindings_internal rule 6 - %start_pListBindings_internal rule 7 - %start_pDispatch_internal rule 8 - %start_pAttribute_internal rule 9 - %start_pListAttribute_internal rule 10 - %start_pDisp_internal rule 11 - %start_pListDisp_internal rule 12 - Bytes rule 13 - Function rule 14 - LabelId rule 15 - AlphaIndex rule 16 - Program rule 17 - Object rules 18, 19, 20, 21 - AbstractObject rules 22, 23, 24 - DispatchedObject rules 25, 26 - Binding rules 27, 28, 29, 30 - ListBinding rules 31, 32, 33 - Bindings rule 34 - ListBindings rules 35, 36 - Dispatch rules 37, 38, 39 - Attribute rules 40, 41, 42, 43, 44, 45 - ListAttribute rules 46, 47 - Disp rule 48 - ListDisp rules 49, 50 - ------------------------------------------------------------------------------ -States ------------------------------------------------------------------------------ -State 0 - - %start_pProgram_internal -> . Program (rule 0) - - '{' shift, and enter state 57 - - Program goto state 56 - -State 1 - - %start_pObject_internal -> . Object (rule 1) - - '{' shift, and enter state 54 - 'Φ' shift, and enter state 33 - 'ξ' shift, and enter state 34 - '⊥' shift, and enter state 55 - - Object goto state 51 - AbstractObject goto state 52 - DispatchedObjectgoto state 30 - Dispatch goto state 53 - -State 2 - - %start_pAbstractObject_internal -> . AbstractObject (rule 2) - - '{' shift, and enter state 49 - 'Φ' shift, and enter state 33 - 'ξ' shift, and enter state 34 - '⊥' shift, and enter state 50 - - AbstractObject goto state 47 - DispatchedObjectgoto state 30 - Dispatch goto state 48 - -State 3 - - %start_pDispatchedObject_internal -> . DispatchedObject (rule 3) - - '{' shift, and enter state 32 - '⊥' shift, and enter state 35 - - DispatchedObjectgoto state 46 - -State 4 - - %start_pBinding_internal -> . Binding (rule 4) - - 'Δ' shift, and enter state 43 - 'λ' shift, and enter state 44 - 'ν' shift, and enter state 23 - 'ρ' shift, and enter state 24 - 'σ' shift, and enter state 25 - 'φ' shift, and enter state 26 - L_LabelId shift, and enter state 27 - L_AlphaIndex shift, and enter state 28 - - LabelId goto state 19 - AlphaIndex goto state 20 - Binding goto state 45 - Attribute goto state 42 - -State 5 - - %start_pListBinding_internal -> . ListBinding (rule 5) - - 'Δ' shift, and enter state 43 - 'λ' shift, and enter state 44 - 'ν' shift, and enter state 23 - 'ρ' shift, and enter state 24 - 'σ' shift, and enter state 25 - 'φ' shift, and enter state 26 - L_LabelId shift, and enter state 27 - L_AlphaIndex shift, and enter state 28 - %eof reduce using rule 31 - - LabelId goto state 19 - AlphaIndex goto state 20 - Binding goto state 40 - ListBinding goto state 41 - Attribute goto state 42 - -State 6 - - %start_pBindings_internal -> . Bindings (rule 6) - - '{' shift, and enter state 38 - - Bindings goto state 39 - -State 7 - - %start_pListBindings_internal -> . ListBindings (rule 7) - - '{' shift, and enter state 38 - %eof reduce using rule 35 - - Bindings goto state 36 - ListBindings goto state 37 - -State 8 - - %start_pDispatch_internal -> . Dispatch (rule 8) - - '{' shift, and enter state 32 - 'Φ' shift, and enter state 33 - 'ξ' shift, and enter state 34 - '⊥' shift, and enter state 35 - - DispatchedObjectgoto state 30 - Dispatch goto state 31 - -State 9 - - %start_pAttribute_internal -> . Attribute (rule 9) - - 'ν' shift, and enter state 23 - 'ρ' shift, and enter state 24 - 'σ' shift, and enter state 25 - 'φ' shift, and enter state 26 - L_LabelId shift, and enter state 27 - L_AlphaIndex shift, and enter state 28 - - LabelId goto state 19 - AlphaIndex goto state 20 - Attribute goto state 29 - -State 10 - - %start_pListAttribute_internal -> . ListAttribute (rule 10) - - 'ν' shift, and enter state 23 - 'ρ' shift, and enter state 24 - 'σ' shift, and enter state 25 - 'φ' shift, and enter state 26 - L_LabelId shift, and enter state 27 - L_AlphaIndex shift, and enter state 28 - - LabelId goto state 19 - AlphaIndex goto state 20 - Attribute goto state 21 - ListAttribute goto state 22 - -State 11 - - %start_pDisp_internal -> . Disp (rule 11) - - '{' shift, and enter state 17 - - Disp goto state 18 - -State 12 - - %start_pListDisp_internal -> . ListDisp (rule 12) - - '{' shift, and enter state 17 - %eof reduce using rule 49 - - Disp goto state 15 - ListDisp goto state 16 - -State 13 - - Bytes -> . L_Bytes (rule 13) - - L_Bytes shift, and enter state 14 - - -State 14 - - Bytes -> L_Bytes . (rule 13) - - ',' reduce using rule 13 - '}' reduce using rule 13 - %eof reduce using rule 13 - - -State 15 - - ListDisp -> Disp . ListDisp (rule 50) - - ',' reduce using rule 49 - '{' shift, and enter state 17 - (reduce using rule 49) - - '}' reduce using rule 49 - %eof reduce using rule 49 - - Disp goto state 15 - ListDisp goto state 74 - -State 16 - - %start_pListDisp_internal -> ListDisp . (rule 12) - - %eof accept - - -State 17 - - Disp -> '{' . ListBinding '}' Bindings '.' ListAttribute (rule 48) - - '}' reduce using rule 31 - 'Δ' shift, and enter state 43 - 'λ' shift, and enter state 44 - 'ν' shift, and enter state 23 - 'ρ' shift, and enter state 24 - 'σ' shift, and enter state 25 - 'φ' shift, and enter state 26 - L_LabelId shift, and enter state 27 - L_AlphaIndex shift, and enter state 28 - - LabelId goto state 19 - AlphaIndex goto state 20 - Binding goto state 40 - ListBinding goto state 73 - Attribute goto state 42 - -State 18 - - %start_pDisp_internal -> Disp . (rule 11) - - %eof accept - - -State 19 - - Attribute -> LabelId . (rule 44) - - ',' reduce using rule 44 - '.' reduce using rule 44 - '{' reduce using rule 44 - '}' reduce using rule 44 - '↦' reduce using rule 44 - %eof reduce using rule 44 - - -State 20 - - Attribute -> AlphaIndex . (rule 45) - - ',' reduce using rule 45 - '.' reduce using rule 45 - '{' reduce using rule 45 - '}' reduce using rule 45 - '↦' reduce using rule 45 - %eof reduce using rule 45 - - -State 21 - - ListAttribute -> Attribute . (rule 46) - ListAttribute -> Attribute . '.' ListAttribute (rule 47) - - ',' reduce using rule 46 - '.' shift, and enter state 72 - '{' reduce using rule 46 - '}' reduce using rule 46 - %eof reduce using rule 46 - - -State 22 - - %start_pListAttribute_internal -> ListAttribute . (rule 10) - - %eof accept - - -State 23 - - Attribute -> 'ν' . (rule 43) - - ',' reduce using rule 43 - '.' reduce using rule 43 - '{' reduce using rule 43 - '}' reduce using rule 43 - '↦' reduce using rule 43 - %eof reduce using rule 43 - - -State 24 - - Attribute -> 'ρ' . (rule 41) - - ',' reduce using rule 41 - '.' reduce using rule 41 - '{' reduce using rule 41 - '}' reduce using rule 41 - '↦' reduce using rule 41 - %eof reduce using rule 41 - - -State 25 - - Attribute -> 'σ' . (rule 42) - - ',' reduce using rule 42 - '.' reduce using rule 42 - '{' reduce using rule 42 - '}' reduce using rule 42 - '↦' reduce using rule 42 - %eof reduce using rule 42 - - -State 26 - - Attribute -> 'φ' . (rule 40) - - ',' reduce using rule 40 - '.' reduce using rule 40 - '{' reduce using rule 40 - '}' reduce using rule 40 - '↦' reduce using rule 40 - %eof reduce using rule 40 - - -State 27 - - LabelId -> L_LabelId . (rule 15) - - ',' reduce using rule 15 - '.' reduce using rule 15 - '{' reduce using rule 15 - '}' reduce using rule 15 - '↦' reduce using rule 15 - %eof reduce using rule 15 - - -State 28 - - AlphaIndex -> L_AlphaIndex . (rule 16) - - ',' reduce using rule 16 - '.' reduce using rule 16 - '{' reduce using rule 16 - '}' reduce using rule 16 - '↦' reduce using rule 16 - %eof reduce using rule 16 - - -State 29 - - %start_pAttribute_internal -> Attribute . (rule 9) - - %eof accept - - -State 30 - - Dispatch -> DispatchedObject . ListBindings '.' ListAttribute ListDisp (rule 37) - - '.' reduce using rule 35 - '{' shift, and enter state 38 - - Bindings goto state 36 - ListBindings goto state 71 - -State 31 - - %start_pDispatch_internal -> Dispatch . (rule 8) - - %eof accept - - -State 32 - - DispatchedObject -> '{' . ListBinding '}' (rule 25) - - '}' reduce using rule 31 - 'Δ' shift, and enter state 43 - 'λ' shift, and enter state 44 - 'ν' shift, and enter state 23 - 'ρ' shift, and enter state 24 - 'σ' shift, and enter state 25 - 'φ' shift, and enter state 26 - L_LabelId shift, and enter state 27 - L_AlphaIndex shift, and enter state 28 - - LabelId goto state 19 - AlphaIndex goto state 20 - Binding goto state 40 - ListBinding goto state 70 - Attribute goto state 42 - -State 33 - - Dispatch -> 'Φ' . '.' ListAttribute ListDisp (rule 38) - - '.' shift, and enter state 69 - - -State 34 - - Dispatch -> 'ξ' . '.' ListAttribute ListDisp (rule 39) - - '.' shift, and enter state 68 - - -State 35 - - DispatchedObject -> '⊥' . (rule 26) - - '.' reduce using rule 26 - '{' reduce using rule 26 - %eof reduce using rule 26 - - -State 36 - - ListBindings -> Bindings . ListBindings (rule 36) - - ',' reduce using rule 35 - '.' reduce using rule 35 - '{' shift, and enter state 38 - '}' reduce using rule 35 - %eof reduce using rule 35 - - Bindings goto state 36 - ListBindings goto state 67 - -State 37 - - %start_pListBindings_internal -> ListBindings . (rule 7) - - %eof accept - - -State 38 - - Bindings -> '{' . ListBinding '}' (rule 34) - - '}' reduce using rule 31 - 'Δ' shift, and enter state 43 - 'λ' shift, and enter state 44 - 'ν' shift, and enter state 23 - 'ρ' shift, and enter state 24 - 'σ' shift, and enter state 25 - 'φ' shift, and enter state 26 - L_LabelId shift, and enter state 27 - L_AlphaIndex shift, and enter state 28 - - LabelId goto state 19 - AlphaIndex goto state 20 - Binding goto state 40 - ListBinding goto state 66 - Attribute goto state 42 - -State 39 - - %start_pBindings_internal -> Bindings . (rule 6) - - %eof accept - - -State 40 - - ListBinding -> Binding . (rule 32) - ListBinding -> Binding . ',' ListBinding (rule 33) - - ',' shift, and enter state 65 - '}' reduce using rule 32 - %eof reduce using rule 32 - - -State 41 - - %start_pListBinding_internal -> ListBinding . (rule 5) - - %eof accept - - -State 42 - - Binding -> Attribute . '↦' Object (rule 27) - Binding -> Attribute . '↦' '∅' (rule 28) - - '↦' shift, and enter state 64 - - -State 43 - - Binding -> 'Δ' . '⤍' Bytes (rule 29) - - '⤍' shift, and enter state 63 - - -State 44 - - Binding -> 'λ' . '⤍' (rule 30) - - '⤍' shift, and enter state 62 - - -State 45 - - %start_pBinding_internal -> Binding . (rule 4) - - %eof accept - - -State 46 - - %start_pDispatchedObject_internal -> DispatchedObject . (rule 3) - - %eof accept - - -State 47 - - %start_pAbstractObject_internal -> AbstractObject . (rule 2) - - %eof accept - - -State 48 - - AbstractObject -> Dispatch . (rule 23) - - %eof reduce using rule 23 - - -State 49 - - AbstractObject -> '{' . ListBinding '}' (rule 22) - DispatchedObject -> '{' . ListBinding '}' (rule 25) - - '}' reduce using rule 31 - 'Δ' shift, and enter state 43 - 'λ' shift, and enter state 44 - 'ν' shift, and enter state 23 - 'ρ' shift, and enter state 24 - 'σ' shift, and enter state 25 - 'φ' shift, and enter state 26 - L_LabelId shift, and enter state 27 - L_AlphaIndex shift, and enter state 28 - - LabelId goto state 19 - AlphaIndex goto state 20 - Binding goto state 40 - ListBinding goto state 61 - Attribute goto state 42 - -State 50 - - AbstractObject -> '⊥' . (rule 24) - DispatchedObject -> '⊥' . (rule 26) - - '.' reduce using rule 26 - '{' reduce using rule 26 - %eof reduce using rule 24 - - -State 51 - - %start_pObject_internal -> Object . (rule 1) - - %eof accept - - -State 52 - - Object -> AbstractObject . '{' ListBinding '}' ListBindings (rule 19) - - '{' shift, and enter state 60 - - -State 53 - - Object -> Dispatch . (rule 20) - AbstractObject -> Dispatch . (rule 23) - - ',' reduce using rule 20 - '{' reduce using rule 23 - '}' reduce using rule 20 - %eof reduce using rule 20 - - -State 54 - - Object -> '{' . ListBinding '}' (rule 18) - AbstractObject -> '{' . ListBinding '}' (rule 22) - DispatchedObject -> '{' . ListBinding '}' (rule 25) - - '}' reduce using rule 31 - 'Δ' shift, and enter state 43 - 'λ' shift, and enter state 44 - 'ν' shift, and enter state 23 - 'ρ' shift, and enter state 24 - 'σ' shift, and enter state 25 - 'φ' shift, and enter state 26 - L_LabelId shift, and enter state 27 - L_AlphaIndex shift, and enter state 28 - - LabelId goto state 19 - AlphaIndex goto state 20 - Binding goto state 40 - ListBinding goto state 59 - Attribute goto state 42 - -State 55 - - Object -> '⊥' . (rule 21) - AbstractObject -> '⊥' . (rule 24) - DispatchedObject -> '⊥' . (rule 26) - - ',' reduce using rule 21 - '.' reduce using rule 26 - '{' reduce using rule 26 - (reduce using rule 24) - - '}' reduce using rule 21 - %eof reduce using rule 21 - - -State 56 - - %start_pProgram_internal -> Program . (rule 0) - - %eof accept - - -State 57 - - Program -> '{' . ListBinding '}' (rule 17) - - '}' reduce using rule 31 - 'Δ' shift, and enter state 43 - 'λ' shift, and enter state 44 - 'ν' shift, and enter state 23 - 'ρ' shift, and enter state 24 - 'σ' shift, and enter state 25 - 'φ' shift, and enter state 26 - L_LabelId shift, and enter state 27 - L_AlphaIndex shift, and enter state 28 - - LabelId goto state 19 - AlphaIndex goto state 20 - Binding goto state 40 - ListBinding goto state 58 - Attribute goto state 42 - -State 58 - - Program -> '{' ListBinding . '}' (rule 17) - - '}' shift, and enter state 89 - - -State 59 - - Object -> '{' ListBinding . '}' (rule 18) - AbstractObject -> '{' ListBinding . '}' (rule 22) - DispatchedObject -> '{' ListBinding . '}' (rule 25) - - '}' shift, and enter state 88 - - -State 60 - - Object -> AbstractObject '{' . ListBinding '}' ListBindings (rule 19) - - '}' reduce using rule 31 - 'Δ' shift, and enter state 43 - 'λ' shift, and enter state 44 - 'ν' shift, and enter state 23 - 'ρ' shift, and enter state 24 - 'σ' shift, and enter state 25 - 'φ' shift, and enter state 26 - L_LabelId shift, and enter state 27 - L_AlphaIndex shift, and enter state 28 - - LabelId goto state 19 - AlphaIndex goto state 20 - Binding goto state 40 - ListBinding goto state 87 - Attribute goto state 42 - -State 61 - - AbstractObject -> '{' ListBinding . '}' (rule 22) - DispatchedObject -> '{' ListBinding . '}' (rule 25) - - '}' shift, and enter state 86 - - -State 62 - - Binding -> 'λ' '⤍' . (rule 30) - - ',' reduce using rule 30 - '}' reduce using rule 30 - %eof reduce using rule 30 - - -State 63 - - Binding -> 'Δ' '⤍' . Bytes (rule 29) - - L_Bytes shift, and enter state 14 - - Bytes goto state 85 - -State 64 - - Binding -> Attribute '↦' . Object (rule 27) - Binding -> Attribute '↦' . '∅' (rule 28) - - '{' shift, and enter state 54 - 'Φ' shift, and enter state 33 - 'ξ' shift, and enter state 34 - '∅' shift, and enter state 84 - '⊥' shift, and enter state 55 - - Object goto state 83 - AbstractObject goto state 52 - DispatchedObjectgoto state 30 - Dispatch goto state 53 - -State 65 - - ListBinding -> Binding ',' . ListBinding (rule 33) - - '}' reduce using rule 31 - 'Δ' shift, and enter state 43 - 'λ' shift, and enter state 44 - 'ν' shift, and enter state 23 - 'ρ' shift, and enter state 24 - 'σ' shift, and enter state 25 - 'φ' shift, and enter state 26 - L_LabelId shift, and enter state 27 - L_AlphaIndex shift, and enter state 28 - %eof reduce using rule 31 - - LabelId goto state 19 - AlphaIndex goto state 20 - Binding goto state 40 - ListBinding goto state 82 - Attribute goto state 42 - -State 66 - - Bindings -> '{' ListBinding . '}' (rule 34) - - '}' shift, and enter state 81 - - -State 67 - - ListBindings -> Bindings ListBindings . (rule 36) - - ',' reduce using rule 36 - '.' reduce using rule 36 - '}' reduce using rule 36 - %eof reduce using rule 36 - - -State 68 - - Dispatch -> 'ξ' '.' . ListAttribute ListDisp (rule 39) - - 'ν' shift, and enter state 23 - 'ρ' shift, and enter state 24 - 'σ' shift, and enter state 25 - 'φ' shift, and enter state 26 - L_LabelId shift, and enter state 27 - L_AlphaIndex shift, and enter state 28 - - LabelId goto state 19 - AlphaIndex goto state 20 - Attribute goto state 21 - ListAttribute goto state 80 - -State 69 - - Dispatch -> 'Φ' '.' . ListAttribute ListDisp (rule 38) - - 'ν' shift, and enter state 23 - 'ρ' shift, and enter state 24 - 'σ' shift, and enter state 25 - 'φ' shift, and enter state 26 - L_LabelId shift, and enter state 27 - L_AlphaIndex shift, and enter state 28 - - LabelId goto state 19 - AlphaIndex goto state 20 - Attribute goto state 21 - ListAttribute goto state 79 - -State 70 - - DispatchedObject -> '{' ListBinding . '}' (rule 25) - - '}' shift, and enter state 78 - - -State 71 - - Dispatch -> DispatchedObject ListBindings . '.' ListAttribute ListDisp (rule 37) - - '.' shift, and enter state 77 - - -State 72 - - ListAttribute -> Attribute '.' . ListAttribute (rule 47) - - 'ν' shift, and enter state 23 - 'ρ' shift, and enter state 24 - 'σ' shift, and enter state 25 - 'φ' shift, and enter state 26 - L_LabelId shift, and enter state 27 - L_AlphaIndex shift, and enter state 28 - - LabelId goto state 19 - AlphaIndex goto state 20 - Attribute goto state 21 - ListAttribute goto state 76 - -State 73 - - Disp -> '{' ListBinding . '}' Bindings '.' ListAttribute (rule 48) - - '}' shift, and enter state 75 - - -State 74 - - ListDisp -> Disp ListDisp . (rule 50) - - ',' reduce using rule 50 - '{' reduce using rule 50 - '}' reduce using rule 50 - %eof reduce using rule 50 - - -State 75 - - Disp -> '{' ListBinding '}' . Bindings '.' ListAttribute (rule 48) - - '{' shift, and enter state 38 - - Bindings goto state 94 - -State 76 - - ListAttribute -> Attribute '.' ListAttribute . (rule 47) - - ',' reduce using rule 47 - '{' reduce using rule 47 - '}' reduce using rule 47 - %eof reduce using rule 47 - - -State 77 - - Dispatch -> DispatchedObject ListBindings '.' . ListAttribute ListDisp (rule 37) - - 'ν' shift, and enter state 23 - 'ρ' shift, and enter state 24 - 'σ' shift, and enter state 25 - 'φ' shift, and enter state 26 - L_LabelId shift, and enter state 27 - L_AlphaIndex shift, and enter state 28 - - LabelId goto state 19 - AlphaIndex goto state 20 - Attribute goto state 21 - ListAttribute goto state 93 - -State 78 - - DispatchedObject -> '{' ListBinding '}' . (rule 25) - - '.' reduce using rule 25 - '{' reduce using rule 25 - %eof reduce using rule 25 - - -State 79 - - Dispatch -> 'Φ' '.' ListAttribute . ListDisp (rule 38) - - ',' reduce using rule 49 - '{' shift, and enter state 17 - (reduce using rule 49) - - '}' reduce using rule 49 - %eof reduce using rule 49 - - Disp goto state 15 - ListDisp goto state 92 - -State 80 - - Dispatch -> 'ξ' '.' ListAttribute . ListDisp (rule 39) - - ',' reduce using rule 49 - '{' shift, and enter state 17 - (reduce using rule 49) - - '}' reduce using rule 49 - %eof reduce using rule 49 - - Disp goto state 15 - ListDisp goto state 91 - -State 81 - - Bindings -> '{' ListBinding '}' . (rule 34) - - ',' reduce using rule 34 - '.' reduce using rule 34 - '{' reduce using rule 34 - '}' reduce using rule 34 - %eof reduce using rule 34 - - -State 82 - - ListBinding -> Binding ',' ListBinding . (rule 33) - - '}' reduce using rule 33 - %eof reduce using rule 33 - - -State 83 - - Binding -> Attribute '↦' Object . (rule 27) - - ',' reduce using rule 27 - '}' reduce using rule 27 - %eof reduce using rule 27 - - -State 84 - - Binding -> Attribute '↦' '∅' . (rule 28) - - ',' reduce using rule 28 - '}' reduce using rule 28 - %eof reduce using rule 28 - - -State 85 - - Binding -> 'Δ' '⤍' Bytes . (rule 29) - - ',' reduce using rule 29 - '}' reduce using rule 29 - %eof reduce using rule 29 - - -State 86 - - AbstractObject -> '{' ListBinding '}' . (rule 22) - DispatchedObject -> '{' ListBinding '}' . (rule 25) - - '.' reduce using rule 25 - '{' reduce using rule 25 - %eof reduce using rule 22 - - -State 87 - - Object -> AbstractObject '{' ListBinding . '}' ListBindings (rule 19) - - '}' shift, and enter state 90 - - -State 88 - - Object -> '{' ListBinding '}' . (rule 18) - AbstractObject -> '{' ListBinding '}' . (rule 22) - DispatchedObject -> '{' ListBinding '}' . (rule 25) - - ',' reduce using rule 18 - '.' reduce using rule 25 - '{' reduce using rule 25 - (reduce using rule 22) - - '}' reduce using rule 18 - %eof reduce using rule 18 - - -State 89 - - Program -> '{' ListBinding '}' . (rule 17) - - %eof reduce using rule 17 - - -State 90 - - Object -> AbstractObject '{' ListBinding '}' . ListBindings (rule 19) - - ',' reduce using rule 35 - '{' shift, and enter state 38 - '}' reduce using rule 35 - %eof reduce using rule 35 - - Bindings goto state 36 - ListBindings goto state 97 - -State 91 - - Dispatch -> 'ξ' '.' ListAttribute ListDisp . (rule 39) - - ',' reduce using rule 39 - '{' reduce using rule 39 - '}' reduce using rule 39 - %eof reduce using rule 39 - - -State 92 - - Dispatch -> 'Φ' '.' ListAttribute ListDisp . (rule 38) - - ',' reduce using rule 38 - '{' reduce using rule 38 - '}' reduce using rule 38 - %eof reduce using rule 38 - - -State 93 - - Dispatch -> DispatchedObject ListBindings '.' ListAttribute . ListDisp (rule 37) - - ',' reduce using rule 49 - '{' shift, and enter state 17 - (reduce using rule 49) - - '}' reduce using rule 49 - %eof reduce using rule 49 - - Disp goto state 15 - ListDisp goto state 96 - -State 94 - - Disp -> '{' ListBinding '}' Bindings . '.' ListAttribute (rule 48) - - '.' shift, and enter state 95 - - -State 95 - - Disp -> '{' ListBinding '}' Bindings '.' . ListAttribute (rule 48) - - 'ν' shift, and enter state 23 - 'ρ' shift, and enter state 24 - 'σ' shift, and enter state 25 - 'φ' shift, and enter state 26 - L_LabelId shift, and enter state 27 - L_AlphaIndex shift, and enter state 28 - - LabelId goto state 19 - AlphaIndex goto state 20 - Attribute goto state 21 - ListAttribute goto state 98 - -State 96 - - Dispatch -> DispatchedObject ListBindings '.' ListAttribute ListDisp . (rule 37) - - ',' reduce using rule 37 - '{' reduce using rule 37 - '}' reduce using rule 37 - %eof reduce using rule 37 - - -State 97 - - Object -> AbstractObject '{' ListBinding '}' ListBindings . (rule 19) - - ',' reduce using rule 19 - '}' reduce using rule 19 - %eof reduce using rule 19 - - -State 98 - - Disp -> '{' ListBinding '}' Bindings '.' ListAttribute . (rule 48) - - ',' reduce using rule 48 - '{' reduce using rule 48 - '}' reduce using rule 48 - %eof reduce using rule 48 - - ------------------------------------------------------------------------------ -Grammar Totals ------------------------------------------------------------------------------ -Number of rules: 51 -Number of terminals: 20 -Number of non-terminals: 30 -Number of states: 99 diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y.bak b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y.bak deleted file mode 100644 index 0a687f005..000000000 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y.bak +++ /dev/null @@ -1,212 +0,0 @@ --- -*- haskell -*- File generated by the BNF Converter (bnfc 2.9.5). - --- Parser definition for use with Happy -{ -{-# OPTIONS_GHC -fno-warn-incomplete-patterns -fno-warn-overlapping-patterns #-} -{-# LANGUAGE PatternSynonyms #-} - -module Language.EO.Phi.Syntax.Par - ( happyError - , myLexer - , pProgram - , pObject - , pAbstractObject - , pDispatchedObject - , pBinding - , pListBinding - , pBindings - , pListBindings - , pDispatch - , pAttribute - , pListAttribute - , pDisp - , pListDisp - ) where - -import Prelude - -import qualified Language.EO.Phi.Syntax.Abs -import Language.EO.Phi.Syntax.Lex - -} - -%name pProgram_internal Program -%name pObject_internal Object -%name pAbstractObject_internal AbstractObject -%name pDispatchedObject_internal DispatchedObject -%name pBinding_internal Binding -%name pListBinding_internal ListBinding -%name pBindings_internal Bindings -%name pListBindings_internal ListBindings -%name pDispatch_internal Dispatch -%name pAttribute_internal Attribute -%name pListAttribute_internal ListAttribute -%name pDisp_internal Disp -%name pListDisp_internal ListDisp --- no lexer declaration -%monad { Err } { (>>=) } { return } -%tokentype {Token} -%token - ',' { PT _ (TS _ 1) } - '.' { PT _ (TS _ 2) } - '{' { PT _ (TS _ 3) } - '}' { PT _ (TS _ 4) } - 'Δ' { PT _ (TS _ 5) } - 'Φ' { PT _ (TS _ 6) } - 'λ' { PT _ (TS _ 7) } - 'ν' { PT _ (TS _ 8) } - 'ξ' { PT _ (TS _ 9) } - 'ρ' { PT _ (TS _ 10) } - 'σ' { PT _ (TS _ 11) } - 'φ' { PT _ (TS _ 12) } - '↦' { PT _ (TS _ 13) } - '∅' { PT _ (TS _ 14) } - '⊥' { PT _ (TS _ 15) } - '⤍' { PT _ (TS _ 16) } - L_Bytes { PT _ (T_Bytes _) } - L_Function { PT _ (T_Function _) } - L_LabelId { PT _ (T_LabelId _) } - L_AlphaIndex { PT _ (T_AlphaIndex _) } - -%% - -Bytes :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Bytes) } -Bytes : L_Bytes { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Bytes (tokenText $1)) } - -Function :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Function) } -Function : L_Function { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Function (tokenText $1)) } - -LabelId :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.LabelId) } -LabelId : L_LabelId { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.LabelId (tokenText $1)) } - -AlphaIndex :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.AlphaIndex) } -AlphaIndex : L_AlphaIndex { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.AlphaIndex (tokenText $1)) } - -Program :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Program) } -Program - : '{' ListBinding '}' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Program (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $2)) } - -Object :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Object) } -Object - : '{' ListBinding '}' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Formation (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $2)) } - | AbstractObject '{' ListBinding '}' ListBindings { (fst $1, Language.EO.Phi.Syntax.Abs.Application (fst $1) (snd $1) (snd $3) (snd $5)) } - | Dispatch { (fst $1, Language.EO.Phi.Syntax.Abs.Dispatch (fst $1) (snd $1)) } - | '⊥' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Termination (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } - -AbstractObject :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.AbstractObject) } -AbstractObject - : '{' ListBinding '}' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.AbstractFormation (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $2)) } - | Dispatch { (fst $1, Language.EO.Phi.Syntax.Abs.AbstractDispatch (fst $1) (snd $1)) } - | '⊥' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.AbstractTermination (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } - -DispatchedObject :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.DispatchedObject) } -DispatchedObject - : '{' ListBinding '}' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.DispatchedFormation (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $2)) } - | '⊥' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.DispatchedTermination (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } - -Binding :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Binding) } -Binding - : Attribute '↦' '∅' { (fst $1, Language.EO.Phi.Syntax.Abs.EmptyBinding (fst $1) (snd $1)) } - | 'Δ' '⤍' Bytes { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.DeltaBinding (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $3)) } - | 'λ' '⤍' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.LambdaBinding (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } - -ListBinding :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, [Language.EO.Phi.Syntax.Abs.Binding]) } -ListBinding - : {- empty -} { (Language.EO.Phi.Syntax.Abs.BNFC'NoPosition, []) } - | Binding { (fst $1, (:[]) (snd $1)) } - | Binding ',' ListBinding { (fst $1, (:) (snd $1) (snd $3)) } - -Bindings :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Bindings) } -Bindings - : '{' ListBinding '}' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Bindings (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $2)) } - -ListBindings :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, [Language.EO.Phi.Syntax.Abs.Bindings]) } -ListBindings - : {- empty -} { (Language.EO.Phi.Syntax.Abs.BNFC'NoPosition, []) } - | Bindings ListBindings { (fst $1, (:) (snd $1) (snd $2)) } - -Dispatch :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Dispatch) } -Dispatch - : 'Φ' '.' ListAttribute ListDisp { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.HomeDispatch (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $3) (snd $4)) } - | 'ξ' '.' ListAttribute ListDisp { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.ThisDispatch (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $3) (snd $4)) } - -Attribute :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Attribute) } -Attribute - : 'φ' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Phi (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } - | 'ρ' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Rho (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } - | 'σ' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Sigma (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } - | 'ν' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.VTX (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } - | LabelId { (fst $1, Language.EO.Phi.Syntax.Abs.Label (fst $1) (snd $1)) } - | AlphaIndex { (fst $1, Language.EO.Phi.Syntax.Abs.Alpha (fst $1) (snd $1)) } - -ListAttribute :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, [Language.EO.Phi.Syntax.Abs.Attribute]) } -ListAttribute - : Attribute { (fst $1, (:[]) (snd $1)) } - | Attribute '.' ListAttribute { (fst $1, (:) (snd $1) (snd $3)) } - -Disp :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Disp) } -Disp - : '{' ListBinding '}' Bindings '.' ListAttribute { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Disp (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $2) (snd $4) (snd $6)) } - -ListDisp :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, [Language.EO.Phi.Syntax.Abs.Disp]) } -ListDisp - : {- empty -} { (Language.EO.Phi.Syntax.Abs.BNFC'NoPosition, []) } - | Disp ListDisp { (fst $1, (:) (snd $1) (snd $2)) } - -{ - -type Err = Either String - -happyError :: [Token] -> Err a -happyError ts = Left $ - "syntax error at " ++ tokenPos ts ++ - case ts of - [] -> [] - [Err _] -> " due to lexer error" - t:_ -> " before `" ++ (prToken t) ++ "'" - -myLexer :: String -> [Token] -myLexer = tokens - --- Entrypoints - -pProgram :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Program -pProgram = fmap snd . pProgram_internal - -pObject :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Object -pObject = fmap snd . pObject_internal - -pAbstractObject :: [Token] -> Err Language.EO.Phi.Syntax.Abs.AbstractObject -pAbstractObject = fmap snd . pAbstractObject_internal - -pDispatchedObject :: [Token] -> Err Language.EO.Phi.Syntax.Abs.DispatchedObject -pDispatchedObject = fmap snd . pDispatchedObject_internal - -pBinding :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Binding -pBinding = fmap snd . pBinding_internal - -pListBinding :: [Token] -> Err [Language.EO.Phi.Syntax.Abs.Binding] -pListBinding = fmap snd . pListBinding_internal - -pBindings :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Bindings -pBindings = fmap snd . pBindings_internal - -pListBindings :: [Token] -> Err [Language.EO.Phi.Syntax.Abs.Bindings] -pListBindings = fmap snd . pListBindings_internal - -pDispatch :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Dispatch -pDispatch = fmap snd . pDispatch_internal - -pAttribute :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Attribute -pAttribute = fmap snd . pAttribute_internal - -pListAttribute :: [Token] -> Err [Language.EO.Phi.Syntax.Abs.Attribute] -pListAttribute = fmap snd . pListAttribute_internal - -pDisp :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Disp -pDisp = fmap snd . pDisp_internal - -pListDisp :: [Token] -> Err [Language.EO.Phi.Syntax.Abs.Disp] -pListDisp = fmap snd . pListDisp_internal -} - diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs.bak b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs.bak deleted file mode 100644 index 53893f89d..000000000 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs.bak +++ /dev/null @@ -1,214 +0,0 @@ --- File generated by the BNF Converter (bnfc 2.9.5). - -{-# LANGUAGE CPP #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE LambdaCase #-} -#if __GLASGOW_HASKELL__ <= 708 -{-# LANGUAGE OverlappingInstances #-} -#endif - --- | Pretty-printer for Language. - -module Language.EO.Phi.Syntax.Print where - -import Prelude - ( ($), (.) - , Bool(..), (==), (<) - , Int, Integer, Double, (+), (-), (*) - , String, (++) - , ShowS, showChar, showString - , all, elem, foldr, id, map, null, replicate, shows, span - ) -import Data.Char ( Char, isSpace ) -import qualified Language.EO.Phi.Syntax.Abs - --- | The top-level printing method. - -printTree :: Print a => a -> String -printTree = render . prt 0 - -type Doc = [ShowS] -> [ShowS] - -doc :: ShowS -> Doc -doc = (:) - -render :: Doc -> String -render d = rend 0 False (map ($ "") $ d []) "" - where - rend - :: Int -- ^ Indentation level. - -> Bool -- ^ Pending indentation to be output before next character? - -> [String] - -> ShowS - rend i p = \case - "[" :ts -> char '[' . rend i False ts - "(" :ts -> char '(' . rend i False ts - "{" :ts -> onNewLine i p . showChar '{' . new (i+1) ts - "}" : ";":ts -> onNewLine (i-1) p . showString "};" . new (i-1) ts - "}" :ts -> onNewLine (i-1) p . showChar '}' . new (i-1) ts - [";"] -> char ';' - ";" :ts -> char ';' . new i ts - t : ts@(s:_) | closingOrPunctuation s - -> pending . showString t . rend i False ts - t :ts -> pending . space t . rend i False ts - [] -> id - where - -- Output character after pending indentation. - char :: Char -> ShowS - char c = pending . showChar c - - -- Output pending indentation. - pending :: ShowS - pending = if p then indent i else id - - -- Indentation (spaces) for given indentation level. - indent :: Int -> ShowS - indent i = replicateS (2*i) (showChar ' ') - - -- Continue rendering in new line with new indentation. - new :: Int -> [String] -> ShowS - new j ts = showChar '\n' . rend j True ts - - -- Make sure we are on a fresh line. - onNewLine :: Int -> Bool -> ShowS - onNewLine i p = (if p then id else showChar '\n') . indent i - - -- Separate given string from following text by a space (if needed). - space :: String -> ShowS - space t s = - case (all isSpace t, null spc, null rest) of - (True , _ , True ) -> [] -- remove trailing space - (False, _ , True ) -> t -- remove trailing space - (False, True, False) -> t ++ ' ' : s -- add space if none - _ -> t ++ s - where - (spc, rest) = span isSpace s - - closingOrPunctuation :: String -> Bool - closingOrPunctuation [c] = c `elem` closerOrPunct - closingOrPunctuation _ = False - - closerOrPunct :: String - closerOrPunct = ")],;" - -parenth :: Doc -> Doc -parenth ss = doc (showChar '(') . ss . doc (showChar ')') - -concatS :: [ShowS] -> ShowS -concatS = foldr (.) id - -concatD :: [Doc] -> Doc -concatD = foldr (.) id - -replicateS :: Int -> ShowS -> ShowS -replicateS n f = concatS (replicate n f) - --- | The printer class does the job. - -class Print a where - prt :: Int -> a -> Doc - -instance {-# OVERLAPPABLE #-} Print a => Print [a] where - prt i = concatD . map (prt i) - -instance Print Char where - prt _ c = doc (showChar '\'' . mkEsc '\'' c . showChar '\'') - -instance Print String where - prt _ = printString - -printString :: String -> Doc -printString s = doc (showChar '"' . concatS (map (mkEsc '"') s) . showChar '"') - -mkEsc :: Char -> Char -> ShowS -mkEsc q = \case - s | s == q -> showChar '\\' . showChar s - '\\' -> showString "\\\\" - '\n' -> showString "\\n" - '\t' -> showString "\\t" - s -> showChar s - -prPrec :: Int -> Int -> Doc -> Doc -prPrec i j = if j < i then parenth else id - -instance Print Integer where - prt _ x = doc (shows x) - -instance Print Double where - prt _ x = doc (shows x) - -instance Print Language.EO.Phi.Syntax.Abs.Bytes where - prt _ (Language.EO.Phi.Syntax.Abs.Bytes i) = doc $ showString i -instance Print Language.EO.Phi.Syntax.Abs.Function where - prt _ (Language.EO.Phi.Syntax.Abs.Function i) = doc $ showString i -instance Print Language.EO.Phi.Syntax.Abs.LabelId where - prt _ (Language.EO.Phi.Syntax.Abs.LabelId i) = doc $ showString i -instance Print Language.EO.Phi.Syntax.Abs.AlphaIndex where - prt _ (Language.EO.Phi.Syntax.Abs.AlphaIndex i) = doc $ showString i -instance Print (Language.EO.Phi.Syntax.Abs.Program' a) where - prt i = \case - Language.EO.Phi.Syntax.Abs.Program _ bindings -> prPrec i 0 (concatD [doc (showString "{"), prt 0 bindings, doc (showString "}")]) - -instance Print (Language.EO.Phi.Syntax.Abs.Object' a) where - prt i = \case - Language.EO.Phi.Syntax.Abs.Formation _ bindings -> prPrec i 0 (concatD [doc (showString "{"), prt 0 bindings, doc (showString "}")]) - Language.EO.Phi.Syntax.Abs.Application _ abstractobject bindings bindingss -> prPrec i 0 (concatD [prt 0 abstractobject, doc (showString "{"), prt 0 bindings, doc (showString "}"), prt 0 bindingss]) - Language.EO.Phi.Syntax.Abs.Dispatch _ dispatch -> prPrec i 0 (concatD [prt 0 dispatch]) - Language.EO.Phi.Syntax.Abs.Termination _ -> prPrec i 0 (concatD [doc (showString "\8869")]) - -instance Print (Language.EO.Phi.Syntax.Abs.AbstractObject' a) where - prt i = \case - Language.EO.Phi.Syntax.Abs.AbstractFormation _ bindings -> prPrec i 0 (concatD [doc (showString "{"), prt 0 bindings, doc (showString "}")]) - Language.EO.Phi.Syntax.Abs.AbstractDispatch _ dispatch -> prPrec i 0 (concatD [prt 0 dispatch]) - Language.EO.Phi.Syntax.Abs.AbstractTermination _ -> prPrec i 0 (concatD [doc (showString "\8869")]) - -instance Print (Language.EO.Phi.Syntax.Abs.DispatchedObject' a) where - prt i = \case - Language.EO.Phi.Syntax.Abs.DispatchedFormation _ bindings -> prPrec i 0 (concatD [doc (showString "{"), prt 0 bindings, doc (showString "}")]) - Language.EO.Phi.Syntax.Abs.DispatchedTermination _ -> prPrec i 0 (concatD [doc (showString "\8869")]) - -instance Print (Language.EO.Phi.Syntax.Abs.Binding' a) where - prt i = \case - Language.EO.Phi.Syntax.Abs.EmptyBinding _ attribute -> prPrec i 0 (concatD [prt 0 attribute, doc (showString "\8614"), doc (showString "\8709")]) - Language.EO.Phi.Syntax.Abs.DeltaBinding _ bytes -> prPrec i 0 (concatD [doc (showString "\916"), doc (showString "\10509"), prt 0 bytes]) - Language.EO.Phi.Syntax.Abs.LambdaBinding _ -> prPrec i 0 (concatD [doc (showString "\955"), doc (showString "\10509")]) - -instance Print [Language.EO.Phi.Syntax.Abs.Binding' a] where - prt _ [] = concatD [] - prt _ [x] = concatD [prt 0 x] - prt _ (x:xs) = concatD [prt 0 x, doc (showString ","), prt 0 xs] - -instance Print (Language.EO.Phi.Syntax.Abs.Bindings' a) where - prt i = \case - Language.EO.Phi.Syntax.Abs.Bindings _ bindings -> prPrec i 0 (concatD [doc (showString "{"), prt 0 bindings, doc (showString "}")]) - -instance Print [Language.EO.Phi.Syntax.Abs.Bindings' a] where - prt _ [] = concatD [] - prt _ (x:xs) = concatD [prt 0 x, prt 0 xs] - -instance Print (Language.EO.Phi.Syntax.Abs.Dispatch' a) where - prt i = \case - Language.EO.Phi.Syntax.Abs.HomeDispatch _ attributes disps -> prPrec i 0 (concatD [doc (showString "\934"), doc (showString "."), prt 0 attributes, prt 0 disps]) - Language.EO.Phi.Syntax.Abs.ThisDispatch _ attributes disps -> prPrec i 0 (concatD [doc (showString "\958"), doc (showString "."), prt 0 attributes, prt 0 disps]) - -instance Print (Language.EO.Phi.Syntax.Abs.Attribute' a) where - prt i = \case - Language.EO.Phi.Syntax.Abs.Phi _ -> prPrec i 0 (concatD [doc (showString "\966")]) - Language.EO.Phi.Syntax.Abs.Rho _ -> prPrec i 0 (concatD [doc (showString "\961")]) - Language.EO.Phi.Syntax.Abs.Sigma _ -> prPrec i 0 (concatD [doc (showString "\963")]) - Language.EO.Phi.Syntax.Abs.VTX _ -> prPrec i 0 (concatD [doc (showString "\957")]) - Language.EO.Phi.Syntax.Abs.Label _ labelid -> prPrec i 0 (concatD [prt 0 labelid]) - Language.EO.Phi.Syntax.Abs.Alpha _ alphaindex -> prPrec i 0 (concatD [prt 0 alphaindex]) - -instance Print [Language.EO.Phi.Syntax.Abs.Attribute' a] where - prt _ [] = concatD [] - prt _ [x] = concatD [prt 0 x] - prt _ (x:xs) = concatD [prt 0 x, doc (showString "."), prt 0 xs] - -instance Print (Language.EO.Phi.Syntax.Abs.Disp' a) where - prt i = \case - Language.EO.Phi.Syntax.Abs.Disp _ bindings1 bindings2 attributes -> prPrec i 0 (concatD [doc (showString "{"), prt 0 bindings1, doc (showString "}"), prt 0 bindings2, doc (showString "."), prt 0 attributes]) - -instance Print [Language.EO.Phi.Syntax.Abs.Disp' a] where - prt _ [] = concatD [] - prt _ (x:xs) = concatD [prt 0 x, prt 0 xs] diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Skel.hs.bak b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Skel.hs.bak deleted file mode 100644 index 5c0ec9611..000000000 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Skel.hs.bak +++ /dev/null @@ -1,82 +0,0 @@ --- File generated by the BNF Converter (bnfc 2.9.5). - --- Templates for pattern matching on abstract syntax - -{-# OPTIONS_GHC -fno-warn-unused-matches #-} - -module Language.EO.Phi.Syntax.Skel where - -import Prelude (($), Either(..), String, (++), Show, show) -import qualified Language.EO.Phi.Syntax.Abs - -type Err = Either String -type Result = Err String - -failure :: Show a => a -> Result -failure x = Left $ "Undefined case: " ++ show x - -transBytes :: Language.EO.Phi.Syntax.Abs.Bytes -> Result -transBytes x = case x of - Language.EO.Phi.Syntax.Abs.Bytes string -> failure x - -transFunction :: Language.EO.Phi.Syntax.Abs.Function -> Result -transFunction x = case x of - Language.EO.Phi.Syntax.Abs.Function string -> failure x - -transLabelId :: Language.EO.Phi.Syntax.Abs.LabelId -> Result -transLabelId x = case x of - Language.EO.Phi.Syntax.Abs.LabelId string -> failure x - -transAlphaIndex :: Language.EO.Phi.Syntax.Abs.AlphaIndex -> Result -transAlphaIndex x = case x of - Language.EO.Phi.Syntax.Abs.AlphaIndex string -> failure x - -transProgram :: Show a => Language.EO.Phi.Syntax.Abs.Program' a -> Result -transProgram x = case x of - Language.EO.Phi.Syntax.Abs.Program _ bindings -> failure x - -transObject :: Show a => Language.EO.Phi.Syntax.Abs.Object' a -> Result -transObject x = case x of - Language.EO.Phi.Syntax.Abs.Formation _ bindings -> failure x - Language.EO.Phi.Syntax.Abs.Application _ abstractobject bindings bindingss -> failure x - Language.EO.Phi.Syntax.Abs.Dispatch _ dispatch -> failure x - Language.EO.Phi.Syntax.Abs.Termination _ -> failure x - -transAbstractObject :: Show a => Language.EO.Phi.Syntax.Abs.AbstractObject' a -> Result -transAbstractObject x = case x of - Language.EO.Phi.Syntax.Abs.AbstractFormation _ bindings -> failure x - Language.EO.Phi.Syntax.Abs.AbstractDispatch _ dispatch -> failure x - Language.EO.Phi.Syntax.Abs.AbstractTermination _ -> failure x - -transDispatchedObject :: Show a => Language.EO.Phi.Syntax.Abs.DispatchedObject' a -> Result -transDispatchedObject x = case x of - Language.EO.Phi.Syntax.Abs.DispatchedFormation _ bindings -> failure x - Language.EO.Phi.Syntax.Abs.DispatchedTermination _ -> failure x - -transBinding :: Show a => Language.EO.Phi.Syntax.Abs.Binding' a -> Result -transBinding x = case x of - Language.EO.Phi.Syntax.Abs.EmptyBinding _ attribute -> failure x - Language.EO.Phi.Syntax.Abs.DeltaBinding _ bytes -> failure x - Language.EO.Phi.Syntax.Abs.LambdaBinding _ -> failure x - -transBindings :: Show a => Language.EO.Phi.Syntax.Abs.Bindings' a -> Result -transBindings x = case x of - Language.EO.Phi.Syntax.Abs.Bindings _ bindings -> failure x - -transDispatch :: Show a => Language.EO.Phi.Syntax.Abs.Dispatch' a -> Result -transDispatch x = case x of - Language.EO.Phi.Syntax.Abs.HomeDispatch _ attributes disps -> failure x - Language.EO.Phi.Syntax.Abs.ThisDispatch _ attributes disps -> failure x - -transAttribute :: Show a => Language.EO.Phi.Syntax.Abs.Attribute' a -> Result -transAttribute x = case x of - Language.EO.Phi.Syntax.Abs.Phi _ -> failure x - Language.EO.Phi.Syntax.Abs.Rho _ -> failure x - Language.EO.Phi.Syntax.Abs.Sigma _ -> failure x - Language.EO.Phi.Syntax.Abs.VTX _ -> failure x - Language.EO.Phi.Syntax.Abs.Label _ labelid -> failure x - Language.EO.Phi.Syntax.Abs.Alpha _ alphaindex -> failure x - -transDisp :: Show a => Language.EO.Phi.Syntax.Abs.Disp' a -> Result -transDisp x = case x of - Language.EO.Phi.Syntax.Abs.Disp _ bindings1 bindings2 attributes -> failure x diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Test.hs.bak b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Test.hs.bak deleted file mode 100644 index b93523a56..000000000 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Test.hs.bak +++ /dev/null @@ -1,76 +0,0 @@ --- File generated by the BNF Converter (bnfc 2.9.5). - --- | Program to test parser. - -module Main where - -import Prelude - ( ($), (.) - , Either(..) - , Int, (>) - , String, (++), concat, unlines - , Show, show - , IO, (>>), (>>=), mapM_, putStrLn - , FilePath - , getContents, readFile - ) -import System.Environment ( getArgs ) -import System.Exit ( exitFailure ) -import Control.Monad ( when ) - -import Language.EO.Phi.Syntax.Abs () -import Language.EO.Phi.Syntax.Lex ( Token, mkPosToken ) -import Language.EO.Phi.Syntax.Par ( pAbstractObject, myLexer ) -import Language.EO.Phi.Syntax.Print ( Print, printTree ) -import Language.EO.Phi.Syntax.Skel () - -type Err = Either String -type ParseFun a = [Token] -> Err a -type Verbosity = Int - -putStrV :: Verbosity -> String -> IO () -putStrV v s = when (v > 1) $ putStrLn s - -runFile :: (Print a, Show a) => Verbosity -> ParseFun a -> FilePath -> IO () -runFile v p f = putStrLn f >> readFile f >>= run v p - -run :: (Print a, Show a) => Verbosity -> ParseFun a -> String -> IO () -run v p s = - case p ts of - Left err -> do - putStrLn "\nParse Failed...\n" - putStrV v "Tokens:" - mapM_ (putStrV v . showPosToken . mkPosToken) ts - putStrLn err - exitFailure - Right tree -> do - putStrLn "\nParse Successful!" - showTree v tree - where - ts = myLexer s - showPosToken ((l,c),t) = concat [ show l, ":", show c, "\t", show t ] - -showTree :: (Show a, Print a) => Int -> a -> IO () -showTree v tree = do - putStrV v $ "\n[Abstract Syntax]\n\n" ++ show tree - putStrV v $ "\n[Linearized tree]\n\n" ++ printTree tree - -usage :: IO () -usage = do - putStrLn $ unlines - [ "usage: Call with one of the following argument combinations:" - , " --help Display this help message." - , " (no arguments) Parse stdin verbosely." - , " (files) Parse content of files verbosely." - , " -s (files) Silent mode. Parse content of files silently." - ] - -main :: IO () -main = do - args <- getArgs - case args of - ["--help"] -> usage - [] -> getContents >>= run 2 pAbstractObject - "-s":fs -> mapM_ (runFile 0 pAbstractObject) fs - fs -> mapM_ (runFile 2 pAbstractObject) fs - From 14270bf67a0d2196882b1eacf09116cf60f3b268 Mon Sep 17 00:00:00 2001 From: Nikolai Kudasov Date: Fri, 22 Dec 2023 01:07:10 +0300 Subject: [PATCH 10/15] Make a simpler, non-ambiguous grammar --- eo-phi-normalizer/grammar/EO/Phi/Syntax.cf | 32 ++---- .../grammar/EO/Phi/Syntax.old.cf | 49 ++++++++ .../src/Language/EO/Phi/Syntax/Abs.hs | 64 +---------- .../src/Language/EO/Phi/Syntax/Doc.txt | 30 ++--- .../src/Language/EO/Phi/Syntax/Lex.x | 16 +-- .../src/Language/EO/Phi/Syntax/Par.y | 106 ++---------------- .../src/Language/EO/Phi/Syntax/Print.hs | 44 +------- .../src/Language/EO/Phi/Syntax/Skel.hs | 31 +---- 8 files changed, 95 insertions(+), 277 deletions(-) create mode 100644 eo-phi-normalizer/grammar/EO/Phi/Syntax.old.cf diff --git a/eo-phi-normalizer/grammar/EO/Phi/Syntax.cf b/eo-phi-normalizer/grammar/EO/Phi/Syntax.cf index 10db3d72e..b0d038675 100644 --- a/eo-phi-normalizer/grammar/EO/Phi/Syntax.cf +++ b/eo-phi-normalizer/grammar/EO/Phi/Syntax.cf @@ -8,42 +8,24 @@ token Bytes ({"--"} | ["0123456789ABCDEF"] ["0123456789ABCDEF"] ({"-"} ["0123456789ABCDEF"] ["0123456789ABCDEF"])* {"--"}) ; token Function upper (char - [" \r\n\t,.|':;!-?][}{)(⟧⟦"])* ; token LabelId lower (char - [" \r\n\t,.|':;!-?][}{)(⟧⟦"])* ; -token AlphaIndex ({"α0"} | {"α"} (digit - ["0"]) (digit)* ); +token AlphaIndex ({"α0"} | {"α"} (digit - ["0"]) (digit)* ) ; Program. Program ::= "{" [Binding] "}" ; Formation. Object ::= "{" [Binding] "}" ; -Application. Object ::= AbstractObject "{" [Binding] "}" [Bindings]; -Dispatch. Object ::= Dispatch ; -Termination. Object ::= "⊥"; - -AbstractFormation. AbstractObject ::= "{" [Binding] "}" ; -AbstractDispatch. AbstractObject ::= Dispatch ; -AbstractTermination. AbstractObject ::= "⊥" ; - -DispatchedFormation. DispatchedObject ::= "{" [Binding] "}" ; -DispatchedTermination. DispatchedObject ::= "⊥" ; +Application. Object ::= Object "{" [Binding] "}" ; +Dispatch. Object ::= Object "." Attribute ; +Termination. Object ::= "⊥" ; AlphaBinding. Binding ::= Attribute "↦" Object ; EmptyBinding. Binding ::= Attribute "↦" "∅" ; -DeltaBinding. Binding ::= "Δ" "⤍" Bytes; -LambdaBinding. Binding ::= "λ" "⤍" ; +DeltaBinding. Binding ::= "Δ" "⤍" Bytes ; +LambdaBinding. Binding ::= "λ" "⤍" Function ; separator Binding "," ; -Bindings. Bindings ::= "{" [Binding] "}" ; -separator Bindings "" ; - -ObjectDispatch. Dispatch ::= DispatchedObject [Bindings] "." [Attribute] [Disp] ; -HomeDispatch. Dispatch ::= "Φ" "." [Attribute] [Disp] ; -ThisDispatch. Dispatch ::= "ξ" "." [Attribute] [Disp] ; - Phi. Attribute ::= "φ" ; -- decoratee object Rho. Attribute ::= "ρ" ; -- parent object -Sigma. Attribute ::= "σ" ; -- ??? +Sigma. Attribute ::= "σ" ; -- home object VTX. Attribute ::= "ν" ; -- ??? Label. Attribute ::= LabelId ; Alpha. Attribute ::= AlphaIndex ; -separator nonempty Attribute "." ; - -Disp. Disp ::= "{" [Binding] "}" Bindings "." [Attribute] ; -separator Disp "" ; diff --git a/eo-phi-normalizer/grammar/EO/Phi/Syntax.old.cf b/eo-phi-normalizer/grammar/EO/Phi/Syntax.old.cf new file mode 100644 index 000000000..72a2f0c4a --- /dev/null +++ b/eo-phi-normalizer/grammar/EO/Phi/Syntax.old.cf @@ -0,0 +1,49 @@ +-- ========================================================== +-- BNFC grammar for φ-programs (translated from EO) +-- ========================================================== +-- +-- This grammar is a (manual) translation of Phi.g4 grammar from objectionary/eo: +-- https://github.com/objectionary/eo/blob/fa24c7cc47e1ac473fb930f3a08ccc4d88d9d1e3/eo-parser/src/main/antlr4/org/eolang/parser/Phi.g4 + +token Bytes ({"--"} | ["0123456789ABCDEF"] ["0123456789ABCDEF"] ({"-"} ["0123456789ABCDEF"] ["0123456789ABCDEF"])* {"--"}) ; +token Function upper (char - [" \r\n\t,.|':;!-?][}{)(⟧⟦"])* ; +token LabelId lower (char - [" \r\n\t,.|':;!-?][}{)(⟧⟦"])* ; +token AlphaIndex ({"α0"} | {"α"} (digit - ["0"]) (digit)* ) ; + +Program. Program ::= "{" [Binding] "}" ; + +Formation. Object ::= "{" [Binding] "}" ; +Application. Object ::= AbstractObject "{" [Binding] "}" [Bindings] ; +Dispatch. Object ::= Dispatch ; +Termination. Object ::= "⊥"; + +AbstractFormation. AbstractObject ::= "{" [Binding] "}" ; +AbstractDispatch. AbstractObject ::= Dispatch ; +AbstractTermination. AbstractObject ::= "⊥" ; + +DispatchedFormation. DispatchedObject ::= "{" [Binding] "}" ; +DispatchedTermination. DispatchedObject ::= "⊥" ; + +AlphaBinding. Binding ::= Attribute "↦" Object ; +EmptyBinding. Binding ::= Attribute "↦" "∅" ; +DeltaBinding. Binding ::= "Δ" "⤍" Bytes ; +LambdaBinding. Binding ::= "λ" "⤍" Function ; +separator Binding "," ; + +Bindings. Bindings ::= "{" [Binding] "}" ; +separator Bindings "" ; + +ObjectDispatch. Dispatch ::= DispatchedObject [Bindings] "." [Attribute] [Disp] ; +HomeDispatch. Dispatch ::= "Φ" "." [Attribute] [Disp] ; +ThisDispatch. Dispatch ::= "ξ" "." [Attribute] [Disp] ; + +Phi. Attribute ::= "φ" ; -- decoratee object +Rho. Attribute ::= "ρ" ; -- parent object +Sigma. Attribute ::= "σ" ; -- ??? +VTX. Attribute ::= "ν" ; -- ??? +Label. Attribute ::= LabelId ; +Alpha. Attribute ::= AlphaIndex ; +separator nonempty Attribute "." ; + +Disp. Disp ::= "{" [Binding] "}" Bindings "." [Attribute] ; +separator Disp "" ; diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Abs.hs b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Abs.hs index b234f3e8e..9bdc7c7d5 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Abs.hs +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Abs.hs @@ -30,40 +30,17 @@ data Program' a = Program a [Binding' a] type Object = Object' BNFC'Position data Object' a = Formation a [Binding' a] - | Application a (AbstractObject' a) [Binding' a] [Bindings' a] - | Dispatch a (Dispatch' a) + | Application a (Object' a) [Binding' a] + | Dispatch a (Object' a) (Attribute' a) | Termination a deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) -type AbstractObject = AbstractObject' BNFC'Position -data AbstractObject' a - = AbstractFormation a [Binding' a] - | AbstractDispatch a (Dispatch' a) - | AbstractTermination a - deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) - -type DispatchedObject = DispatchedObject' BNFC'Position -data DispatchedObject' a - = DispatchedFormation a [Binding' a] | DispatchedTermination a - deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) - type Binding = Binding' BNFC'Position data Binding' a = AlphaBinding a (Attribute' a) (Object' a) | EmptyBinding a (Attribute' a) | DeltaBinding a Bytes - | LambdaBinding a - deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) - -type Bindings = Bindings' BNFC'Position -data Bindings' a = Bindings a [Binding' a] - deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) - -type Dispatch = Dispatch' BNFC'Position -data Dispatch' a - = ObjectDispatch a (DispatchedObject' a) [Bindings' a] [Attribute' a] [Disp' a] - | HomeDispatch a [Attribute' a] [Disp' a] - | ThisDispatch a [Attribute' a] [Disp' a] + | LambdaBinding a Function deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) type Attribute = Attribute' BNFC'Position @@ -76,10 +53,6 @@ data Attribute' a | Alpha a AlphaIndex deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) -type Disp = Disp' BNFC'Position -data Disp' a = Disp a [Binding' a] (Bindings' a) [Attribute' a] - deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) - newtype Bytes = Bytes String deriving (C.Eq, C.Ord, C.Show, C.Read, C.Data, C.Typeable, C.Generic, Data.String.IsString) @@ -114,37 +87,16 @@ instance HasPosition Program where instance HasPosition Object where hasPosition = \case Formation p _ -> p - Application p _ _ _ -> p - Dispatch p _ -> p + Application p _ _ -> p + Dispatch p _ _ -> p Termination p -> p -instance HasPosition AbstractObject where - hasPosition = \case - AbstractFormation p _ -> p - AbstractDispatch p _ -> p - AbstractTermination p -> p - -instance HasPosition DispatchedObject where - hasPosition = \case - DispatchedFormation p _ -> p - DispatchedTermination p -> p - instance HasPosition Binding where hasPosition = \case AlphaBinding p _ _ -> p EmptyBinding p _ -> p DeltaBinding p _ -> p - LambdaBinding p -> p - -instance HasPosition Bindings where - hasPosition = \case - Bindings p _ -> p - -instance HasPosition Dispatch where - hasPosition = \case - ObjectDispatch p _ _ _ _ -> p - HomeDispatch p _ _ -> p - ThisDispatch p _ _ -> p + LambdaBinding p _ -> p instance HasPosition Attribute where hasPosition = \case @@ -155,7 +107,3 @@ instance HasPosition Attribute where Label p _ -> p Alpha p _ -> p -instance HasPosition Disp where - hasPosition = \case - Disp p _ _ _ -> p - diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt index 2f1238ec4..8eb276aed 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt @@ -35,12 +35,12 @@ AlphaIndex literals are recognized by the regular expression The set of reserved words is the set of terminals appearing in the grammar. Those reserved words that consist of non-letter characters are called symbols, and they are treated in a different way from those that are similar to identifiers. The lexer follows rules familiar from languages like Haskell, C, and Java, including longest match and spacing conventions. The reserved words used in Syntax are the following: - | ``Δ`` | ``Φ`` | ``λ`` | ``ν`` - | ``ξ`` | ``ρ`` | ``σ`` | ``φ`` + | ``Δ`` | ``λ`` | ``ν`` | ``ρ`` + | ``σ`` | ``φ`` | | The symbols used in Syntax are the following: - | { | } | ⊥ | ↦ - | ∅ | ⤍ | , | . + | { | } | . | ⊥ + | ↦ | ∅ | ⤍ | , ===Comments=== There are no single-line comments in the grammar.There are no multiple-line comments in the grammar. @@ -53,38 +53,22 @@ All other symbols are terminals. | //Program// | -> | ``{`` //[Binding]// ``}`` | //Object// | -> | ``{`` //[Binding]// ``}`` - | | **|** | //AbstractObject// ``{`` //[Binding]// ``}`` //[Bindings]// - | | **|** | //Dispatch// - | | **|** | ``⊥`` - | //AbstractObject// | -> | ``{`` //[Binding]// ``}`` - | | **|** | //Dispatch// - | | **|** | ``⊥`` - | //DispatchedObject// | -> | ``{`` //[Binding]// ``}`` + | | **|** | //Object// ``{`` //[Binding]// ``}`` + | | **|** | //Object// ``.`` //Attribute// | | **|** | ``⊥`` | //Binding// | -> | //Attribute// ``↦`` //Object// | | **|** | //Attribute// ``↦`` ``∅`` | | **|** | ``Δ`` ``⤍`` //Bytes// - | | **|** | ``λ`` ``⤍`` + | | **|** | ``λ`` ``⤍`` //Function// | //[Binding]// | -> | **eps** | | **|** | //Binding// | | **|** | //Binding// ``,`` //[Binding]// - | //Bindings// | -> | ``{`` //[Binding]// ``}`` - | //[Bindings]// | -> | **eps** - | | **|** | //Bindings// //[Bindings]// - | //Dispatch// | -> | //DispatchedObject// //[Bindings]// ``.`` //[Attribute]// //[Disp]// - | | **|** | ``Φ`` ``.`` //[Attribute]// //[Disp]// - | | **|** | ``ξ`` ``.`` //[Attribute]// //[Disp]// | //Attribute// | -> | ``φ`` | | **|** | ``ρ`` | | **|** | ``σ`` | | **|** | ``ν`` | | **|** | //LabelId// | | **|** | //AlphaIndex// - | //[Attribute]// | -> | //Attribute// - | | **|** | //Attribute// ``.`` //[Attribute]// - | //Disp// | -> | ``{`` //[Binding]// ``}`` //Bindings// ``.`` //[Attribute]// - | //[Disp]// | -> | **eps** - | | **|** | //Disp// //[Disp]// diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.x b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.x index e36054bde..d2b6608f1 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.x +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.x @@ -28,7 +28,7 @@ $u = [. \n] -- universal: any character -- Symbols and non-identifier-like reserved words -@rsyms = \Δ | \λ | \Φ | \ξ | \φ | \ρ | \σ | \ν | \{ | \} | \⊥ | \↦ | \∅ | \⤍ | \, | \. +@rsyms = \Δ | \λ | \φ | \ρ | \σ | \ν | \{ | \} | \. | \⊥ | \↦ | \∅ | \⤍ | \, :- @@ -168,13 +168,13 @@ eitherResIdent tv s = treeFind resWords -- | The keywords and symbols of the language organized as binary search tree. resWords :: BTree resWords = - b "\958" 9 - (b "\916" 5 - (b "{" 3 (b "." 2 (b "," 1 N N) N) (b "}" 4 N N)) - (b "\955" 7 (b "\934" 6 N N) (b "\957" 8 N N))) - (b "\8614" 13 - (b "\963" 11 (b "\961" 10 N N) (b "\966" 12 N N)) - (b "\8869" 15 (b "\8709" 14 N N) (b "\10509" 16 N N))) + b "\961" 8 + (b "}" 4 + (b "." 2 (b "," 1 N N) (b "{" 3 N N)) + (b "\955" 6 (b "\916" 5 N N) (b "\957" 7 N N))) + (b "\8709" 12 + (b "\966" 10 (b "\963" 9 N N) (b "\8614" 11 N N)) + (b "\10509" 14 (b "\8869" 13 N N) N)) where b s n = B bs (TS bs n) where diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y index 382664649..ef49762fc 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y @@ -10,17 +10,9 @@ module Language.EO.Phi.Syntax.Par , myLexer , pProgram , pObject - , pAbstractObject - , pDispatchedObject , pBinding , pListBinding - , pBindings - , pListBindings - , pDispatch , pAttribute - , pListAttribute - , pDisp - , pListDisp ) where import Prelude @@ -32,17 +24,9 @@ import Language.EO.Phi.Syntax.Lex %name pProgram_internal Program %name pObject_internal Object -%name pAbstractObject_internal AbstractObject -%name pDispatchedObject_internal DispatchedObject %name pBinding_internal Binding %name pListBinding_internal ListBinding -%name pBindings_internal Bindings -%name pListBindings_internal ListBindings -%name pDispatch_internal Dispatch %name pAttribute_internal Attribute -%name pListAttribute_internal ListAttribute -%name pDisp_internal Disp -%name pListDisp_internal ListDisp -- no lexer declaration %monad { Err } { (>>=) } { return } %tokentype {Token} @@ -52,17 +36,15 @@ import Language.EO.Phi.Syntax.Lex '{' { PT _ (TS _ 3) } '}' { PT _ (TS _ 4) } 'Δ' { PT _ (TS _ 5) } - 'Φ' { PT _ (TS _ 6) } - 'λ' { PT _ (TS _ 7) } - 'ν' { PT _ (TS _ 8) } - 'ξ' { PT _ (TS _ 9) } - 'ρ' { PT _ (TS _ 10) } - 'σ' { PT _ (TS _ 11) } - 'φ' { PT _ (TS _ 12) } - '↦' { PT _ (TS _ 13) } - '∅' { PT _ (TS _ 14) } - '⊥' { PT _ (TS _ 15) } - '⤍' { PT _ (TS _ 16) } + 'λ' { PT _ (TS _ 6) } + 'ν' { PT _ (TS _ 7) } + 'ρ' { PT _ (TS _ 8) } + 'σ' { PT _ (TS _ 9) } + 'φ' { PT _ (TS _ 10) } + '↦' { PT _ (TS _ 11) } + '∅' { PT _ (TS _ 12) } + '⊥' { PT _ (TS _ 13) } + '⤍' { PT _ (TS _ 14) } L_Bytes { PT _ (T_Bytes _) } L_Function { PT _ (T_Function _) } L_LabelId { PT _ (T_LabelId _) } @@ -89,27 +71,16 @@ Program Object :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Object) } Object : '{' ListBinding '}' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Formation (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $2)) } - | AbstractObject '{' ListBinding '}' ListBindings { (fst $1, Language.EO.Phi.Syntax.Abs.Application (fst $1) (snd $1) (snd $3) (snd $5)) } - | Dispatch { (fst $1, Language.EO.Phi.Syntax.Abs.Dispatch (fst $1) (snd $1)) } + | Object '{' ListBinding '}' { (fst $1, Language.EO.Phi.Syntax.Abs.Application (fst $1) (snd $1) (snd $3)) } + | Object '.' Attribute { (fst $1, Language.EO.Phi.Syntax.Abs.Dispatch (fst $1) (snd $1) (snd $3)) } | '⊥' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Termination (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } -AbstractObject :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.AbstractObject) } -AbstractObject - : '{' ListBinding '}' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.AbstractFormation (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $2)) } - | Dispatch { (fst $1, Language.EO.Phi.Syntax.Abs.AbstractDispatch (fst $1) (snd $1)) } - | '⊥' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.AbstractTermination (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } - -DispatchedObject :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.DispatchedObject) } -DispatchedObject - : '{' ListBinding '}' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.DispatchedFormation (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $2)) } - | '⊥' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.DispatchedTermination (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } - Binding :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Binding) } Binding : Attribute '↦' Object { (fst $1, Language.EO.Phi.Syntax.Abs.AlphaBinding (fst $1) (snd $1) (snd $3)) } | Attribute '↦' '∅' { (fst $1, Language.EO.Phi.Syntax.Abs.EmptyBinding (fst $1) (snd $1)) } | 'Δ' '⤍' Bytes { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.DeltaBinding (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $3)) } - | 'λ' '⤍' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.LambdaBinding (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } + | 'λ' '⤍' Function { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.LambdaBinding (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $3)) } ListBinding :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, [Language.EO.Phi.Syntax.Abs.Binding]) } ListBinding @@ -117,21 +88,6 @@ ListBinding | Binding { (fst $1, (:[]) (snd $1)) } | Binding ',' ListBinding { (fst $1, (:) (snd $1) (snd $3)) } -Bindings :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Bindings) } -Bindings - : '{' ListBinding '}' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Bindings (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $2)) } - -ListBindings :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, [Language.EO.Phi.Syntax.Abs.Bindings]) } -ListBindings - : {- empty -} { (Language.EO.Phi.Syntax.Abs.BNFC'NoPosition, []) } - | Bindings ListBindings { (fst $1, (:) (snd $1) (snd $2)) } - -Dispatch :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Dispatch) } -Dispatch - : DispatchedObject ListBindings '.' ListAttribute ListDisp { (fst $1, Language.EO.Phi.Syntax.Abs.ObjectDispatch (fst $1) (snd $1) (snd $2) (snd $4) (snd $5)) } - | 'Φ' '.' ListAttribute ListDisp { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.HomeDispatch (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $3) (snd $4)) } - | 'ξ' '.' ListAttribute ListDisp { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.ThisDispatch (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $3) (snd $4)) } - Attribute :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Attribute) } Attribute : 'φ' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Phi (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } @@ -141,20 +97,6 @@ Attribute | LabelId { (fst $1, Language.EO.Phi.Syntax.Abs.Label (fst $1) (snd $1)) } | AlphaIndex { (fst $1, Language.EO.Phi.Syntax.Abs.Alpha (fst $1) (snd $1)) } -ListAttribute :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, [Language.EO.Phi.Syntax.Abs.Attribute]) } -ListAttribute - : Attribute { (fst $1, (:[]) (snd $1)) } - | Attribute '.' ListAttribute { (fst $1, (:) (snd $1) (snd $3)) } - -Disp :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Disp) } -Disp - : '{' ListBinding '}' Bindings '.' ListAttribute { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Disp (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $2) (snd $4) (snd $6)) } - -ListDisp :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, [Language.EO.Phi.Syntax.Abs.Disp]) } -ListDisp - : {- empty -} { (Language.EO.Phi.Syntax.Abs.BNFC'NoPosition, []) } - | Disp ListDisp { (fst $1, (:) (snd $1) (snd $2)) } - { type Err = Either String @@ -178,37 +120,13 @@ pProgram = fmap snd . pProgram_internal pObject :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Object pObject = fmap snd . pObject_internal -pAbstractObject :: [Token] -> Err Language.EO.Phi.Syntax.Abs.AbstractObject -pAbstractObject = fmap snd . pAbstractObject_internal - -pDispatchedObject :: [Token] -> Err Language.EO.Phi.Syntax.Abs.DispatchedObject -pDispatchedObject = fmap snd . pDispatchedObject_internal - pBinding :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Binding pBinding = fmap snd . pBinding_internal pListBinding :: [Token] -> Err [Language.EO.Phi.Syntax.Abs.Binding] pListBinding = fmap snd . pListBinding_internal -pBindings :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Bindings -pBindings = fmap snd . pBindings_internal - -pListBindings :: [Token] -> Err [Language.EO.Phi.Syntax.Abs.Bindings] -pListBindings = fmap snd . pListBindings_internal - -pDispatch :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Dispatch -pDispatch = fmap snd . pDispatch_internal - pAttribute :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Attribute pAttribute = fmap snd . pAttribute_internal - -pListAttribute :: [Token] -> Err [Language.EO.Phi.Syntax.Abs.Attribute] -pListAttribute = fmap snd . pListAttribute_internal - -pDisp :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Disp -pDisp = fmap snd . pDisp_internal - -pListDisp :: [Token] -> Err [Language.EO.Phi.Syntax.Abs.Disp] -pListDisp = fmap snd . pListDisp_internal } diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs index 8be1ef5c4..3335b9e01 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs @@ -152,47 +152,22 @@ instance Print (Language.EO.Phi.Syntax.Abs.Program' a) where instance Print (Language.EO.Phi.Syntax.Abs.Object' a) where prt i = \case Language.EO.Phi.Syntax.Abs.Formation _ bindings -> prPrec i 0 (concatD [doc (showString "{"), prt 0 bindings, doc (showString "}")]) - Language.EO.Phi.Syntax.Abs.Application _ abstractobject bindings bindingss -> prPrec i 0 (concatD [prt 0 abstractobject, doc (showString "{"), prt 0 bindings, doc (showString "}"), prt 0 bindingss]) - Language.EO.Phi.Syntax.Abs.Dispatch _ dispatch -> prPrec i 0 (concatD [prt 0 dispatch]) + Language.EO.Phi.Syntax.Abs.Application _ object bindings -> prPrec i 0 (concatD [prt 0 object, doc (showString "{"), prt 0 bindings, doc (showString "}")]) + Language.EO.Phi.Syntax.Abs.Dispatch _ object attribute -> prPrec i 0 (concatD [prt 0 object, doc (showString "."), prt 0 attribute]) Language.EO.Phi.Syntax.Abs.Termination _ -> prPrec i 0 (concatD [doc (showString "\8869")]) -instance Print (Language.EO.Phi.Syntax.Abs.AbstractObject' a) where - prt i = \case - Language.EO.Phi.Syntax.Abs.AbstractFormation _ bindings -> prPrec i 0 (concatD [doc (showString "{"), prt 0 bindings, doc (showString "}")]) - Language.EO.Phi.Syntax.Abs.AbstractDispatch _ dispatch -> prPrec i 0 (concatD [prt 0 dispatch]) - Language.EO.Phi.Syntax.Abs.AbstractTermination _ -> prPrec i 0 (concatD [doc (showString "\8869")]) - -instance Print (Language.EO.Phi.Syntax.Abs.DispatchedObject' a) where - prt i = \case - Language.EO.Phi.Syntax.Abs.DispatchedFormation _ bindings -> prPrec i 0 (concatD [doc (showString "{"), prt 0 bindings, doc (showString "}")]) - Language.EO.Phi.Syntax.Abs.DispatchedTermination _ -> prPrec i 0 (concatD [doc (showString "\8869")]) - instance Print (Language.EO.Phi.Syntax.Abs.Binding' a) where prt i = \case Language.EO.Phi.Syntax.Abs.AlphaBinding _ attribute object -> prPrec i 0 (concatD [prt 0 attribute, doc (showString "\8614"), prt 0 object]) Language.EO.Phi.Syntax.Abs.EmptyBinding _ attribute -> prPrec i 0 (concatD [prt 0 attribute, doc (showString "\8614"), doc (showString "\8709")]) Language.EO.Phi.Syntax.Abs.DeltaBinding _ bytes -> prPrec i 0 (concatD [doc (showString "\916"), doc (showString "\10509"), prt 0 bytes]) - Language.EO.Phi.Syntax.Abs.LambdaBinding _ -> prPrec i 0 (concatD [doc (showString "\955"), doc (showString "\10509")]) + Language.EO.Phi.Syntax.Abs.LambdaBinding _ function -> prPrec i 0 (concatD [doc (showString "\955"), doc (showString "\10509"), prt 0 function]) instance Print [Language.EO.Phi.Syntax.Abs.Binding' a] where prt _ [] = concatD [] prt _ [x] = concatD [prt 0 x] prt _ (x:xs) = concatD [prt 0 x, doc (showString ","), prt 0 xs] -instance Print (Language.EO.Phi.Syntax.Abs.Bindings' a) where - prt i = \case - Language.EO.Phi.Syntax.Abs.Bindings _ bindings -> prPrec i 0 (concatD [doc (showString "{"), prt 0 bindings, doc (showString "}")]) - -instance Print [Language.EO.Phi.Syntax.Abs.Bindings' a] where - prt _ [] = concatD [] - prt _ (x:xs) = concatD [prt 0 x, prt 0 xs] - -instance Print (Language.EO.Phi.Syntax.Abs.Dispatch' a) where - prt i = \case - Language.EO.Phi.Syntax.Abs.ObjectDispatch _ dispatchedobject bindingss attributes disps -> prPrec i 0 (concatD [prt 0 dispatchedobject, prt 0 bindingss, doc (showString "."), prt 0 attributes, prt 0 disps]) - Language.EO.Phi.Syntax.Abs.HomeDispatch _ attributes disps -> prPrec i 0 (concatD [doc (showString "\934"), doc (showString "."), prt 0 attributes, prt 0 disps]) - Language.EO.Phi.Syntax.Abs.ThisDispatch _ attributes disps -> prPrec i 0 (concatD [doc (showString "\958"), doc (showString "."), prt 0 attributes, prt 0 disps]) - instance Print (Language.EO.Phi.Syntax.Abs.Attribute' a) where prt i = \case Language.EO.Phi.Syntax.Abs.Phi _ -> prPrec i 0 (concatD [doc (showString "\966")]) @@ -201,16 +176,3 @@ instance Print (Language.EO.Phi.Syntax.Abs.Attribute' a) where Language.EO.Phi.Syntax.Abs.VTX _ -> prPrec i 0 (concatD [doc (showString "\957")]) Language.EO.Phi.Syntax.Abs.Label _ labelid -> prPrec i 0 (concatD [prt 0 labelid]) Language.EO.Phi.Syntax.Abs.Alpha _ alphaindex -> prPrec i 0 (concatD [prt 0 alphaindex]) - -instance Print [Language.EO.Phi.Syntax.Abs.Attribute' a] where - prt _ [] = concatD [] - prt _ [x] = concatD [prt 0 x] - prt _ (x:xs) = concatD [prt 0 x, doc (showString "."), prt 0 xs] - -instance Print (Language.EO.Phi.Syntax.Abs.Disp' a) where - prt i = \case - Language.EO.Phi.Syntax.Abs.Disp _ bindings1 bindings2 attributes -> prPrec i 0 (concatD [doc (showString "{"), prt 0 bindings1, doc (showString "}"), prt 0 bindings2, doc (showString "."), prt 0 attributes]) - -instance Print [Language.EO.Phi.Syntax.Abs.Disp' a] where - prt _ [] = concatD [] - prt _ (x:xs) = concatD [prt 0 x, prt 0 xs] diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Skel.hs b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Skel.hs index 735fb29e0..2cfe2f044 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Skel.hs +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Skel.hs @@ -38,37 +38,16 @@ transProgram x = case x of transObject :: Show a => Language.EO.Phi.Syntax.Abs.Object' a -> Result transObject x = case x of Language.EO.Phi.Syntax.Abs.Formation _ bindings -> failure x - Language.EO.Phi.Syntax.Abs.Application _ abstractobject bindings bindingss -> failure x - Language.EO.Phi.Syntax.Abs.Dispatch _ dispatch -> failure x + Language.EO.Phi.Syntax.Abs.Application _ object bindings -> failure x + Language.EO.Phi.Syntax.Abs.Dispatch _ object attribute -> failure x Language.EO.Phi.Syntax.Abs.Termination _ -> failure x -transAbstractObject :: Show a => Language.EO.Phi.Syntax.Abs.AbstractObject' a -> Result -transAbstractObject x = case x of - Language.EO.Phi.Syntax.Abs.AbstractFormation _ bindings -> failure x - Language.EO.Phi.Syntax.Abs.AbstractDispatch _ dispatch -> failure x - Language.EO.Phi.Syntax.Abs.AbstractTermination _ -> failure x - -transDispatchedObject :: Show a => Language.EO.Phi.Syntax.Abs.DispatchedObject' a -> Result -transDispatchedObject x = case x of - Language.EO.Phi.Syntax.Abs.DispatchedFormation _ bindings -> failure x - Language.EO.Phi.Syntax.Abs.DispatchedTermination _ -> failure x - transBinding :: Show a => Language.EO.Phi.Syntax.Abs.Binding' a -> Result transBinding x = case x of Language.EO.Phi.Syntax.Abs.AlphaBinding _ attribute object -> failure x Language.EO.Phi.Syntax.Abs.EmptyBinding _ attribute -> failure x Language.EO.Phi.Syntax.Abs.DeltaBinding _ bytes -> failure x - Language.EO.Phi.Syntax.Abs.LambdaBinding _ -> failure x - -transBindings :: Show a => Language.EO.Phi.Syntax.Abs.Bindings' a -> Result -transBindings x = case x of - Language.EO.Phi.Syntax.Abs.Bindings _ bindings -> failure x - -transDispatch :: Show a => Language.EO.Phi.Syntax.Abs.Dispatch' a -> Result -transDispatch x = case x of - Language.EO.Phi.Syntax.Abs.ObjectDispatch _ dispatchedobject bindingss attributes disps -> failure x - Language.EO.Phi.Syntax.Abs.HomeDispatch _ attributes disps -> failure x - Language.EO.Phi.Syntax.Abs.ThisDispatch _ attributes disps -> failure x + Language.EO.Phi.Syntax.Abs.LambdaBinding _ function -> failure x transAttribute :: Show a => Language.EO.Phi.Syntax.Abs.Attribute' a -> Result transAttribute x = case x of @@ -78,7 +57,3 @@ transAttribute x = case x of Language.EO.Phi.Syntax.Abs.VTX _ -> failure x Language.EO.Phi.Syntax.Abs.Label _ labelid -> failure x Language.EO.Phi.Syntax.Abs.Alpha _ alphaindex -> failure x - -transDisp :: Show a => Language.EO.Phi.Syntax.Abs.Disp' a -> Result -transDisp x = case x of - Language.EO.Phi.Syntax.Abs.Disp _ bindings1 bindings2 attributes -> failure x From 345934b3dccf6b416e6a74a05750c152f38c55d7 Mon Sep 17 00:00:00 2001 From: Nikolai Kudasov Date: Fri, 22 Dec 2023 01:09:22 +0300 Subject: [PATCH 11/15] Remove more ignored files from repo --- .../src/Language/EO/Phi/Syntax/ErrM.hs | 91 ------------------- .../src/Language/EO/Phi/Syntax/Skel.hs | 59 ------------ .../src/Language/EO/Phi/Syntax/Test.hs | 76 ---------------- 3 files changed, 226 deletions(-) delete mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Syntax/ErrM.hs delete mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Syntax/Skel.hs delete mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Syntax/Test.hs diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/ErrM.hs b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/ErrM.hs deleted file mode 100644 index fb27b4f4c..000000000 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/ErrM.hs +++ /dev/null @@ -1,91 +0,0 @@ --- File generated by the BNF Converter (bnfc 2.9.5). - -{-# LANGUAGE CPP #-} - -#if __GLASGOW_HASKELL__ >= 708 ---------------------------------------------------------------------------- --- Pattern synonyms exist since ghc 7.8. - --- | BNF Converter: Error Monad. --- --- Module for backwards compatibility. --- --- The generated parser now uses @'Either' String@ as error monad. --- This module defines a type synonym 'Err' and pattern synonyms --- 'Bad' and 'Ok' for 'Left' and 'Right'. - -{-# LANGUAGE PatternSynonyms #-} -{-# LANGUAGE FlexibleInstances #-} - -module Language.EO.Phi.Syntax.ErrM where - -import Prelude (id, const, Either(..), String) - -import Control.Monad (MonadPlus(..)) -import Control.Applicative (Alternative(..)) -#if __GLASGOW_HASKELL__ >= 808 -import Control.Monad (MonadFail(..)) -#endif - --- | Error monad with 'String' error messages. -type Err = Either String - -pattern Bad msg = Left msg -pattern Ok a = Right a - -#if __GLASGOW_HASKELL__ >= 808 -instance MonadFail Err where - fail = Bad -#endif - -instance Alternative Err where - empty = Left "Err.empty" - (<|>) Left{} = id - (<|>) x@Right{} = const x - -instance MonadPlus Err where - mzero = empty - mplus = (<|>) - -#else ---------------------------------------------------------------------------- --- ghc 7.6 and before: use old definition as data type. - --- | BNF Converter: Error Monad - --- Copyright (C) 2004 Author: Aarne Ranta --- This file comes with NO WARRANTY and may be used FOR ANY PURPOSE. - -module Language.EO.Phi.Syntax.ErrM where - --- the Error monad: like Maybe type with error msgs - -import Control.Applicative (Applicative(..), Alternative(..)) -import Control.Monad (MonadPlus(..), liftM) - -data Err a = Ok a | Bad String - deriving (Read, Show, Eq, Ord) - -instance Monad Err where - return = Ok - Ok a >>= f = f a - Bad s >>= _ = Bad s - -instance Applicative Err where - pure = Ok - (Bad s) <*> _ = Bad s - (Ok f) <*> o = liftM f o - -instance Functor Err where - fmap = liftM - -instance MonadPlus Err where - mzero = Bad "Err.mzero" - mplus (Bad _) y = y - mplus x _ = x - -instance Alternative Err where - empty = mzero - (<|>) = mplus - -#endif diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Skel.hs b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Skel.hs deleted file mode 100644 index 2cfe2f044..000000000 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Skel.hs +++ /dev/null @@ -1,59 +0,0 @@ --- File generated by the BNF Converter (bnfc 2.9.5). - --- Templates for pattern matching on abstract syntax - -{-# OPTIONS_GHC -fno-warn-unused-matches #-} - -module Language.EO.Phi.Syntax.Skel where - -import Prelude (($), Either(..), String, (++), Show, show) -import qualified Language.EO.Phi.Syntax.Abs - -type Err = Either String -type Result = Err String - -failure :: Show a => a -> Result -failure x = Left $ "Undefined case: " ++ show x - -transBytes :: Language.EO.Phi.Syntax.Abs.Bytes -> Result -transBytes x = case x of - Language.EO.Phi.Syntax.Abs.Bytes string -> failure x - -transFunction :: Language.EO.Phi.Syntax.Abs.Function -> Result -transFunction x = case x of - Language.EO.Phi.Syntax.Abs.Function string -> failure x - -transLabelId :: Language.EO.Phi.Syntax.Abs.LabelId -> Result -transLabelId x = case x of - Language.EO.Phi.Syntax.Abs.LabelId string -> failure x - -transAlphaIndex :: Language.EO.Phi.Syntax.Abs.AlphaIndex -> Result -transAlphaIndex x = case x of - Language.EO.Phi.Syntax.Abs.AlphaIndex string -> failure x - -transProgram :: Show a => Language.EO.Phi.Syntax.Abs.Program' a -> Result -transProgram x = case x of - Language.EO.Phi.Syntax.Abs.Program _ bindings -> failure x - -transObject :: Show a => Language.EO.Phi.Syntax.Abs.Object' a -> Result -transObject x = case x of - Language.EO.Phi.Syntax.Abs.Formation _ bindings -> failure x - Language.EO.Phi.Syntax.Abs.Application _ object bindings -> failure x - Language.EO.Phi.Syntax.Abs.Dispatch _ object attribute -> failure x - Language.EO.Phi.Syntax.Abs.Termination _ -> failure x - -transBinding :: Show a => Language.EO.Phi.Syntax.Abs.Binding' a -> Result -transBinding x = case x of - Language.EO.Phi.Syntax.Abs.AlphaBinding _ attribute object -> failure x - Language.EO.Phi.Syntax.Abs.EmptyBinding _ attribute -> failure x - Language.EO.Phi.Syntax.Abs.DeltaBinding _ bytes -> failure x - Language.EO.Phi.Syntax.Abs.LambdaBinding _ function -> failure x - -transAttribute :: Show a => Language.EO.Phi.Syntax.Abs.Attribute' a -> Result -transAttribute x = case x of - Language.EO.Phi.Syntax.Abs.Phi _ -> failure x - Language.EO.Phi.Syntax.Abs.Rho _ -> failure x - Language.EO.Phi.Syntax.Abs.Sigma _ -> failure x - Language.EO.Phi.Syntax.Abs.VTX _ -> failure x - Language.EO.Phi.Syntax.Abs.Label _ labelid -> failure x - Language.EO.Phi.Syntax.Abs.Alpha _ alphaindex -> failure x diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Test.hs b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Test.hs deleted file mode 100644 index 1e846af00..000000000 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Test.hs +++ /dev/null @@ -1,76 +0,0 @@ --- File generated by the BNF Converter (bnfc 2.9.5). - --- | Program to test parser. - -module Main where - -import Prelude - ( ($), (.) - , Either(..) - , Int, (>) - , String, (++), concat, unlines - , Show, show - , IO, (>>), (>>=), mapM_, putStrLn - , FilePath - , getContents, readFile - ) -import System.Environment ( getArgs ) -import System.Exit ( exitFailure ) -import Control.Monad ( when ) - -import Language.EO.Phi.Syntax.Abs () -import Language.EO.Phi.Syntax.Lex ( Token, mkPosToken ) -import Language.EO.Phi.Syntax.Par ( pProgram, myLexer ) -import Language.EO.Phi.Syntax.Print ( Print, printTree ) -import Language.EO.Phi.Syntax.Skel () - -type Err = Either String -type ParseFun a = [Token] -> Err a -type Verbosity = Int - -putStrV :: Verbosity -> String -> IO () -putStrV v s = when (v > 1) $ putStrLn s - -runFile :: (Print a, Show a) => Verbosity -> ParseFun a -> FilePath -> IO () -runFile v p f = putStrLn f >> readFile f >>= run v p - -run :: (Print a, Show a) => Verbosity -> ParseFun a -> String -> IO () -run v p s = - case p ts of - Left err -> do - putStrLn "\nParse Failed...\n" - putStrV v "Tokens:" - mapM_ (putStrV v . showPosToken . mkPosToken) ts - putStrLn err - exitFailure - Right tree -> do - putStrLn "\nParse Successful!" - showTree v tree - where - ts = myLexer s - showPosToken ((l,c),t) = concat [ show l, ":", show c, "\t", show t ] - -showTree :: (Show a, Print a) => Int -> a -> IO () -showTree v tree = do - putStrV v $ "\n[Abstract Syntax]\n\n" ++ show tree - putStrV v $ "\n[Linearized tree]\n\n" ++ printTree tree - -usage :: IO () -usage = do - putStrLn $ unlines - [ "usage: Call with one of the following argument combinations:" - , " --help Display this help message." - , " (no arguments) Parse stdin verbosely." - , " (files) Parse content of files verbosely." - , " -s (files) Silent mode. Parse content of files silently." - ] - -main :: IO () -main = do - args <- getArgs - case args of - ["--help"] -> usage - [] -> getContents >>= run 2 pProgram - "-s":fs -> mapM_ (runFile 0 pProgram) fs - fs -> mapM_ (runFile 2 pProgram) fs - From 817c3666a0f2f2703dcacfd50082c079e5981954 Mon Sep 17 00:00:00 2001 From: Nikolai Kudasov Date: Fri, 22 Dec 2023 01:33:08 +0300 Subject: [PATCH 12/15] Remove location information from the AST (for now) --- eo-phi-normalizer/Setup.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo-phi-normalizer/Setup.hs b/eo-phi-normalizer/Setup.hs index ce054df98..f73408725 100644 --- a/eo-phi-normalizer/Setup.hs +++ b/eo-phi-normalizer/Setup.hs @@ -20,7 +20,7 @@ main = defaultMainWithHooks $ simpleUserHooks { hookedPrograms = [ bnfcProgram ] , postConf = \args flags packageDesc localBuildInfo -> do #ifndef mingw32_HOST_OS - _ <- system "bnfc -d -p Language.EO.Phi --generic --functor -o src/ grammar/EO/Phi/Syntax.cf" + _ <- system "bnfc -d -p Language.EO.Phi --generic -o src/ grammar/EO/Phi/Syntax.cf" #endif postConf simpleUserHooks args flags packageDesc localBuildInfo } From 5657817c88e7c3281a32969863af7a62aa785996 Mon Sep 17 00:00:00 2001 From: Nikolai Kudasov Date: Fri, 22 Dec 2023 01:33:49 +0300 Subject: [PATCH 13/15] Fix grammar --- eo-phi-normalizer/eo-phi-normalizer.cabal | 1 + eo-phi-normalizer/grammar/EO/Phi/Syntax.cf | 13 +- .../grammar/EO/Phi/Syntax.old.cf | 2 +- .../src/Language/EO/Phi/Syntax/Abs.hs | 103 ++++---------- .../src/Language/EO/Phi/Syntax/Doc.txt | 6 +- .../src/Language/EO/Phi/Syntax/Lex.x | 16 +-- .../src/Language/EO/Phi/Syntax/Par.y | 130 ++++++++---------- .../src/Language/EO/Phi/Syntax/Print.hs | 44 +++--- eo-phi-normalizer/test/eo/phi/test.yaml | 4 +- 9 files changed, 128 insertions(+), 191 deletions(-) diff --git a/eo-phi-normalizer/eo-phi-normalizer.cabal b/eo-phi-normalizer/eo-phi-normalizer.cabal index 95d392901..f342af145 100644 --- a/eo-phi-normalizer/eo-phi-normalizer.cabal +++ b/eo-phi-normalizer/eo-phi-normalizer.cabal @@ -33,6 +33,7 @@ custom-setup library exposed-modules: Language.EO.Phi + Language.EO.Phi.Normalize Language.EO.Phi.Syntax.Abs Language.EO.Phi.Syntax.Lex Language.EO.Phi.Syntax.Par diff --git a/eo-phi-normalizer/grammar/EO/Phi/Syntax.cf b/eo-phi-normalizer/grammar/EO/Phi/Syntax.cf index b0d038675..c83631dd5 100644 --- a/eo-phi-normalizer/grammar/EO/Phi/Syntax.cf +++ b/eo-phi-normalizer/grammar/EO/Phi/Syntax.cf @@ -2,8 +2,7 @@ -- BNFC grammar for φ-programs (translated from EO) -- ========================================================== -- --- This grammar is a (manual) translation of Phi.g4 grammar from objectionary/eo: --- https://github.com/objectionary/eo/blob/fa24c7cc47e1ac473fb930f3a08ccc4d88d9d1e3/eo-parser/src/main/antlr4/org/eolang/parser/Phi.g4 +-- This is a non-ambiguous grammar for φ-programs. token Bytes ({"--"} | ["0123456789ABCDEF"] ["0123456789ABCDEF"] ({"-"} ["0123456789ABCDEF"] ["0123456789ABCDEF"])* {"--"}) ; token Function upper (char - [" \r\n\t,.|':;!-?][}{)(⟧⟦"])* ; @@ -12,10 +11,12 @@ token AlphaIndex ({"α0"} | {"α"} (digit - ["0"]) (digit)* ) ; Program. Program ::= "{" [Binding] "}" ; -Formation. Object ::= "{" [Binding] "}" ; -Application. Object ::= Object "{" [Binding] "}" ; -Dispatch. Object ::= Object "." Attribute ; -Termination. Object ::= "⊥" ; +Formation. Object ::= "{" [Binding] "}" ; +Application. Object ::= Object "{" [Binding] "}" ; +ObjectDispatch. Object ::= Object "." Attribute ; +GlobalDispatch. Object ::= "Φ" "." Attribute ; +ThisDispatch. Object ::= "ξ" "." Attribute ; +Termination. Object ::= "⊥" ; AlphaBinding. Binding ::= Attribute "↦" Object ; EmptyBinding. Binding ::= Attribute "↦" "∅" ; diff --git a/eo-phi-normalizer/grammar/EO/Phi/Syntax.old.cf b/eo-phi-normalizer/grammar/EO/Phi/Syntax.old.cf index 72a2f0c4a..86996b16a 100644 --- a/eo-phi-normalizer/grammar/EO/Phi/Syntax.old.cf +++ b/eo-phi-normalizer/grammar/EO/Phi/Syntax.old.cf @@ -34,7 +34,7 @@ Bindings. Bindings ::= "{" [Binding] "}" ; separator Bindings "" ; ObjectDispatch. Dispatch ::= DispatchedObject [Bindings] "." [Attribute] [Disp] ; -HomeDispatch. Dispatch ::= "Φ" "." [Attribute] [Disp] ; +GlobalDispatch. Dispatch ::= "Φ" "." [Attribute] [Disp] ; ThisDispatch. Dispatch ::= "ξ" "." [Attribute] [Disp] ; Phi. Attribute ::= "φ" ; -- decoratee object diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Abs.hs b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Abs.hs index 9bdc7c7d5..d2199cfd7 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Abs.hs +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Abs.hs @@ -2,56 +2,41 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE DeriveTraversable #-} -{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE PatternSynonyms #-} -- | The abstract syntax of language Syntax. module Language.EO.Phi.Syntax.Abs where import Prelude (String) -import qualified Prelude as C - ( Eq, Ord, Show, Read - , Functor, Foldable, Traversable - , Int, Maybe(..) - ) +import qualified Prelude as C (Eq, Ord, Show, Read) import qualified Data.String import qualified Data.Data as C (Data, Typeable) import qualified GHC.Generics as C (Generic) -type Program = Program' BNFC'Position -data Program' a = Program a [Binding' a] - deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) - -type Object = Object' BNFC'Position -data Object' a - = Formation a [Binding' a] - | Application a (Object' a) [Binding' a] - | Dispatch a (Object' a) (Attribute' a) - | Termination a - deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) - -type Binding = Binding' BNFC'Position -data Binding' a - = AlphaBinding a (Attribute' a) (Object' a) - | EmptyBinding a (Attribute' a) - | DeltaBinding a Bytes - | LambdaBinding a Function - deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) - -type Attribute = Attribute' BNFC'Position -data Attribute' a - = Phi a - | Rho a - | Sigma a - | VTX a - | Label a LabelId - | Alpha a AlphaIndex - deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable, C.Data, C.Typeable, C.Generic) +data Program = Program [Binding] + deriving (C.Eq, C.Ord, C.Show, C.Read, C.Data, C.Typeable, C.Generic) + +data Object + = Formation [Binding] + | Application Object [Binding] + | ObjectDispatch Object Attribute + | GlobalDispatch Attribute + | ThisDispatch Attribute + | Termination + deriving (C.Eq, C.Ord, C.Show, C.Read, C.Data, C.Typeable, C.Generic) + +data Binding + = AlphaBinding Attribute Object + | EmptyBinding Attribute + | DeltaBinding Bytes + | LambdaBinding Function + deriving (C.Eq, C.Ord, C.Show, C.Read, C.Data, C.Typeable, C.Generic) + +data Attribute + = Phi | Rho | Sigma | VTX | Label LabelId | Alpha AlphaIndex + deriving (C.Eq, C.Ord, C.Show, C.Read, C.Data, C.Typeable, C.Generic) newtype Bytes = Bytes String deriving (C.Eq, C.Ord, C.Show, C.Read, C.Data, C.Typeable, C.Generic, Data.String.IsString) @@ -65,45 +50,3 @@ newtype LabelId = LabelId String newtype AlphaIndex = AlphaIndex String deriving (C.Eq, C.Ord, C.Show, C.Read, C.Data, C.Typeable, C.Generic, Data.String.IsString) --- | Start position (line, column) of something. - -type BNFC'Position = C.Maybe (C.Int, C.Int) - -pattern BNFC'NoPosition :: BNFC'Position -pattern BNFC'NoPosition = C.Nothing - -pattern BNFC'Position :: C.Int -> C.Int -> BNFC'Position -pattern BNFC'Position line col = C.Just (line, col) - --- | Get the start position of something. - -class HasPosition a where - hasPosition :: a -> BNFC'Position - -instance HasPosition Program where - hasPosition = \case - Program p _ -> p - -instance HasPosition Object where - hasPosition = \case - Formation p _ -> p - Application p _ _ -> p - Dispatch p _ _ -> p - Termination p -> p - -instance HasPosition Binding where - hasPosition = \case - AlphaBinding p _ _ -> p - EmptyBinding p _ -> p - DeltaBinding p _ -> p - LambdaBinding p _ -> p - -instance HasPosition Attribute where - hasPosition = \case - Phi p -> p - Rho p -> p - Sigma p -> p - VTX p -> p - Label p _ -> p - Alpha p _ -> p - diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt index 8eb276aed..6af556ed4 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt @@ -35,8 +35,8 @@ AlphaIndex literals are recognized by the regular expression The set of reserved words is the set of terminals appearing in the grammar. Those reserved words that consist of non-letter characters are called symbols, and they are treated in a different way from those that are similar to identifiers. The lexer follows rules familiar from languages like Haskell, C, and Java, including longest match and spacing conventions. The reserved words used in Syntax are the following: - | ``Δ`` | ``λ`` | ``ν`` | ``ρ`` - | ``σ`` | ``φ`` | | + | ``Δ`` | ``Φ`` | ``λ`` | ``ν`` + | ``ξ`` | ``ρ`` | ``σ`` | ``φ`` The symbols used in Syntax are the following: | { | } | . | ⊥ @@ -55,6 +55,8 @@ All other symbols are terminals. | //Object// | -> | ``{`` //[Binding]// ``}`` | | **|** | //Object// ``{`` //[Binding]// ``}`` | | **|** | //Object// ``.`` //Attribute// + | | **|** | ``Φ`` ``.`` //Attribute// + | | **|** | ``ξ`` ``.`` //Attribute// | | **|** | ``⊥`` | //Binding// | -> | //Attribute// ``↦`` //Object// | | **|** | //Attribute// ``↦`` ``∅`` diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.x b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.x index d2b6608f1..6978d4e61 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.x +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.x @@ -28,7 +28,7 @@ $u = [. \n] -- universal: any character -- Symbols and non-identifier-like reserved words -@rsyms = \Δ | \λ | \φ | \ρ | \σ | \ν | \{ | \} | \. | \⊥ | \↦ | \∅ | \⤍ | \, +@rsyms = \Φ | \ξ | \Δ | \λ | \φ | \ρ | \σ | \ν | \{ | \} | \. | \⊥ | \↦ | \∅ | \⤍ | \, :- @@ -168,13 +168,13 @@ eitherResIdent tv s = treeFind resWords -- | The keywords and symbols of the language organized as binary search tree. resWords :: BTree resWords = - b "\961" 8 - (b "}" 4 - (b "." 2 (b "," 1 N N) (b "{" 3 N N)) - (b "\955" 6 (b "\916" 5 N N) (b "\957" 7 N N))) - (b "\8709" 12 - (b "\966" 10 (b "\963" 9 N N) (b "\8614" 11 N N)) - (b "\10509" 14 (b "\8869" 13 N N) N)) + b "\958" 9 + (b "\916" 5 + (b "{" 3 (b "." 2 (b "," 1 N N) N) (b "}" 4 N N)) + (b "\955" 7 (b "\934" 6 N N) (b "\957" 8 N N))) + (b "\8614" 13 + (b "\963" 11 (b "\961" 10 N N) (b "\966" 12 N N)) + (b "\8869" 15 (b "\8709" 14 N N) (b "\10509" 16 N N))) where b s n = B bs (TS bs n) where diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y index ef49762fc..b313e01e5 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y @@ -22,80 +22,84 @@ import Language.EO.Phi.Syntax.Lex } -%name pProgram_internal Program -%name pObject_internal Object -%name pBinding_internal Binding -%name pListBinding_internal ListBinding -%name pAttribute_internal Attribute +%name pProgram Program +%name pObject Object +%name pBinding Binding +%name pListBinding ListBinding +%name pAttribute Attribute -- no lexer declaration %monad { Err } { (>>=) } { return } %tokentype {Token} %token - ',' { PT _ (TS _ 1) } - '.' { PT _ (TS _ 2) } - '{' { PT _ (TS _ 3) } - '}' { PT _ (TS _ 4) } - 'Δ' { PT _ (TS _ 5) } - 'λ' { PT _ (TS _ 6) } - 'ν' { PT _ (TS _ 7) } - 'ρ' { PT _ (TS _ 8) } - 'σ' { PT _ (TS _ 9) } - 'φ' { PT _ (TS _ 10) } - '↦' { PT _ (TS _ 11) } - '∅' { PT _ (TS _ 12) } - '⊥' { PT _ (TS _ 13) } - '⤍' { PT _ (TS _ 14) } - L_Bytes { PT _ (T_Bytes _) } - L_Function { PT _ (T_Function _) } - L_LabelId { PT _ (T_LabelId _) } - L_AlphaIndex { PT _ (T_AlphaIndex _) } + ',' { PT _ (TS _ 1) } + '.' { PT _ (TS _ 2) } + '{' { PT _ (TS _ 3) } + '}' { PT _ (TS _ 4) } + 'Δ' { PT _ (TS _ 5) } + 'Φ' { PT _ (TS _ 6) } + 'λ' { PT _ (TS _ 7) } + 'ν' { PT _ (TS _ 8) } + 'ξ' { PT _ (TS _ 9) } + 'ρ' { PT _ (TS _ 10) } + 'σ' { PT _ (TS _ 11) } + 'φ' { PT _ (TS _ 12) } + '↦' { PT _ (TS _ 13) } + '∅' { PT _ (TS _ 14) } + '⊥' { PT _ (TS _ 15) } + '⤍' { PT _ (TS _ 16) } + L_Bytes { PT _ (T_Bytes $$) } + L_Function { PT _ (T_Function $$) } + L_LabelId { PT _ (T_LabelId $$) } + L_AlphaIndex { PT _ (T_AlphaIndex $$) } %% -Bytes :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Bytes) } -Bytes : L_Bytes { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Bytes (tokenText $1)) } +Bytes :: { Language.EO.Phi.Syntax.Abs.Bytes } +Bytes : L_Bytes { Language.EO.Phi.Syntax.Abs.Bytes $1 } -Function :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Function) } -Function : L_Function { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Function (tokenText $1)) } +Function :: { Language.EO.Phi.Syntax.Abs.Function } +Function : L_Function { Language.EO.Phi.Syntax.Abs.Function $1 } -LabelId :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.LabelId) } -LabelId : L_LabelId { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.LabelId (tokenText $1)) } +LabelId :: { Language.EO.Phi.Syntax.Abs.LabelId } +LabelId : L_LabelId { Language.EO.Phi.Syntax.Abs.LabelId $1 } -AlphaIndex :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.AlphaIndex) } -AlphaIndex : L_AlphaIndex { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.AlphaIndex (tokenText $1)) } +AlphaIndex :: { Language.EO.Phi.Syntax.Abs.AlphaIndex } +AlphaIndex : L_AlphaIndex { Language.EO.Phi.Syntax.Abs.AlphaIndex $1 } -Program :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Program) } +Program :: { Language.EO.Phi.Syntax.Abs.Program } Program - : '{' ListBinding '}' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Program (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $2)) } + : '{' ListBinding '}' { Language.EO.Phi.Syntax.Abs.Program $2 } -Object :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Object) } +Object :: { Language.EO.Phi.Syntax.Abs.Object } Object - : '{' ListBinding '}' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Formation (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $2)) } - | Object '{' ListBinding '}' { (fst $1, Language.EO.Phi.Syntax.Abs.Application (fst $1) (snd $1) (snd $3)) } - | Object '.' Attribute { (fst $1, Language.EO.Phi.Syntax.Abs.Dispatch (fst $1) (snd $1) (snd $3)) } - | '⊥' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Termination (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } - -Binding :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Binding) } + : '{' ListBinding '}' { Language.EO.Phi.Syntax.Abs.Formation $2 } + | Object '{' ListBinding '}' { Language.EO.Phi.Syntax.Abs.Application $1 $3 } + | Object '.' Attribute { Language.EO.Phi.Syntax.Abs.ObjectDispatch $1 $3 } + | 'Φ' '.' Attribute { Language.EO.Phi.Syntax.Abs.GlobalDispatch $3 } + | 'ξ' '.' Attribute { Language.EO.Phi.Syntax.Abs.ThisDispatch $3 } + | '⊥' { Language.EO.Phi.Syntax.Abs.Termination } + +Binding :: { Language.EO.Phi.Syntax.Abs.Binding } Binding - : Attribute '↦' Object { (fst $1, Language.EO.Phi.Syntax.Abs.AlphaBinding (fst $1) (snd $1) (snd $3)) } - | Attribute '↦' '∅' { (fst $1, Language.EO.Phi.Syntax.Abs.EmptyBinding (fst $1) (snd $1)) } - | 'Δ' '⤍' Bytes { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.DeltaBinding (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $3)) } - | 'λ' '⤍' Function { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.LambdaBinding (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $3)) } + : Attribute '↦' Object { Language.EO.Phi.Syntax.Abs.AlphaBinding $1 $3 } + | Attribute '↦' '∅' { Language.EO.Phi.Syntax.Abs.EmptyBinding $1 } + | 'Δ' '⤍' Bytes { Language.EO.Phi.Syntax.Abs.DeltaBinding $3 } + | 'λ' '⤍' Function { Language.EO.Phi.Syntax.Abs.LambdaBinding $3 } -ListBinding :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, [Language.EO.Phi.Syntax.Abs.Binding]) } +ListBinding :: { [Language.EO.Phi.Syntax.Abs.Binding] } ListBinding - : {- empty -} { (Language.EO.Phi.Syntax.Abs.BNFC'NoPosition, []) } - | Binding { (fst $1, (:[]) (snd $1)) } - | Binding ',' ListBinding { (fst $1, (:) (snd $1) (snd $3)) } + : {- empty -} { [] } + | Binding { (:[]) $1 } + | Binding ',' ListBinding { (:) $1 $3 } -Attribute :: { (Language.EO.Phi.Syntax.Abs.BNFC'Position, Language.EO.Phi.Syntax.Abs.Attribute) } +Attribute :: { Language.EO.Phi.Syntax.Abs.Attribute } Attribute - : 'φ' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Phi (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } - | 'ρ' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Rho (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } - | 'σ' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.Sigma (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } - | 'ν' { (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.EO.Phi.Syntax.Abs.VTX (uncurry Language.EO.Phi.Syntax.Abs.BNFC'Position (tokenLineCol $1))) } - | LabelId { (fst $1, Language.EO.Phi.Syntax.Abs.Label (fst $1) (snd $1)) } - | AlphaIndex { (fst $1, Language.EO.Phi.Syntax.Abs.Alpha (fst $1) (snd $1)) } + : 'φ' { Language.EO.Phi.Syntax.Abs.Phi } + | 'ρ' { Language.EO.Phi.Syntax.Abs.Rho } + | 'σ' { Language.EO.Phi.Syntax.Abs.Sigma } + | 'ν' { Language.EO.Phi.Syntax.Abs.VTX } + | LabelId { Language.EO.Phi.Syntax.Abs.Label $1 } + | AlphaIndex { Language.EO.Phi.Syntax.Abs.Alpha $1 } { @@ -112,21 +116,5 @@ happyError ts = Left $ myLexer :: String -> [Token] myLexer = tokens --- Entrypoints - -pProgram :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Program -pProgram = fmap snd . pProgram_internal - -pObject :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Object -pObject = fmap snd . pObject_internal - -pBinding :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Binding -pBinding = fmap snd . pBinding_internal - -pListBinding :: [Token] -> Err [Language.EO.Phi.Syntax.Abs.Binding] -pListBinding = fmap snd . pListBinding_internal - -pAttribute :: [Token] -> Err Language.EO.Phi.Syntax.Abs.Attribute -pAttribute = fmap snd . pAttribute_internal } diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs index 3335b9e01..6f07779f0 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs @@ -145,34 +145,36 @@ instance Print Language.EO.Phi.Syntax.Abs.LabelId where prt _ (Language.EO.Phi.Syntax.Abs.LabelId i) = doc $ showString i instance Print Language.EO.Phi.Syntax.Abs.AlphaIndex where prt _ (Language.EO.Phi.Syntax.Abs.AlphaIndex i) = doc $ showString i -instance Print (Language.EO.Phi.Syntax.Abs.Program' a) where +instance Print Language.EO.Phi.Syntax.Abs.Program where prt i = \case - Language.EO.Phi.Syntax.Abs.Program _ bindings -> prPrec i 0 (concatD [doc (showString "{"), prt 0 bindings, doc (showString "}")]) + Language.EO.Phi.Syntax.Abs.Program bindings -> prPrec i 0 (concatD [doc (showString "{"), prt 0 bindings, doc (showString "}")]) -instance Print (Language.EO.Phi.Syntax.Abs.Object' a) where +instance Print Language.EO.Phi.Syntax.Abs.Object where prt i = \case - Language.EO.Phi.Syntax.Abs.Formation _ bindings -> prPrec i 0 (concatD [doc (showString "{"), prt 0 bindings, doc (showString "}")]) - Language.EO.Phi.Syntax.Abs.Application _ object bindings -> prPrec i 0 (concatD [prt 0 object, doc (showString "{"), prt 0 bindings, doc (showString "}")]) - Language.EO.Phi.Syntax.Abs.Dispatch _ object attribute -> prPrec i 0 (concatD [prt 0 object, doc (showString "."), prt 0 attribute]) - Language.EO.Phi.Syntax.Abs.Termination _ -> prPrec i 0 (concatD [doc (showString "\8869")]) - -instance Print (Language.EO.Phi.Syntax.Abs.Binding' a) where + Language.EO.Phi.Syntax.Abs.Formation bindings -> prPrec i 0 (concatD [doc (showString "{"), prt 0 bindings, doc (showString "}")]) + Language.EO.Phi.Syntax.Abs.Application object bindings -> prPrec i 0 (concatD [prt 0 object, doc (showString "{"), prt 0 bindings, doc (showString "}")]) + Language.EO.Phi.Syntax.Abs.ObjectDispatch object attribute -> prPrec i 0 (concatD [prt 0 object, doc (showString "."), prt 0 attribute]) + Language.EO.Phi.Syntax.Abs.GlobalDispatch attribute -> prPrec i 0 (concatD [doc (showString "\934"), doc (showString "."), prt 0 attribute]) + Language.EO.Phi.Syntax.Abs.ThisDispatch attribute -> prPrec i 0 (concatD [doc (showString "\958"), doc (showString "."), prt 0 attribute]) + Language.EO.Phi.Syntax.Abs.Termination -> prPrec i 0 (concatD [doc (showString "\8869")]) + +instance Print Language.EO.Phi.Syntax.Abs.Binding where prt i = \case - Language.EO.Phi.Syntax.Abs.AlphaBinding _ attribute object -> prPrec i 0 (concatD [prt 0 attribute, doc (showString "\8614"), prt 0 object]) - Language.EO.Phi.Syntax.Abs.EmptyBinding _ attribute -> prPrec i 0 (concatD [prt 0 attribute, doc (showString "\8614"), doc (showString "\8709")]) - Language.EO.Phi.Syntax.Abs.DeltaBinding _ bytes -> prPrec i 0 (concatD [doc (showString "\916"), doc (showString "\10509"), prt 0 bytes]) - Language.EO.Phi.Syntax.Abs.LambdaBinding _ function -> prPrec i 0 (concatD [doc (showString "\955"), doc (showString "\10509"), prt 0 function]) + Language.EO.Phi.Syntax.Abs.AlphaBinding attribute object -> prPrec i 0 (concatD [prt 0 attribute, doc (showString "\8614"), prt 0 object]) + Language.EO.Phi.Syntax.Abs.EmptyBinding attribute -> prPrec i 0 (concatD [prt 0 attribute, doc (showString "\8614"), doc (showString "\8709")]) + Language.EO.Phi.Syntax.Abs.DeltaBinding bytes -> prPrec i 0 (concatD [doc (showString "\916"), doc (showString "\10509"), prt 0 bytes]) + Language.EO.Phi.Syntax.Abs.LambdaBinding function -> prPrec i 0 (concatD [doc (showString "\955"), doc (showString "\10509"), prt 0 function]) -instance Print [Language.EO.Phi.Syntax.Abs.Binding' a] where +instance Print [Language.EO.Phi.Syntax.Abs.Binding] where prt _ [] = concatD [] prt _ [x] = concatD [prt 0 x] prt _ (x:xs) = concatD [prt 0 x, doc (showString ","), prt 0 xs] -instance Print (Language.EO.Phi.Syntax.Abs.Attribute' a) where +instance Print Language.EO.Phi.Syntax.Abs.Attribute where prt i = \case - Language.EO.Phi.Syntax.Abs.Phi _ -> prPrec i 0 (concatD [doc (showString "\966")]) - Language.EO.Phi.Syntax.Abs.Rho _ -> prPrec i 0 (concatD [doc (showString "\961")]) - Language.EO.Phi.Syntax.Abs.Sigma _ -> prPrec i 0 (concatD [doc (showString "\963")]) - Language.EO.Phi.Syntax.Abs.VTX _ -> prPrec i 0 (concatD [doc (showString "\957")]) - Language.EO.Phi.Syntax.Abs.Label _ labelid -> prPrec i 0 (concatD [prt 0 labelid]) - Language.EO.Phi.Syntax.Abs.Alpha _ alphaindex -> prPrec i 0 (concatD [prt 0 alphaindex]) + Language.EO.Phi.Syntax.Abs.Phi -> prPrec i 0 (concatD [doc (showString "\966")]) + Language.EO.Phi.Syntax.Abs.Rho -> prPrec i 0 (concatD [doc (showString "\961")]) + Language.EO.Phi.Syntax.Abs.Sigma -> prPrec i 0 (concatD [doc (showString "\963")]) + Language.EO.Phi.Syntax.Abs.VTX -> prPrec i 0 (concatD [doc (showString "\957")]) + Language.EO.Phi.Syntax.Abs.Label labelid -> prPrec i 0 (concatD [prt 0 labelid]) + Language.EO.Phi.Syntax.Abs.Alpha alphaindex -> prPrec i 0 (concatD [prt 0 alphaindex]) diff --git a/eo-phi-normalizer/test/eo/phi/test.yaml b/eo-phi-normalizer/test/eo/phi/test.yaml index 08bc44244..741ee8506 100644 --- a/eo-phi-normalizer/test/eo/phi/test.yaml +++ b/eo-phi-normalizer/test/eo/phi/test.yaml @@ -1,10 +1,10 @@ name: "Simple static attribute reference" input: | - { φ ↦ { } , a ↦ ξ.a } + { φ ↦ { } , a ↦ ξ.φ } normalized: | { φ ↦ {}, a ↦ {} } prettified: | - { φ ↦ { }, a ↦ ξ.a } + { φ ↦ { }, a ↦ ξ.φ } From 4d3a22816d1c2e2044f6276edaa88e13c56f47be Mon Sep 17 00:00:00 2001 From: Nikolai Kudasov Date: Fri, 22 Dec 2023 01:34:13 +0300 Subject: [PATCH 14/15] Sketch Language.EO.Phi.Normalize module --- eo-phi-normalizer/src/Language/EO/Phi.hs | 4 +- .../src/Language/EO/Phi/Normalize.hs | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 eo-phi-normalizer/src/Language/EO/Phi/Normalize.hs diff --git a/eo-phi-normalizer/src/Language/EO/Phi.hs b/eo-phi-normalizer/src/Language/EO/Phi.hs index 1545471ec..a849182c2 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi.hs +++ b/eo-phi-normalizer/src/Language/EO/Phi.hs @@ -17,9 +17,7 @@ import qualified Language.EO.Phi.Syntax.Print as Phi import Language.EO.Phi.Syntax.Abs import qualified Language.EO.Phi.Syntax.Abs as Phi --- | Normalize an input 𝜑-program. -normalize :: Phi.Program -> Phi.Program -normalize program = program -- do nothing for now +import Language.EO.Phi.Normalize -- | Parse a 'Program' or return a parsing error. parseProgram :: String -> Either String Phi.Program diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Normalize.hs b/eo-phi-normalizer/src/Language/EO/Phi/Normalize.hs new file mode 100644 index 000000000..83c5890bf --- /dev/null +++ b/eo-phi-normalizer/src/Language/EO/Phi/Normalize.hs @@ -0,0 +1,39 @@ +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE RecordWildCards #-} +module Language.EO.Phi.Normalize where + +import Language.EO.Phi.Syntax.Abs +import Data.Maybe (fromMaybe) + +data Context = Context + { globalObject :: [Binding] + , thisObject :: [Binding] + } + +lookupBinding :: Attribute -> [Binding] -> Maybe Object +lookupBinding _ [] = Nothing +lookupBinding a (AlphaBinding a' object : bindings) + | a == a' = Just object + | otherwise = lookupBinding a bindings +lookupBinding _ _ = Nothing + +-- | Normalize an input 𝜑-program. +normalize :: Program -> Program +normalize (Program bindings) = Program (map (normalizeBindingWith context) bindings) + where + context = Context + { globalObject = bindings + , thisObject = bindings + } + +normalizeBindingWith :: Context -> Binding -> Binding +normalizeBindingWith context = \case + AlphaBinding a object -> AlphaBinding a (normalizeObjectWith context object) + binding -> binding + +normalizeObjectWith :: Context -> Object -> Object +normalizeObjectWith Context{..} object = + case object of + ThisDispatch a -> + fromMaybe object (lookupBinding a thisObject) + _ -> object From 355391772d7902c4a0166b4629e81b1615aff634 Mon Sep 17 00:00:00 2001 From: Nikolai Kudasov Date: Fri, 22 Dec 2023 01:49:11 +0300 Subject: [PATCH 15/15] Add PeeledObject and conversion functions --- eo-phi-normalizer/grammar/EO/Phi/Syntax.cf | 11 +++++++ .../src/Language/EO/Phi/Normalize.hs | 31 +++++++++++++++++++ .../src/Language/EO/Phi/Syntax/Abs.hs | 11 +++++++ .../src/Language/EO/Phi/Syntax/Doc.txt | 9 ++++++ .../src/Language/EO/Phi/Syntax/Par.y | 28 +++++++++++++++++ .../src/Language/EO/Phi/Syntax/Print.hs | 20 ++++++++++++ 6 files changed, 110 insertions(+) diff --git a/eo-phi-normalizer/grammar/EO/Phi/Syntax.cf b/eo-phi-normalizer/grammar/EO/Phi/Syntax.cf index c83631dd5..40099c94c 100644 --- a/eo-phi-normalizer/grammar/EO/Phi/Syntax.cf +++ b/eo-phi-normalizer/grammar/EO/Phi/Syntax.cf @@ -30,3 +30,14 @@ Sigma. Attribute ::= "σ" ; -- home object VTX. Attribute ::= "ν" ; -- ??? Label. Attribute ::= LabelId ; Alpha. Attribute ::= AlphaIndex ; + +PeeledObject. PeeledObject ::= ObjectHead [ObjectAction] ; + +HeadFormation. ObjectHead ::= "{" [Binding] "}" ; +HeadGlobal. ObjectHead ::= "Φ" ; +HeadThis. ObjectHead ::= "ξ" ; +HeadTermination. ObjectHead ::= "⊥" ; + +ActionApplication. ObjectAction ::= "{" [Binding] "}" ; +ActionDispatch. ObjectAction ::= "." Attribute ; +separator ObjectAction "" ; diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Normalize.hs b/eo-phi-normalizer/src/Language/EO/Phi/Normalize.hs index 83c5890bf..ffeb943be 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Normalize.hs +++ b/eo-phi-normalizer/src/Language/EO/Phi/Normalize.hs @@ -37,3 +37,34 @@ normalizeObjectWith Context{..} object = ThisDispatch a -> fromMaybe object (lookupBinding a thisObject) _ -> object + +-- | Split compound object into its head and applications/dispatch actions. +peelObject :: Object -> PeeledObject +peelObject = \case + Formation bindings -> PeeledObject (HeadFormation bindings) [] + Application object bindings -> peelObject object `followedBy` ActionApplication bindings + ObjectDispatch object attr -> peelObject object `followedBy` ActionDispatch attr + GlobalDispatch attr -> PeeledObject HeadGlobal [ActionDispatch attr] + ThisDispatch attr -> PeeledObject HeadThis [ActionDispatch attr] + Termination -> PeeledObject HeadTermination [] + where + followedBy (PeeledObject object actions) action = PeeledObject object (actions ++ [action]) + +unpeelObject :: PeeledObject -> Object +unpeelObject (PeeledObject head_ actions) = + case head_ of + HeadFormation bindings -> go (Formation bindings) actions + HeadGlobal -> + case actions of + ActionDispatch a : as -> go (GlobalDispatch a) as + _ -> error "impossible: global object without dispatch!" + HeadThis -> + case actions of + ActionDispatch a : as -> go (ThisDispatch a) as + _ -> error "impossible: this object without dispatch!" + HeadTermination -> go Termination actions + where + go = foldl applyAction + applyAction object = \case + ActionDispatch attr -> ObjectDispatch object attr + ActionApplication bindings -> Application object bindings diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Abs.hs b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Abs.hs index d2199cfd7..ae634d48b 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Abs.hs +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Abs.hs @@ -38,6 +38,17 @@ data Attribute = Phi | Rho | Sigma | VTX | Label LabelId | Alpha AlphaIndex deriving (C.Eq, C.Ord, C.Show, C.Read, C.Data, C.Typeable, C.Generic) +data PeeledObject = PeeledObject ObjectHead [ObjectAction] + deriving (C.Eq, C.Ord, C.Show, C.Read, C.Data, C.Typeable, C.Generic) + +data ObjectHead + = HeadFormation [Binding] | HeadGlobal | HeadThis | HeadTermination + deriving (C.Eq, C.Ord, C.Show, C.Read, C.Data, C.Typeable, C.Generic) + +data ObjectAction + = ActionApplication [Binding] | ActionDispatch Attribute + deriving (C.Eq, C.Ord, C.Show, C.Read, C.Data, C.Typeable, C.Generic) + newtype Bytes = Bytes String deriving (C.Eq, C.Ord, C.Show, C.Read, C.Data, C.Typeable, C.Generic, Data.String.IsString) diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt index 6af556ed4..d611fb084 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt @@ -71,6 +71,15 @@ All other symbols are terminals. | | **|** | ``ν`` | | **|** | //LabelId// | | **|** | //AlphaIndex// + | //PeeledObject// | -> | //ObjectHead// //[ObjectAction]// + | //ObjectHead// | -> | ``{`` //[Binding]// ``}`` + | | **|** | ``Φ`` + | | **|** | ``ξ`` + | | **|** | ``⊥`` + | //ObjectAction// | -> | ``{`` //[Binding]// ``}`` + | | **|** | ``.`` //Attribute// + | //[ObjectAction]// | -> | **eps** + | | **|** | //ObjectAction// //[ObjectAction]// diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y index b313e01e5..e07d7cc2d 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y @@ -13,6 +13,10 @@ module Language.EO.Phi.Syntax.Par , pBinding , pListBinding , pAttribute + , pPeeledObject + , pObjectHead + , pObjectAction + , pListObjectAction ) where import Prelude @@ -27,6 +31,10 @@ import Language.EO.Phi.Syntax.Lex %name pBinding Binding %name pListBinding ListBinding %name pAttribute Attribute +%name pPeeledObject PeeledObject +%name pObjectHead ObjectHead +%name pObjectAction ObjectAction +%name pListObjectAction ListObjectAction -- no lexer declaration %monad { Err } { (>>=) } { return } %tokentype {Token} @@ -101,6 +109,26 @@ Attribute | LabelId { Language.EO.Phi.Syntax.Abs.Label $1 } | AlphaIndex { Language.EO.Phi.Syntax.Abs.Alpha $1 } +PeeledObject :: { Language.EO.Phi.Syntax.Abs.PeeledObject } +PeeledObject + : ObjectHead ListObjectAction { Language.EO.Phi.Syntax.Abs.PeeledObject $1 $2 } + +ObjectHead :: { Language.EO.Phi.Syntax.Abs.ObjectHead } +ObjectHead + : '{' ListBinding '}' { Language.EO.Phi.Syntax.Abs.HeadFormation $2 } + | 'Φ' { Language.EO.Phi.Syntax.Abs.HeadGlobal } + | 'ξ' { Language.EO.Phi.Syntax.Abs.HeadThis } + | '⊥' { Language.EO.Phi.Syntax.Abs.HeadTermination } + +ObjectAction :: { Language.EO.Phi.Syntax.Abs.ObjectAction } +ObjectAction + : '{' ListBinding '}' { Language.EO.Phi.Syntax.Abs.ActionApplication $2 } + | '.' Attribute { Language.EO.Phi.Syntax.Abs.ActionDispatch $2 } + +ListObjectAction :: { [Language.EO.Phi.Syntax.Abs.ObjectAction] } +ListObjectAction + : {- empty -} { [] } | ObjectAction ListObjectAction { (:) $1 $2 } + { type Err = Either String diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs index 6f07779f0..9156fd24e 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs @@ -178,3 +178,23 @@ instance Print Language.EO.Phi.Syntax.Abs.Attribute where Language.EO.Phi.Syntax.Abs.VTX -> prPrec i 0 (concatD [doc (showString "\957")]) Language.EO.Phi.Syntax.Abs.Label labelid -> prPrec i 0 (concatD [prt 0 labelid]) Language.EO.Phi.Syntax.Abs.Alpha alphaindex -> prPrec i 0 (concatD [prt 0 alphaindex]) + +instance Print Language.EO.Phi.Syntax.Abs.PeeledObject where + prt i = \case + Language.EO.Phi.Syntax.Abs.PeeledObject objecthead objectactions -> prPrec i 0 (concatD [prt 0 objecthead, prt 0 objectactions]) + +instance Print Language.EO.Phi.Syntax.Abs.ObjectHead where + prt i = \case + Language.EO.Phi.Syntax.Abs.HeadFormation bindings -> prPrec i 0 (concatD [doc (showString "{"), prt 0 bindings, doc (showString "}")]) + Language.EO.Phi.Syntax.Abs.HeadGlobal -> prPrec i 0 (concatD [doc (showString "\934")]) + Language.EO.Phi.Syntax.Abs.HeadThis -> prPrec i 0 (concatD [doc (showString "\958")]) + Language.EO.Phi.Syntax.Abs.HeadTermination -> prPrec i 0 (concatD [doc (showString "\8869")]) + +instance Print Language.EO.Phi.Syntax.Abs.ObjectAction where + prt i = \case + Language.EO.Phi.Syntax.Abs.ActionApplication bindings -> prPrec i 0 (concatD [doc (showString "{"), prt 0 bindings, doc (showString "}")]) + Language.EO.Phi.Syntax.Abs.ActionDispatch attribute -> prPrec i 0 (concatD [doc (showString "."), prt 0 attribute]) + +instance Print [Language.EO.Phi.Syntax.Abs.ObjectAction] where + prt _ [] = concatD [] + prt _ (x:xs) = concatD [prt 0 x, prt 0 xs]