Commits

Kirill Simonov  committed 80f35ca

htsql-ctl shell: support for locator in auto-completer.

  • Participants
  • Parent commits 00cc809

Comments (0)

Files changed (1)

File src/htsql/ctl/shell.py

     pattern = r"""
     ~ | < | > | = | ! | & | \| | -> | \. | , | \? | \^ |
     / | \* | \+ | - | \( | \) | \{ | \} | := | : | \$ | @ |
-    ' (?: [^'] | '')* ' | \d+ [.eE]? |
+    \[ | \] |
+    ' (?: [^'] | '')* ' | \d+ [.eE]?|
     (?! \d) \w+
     """
     letter_pattern = r"""(?! \d) \w"""
             token = tokens[idx]
             prev_token = tokens[idx-1]
             next_token = tokens[idx+1]
+            if state.indicator == '[':
+                if token == '[' or token == '(':
+                    state.push('[', [])
+                elif token == ']' or token == ')':
+                    state.drop('[')
+                continue
             if cls.letter_regexp.match(token) is not None:
                 if not (prev_token == ':' or prev_token == '$'
                         or next_token == '('):
                 state.drop_all('_?^')
             elif token == '$':
                 state.push('_', [])
+            elif token == '[':
+                state.push('[', [])
             else:
                 state.drop_all('_')
+        if state.indicator == '[':
+            return []
         identifiers = state.identifiers
         chain = NodeChain(routine.state.app)
         chain.push(HomeNode())