def visitTerminal(self, ctx: TerminalNodeImpl): if self.fn_nest_cnt == 0: #Tokens under FUNCTION calls are not to be handled by this method tok_txt = ctx.getText() if tok_txt.upper() in ['__LOAD__', '__BLOCK__']: tok_txt = tok_txt.strip('_') hdn_tok = self.getLeftHiddenToken(ctx) if tok_txt == '<EOF>': pass else: self.out_sql += hdn_tok + tok_txt self.last_visited_token = tok_txt
def visitTerminal(self, ctx:TerminalNodeImpl): tok_txt = ctx.getText() if tok_txt.upper() in ['__LOAD__','__BLOCK__']: tok_txt = tok_txt.strip('_') hdn_tok = self.getLeftHiddenToken(ctx) self.out_script += (hdn_tok + tok_txt) self.last_token = tok_txt if tok_txt.upper() in ['BEGIN', 'TRY', 'CATCH', 'TRANSACTION'] or (tok_txt.upper() == 'END' and not(isinstance(ctx.parentCtx, FullTSqlAntlrParser.Case_expressionContext))): self.out_script += ';' self.last_token = ';' self.out_script = re.sub(r'(BEGIN|END)\s*;(\s+)(TRY|CATCH)\s*;',r'\1\2\3;', self.out_script, flags=re.S|re.I) self.out_script = re.sub(r'(BEGIN|END|COMMIT|ROLLBACK)\s*;?(\s+TRANSACTION)\s*;(\s+\w+)\s*;?',r'\1\2\3;', self.out_script, flags=re.S|re.I)
def visitTerminal(self, ctx:TerminalNodeImpl): if self.fn_nest_cnt == 0 and \ self.intv_nest_cnt == 0 and \ self.cnct_nest_cnt == 0 and \ not(self.fld_mode_cast) and \ not(self.case_spf) and \ not(self.qlfy_expr): tok_txt = ctx.getText() hdn_tok = self.getLeftHiddenToken(ctx) if tok_txt.upper() == 'SELECT' and self.qlfy_scope_stat[self.qlfy_scope]: tok_txt = '[' + str(self.qlfy_scope) + '.S1]' + hdn_tok + tok_txt + ' [' + str(self.qlfy_scope) + '.S2]' self.out_sql += hdn_tok + tok_txt elif isinstance(ctx.parentCtx, TDantlrParser.Column_nameContext) and not(self.alias_order_by) and tok_txt in self.alias_scope_txt[self.alias_scope].keys(): self.out_sql += hdn_tok + self.alias_scope_txt[self.alias_scope][tok_txt] else: if tok_txt == '<EOF>': self.out_sql += hdn_tok + ';' else: self.out_sql += hdn_tok + tok_txt