add comment lexing and remove references stuff

fogti
Aug 26, 2024, 3:02 PM
HQ2ZYTX5DUKYFUHN5VHTMBQGXXLKPOO3CSGWK4G44SQ6ZO5PMFRQC

Dependencies

  • [2] JDF4JUMS some attempts at abstract syntax
  • [*] GMGXNJEP add back more stuff from yanais
  • [*] 6XMVEBZA add simple stuff (e.g. haskell basics)

Change contents

  • file addition: Comments.hs (----------)
    [4.2678]
    module GardGround.Utils.SteParser.Comments (
    lexeComments,
    ) where
    import qualified Data.HashMap.Strict as H
    import GardGround.Utils.SteParser.Lex (HandleTree(..), Parser', eats, skipWhiteSpace, tryOne)
    data LevelDelta = LevelIncr | LevelDecr
    lvladj :: LevelDelta -> Integer -> Integer
    lvladj LevelDecr lvl = lvl - 1
    lvladj LevelIncr lvl = lvl + 1
    lexeCommentsTreeInit :: HandleTree LevelDelta
    lexeCommentsTreeInit = HandleTree (H.fromList l1) Nothing
    where
    l1 = [('(' {- ) -}, HandleTree (H.fromList l2) Nothing)]
    l2 = [('*', Htleaf LevelIncr)]
    lexeCommentsTree :: HandleTree LevelDelta
    lexeCommentsTree = HandleTree (H.fromList l1) Nothing
    where
    -- (* ... comment start; *) ... comment end
    l1 = [('(' {- ) -}, HandleTree (H.fromList l2) Nothing)
    ,('*', HandleTree (H.fromList l3) Nothing)]
    l2 = [('*', Htleaf LevelIncr)]
    l3 = [({- ( -} ')', Htleaf LevelDecr)]
    lexeComments :: Integer -> Parser' e ()
    lexeComments (-1) = error "lexeComments invalid index"
    lexeComments lvl = do
    (if lvl <= 0 then skipWhiteSpace else pure ())
    fi <- eats (if lvl <= 0 then lexeCommentsTreeInit else lexeCommentsTree)
    case fi of
    Just ld -> lexeComments $ lvladj ld lvl
    -- we either can abort searching for comment contents (lvl == 0)
    -- or we skip over a single character and continue
    Nothing -> if lvl <= 0 then pure () else tryOne (\_ -> Just ()) >> lexeComments lvl
  • edit in core/lib/GardGround/Syntax/Abstract.hs at line 46
    [2.1209][2.1209:1321]()
    | VRefOf Value -- ^ value being pointed to
    | VRefOfTy Natural Value -- ^ region and type being pointed to
  • edit in core/lib/GardGround/Syntax/Abstract.hs at line 55
    [2.1649][2.1649:1674]()
    vapp (VRefOf r) = vapp r
  • edit in core/lib/GardGround/Syntax/Abstract.hs at line 67
    [2.2068][2.2068:2110]()
    | ERefOf Expr
    | ERefOfTy Natural Expr
  • replacement in core/lib/GardGround/Syntax/Abstract.hs at line 72
    [2.2238][2.2238:2245]()
    let
    [2.2238]
    [2.2245]
    let
  • edit in core/lib/GardGround/Syntax/Abstract.hs at line 92
    [2.2837][2.2837:2934]()
    quote i (VRefOf pt) = ERefOf <$> quote i pt
    quote i (VRefOfTy j pt) = ERefOfTy j <$> quote i pt
  • edit in core/gardground-core.cabal at line 24
    [4.10877]
    [2.2935]
    GardGround.Utils.SteParser.Comments