diff --git a/CommentMacro.g4 b/CommentMacro.g4 index 41abb13..7287466 100644 --- a/CommentMacro.g4 +++ b/CommentMacro.g4 @@ -39,37 +39,37 @@ statement : macro (':' macro)* NEWLINE? ; macro - : op='GM' ( t=target | '*' ) (dev=device)? // Go Master - | op='GM' ( t=target | '*' ) '/' n=number (dev=device)? // Go Master - | op='HM' ( t=target | '*' ) (dev=device)? // Halt Master - | op='AM' ( t=target | '*' ) (dev=device)? // Assert Master - | op='RM' ( t=target | '*' ) (dev=device)? // Relesae Master - | op='RA' (dev=device)? // Release All - | op='RO' (dev=device)? // Release Others - | op='FM' ( t=target | '*' ) '/' n=number (f=time)? (dev=device)? // Fade Master - | op='FGM' n=number (f=time)? (dev=device)? // Fade Grand Master - | op='CM' n=number (dev=device)? // Choose Master - | op='GL' t=target (dev=device)? // Go List - | op='GL' t=target '/' n=number (dev=device)? // Go List - | op='HL' t=target (dev=device)? // Halt List - | op='AL' t=target (dev=device)? // Assert List - | op='RL' t=target (dev=device)? // Release List - | op='GB' t=target (dev=device)? // Go Batch - | op='HB' t=target (dev=device)? // Halt Batch - | op='AB' t=target (dev=device)? // Assert Batch - | op='RB' t=target (dev=device)? // Release Batch - | op='GS' t=target (dev=device)? // Go Scene - | op='HS' t=target (dev=device)? // Halt Scene - | op='AS' t=target (dev=device)? // Assert Scene - | op='RS' t=target (dev=device)? // Release Scene - | op='CP' n=number (dev=device)? // Change Page - | op='CP' d='+' (dev=device)? // Next Page - | op='CP' d='-' (dev=device)? // Prev Page - | op='RV' n=number (dev=device)? // Recall View - | op='RN' dev=device // Reset Node - | op='GK' t=target (dev=device)? // Go Keystroke Macro - | op='HK' t=target (dev=device)? // Halt Keystroke Macro - | op='RK' t=target (dev=device)? // Stop Keystroke Macro + : op='GM' ( t=target | '*' ) (dev=device)? #MasterGo + | op='GM' ( t=target | '*' ) '/' n=number (dev=device)? #MasterGoto + | op='HM' ( t=target | '*' ) (dev=device)? #MasterHalt + | op='AM' ( t=target | '*' ) (dev=device)? #MasterAssert + | op='RM' ( t=target | '*' ) (dev=device)? #MasterRelease + | op='RA' (dev=device)? #ReleaseAll + | op='RO' (dev=device)? #ReleaseOthers + | op='FM' ( t=target | '*' ) '/' n=number (f=time)? (dev=device)? #MasterFade + | op='FGM' n=number (f=time)? (dev=device)? #FadeGrandMaster + | op='CM' n=number (dev=device)? #MasterChoose + | op='GL' t=target (dev=device)? #ListGo + | op='GL' t=target '/' n=number (dev=device)? #ListGoto + | op='HL' t=target (dev=device)? #ListHalt + | op='AL' t=target (dev=device)? #ListAssert + | op='RL' t=target (dev=device)? #ListRelese + | op='GB' t=target (dev=device)? #BatchGo + | op='HB' t=target (dev=device)? #BatchHalt + | op='AB' t=target (dev=device)? #BatchAssert + | op='RB' t=target (dev=device)? #BatchRelease + | op='GS' t=target (dev=device)? #SceneGo + | op='HS' t=target (dev=device)? #SceneHalt + | op='AS' t=target (dev=device)? #SceneAssert + | op='RS' t=target (dev=device)? #SceneRelease + | op='CP' n=number (dev=device)? #PageChange + | op='CP' '+' (dev=device)? #PageNext + | op='CP' '-' (dev=device)? #PagePrev + | op='RV' n=number (dev=device)? #RecallView + | op='RN' dev=device #NodeReset + | op='GK' t=target (dev=device)? #MacroGo + | op='HK' t=target (dev=device)? #MacroHalt + | op='RK' t=target (dev=device)? #MacroStop ; time : TIME n=number ; diff --git a/CommentMacroListener.py b/CommentMacroListener.py index 66703e8..94a7a3a 100644 --- a/CommentMacroListener.py +++ b/CommentMacroListener.py @@ -26,12 +26,282 @@ class CommentMacroListener(ParseTreeListener): pass - # Enter a parse tree produced by CommentMacroParser#macro. - def enterMacro(self, ctx:CommentMacroParser.MacroContext): + # Enter a parse tree produced by CommentMacroParser#MasterGo. + def enterMasterGo(self, ctx:CommentMacroParser.MasterGoContext): pass - # Exit a parse tree produced by CommentMacroParser#macro. - def exitMacro(self, ctx:CommentMacroParser.MacroContext): + # Exit a parse tree produced by CommentMacroParser#MasterGo. + def exitMasterGo(self, ctx:CommentMacroParser.MasterGoContext): + pass + + + # Enter a parse tree produced by CommentMacroParser#MasterGoto. + def enterMasterGoto(self, ctx:CommentMacroParser.MasterGotoContext): + pass + + # Exit a parse tree produced by CommentMacroParser#MasterGoto. + def exitMasterGoto(self, ctx:CommentMacroParser.MasterGotoContext): + pass + + + # Enter a parse tree produced by CommentMacroParser#MasterHalt. + def enterMasterHalt(self, ctx:CommentMacroParser.MasterHaltContext): + pass + + # Exit a parse tree produced by CommentMacroParser#MasterHalt. + def exitMasterHalt(self, ctx:CommentMacroParser.MasterHaltContext): + pass + + + # Enter a parse tree produced by CommentMacroParser#MasterAssert. + def enterMasterAssert(self, ctx:CommentMacroParser.MasterAssertContext): + pass + + # Exit a parse tree produced by CommentMacroParser#MasterAssert. + def exitMasterAssert(self, ctx:CommentMacroParser.MasterAssertContext): + pass + + + # Enter a parse tree produced by CommentMacroParser#MasterRelease. + def enterMasterRelease(self, ctx:CommentMacroParser.MasterReleaseContext): + pass + + # Exit a parse tree produced by CommentMacroParser#MasterRelease. + def exitMasterRelease(self, ctx:CommentMacroParser.MasterReleaseContext): + pass + + + # Enter a parse tree produced by CommentMacroParser#ReleaseAll. + def enterReleaseAll(self, ctx:CommentMacroParser.ReleaseAllContext): + pass + + # Exit a parse tree produced by CommentMacroParser#ReleaseAll. + def exitReleaseAll(self, ctx:CommentMacroParser.ReleaseAllContext): + pass + + + # Enter a parse tree produced by CommentMacroParser#ReleaseOthers. + def enterReleaseOthers(self, ctx:CommentMacroParser.ReleaseOthersContext): + pass + + # Exit a parse tree produced by CommentMacroParser#ReleaseOthers. + def exitReleaseOthers(self, ctx:CommentMacroParser.ReleaseOthersContext): + pass + + + # Enter a parse tree produced by CommentMacroParser#MasterFade. + def enterMasterFade(self, ctx:CommentMacroParser.MasterFadeContext): + pass + + # Exit a parse tree produced by CommentMacroParser#MasterFade. + def exitMasterFade(self, ctx:CommentMacroParser.MasterFadeContext): + pass + + + # Enter a parse tree produced by CommentMacroParser#FadeGrandMaster. + def enterFadeGrandMaster(self, ctx:CommentMacroParser.FadeGrandMasterContext): + pass + + # Exit a parse tree produced by CommentMacroParser#FadeGrandMaster. + def exitFadeGrandMaster(self, ctx:CommentMacroParser.FadeGrandMasterContext): + pass + + + # Enter a parse tree produced by CommentMacroParser#MasterChoose. + def enterMasterChoose(self, ctx:CommentMacroParser.MasterChooseContext): + pass + + # Exit a parse tree produced by CommentMacroParser#MasterChoose. + def exitMasterChoose(self, ctx:CommentMacroParser.MasterChooseContext): + pass + + + # Enter a parse tree produced by CommentMacroParser#ListGo. + def enterListGo(self, ctx:CommentMacroParser.ListGoContext): + pass + + # Exit a parse tree produced by CommentMacroParser#ListGo. + def exitListGo(self, ctx:CommentMacroParser.ListGoContext): + pass + + + # Enter a parse tree produced by CommentMacroParser#ListGoto. + def enterListGoto(self, ctx:CommentMacroParser.ListGotoContext): + pass + + # Exit a parse tree produced by CommentMacroParser#ListGoto. + def exitListGoto(self, ctx:CommentMacroParser.ListGotoContext): + pass + + + # Enter a parse tree produced by CommentMacroParser#ListHalt. + def enterListHalt(self, ctx:CommentMacroParser.ListHaltContext): + pass + + # Exit a parse tree produced by CommentMacroParser#ListHalt. + def exitListHalt(self, ctx:CommentMacroParser.ListHaltContext): + pass + + + # Enter a parse tree produced by CommentMacroParser#ListAssert. + def enterListAssert(self, ctx:CommentMacroParser.ListAssertContext): + pass + + # Exit a parse tree produced by CommentMacroParser#ListAssert. + def exitListAssert(self, ctx:CommentMacroParser.ListAssertContext): + pass + + + # Enter a parse tree produced by CommentMacroParser#ListRelese. + def enterListRelese(self, ctx:CommentMacroParser.ListReleseContext): + pass + + # Exit a parse tree produced by CommentMacroParser#ListRelese. + def exitListRelese(self, ctx:CommentMacroParser.ListReleseContext): + pass + + + # Enter a parse tree produced by CommentMacroParser#BatchGo. + def enterBatchGo(self, ctx:CommentMacroParser.BatchGoContext): + pass + + # Exit a parse tree produced by CommentMacroParser#BatchGo. + def exitBatchGo(self, ctx:CommentMacroParser.BatchGoContext): + pass + + + # Enter a parse tree produced by CommentMacroParser#BatchHalt. + def enterBatchHalt(self, ctx:CommentMacroParser.BatchHaltContext): + pass + + # Exit a parse tree produced by CommentMacroParser#BatchHalt. + def exitBatchHalt(self, ctx:CommentMacroParser.BatchHaltContext): + pass + + + # Enter a parse tree produced by CommentMacroParser#BatchAssert. + def enterBatchAssert(self, ctx:CommentMacroParser.BatchAssertContext): + pass + + # Exit a parse tree produced by CommentMacroParser#BatchAssert. + def exitBatchAssert(self, ctx:CommentMacroParser.BatchAssertContext): + pass + + + # Enter a parse tree produced by CommentMacroParser#BatchRelease. + def enterBatchRelease(self, ctx:CommentMacroParser.BatchReleaseContext): + pass + + # Exit a parse tree produced by CommentMacroParser#BatchRelease. + def exitBatchRelease(self, ctx:CommentMacroParser.BatchReleaseContext): + pass + + + # Enter a parse tree produced by CommentMacroParser#SceneGo. + def enterSceneGo(self, ctx:CommentMacroParser.SceneGoContext): + pass + + # Exit a parse tree produced by CommentMacroParser#SceneGo. + def exitSceneGo(self, ctx:CommentMacroParser.SceneGoContext): + pass + + + # Enter a parse tree produced by CommentMacroParser#SceneHalt. + def enterSceneHalt(self, ctx:CommentMacroParser.SceneHaltContext): + pass + + # Exit a parse tree produced by CommentMacroParser#SceneHalt. + def exitSceneHalt(self, ctx:CommentMacroParser.SceneHaltContext): + pass + + + # Enter a parse tree produced by CommentMacroParser#SceneAssert. + def enterSceneAssert(self, ctx:CommentMacroParser.SceneAssertContext): + pass + + # Exit a parse tree produced by CommentMacroParser#SceneAssert. + def exitSceneAssert(self, ctx:CommentMacroParser.SceneAssertContext): + pass + + + # Enter a parse tree produced by CommentMacroParser#SceneRelease. + def enterSceneRelease(self, ctx:CommentMacroParser.SceneReleaseContext): + pass + + # Exit a parse tree produced by CommentMacroParser#SceneRelease. + def exitSceneRelease(self, ctx:CommentMacroParser.SceneReleaseContext): + pass + + + # Enter a parse tree produced by CommentMacroParser#PageChange. + def enterPageChange(self, ctx:CommentMacroParser.PageChangeContext): + pass + + # Exit a parse tree produced by CommentMacroParser#PageChange. + def exitPageChange(self, ctx:CommentMacroParser.PageChangeContext): + pass + + + # Enter a parse tree produced by CommentMacroParser#PageNext. + def enterPageNext(self, ctx:CommentMacroParser.PageNextContext): + pass + + # Exit a parse tree produced by CommentMacroParser#PageNext. + def exitPageNext(self, ctx:CommentMacroParser.PageNextContext): + pass + + + # Enter a parse tree produced by CommentMacroParser#PagePrev. + def enterPagePrev(self, ctx:CommentMacroParser.PagePrevContext): + pass + + # Exit a parse tree produced by CommentMacroParser#PagePrev. + def exitPagePrev(self, ctx:CommentMacroParser.PagePrevContext): + pass + + + # Enter a parse tree produced by CommentMacroParser#RecallView. + def enterRecallView(self, ctx:CommentMacroParser.RecallViewContext): + pass + + # Exit a parse tree produced by CommentMacroParser#RecallView. + def exitRecallView(self, ctx:CommentMacroParser.RecallViewContext): + pass + + + # Enter a parse tree produced by CommentMacroParser#NodeReset. + def enterNodeReset(self, ctx:CommentMacroParser.NodeResetContext): + pass + + # Exit a parse tree produced by CommentMacroParser#NodeReset. + def exitNodeReset(self, ctx:CommentMacroParser.NodeResetContext): + pass + + + # Enter a parse tree produced by CommentMacroParser#MacroGo. + def enterMacroGo(self, ctx:CommentMacroParser.MacroGoContext): + pass + + # Exit a parse tree produced by CommentMacroParser#MacroGo. + def exitMacroGo(self, ctx:CommentMacroParser.MacroGoContext): + pass + + + # Enter a parse tree produced by CommentMacroParser#MacroHalt. + def enterMacroHalt(self, ctx:CommentMacroParser.MacroHaltContext): + pass + + # Exit a parse tree produced by CommentMacroParser#MacroHalt. + def exitMacroHalt(self, ctx:CommentMacroParser.MacroHaltContext): + pass + + + # Enter a parse tree produced by CommentMacroParser#MacroStop. + def enterMacroStop(self, ctx:CommentMacroParser.MacroStopContext): + pass + + # Exit a parse tree produced by CommentMacroParser#MacroStop. + def exitMacroStop(self, ctx:CommentMacroParser.MacroStopContext): pass diff --git a/CommentMacroParser.py b/CommentMacroParser.py index 8b0956e..e1536a7 100644 --- a/CommentMacroParser.py +++ b/CommentMacroParser.py @@ -368,41 +368,791 @@ class CommentMacroParser ( Parser ): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): super().__init__(parent, invokingState) self.parser = parser - self.op = None # Token - self.t = None # TargetContext - self.dev = None # DeviceContext - self.n = None # NumberContext - self.f = None # TimeContext - self.d = None # Token - - def target(self): - return self.getTypedRuleContext(CommentMacroParser.TargetContext,0) - - - def device(self): - return self.getTypedRuleContext(CommentMacroParser.DeviceContext,0) - - - def number(self): - return self.getTypedRuleContext(CommentMacroParser.NumberContext,0) - - - def time(self): - return self.getTypedRuleContext(CommentMacroParser.TimeContext,0) def getRuleIndex(self): return CommentMacroParser.RULE_macro + + def copyFrom(self, ctx:ParserRuleContext): + super().copyFrom(ctx) + + + + class SceneReleaseContext(MacroContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a CommentMacroParser.MacroContext + super().__init__(parser) + self.op = None # Token + self.t = None # TargetContext + self.dev = None # DeviceContext + self.copyFrom(ctx) + + def target(self): + return self.getTypedRuleContext(CommentMacroParser.TargetContext,0) + + def device(self): + return self.getTypedRuleContext(CommentMacroParser.DeviceContext,0) + + def enterRule(self, listener:ParseTreeListener): - if hasattr( listener, "enterMacro" ): - listener.enterMacro(self) + if hasattr( listener, "enterSceneRelease" ): + listener.enterSceneRelease(self) def exitRule(self, listener:ParseTreeListener): - if hasattr( listener, "exitMacro" ): - listener.exitMacro(self) + if hasattr( listener, "exitSceneRelease" ): + listener.exitSceneRelease(self) + class MasterAssertContext(MacroContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a CommentMacroParser.MacroContext + super().__init__(parser) + self.op = None # Token + self.t = None # TargetContext + self.dev = None # DeviceContext + self.copyFrom(ctx) + + def target(self): + return self.getTypedRuleContext(CommentMacroParser.TargetContext,0) + + def device(self): + return self.getTypedRuleContext(CommentMacroParser.DeviceContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterMasterAssert" ): + listener.enterMasterAssert(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitMasterAssert" ): + listener.exitMasterAssert(self) + + + class MasterGotoContext(MacroContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a CommentMacroParser.MacroContext + super().__init__(parser) + self.op = None # Token + self.t = None # TargetContext + self.n = None # NumberContext + self.dev = None # DeviceContext + self.copyFrom(ctx) + + def number(self): + return self.getTypedRuleContext(CommentMacroParser.NumberContext,0) + + def target(self): + return self.getTypedRuleContext(CommentMacroParser.TargetContext,0) + + def device(self): + return self.getTypedRuleContext(CommentMacroParser.DeviceContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterMasterGoto" ): + listener.enterMasterGoto(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitMasterGoto" ): + listener.exitMasterGoto(self) + + + class ListGotoContext(MacroContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a CommentMacroParser.MacroContext + super().__init__(parser) + self.op = None # Token + self.t = None # TargetContext + self.n = None # NumberContext + self.dev = None # DeviceContext + self.copyFrom(ctx) + + def target(self): + return self.getTypedRuleContext(CommentMacroParser.TargetContext,0) + + def number(self): + return self.getTypedRuleContext(CommentMacroParser.NumberContext,0) + + def device(self): + return self.getTypedRuleContext(CommentMacroParser.DeviceContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterListGoto" ): + listener.enterListGoto(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitListGoto" ): + listener.exitListGoto(self) + + + class SceneAssertContext(MacroContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a CommentMacroParser.MacroContext + super().__init__(parser) + self.op = None # Token + self.t = None # TargetContext + self.dev = None # DeviceContext + self.copyFrom(ctx) + + def target(self): + return self.getTypedRuleContext(CommentMacroParser.TargetContext,0) + + def device(self): + return self.getTypedRuleContext(CommentMacroParser.DeviceContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterSceneAssert" ): + listener.enterSceneAssert(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitSceneAssert" ): + listener.exitSceneAssert(self) + + + class RecallViewContext(MacroContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a CommentMacroParser.MacroContext + super().__init__(parser) + self.op = None # Token + self.n = None # NumberContext + self.dev = None # DeviceContext + self.copyFrom(ctx) + + def number(self): + return self.getTypedRuleContext(CommentMacroParser.NumberContext,0) + + def device(self): + return self.getTypedRuleContext(CommentMacroParser.DeviceContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterRecallView" ): + listener.enterRecallView(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitRecallView" ): + listener.exitRecallView(self) + + + class MasterGoContext(MacroContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a CommentMacroParser.MacroContext + super().__init__(parser) + self.op = None # Token + self.t = None # TargetContext + self.dev = None # DeviceContext + self.copyFrom(ctx) + + def target(self): + return self.getTypedRuleContext(CommentMacroParser.TargetContext,0) + + def device(self): + return self.getTypedRuleContext(CommentMacroParser.DeviceContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterMasterGo" ): + listener.enterMasterGo(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitMasterGo" ): + listener.exitMasterGo(self) + + + class SceneHaltContext(MacroContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a CommentMacroParser.MacroContext + super().__init__(parser) + self.op = None # Token + self.t = None # TargetContext + self.dev = None # DeviceContext + self.copyFrom(ctx) + + def target(self): + return self.getTypedRuleContext(CommentMacroParser.TargetContext,0) + + def device(self): + return self.getTypedRuleContext(CommentMacroParser.DeviceContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterSceneHalt" ): + listener.enterSceneHalt(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitSceneHalt" ): + listener.exitSceneHalt(self) + + + class MasterChooseContext(MacroContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a CommentMacroParser.MacroContext + super().__init__(parser) + self.op = None # Token + self.n = None # NumberContext + self.dev = None # DeviceContext + self.copyFrom(ctx) + + def number(self): + return self.getTypedRuleContext(CommentMacroParser.NumberContext,0) + + def device(self): + return self.getTypedRuleContext(CommentMacroParser.DeviceContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterMasterChoose" ): + listener.enterMasterChoose(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitMasterChoose" ): + listener.exitMasterChoose(self) + + + class BatchGoContext(MacroContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a CommentMacroParser.MacroContext + super().__init__(parser) + self.op = None # Token + self.t = None # TargetContext + self.dev = None # DeviceContext + self.copyFrom(ctx) + + def target(self): + return self.getTypedRuleContext(CommentMacroParser.TargetContext,0) + + def device(self): + return self.getTypedRuleContext(CommentMacroParser.DeviceContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterBatchGo" ): + listener.enterBatchGo(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitBatchGo" ): + listener.exitBatchGo(self) + + + class PagePrevContext(MacroContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a CommentMacroParser.MacroContext + super().__init__(parser) + self.op = None # Token + self.dev = None # DeviceContext + self.copyFrom(ctx) + + def device(self): + return self.getTypedRuleContext(CommentMacroParser.DeviceContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterPagePrev" ): + listener.enterPagePrev(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitPagePrev" ): + listener.exitPagePrev(self) + + + class PageNextContext(MacroContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a CommentMacroParser.MacroContext + super().__init__(parser) + self.op = None # Token + self.dev = None # DeviceContext + self.copyFrom(ctx) + + def device(self): + return self.getTypedRuleContext(CommentMacroParser.DeviceContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterPageNext" ): + listener.enterPageNext(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitPageNext" ): + listener.exitPageNext(self) + + + class ListReleseContext(MacroContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a CommentMacroParser.MacroContext + super().__init__(parser) + self.op = None # Token + self.t = None # TargetContext + self.dev = None # DeviceContext + self.copyFrom(ctx) + + def target(self): + return self.getTypedRuleContext(CommentMacroParser.TargetContext,0) + + def device(self): + return self.getTypedRuleContext(CommentMacroParser.DeviceContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterListRelese" ): + listener.enterListRelese(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitListRelese" ): + listener.exitListRelese(self) + + + class ListHaltContext(MacroContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a CommentMacroParser.MacroContext + super().__init__(parser) + self.op = None # Token + self.t = None # TargetContext + self.dev = None # DeviceContext + self.copyFrom(ctx) + + def target(self): + return self.getTypedRuleContext(CommentMacroParser.TargetContext,0) + + def device(self): + return self.getTypedRuleContext(CommentMacroParser.DeviceContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterListHalt" ): + listener.enterListHalt(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitListHalt" ): + listener.exitListHalt(self) + + + class ReleaseAllContext(MacroContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a CommentMacroParser.MacroContext + super().__init__(parser) + self.op = None # Token + self.dev = None # DeviceContext + self.copyFrom(ctx) + + def device(self): + return self.getTypedRuleContext(CommentMacroParser.DeviceContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterReleaseAll" ): + listener.enterReleaseAll(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitReleaseAll" ): + listener.exitReleaseAll(self) + + + class MacroGoContext(MacroContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a CommentMacroParser.MacroContext + super().__init__(parser) + self.op = None # Token + self.t = None # TargetContext + self.dev = None # DeviceContext + self.copyFrom(ctx) + + def target(self): + return self.getTypedRuleContext(CommentMacroParser.TargetContext,0) + + def device(self): + return self.getTypedRuleContext(CommentMacroParser.DeviceContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterMacroGo" ): + listener.enterMacroGo(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitMacroGo" ): + listener.exitMacroGo(self) + + + class MasterReleaseContext(MacroContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a CommentMacroParser.MacroContext + super().__init__(parser) + self.op = None # Token + self.t = None # TargetContext + self.dev = None # DeviceContext + self.copyFrom(ctx) + + def target(self): + return self.getTypedRuleContext(CommentMacroParser.TargetContext,0) + + def device(self): + return self.getTypedRuleContext(CommentMacroParser.DeviceContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterMasterRelease" ): + listener.enterMasterRelease(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitMasterRelease" ): + listener.exitMasterRelease(self) + + + class MasterFadeContext(MacroContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a CommentMacroParser.MacroContext + super().__init__(parser) + self.op = None # Token + self.t = None # TargetContext + self.n = None # NumberContext + self.f = None # TimeContext + self.dev = None # DeviceContext + self.copyFrom(ctx) + + def number(self): + return self.getTypedRuleContext(CommentMacroParser.NumberContext,0) + + def target(self): + return self.getTypedRuleContext(CommentMacroParser.TargetContext,0) + + def time(self): + return self.getTypedRuleContext(CommentMacroParser.TimeContext,0) + + def device(self): + return self.getTypedRuleContext(CommentMacroParser.DeviceContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterMasterFade" ): + listener.enterMasterFade(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitMasterFade" ): + listener.exitMasterFade(self) + + + class BatchAssertContext(MacroContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a CommentMacroParser.MacroContext + super().__init__(parser) + self.op = None # Token + self.t = None # TargetContext + self.dev = None # DeviceContext + self.copyFrom(ctx) + + def target(self): + return self.getTypedRuleContext(CommentMacroParser.TargetContext,0) + + def device(self): + return self.getTypedRuleContext(CommentMacroParser.DeviceContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterBatchAssert" ): + listener.enterBatchAssert(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitBatchAssert" ): + listener.exitBatchAssert(self) + + + class MasterHaltContext(MacroContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a CommentMacroParser.MacroContext + super().__init__(parser) + self.op = None # Token + self.t = None # TargetContext + self.dev = None # DeviceContext + self.copyFrom(ctx) + + def target(self): + return self.getTypedRuleContext(CommentMacroParser.TargetContext,0) + + def device(self): + return self.getTypedRuleContext(CommentMacroParser.DeviceContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterMasterHalt" ): + listener.enterMasterHalt(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitMasterHalt" ): + listener.exitMasterHalt(self) + + + class SceneGoContext(MacroContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a CommentMacroParser.MacroContext + super().__init__(parser) + self.op = None # Token + self.t = None # TargetContext + self.dev = None # DeviceContext + self.copyFrom(ctx) + + def target(self): + return self.getTypedRuleContext(CommentMacroParser.TargetContext,0) + + def device(self): + return self.getTypedRuleContext(CommentMacroParser.DeviceContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterSceneGo" ): + listener.enterSceneGo(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitSceneGo" ): + listener.exitSceneGo(self) + + + class ListAssertContext(MacroContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a CommentMacroParser.MacroContext + super().__init__(parser) + self.op = None # Token + self.t = None # TargetContext + self.dev = None # DeviceContext + self.copyFrom(ctx) + + def target(self): + return self.getTypedRuleContext(CommentMacroParser.TargetContext,0) + + def device(self): + return self.getTypedRuleContext(CommentMacroParser.DeviceContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterListAssert" ): + listener.enterListAssert(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitListAssert" ): + listener.exitListAssert(self) + + + class ListGoContext(MacroContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a CommentMacroParser.MacroContext + super().__init__(parser) + self.op = None # Token + self.t = None # TargetContext + self.dev = None # DeviceContext + self.copyFrom(ctx) + + def target(self): + return self.getTypedRuleContext(CommentMacroParser.TargetContext,0) + + def device(self): + return self.getTypedRuleContext(CommentMacroParser.DeviceContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterListGo" ): + listener.enterListGo(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitListGo" ): + listener.exitListGo(self) + + + class BatchReleaseContext(MacroContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a CommentMacroParser.MacroContext + super().__init__(parser) + self.op = None # Token + self.t = None # TargetContext + self.dev = None # DeviceContext + self.copyFrom(ctx) + + def target(self): + return self.getTypedRuleContext(CommentMacroParser.TargetContext,0) + + def device(self): + return self.getTypedRuleContext(CommentMacroParser.DeviceContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterBatchRelease" ): + listener.enterBatchRelease(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitBatchRelease" ): + listener.exitBatchRelease(self) + + + class FadeGrandMasterContext(MacroContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a CommentMacroParser.MacroContext + super().__init__(parser) + self.op = None # Token + self.n = None # NumberContext + self.f = None # TimeContext + self.dev = None # DeviceContext + self.copyFrom(ctx) + + def number(self): + return self.getTypedRuleContext(CommentMacroParser.NumberContext,0) + + def time(self): + return self.getTypedRuleContext(CommentMacroParser.TimeContext,0) + + def device(self): + return self.getTypedRuleContext(CommentMacroParser.DeviceContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterFadeGrandMaster" ): + listener.enterFadeGrandMaster(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitFadeGrandMaster" ): + listener.exitFadeGrandMaster(self) + + + class BatchHaltContext(MacroContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a CommentMacroParser.MacroContext + super().__init__(parser) + self.op = None # Token + self.t = None # TargetContext + self.dev = None # DeviceContext + self.copyFrom(ctx) + + def target(self): + return self.getTypedRuleContext(CommentMacroParser.TargetContext,0) + + def device(self): + return self.getTypedRuleContext(CommentMacroParser.DeviceContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterBatchHalt" ): + listener.enterBatchHalt(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitBatchHalt" ): + listener.exitBatchHalt(self) + + + class MacroStopContext(MacroContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a CommentMacroParser.MacroContext + super().__init__(parser) + self.op = None # Token + self.t = None # TargetContext + self.dev = None # DeviceContext + self.copyFrom(ctx) + + def target(self): + return self.getTypedRuleContext(CommentMacroParser.TargetContext,0) + + def device(self): + return self.getTypedRuleContext(CommentMacroParser.DeviceContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterMacroStop" ): + listener.enterMacroStop(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitMacroStop" ): + listener.exitMacroStop(self) + + + class PageChangeContext(MacroContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a CommentMacroParser.MacroContext + super().__init__(parser) + self.op = None # Token + self.n = None # NumberContext + self.dev = None # DeviceContext + self.copyFrom(ctx) + + def number(self): + return self.getTypedRuleContext(CommentMacroParser.NumberContext,0) + + def device(self): + return self.getTypedRuleContext(CommentMacroParser.DeviceContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterPageChange" ): + listener.enterPageChange(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitPageChange" ): + listener.exitPageChange(self) + + + class NodeResetContext(MacroContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a CommentMacroParser.MacroContext + super().__init__(parser) + self.op = None # Token + self.dev = None # DeviceContext + self.copyFrom(ctx) + + def device(self): + return self.getTypedRuleContext(CommentMacroParser.DeviceContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterNodeReset" ): + listener.enterNodeReset(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitNodeReset" ): + listener.exitNodeReset(self) + + + class ReleaseOthersContext(MacroContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a CommentMacroParser.MacroContext + super().__init__(parser) + self.op = None # Token + self.dev = None # DeviceContext + self.copyFrom(ctx) + + def device(self): + return self.getTypedRuleContext(CommentMacroParser.DeviceContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterReleaseOthers" ): + listener.enterReleaseOthers(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitReleaseOthers" ): + listener.exitReleaseOthers(self) + + + class MacroHaltContext(MacroContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a CommentMacroParser.MacroContext + super().__init__(parser) + self.op = None # Token + self.t = None # TargetContext + self.dev = None # DeviceContext + self.copyFrom(ctx) + + def target(self): + return self.getTypedRuleContext(CommentMacroParser.TargetContext,0) + + def device(self): + return self.getTypedRuleContext(CommentMacroParser.DeviceContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterMacroHalt" ): + listener.enterMacroHalt(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitMacroHalt" ): + listener.exitMacroHalt(self) + def macro(self): @@ -415,6 +1165,7 @@ class CommentMacroParser ( Parser ): self._errHandler.sync(self) la_ = self._interp.adaptivePredict(self._input,42,self._ctx) if la_ == 1: + localctx = CommentMacroParser.MasterGoContext(self, localctx) self.enterOuterAlt(localctx, 1) self.state = 39 localctx.op = self.match(CommentMacroParser.T__1) @@ -443,6 +1194,7 @@ class CommentMacroParser ( Parser ): pass elif la_ == 2: + localctx = CommentMacroParser.MasterGotoContext(self, localctx) self.enterOuterAlt(localctx, 2) self.state = 47 localctx.op = self.match(CommentMacroParser.T__1) @@ -475,6 +1227,7 @@ class CommentMacroParser ( Parser ): pass elif la_ == 3: + localctx = CommentMacroParser.MasterHaltContext(self, localctx) self.enterOuterAlt(localctx, 3) self.state = 57 localctx.op = self.match(CommentMacroParser.T__3) @@ -503,6 +1256,7 @@ class CommentMacroParser ( Parser ): pass elif la_ == 4: + localctx = CommentMacroParser.MasterAssertContext(self, localctx) self.enterOuterAlt(localctx, 4) self.state = 65 localctx.op = self.match(CommentMacroParser.T__4) @@ -531,6 +1285,7 @@ class CommentMacroParser ( Parser ): pass elif la_ == 5: + localctx = CommentMacroParser.MasterReleaseContext(self, localctx) self.enterOuterAlt(localctx, 5) self.state = 73 localctx.op = self.match(CommentMacroParser.T__5) @@ -559,6 +1314,7 @@ class CommentMacroParser ( Parser ): pass elif la_ == 6: + localctx = CommentMacroParser.ReleaseAllContext(self, localctx) self.enterOuterAlt(localctx, 6) self.state = 81 localctx.op = self.match(CommentMacroParser.T__6) @@ -573,6 +1329,7 @@ class CommentMacroParser ( Parser ): pass elif la_ == 7: + localctx = CommentMacroParser.ReleaseOthersContext(self, localctx) self.enterOuterAlt(localctx, 7) self.state = 85 localctx.op = self.match(CommentMacroParser.T__7) @@ -587,6 +1344,7 @@ class CommentMacroParser ( Parser ): pass elif la_ == 8: + localctx = CommentMacroParser.MasterFadeContext(self, localctx) self.enterOuterAlt(localctx, 8) self.state = 89 localctx.op = self.match(CommentMacroParser.T__8) @@ -627,6 +1385,7 @@ class CommentMacroParser ( Parser ): pass elif la_ == 9: + localctx = CommentMacroParser.FadeGrandMasterContext(self, localctx) self.enterOuterAlt(localctx, 9) self.state = 102 localctx.op = self.match(CommentMacroParser.T__9) @@ -651,6 +1410,7 @@ class CommentMacroParser ( Parser ): pass elif la_ == 10: + localctx = CommentMacroParser.MasterChooseContext(self, localctx) self.enterOuterAlt(localctx, 10) self.state = 110 localctx.op = self.match(CommentMacroParser.T__10) @@ -667,6 +1427,7 @@ class CommentMacroParser ( Parser ): pass elif la_ == 11: + localctx = CommentMacroParser.ListGoContext(self, localctx) self.enterOuterAlt(localctx, 11) self.state = 115 localctx.op = self.match(CommentMacroParser.T__11) @@ -683,6 +1444,7 @@ class CommentMacroParser ( Parser ): pass elif la_ == 12: + localctx = CommentMacroParser.ListGotoContext(self, localctx) self.enterOuterAlt(localctx, 12) self.state = 120 localctx.op = self.match(CommentMacroParser.T__11) @@ -703,6 +1465,7 @@ class CommentMacroParser ( Parser ): pass elif la_ == 13: + localctx = CommentMacroParser.ListHaltContext(self, localctx) self.enterOuterAlt(localctx, 13) self.state = 127 localctx.op = self.match(CommentMacroParser.T__12) @@ -719,6 +1482,7 @@ class CommentMacroParser ( Parser ): pass elif la_ == 14: + localctx = CommentMacroParser.ListAssertContext(self, localctx) self.enterOuterAlt(localctx, 14) self.state = 132 localctx.op = self.match(CommentMacroParser.T__13) @@ -735,6 +1499,7 @@ class CommentMacroParser ( Parser ): pass elif la_ == 15: + localctx = CommentMacroParser.ListReleseContext(self, localctx) self.enterOuterAlt(localctx, 15) self.state = 137 localctx.op = self.match(CommentMacroParser.T__14) @@ -751,6 +1516,7 @@ class CommentMacroParser ( Parser ): pass elif la_ == 16: + localctx = CommentMacroParser.BatchGoContext(self, localctx) self.enterOuterAlt(localctx, 16) self.state = 142 localctx.op = self.match(CommentMacroParser.T__15) @@ -767,6 +1533,7 @@ class CommentMacroParser ( Parser ): pass elif la_ == 17: + localctx = CommentMacroParser.BatchHaltContext(self, localctx) self.enterOuterAlt(localctx, 17) self.state = 147 localctx.op = self.match(CommentMacroParser.T__16) @@ -783,6 +1550,7 @@ class CommentMacroParser ( Parser ): pass elif la_ == 18: + localctx = CommentMacroParser.BatchAssertContext(self, localctx) self.enterOuterAlt(localctx, 18) self.state = 152 localctx.op = self.match(CommentMacroParser.T__17) @@ -799,6 +1567,7 @@ class CommentMacroParser ( Parser ): pass elif la_ == 19: + localctx = CommentMacroParser.BatchReleaseContext(self, localctx) self.enterOuterAlt(localctx, 19) self.state = 157 localctx.op = self.match(CommentMacroParser.T__18) @@ -815,6 +1584,7 @@ class CommentMacroParser ( Parser ): pass elif la_ == 20: + localctx = CommentMacroParser.SceneGoContext(self, localctx) self.enterOuterAlt(localctx, 20) self.state = 162 localctx.op = self.match(CommentMacroParser.T__19) @@ -831,6 +1601,7 @@ class CommentMacroParser ( Parser ): pass elif la_ == 21: + localctx = CommentMacroParser.SceneHaltContext(self, localctx) self.enterOuterAlt(localctx, 21) self.state = 167 localctx.op = self.match(CommentMacroParser.T__20) @@ -847,6 +1618,7 @@ class CommentMacroParser ( Parser ): pass elif la_ == 22: + localctx = CommentMacroParser.SceneAssertContext(self, localctx) self.enterOuterAlt(localctx, 22) self.state = 172 localctx.op = self.match(CommentMacroParser.T__21) @@ -863,6 +1635,7 @@ class CommentMacroParser ( Parser ): pass elif la_ == 23: + localctx = CommentMacroParser.SceneReleaseContext(self, localctx) self.enterOuterAlt(localctx, 23) self.state = 177 localctx.op = self.match(CommentMacroParser.T__22) @@ -879,6 +1652,7 @@ class CommentMacroParser ( Parser ): pass elif la_ == 24: + localctx = CommentMacroParser.PageChangeContext(self, localctx) self.enterOuterAlt(localctx, 24) self.state = 182 localctx.op = self.match(CommentMacroParser.T__23) @@ -895,11 +1669,12 @@ class CommentMacroParser ( Parser ): pass elif la_ == 25: + localctx = CommentMacroParser.PageNextContext(self, localctx) self.enterOuterAlt(localctx, 25) self.state = 187 localctx.op = self.match(CommentMacroParser.T__23) self.state = 188 - localctx.d = self.match(CommentMacroParser.T__24) + self.match(CommentMacroParser.T__24) self.state = 190 self._errHandler.sync(self) _la = self._input.LA(1) @@ -911,11 +1686,12 @@ class CommentMacroParser ( Parser ): pass elif la_ == 26: + localctx = CommentMacroParser.PagePrevContext(self, localctx) self.enterOuterAlt(localctx, 26) self.state = 192 localctx.op = self.match(CommentMacroParser.T__23) self.state = 193 - localctx.d = self.match(CommentMacroParser.T__25) + self.match(CommentMacroParser.T__25) self.state = 195 self._errHandler.sync(self) _la = self._input.LA(1) @@ -927,6 +1703,7 @@ class CommentMacroParser ( Parser ): pass elif la_ == 27: + localctx = CommentMacroParser.RecallViewContext(self, localctx) self.enterOuterAlt(localctx, 27) self.state = 197 localctx.op = self.match(CommentMacroParser.T__26) @@ -943,6 +1720,7 @@ class CommentMacroParser ( Parser ): pass elif la_ == 28: + localctx = CommentMacroParser.NodeResetContext(self, localctx) self.enterOuterAlt(localctx, 28) self.state = 202 localctx.op = self.match(CommentMacroParser.T__27) @@ -951,6 +1729,7 @@ class CommentMacroParser ( Parser ): pass elif la_ == 29: + localctx = CommentMacroParser.MacroGoContext(self, localctx) self.enterOuterAlt(localctx, 29) self.state = 204 localctx.op = self.match(CommentMacroParser.T__28) @@ -967,6 +1746,7 @@ class CommentMacroParser ( Parser ): pass elif la_ == 30: + localctx = CommentMacroParser.MacroHaltContext(self, localctx) self.enterOuterAlt(localctx, 30) self.state = 209 localctx.op = self.match(CommentMacroParser.T__29) @@ -983,6 +1763,7 @@ class CommentMacroParser ( Parser ): pass elif la_ == 31: + localctx = CommentMacroParser.MacroStopContext(self, localctx) self.enterOuterAlt(localctx, 31) self.state = 214 localctx.op = self.match(CommentMacroParser.T__30) @@ -1012,6 +1793,7 @@ class CommentMacroParser ( Parser ): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): super().__init__(parent, invokingState) self.parser = parser + self.n = None # NumberContext def TIME(self): return self.getToken(CommentMacroParser.TIME, 0) @@ -1043,7 +1825,7 @@ class CommentMacroParser ( Parser ): self.state = 221 self.match(CommentMacroParser.TIME) self.state = 222 - self.number() + localctx.n = self.number() except RecognitionException as re: localctx.exception = re self._errHandler.reportError(self, re) diff --git a/OscCommentMacroListener.py b/OscCommentMacroListener.py index b87085f..7a26e29 100644 --- a/OscCommentMacroListener.py +++ b/OscCommentMacroListener.py @@ -16,7 +16,6 @@ __status__ = "Prototype" import logging -import OscMacroDefinitions from CommentMacroParser import CommentMacroParser from CommentMacroListener import CommentMacroListener @@ -44,31 +43,60 @@ def beautify_lisp_string(in_string): return out_string +class HogDevice(): + # button state constants + buttonDOWN = 1 + buttonUP = 0 + + def __init__(self, servers): + self.servers = servers + + def button_press(self, device, path, delay=0.05): + self.send_message(device, path, HogDevice.buttonDOWN) # button down + sleep(delay) + self.send_message(device, path, HogDevice.buttonUP) # button up + + # utility function to send simple messages with one argument + def send_message(self, device, path, arg): + msg = osc_message_builder.OscMessageBuilder(address=path) + msg.add_arg(arg) + self.send(device, msg.build()) + + # send python-osc messages + def send(self, device, msg): + if device is None: + osc = list(self.servers.values())[0] + else: + if (device.ntype.getText().lower() != 'h'): + logger.error("ERROR: Only Hog type devices are supported.") + return + else: + try: + osc = self.servers[device.n.value] + except KeyError: + logger.error("ERROR: Net# " + str(device.n.value) + + " not found.") + return + try: + osc.send(msg) + except Exception as e: + logger.error(e) + + class OscCommentMacroListener(CommentMacroListener): def __init__(self, servers): self.osc = OscMacroDefinitions.HogDevice(servers) - def exitMacro(self, ctx: CommentMacroParser.MacroContext): + def enterStatement(self, ctx: CommentMacroParser.StatementContext): # print the lisp tree of this macro lisp_tree_str = ctx.toStringTree(recog=ctx.parser) logger.info(beautify_lisp_string(lisp_tree_str)) - # disallow duplicate targets - if ctx.t is not None: - ctx.t.targets = set(ctx.t.targets) - - # execute macro from name - name = ctx.op.text - try: - self.osc.command[name](self, ctx) - except KeyError: - print(name + " macro is not compatable with OSC.") - logger.debug("Exiting Macro") - def enterTarget(self, ctx: CommentMacroParser.TargetContext): ctx.targets = [] def exitTarget(self, ctx: CommentMacroParser.TargetContext): + ctx.targets = set(ctx.targets) if isinstance(ctx.parentCtx, CommentMacroParser.TargetContext): ctx.parentCtx.targets.extend(ctx.targets) # add to parent targets @@ -77,7 +105,6 @@ class OscCommentMacroListener(CommentMacroListener): ctx.value = int(ctx.getText()) except ValueError: ctx.value = float(ctx.getText()) - if isinstance(ctx.parentCtx, CommentMacroParser.TargetContext): ctx.parentCtx.targets.append(ctx.value) @@ -91,3 +118,157 @@ class OscCommentMacroListener(CommentMacroListener): ctx.parentCtx.targets.append(i) else: logger.error("ERROR: Spans must be ranged with intigers.") + + def exitMasterGo(self, ctx: CommentMacroParser.MasterGoContext): + if ctx.t is None: + logger.info("Main GO") + self.osc.button_press(ctx.dev, "/hog/hardware/maingo") + return + for i in ctx.t.targets: + if isinstance(i, int) is not True: + logger.warn("GO MASTER macro targets must be intigers. " + + str(i) + " is not an intigers.") + continue + if (i < 0): + logger.warn("Master "+str(i)+" is not greater than 0.") + continue + master = str(i) + logger.info("GO on master " + master) + self.osc.button_press(ctx.dev, "/hog/hardware/go/" + master) + + def exitMasterHalt(self, ctx: CommentMacroParser.MasterHaltContext): + if ctx.t is None: + logger.info("Main HALT") + self.osc.button_press(ctx.dev, "/hog/hardware/mainhalt") + return + for i in ctx.t.targets: + if isinstance(i, int) is not True: + logger.warn("GO MASTER macro targets must be intigers. " + + str(i) + " is not an intigers.") + continue + if (i < 0): + logger.warn("Master "+str(i)+" is not greater than 0.") + continue + master = str(i) + logger.info("HALT on master " + master) + self.osc.button_press(ctx.dev, "/hog/hardware/pause/" + master) + + def exitMasterAssert(self, ctx: CommentMacroParser.MasterAssertContext): + if ctx.t is None: + logger.error("ERROR: limited to asserting current master only.") + return + logger.info("ASSERT on current master.") + self.osc.button_press(ctx.dev, "/hog/hardware/assert") + + def exitMasterRelease(self, ctx: CommentMacroParser.MasterReleaseContext): + if ctx.t is None: + logger.error("ERROR: limited to releasing current master only.") + return + logger.info("RELEASE on current master.") + self.osc.button_press(ctx.dev, "/hog/hardware/release") + + def exitMasterFade(self, ctx: CommentMacroParser.MasterFadeContext): + if ctx.t is None: + logger.error("ERROR: limited to fading current master only.") + return + level = ctx.n.value + if (level < 0 or level > 100): + logger.error("Level must be between 0 and 100.") + return + for i in ctx.t.targets: + if isinstance(i, int) is not True: + logger.warn("FADE MASTER macro targets must be intigers. " + + str(i) + " is not an intigers.") + continue + if (i < 0): + logger.warn("Master "+str(i)+" is not greater than 0.") + continue + master = str(i) + logger.info("Fade Master "+master+" to "+str(level)+"%") + level *= 255 / 100 # percent in Macro, 0>255 in OSC + self.osc.send_message(ctx.dev, + "/hog/hardware/fader/" + master, + level) + + def exitFadeGrandMaster(self, + ctx: CommentMacroParser.FadeGrandMasterContext): + level = ctx.n.value + if (level < 0 or level > 100): + logger.error("Level must be between 0 and 100.") + return + logger.info("Fading Grand Master to " + str(level) + "%") + level *= 255 / 100 # percent in Macro, 0>255 in OSC + self.osc.send_message(ctx.dev, "/hog/hardware/fader/0", level) + + def exitMasterChoose(self, ctx: CommentMacroParser.MasterChooseContext): + if (ctx.n.value < 0): + logger.error("Master must be greater than 0.") + return + master = str(ctx.n.value) + logger.info("Choose Master " + master) + self.osc.button_press(ctx.dev, "/hog/hardware/choose/" + master) + + def exitReleaseAll(self, ctx: CommentMacroParser.ReleaseAllContext): + logger.info("Release All") + self.osc.send_message(ctx.dev, "/hog/hardware/pig", + self.osc.buttonDOWN) + self.osc.button_press(ctx.dev, "/hog/hardware/release") + self.osc.send_message(ctx.dev, "/hog/hardware/pig", + self.osc.buttonUP) + + def exitListGo(self, ctx: CommentMacroParser.ListGoContext): + for i in ctx.t.targets: + if ctx.n is not None: + list = str(i) + "." + str(ctx.n.value) + else: + list = i + logger.info("Go on List " + str(list)) + self.osc.send_message(ctx.dev, "/hog/playback/go/0", list) + + def exitListHalt(self, ctx: CommentMacroParser.ListHaltContext): + for i in ctx.t.targets: + logger.info("Halting List " + str(i)) + self.osc.send_message(ctx.dev, "/hog/playback/halt/0", i) + + def exitListRelese(self, ctx: CommentMacroParser.ListReleseContext): + for i in ctx.t.targets: + logger.info("Releasing List " + str(i)) + self.osc.send_message(ctx.dev, "/hog/playback/release/0", i) + + def exitSceneGo(self, ctx: CommentMacroParser.SceneGoContext): + for i in ctx.t.targets: + logger.info("Go on Scene " + str(i)) + self.osc.send_message(ctx.dev, "/hog/playback/go/1", i) + + def exitSceneHalt(self, ctx: CommentMacroParser.SceneHaltContext): + for i in ctx.t.targets: + logger.info("Halt Scene " + str(i)) + self.osc.send_message(ctx.dev, "/hog/playback/halt/1", i) + + def exitSceneRelease(self, ctx: CommentMacroParser.SceneReleaseContext): + for i in ctx.t.targets: + logger.info("Release Scene " + str(i)) + self.osc.send_message(ctx.dev, "/hog/playback/release/1", i) + + def exitMacroGo(self, ctx: CommentMacroParser.MacroGoContext): + for i in ctx.t.targets: + logger.info("Go on Macro " + str(i)) + self.osc.send_message(ctx.dev, "/hog/playback/go/2", i) + + def exitMacroHalt(self, ctx: CommentMacroParser.MacroHaltContext): + for i in ctx.t.targets: + logger.info("Pause Macro " + str(i)) + self.osc.send_message(ctx.dev, "/hog/playback/halt/2", i) + + def exitMacroStop(self, ctx: CommentMacroParser.MacroStopContext): + for i in ctx.t.targets: + logger.info("Stop Macro " + str(i)) + self.osc.send_message(ctx.dev, "/hog/playback/release/2", i) + + def exitPageNext(self, ctx: CommentMacroParser.PageNextContext): + logger.info("Next Page") + self.osc.button_press(ctx.dev, "/hog/hardware/nextpage") + + def exitPagePrev(self, ctx: CommentMacroParser.PagePrevContext): + logger.info("Prev Page") + self.osc.button_press(ctx.dev, "/hog/hardware/backpage") diff --git a/OscMacroDefinitions.py b/OscMacroDefinitions.py deleted file mode 100644 index b0bfb5e..0000000 --- a/OscMacroDefinitions.py +++ /dev/null @@ -1,246 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -"""OscMacroDefinitions.py: Hog 4 comment macros in OSC for Python3.""" - -__author__ = "Kevin Matz" -__copyright__ = "Copyright 2018, Company 235, LLC" -__credits__ = ["Kevin Matz"] - -__license__ = "MIT" -__version__ = "3.9" -__maintainer__ = "Kevin Matz" -__email__ = "kevin@company235.com" - -__status__ = "Prototype" - -import logging -from pythonosc import udp_client -from pythonosc import osc_message_builder -from pythonosc import osc_bundle_builder -from time import sleep - -logger = logging.getLogger("CommentMacro") - - -class HogDevice(): - # button state constants - buttonDOWN = 1 - buttonUP = 0 - - def __init__(self, servers): - self.servers = servers - - def button_press(self, device, path, delay=0.05): - self.send_message(device, path, HogDevice.buttonDOWN) # button down - sleep(delay) - self.send_message(device, path, HogDevice.buttonUP) # button up - - # utility function to send simple messages with one argument - def send_message(self, device, path, arg): - msg = osc_message_builder.OscMessageBuilder(address=path) - msg.add_arg(arg) - self.send(device, msg.build()) - - # send python-osc messages - def send(self, device, msg): - if device is None: - osc = list(self.servers.values())[0] - else: - if (device.ntype.getText().lower() != 'h'): - logger.error("ERROR: Only Hog type devices are supported.") - return - else: - try: - osc = self.servers[device.n.value] - except KeyError: - logger.error("ERROR: Net# " + str(device.n.value) + - " not found.") - return - try: - osc.send(msg) - except Exception as e: - logger.error(e) - - def _master_go(self, ctx): - if ctx.n is not None: - logger.warn("GO MASTER doesn't support goto. " + - "Cue number "+str(ctx.n.value)+" is ignored.") - if ctx.t is None: - logger.info("Main GO") - self.osc.button_press(ctx.dev, "/hog/hardware/maingo") - return - else: - for i in ctx.t.targets: - if isinstance(i, int) is not True: - logger.warn("GO MASTER macro targets must be intigers. " - + str(i) + " is not an intigers.") - continue - if (i < 0): - logger.warn("Master "+str(i)+" is not greater than 0.") - continue - master = str(i) - logger.info("GO on master " + master) - self.osc.button_press(ctx.dev, "/hog/hardware/go/" + master) - - def _master_halt(self, ctx): - if ctx.t is None: - logger.info("Main HALT") - self.osc.button_press(ctx.dev, "/hog/hardware/mainhalt") - return - else: - for i in ctx.t.targets: - if isinstance(i, int) is not True: - logger.warn("GO MASTER macro targets must be intigers. " - + str(i) + " is not an intigers.") - continue - if (i < 0): - logger.warn("Master "+str(i)+" is not greater than 0.") - continue - master = str(i) - logger.info("HALT on master " + master) - self.osc.button_press(ctx.dev, - "/hog/hardware/pause/" + master) - - def _master_assert(self, ctx): - if ctx.t is None: - logger.error("ERROR: limited to asserting current master only.") - return - logger.info("ASSERT on current master.") - self.osc.button_press(ctx.dev, "/hog/hardware/assert") - - def _master_release(self, ctx): - if ctx.t is None: - logger.error("ERROR: limited to releasing current master only.") - return - logger.info("RELEASE on current master.") - self.osc.button_press(ctx.dev, "/hog/hardware/release") - - def _master_fade(self, ctx): - level = ctx.n.value - if (level < 0 or level > 100): - logger.error("Level must be between 0 and 100.") - return - if (len(ctx.master.targets) == 0): - logger.error("MASTER FADE doesn't support * current master.") - return - else: - for i in ctx.t.targets: - if isinstance(i, int) is not True: - logger.warn("FADE MASTER macro targets must be intigers. " - + str(i) + " is not an intigers.") - continue - if (i < 0): - logger.warn("Master "+str(i)+" is not greater than 0.") - continue - master = str(i) - logger.info("Fade Master "+master+" to "+str(level)+"%") - level *= 255 / 100 # percent in Macro, 0>255 in OSC - self.osc.send_message(ctx.dev, - "/hog/hardware/fader/" + master, - level) - - def _master_fade_grand(self, ctx): - level = ctx.n.value - if (level < 0 or level > 100): - logger.error("Level must be between 0 and 100.") - return - logger.info("Fading Grand Master to " + str(level) + "%") - level *= 255 / 100 # percent in Macro, 0>255 in OSC - self.osc.send_message(ctx.dev, "/hog/hardware/fader/0", level) - - def _master_choose(self, ctx): - if (ctx.n.value < 0): - logger.error("Master must be greater than 0.") - return - master = str(ctx.n.value) - logger.info("Choose Master " + master) - self.osc.button_press(ctx.dev, "/hog/hardware/choose/" + master) - - def _release_all(self, ctx): - logger.info("Release All") - self.osc.send_message(ctx.dev, "/hog/hardware/pig", - HogDevice.buttonDOWN) - self.osc.button_press(ctx.dev, "/hog/hardware/release") - self.osc.send_message(ctx.dev, "/hog/hardware/pig", - HogDevice.buttonUP) - - def _list_go(self, ctx): - for i in ctx.t.targets: - if ctx.n is not None: - list = str(i) + "." + str(ctx.n.value) - else: - list = i - logger.info("Go on List " + str(list)) - self.osc.send_message(ctx.dev, "/hog/playback/go/0", list) - - def _list_halt(self, ctx): - for i in ctx.t.targets: - logger.info("Halting List " + str(i)) - self.osc.send_message(ctx.dev, "/hog/playback/halt/0", i) - - def _list_release(self, ctx): - for i in ctx.t.targets: - logger.info("Releasing List " + str(i)) - self.osc.send_message(ctx.dev, "/hog/playback/release/0", i) - - def _scene_go(self, ctx): - for i in ctx.t.targets: - logger.info("Go on Scene " + str(i)) - self.osc.send_message(ctx.dev, "/hog/playback/go/1", i) - - def _scene_halt(self, ctx): - for i in ctx.t.targets: - logger.info("Halt Scene " + str(i)) - self.osc.send_message(ctx.dev, "/hog/playback/halt/1", i) - - def _scene_release(self, ctx): - for i in ctx.t.targets: - logger.info("Release Scene " + str(i)) - self.osc.send_message(ctx.dev, "/hog/playback/release/1", i) - - def _macro_go(self, ctx): - for i in ctx.t.targets: - logger.info("Go on Macro " + str(i)) - self.osc.send_message(ctx.dev, "/hog/playback/go/2", i) - - def _macro_halt(self, ctx): - for i in ctx.t.targets: - logger.info("Pause Macro " + str(i)) - self.osc.send_message(ctx.dev, "/hog/playback/halt/2", i) - - def _macro_release(self, ctx): - for i in ctx.t.targets: - logger.info("Stop Macro " + str(i)) - self.osc.send_message(ctx.dev, "/hog/playback/release/2", i) - - def _page_change(self, ctx): - if ctx.d is None: - logger.error("ERROR: changing page by number is unsupported.") - return - if ctx.d.text == '+': - logger.info("Next Page") - self.osc.button_press(ctx.dev, "/hog/hardware/nextpage") - elif ctx.d.text == '-': - logger.info("Previous Page") - self.osc.button_press(ctx.dev, "/hog/hardware/backpage") - - command = {"GM": _master_go, - "HM": _master_halt, - "AM": _master_assert, - "RM": _master_release, - "FM": _master_fade, - "FGM": _master_fade_grand, - "CM": _master_choose, - "RA": _release_all, - "GL": _list_go, - "HL": _list_halt, - "RL": _list_release, - "GS": _scene_go, - "HS": _scene_halt, - "RS": _scene_release, - "GK": _macro_go, - "HK": _macro_halt, - "RK": _macro_release, - "CP": _page_change - } diff --git a/README.md b/README.md index e87c831..b3272bb 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ A theoretical exercise to control a Hog 4 via OSC, with comment macros. -The comment macro grammar described in `CommentMacro.g4` is based upon the Hog 3.9 manual, Chapter 22.4. The python3 implementation in `OscMacroDefinitions.py` is based on Chapter 24.2 in the same manual. +The comment macro grammar described in `CommentMacro.g4` is based upon the Hog 3.9 manual, Chapter 22.4. The python3 implementation in `OscCommentMacroListener.py` is based on Chapter 24.2 in the same manual. Some macros are unsupported/unsupportable with this method. Some macro features, like timing, are not yet implemented. Refer to the **Features** table for specific notes.