| Copyright | (c) Nadia Yvette Chambers 2026 |
|---|---|
| License | Apache-2.0 |
| Safe Haskell | None |
| Language | GHC2021 |
Smirk.Core.Bytecode
Description
Defines the low-level virtual machine bytecode instruction set (Opcode)
used by the Pike-style non-backtracking / thread-stepped VM in VM.
Includes relative jumping, nondeterministic thread branching (OpSplit),
capture slot registers (OpSaveStart, OpSaveEnd), and lookaround subprograms.
Synopsis
- data Opcode
- = OpChar !Char
- | OpClass !CharClass
- | OpAnchor !Anchor
- | OpSplit !Int !Int
- | OpJump !Int
- | OpSaveStart !Int
- | OpSaveEnd !Int
- | OpAssertLookahead !(Vector Opcode) !Bool
- | OpAssertLookbehind !(Vector Opcode) !Bool
- | OpMatchBackRef !Int
- | OpMatch
- type Program = Vector Opcode
- data Regex = Regex {
- originalPattern :: !Text
- program :: !Program
- groupNames :: !(Map Text Int)
- maxGroupIndex :: !Int
Documentation
Low-level bytecode instruction for the Smirk regex virtual machine.
Constructors
| OpChar !Char | Match a single literal character |
| OpClass !CharClass | Match a character class or set |
| OpAnchor !Anchor | Assert a zero-width anchor condition |
| OpSplit !Int !Int | Fork execution: try relative offset 1, alternative at offset 2 |
| OpJump !Int | Unconditional relative jump by specified offset |
| OpSaveStart !Int | Save current input position as start of capture group $n$ |
| OpSaveEnd !Int | Save current input position as end of capture group $n$ |
| OpAssertLookahead !(Vector Opcode) !Bool | Zero-width lookahead assertion: subprogram and polarity |
| OpAssertLookbehind !(Vector Opcode) !Bool | Zero-width lookbehind assertion: subprogram and polarity |
| OpMatchBackRef !Int | Match dynamic slice previously captured by group $n$ |
| OpMatch | Successful match reached; terminate thread |
Instances
| Eq Opcode Source # | |||||
| Generic Opcode Source # | |||||
Defined in Smirk.Core.Bytecode Associated Types
| |||||
| Show Opcode Source # | |||||
| type Rep Opcode Source # | |||||
Defined in Smirk.Core.Bytecode type Rep Opcode = D1 ('MetaData "Opcode" "Smirk.Core.Bytecode" "smirk-0.1.0.0-inplace" 'False) (((C1 ('MetaCons "OpChar" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Char)) :+: C1 ('MetaCons "OpClass" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 CharClass))) :+: (C1 ('MetaCons "OpAnchor" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Anchor)) :+: (C1 ('MetaCons "OpSplit" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int)) :+: C1 ('MetaCons "OpJump" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int))))) :+: ((C1 ('MetaCons "OpSaveStart" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int)) :+: (C1 ('MetaCons "OpSaveEnd" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int)) :+: C1 ('MetaCons "OpAssertLookahead" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Vector Opcode)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool)))) :+: (C1 ('MetaCons "OpAssertLookbehind" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Vector Opcode)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool)) :+: (C1 ('MetaCons "OpMatchBackRef" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int)) :+: C1 ('MetaCons "OpMatch" 'PrefixI 'False) (U1 :: Type -> Type))))) | |||||
Complete compiled regular expression ready for VM execution.
Constructors
| Regex | |
Fields
| |
Instances
| Eq Regex Source # | |||||
| Generic Regex Source # | |||||
Defined in Smirk.Core.Bytecode Associated Types
| |||||
| Show Regex Source # | |||||
| type Rep Regex Source # | |||||
Defined in Smirk.Core.Bytecode type Rep Regex = D1 ('MetaData "Regex" "Smirk.Core.Bytecode" "smirk-0.1.0.0-inplace" 'False) (C1 ('MetaCons "Regex" 'PrefixI 'True) ((S1 ('MetaSel ('Just "originalPattern") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text) :*: S1 ('MetaSel ('Just "program") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Program)) :*: (S1 ('MetaSel ('Just "groupNames") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Map Text Int)) :*: S1 ('MetaSel ('Just "maxGroupIndex") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int)))) | |||||