code: def frac(self):
      localctx = LaTeXParser.FracContext(self, self._ctx, self.state)
      self.enterRule(localctx, 54, self.RULE_frac)
      try:
          self.enterOuterAlt(localctx, 1)
          self.state = 338
          self.match(LaTeXParser.CMD_FRAC)
          self.state = 344
          self._errHandler.sync(self)
          token = self._input.LA(1)
          if token in [78]:
              self.state = 339
              localctx.upperd = self.match(LaTeXParser.DIGIT)
              pass
          elif token in [21]:
              self.state = 340
              self.match(LaTeXParser.L_BRACE)
              self.state = 341
              localctx.upper = self.expr()
              self.state = 342
              self.match(LaTeXParser.R_BRACE)
              pass
          else:
              raise NoViableAltException(self)
  
          self.state = 351
          self._errHandler.sync(self)
          token = self._input.LA(1)
          if token in [78]:
              self.state = 346
              localctx.lowerd = self.match(LaTeXParser.DIGIT)
              pass
          elif token in [21]:
              self.state = 347
              self.match(LaTeXParser.L_BRACE)
              self.state = 348
              localctx.lower = self.expr()
              self.state = 349
              self.match(LaTeXParser.R_BRACE)
              pass
          else:
              raise NoViableAltException(self)
  
      except RecognitionException as re:
          localctx.exception = re
          self._errHandler.reportError(self, re)
          self._errHandler.recover(self, re)
      finally:
          self.exitRule()
      return localctx
  
imports: from antlr4 import *
  from io import StringIO
  import sys
label_desc: Use image node_id 29 for calling the LaTeXParser obj's underlying member method code with example usage: obj.frac() and returns: localctx