junyang / radb

RA (radb): A relational algebra interpreter over relational databases
http://www.cs.duke.edu/~junyang/radb
Other
62 stars 14 forks source link

cannot parse "rename" from string #1

Closed Meffi42 closed 6 years ago

Meffi42 commented 6 years ago

It seems I cannot parse the rename operator from string. The rename-statement to be parsed is a snippet from the documentation.

radb.parse.one_statement_fromstring('\rename{s2} (Serves);') Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/antlr4/Lexer.py", line 128, in nextToken ttype = self._interp.match(self._input, self._mode) File "/usr/lib/python3.6/site-packages/antlr4/atn/LexerATNSimulator.py", line 99, in match return self.execATN(input, dfa.s0) File "/usr/lib/python3.6/site-packages/antlr4/atn/LexerATNSimulator.py", line 191, in execATN return self.failOrAccept(self.prevAccept, input, s.configs, t) File "/usr/lib/python3.6/site-packages/antlr4/atn/LexerATNSimulator.py", line 250, in failOrAccept raise LexerNoViableAltException(self.recog, input, self.startIndex, reach) antlr4.error.Errors.LexerNoViableAltException: LexerNoViableAltException('{')

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "", line 1, in File "/usr/lib/python3.6/site-packages/radb/parse.py", line 252, in one_statement_fromstring tree = parser.statement() File "/usr/lib/python3.6/site-packages/radb/RAParser.py", line 1673, in statement la = self._interp.adaptivePredict(self._input,18,self._ctx) File "/usr/lib/python3.6/site-packages/antlr4/atn/ParserATNSimulator.py", line 342, in adaptivePredict alt = self.execATN(dfa, s0, input, index, outerContext) File "/usr/lib/python3.6/site-packages/antlr4/atn/ParserATNSimulator.py", line 465, in execATN input.consume() File "/usr/lib/python3.6/site-packages/antlr4/BufferedTokenStream.py", line 99, in consume if self.sync(self.index + 1): File "/usr/lib/python3.6/site-packages/antlr4/BufferedTokenStream.py", line 111, in sync fetched = self.fetch(n) File "/usr/lib/python3.6/site-packages/antlr4/BufferedTokenStream.py", line 123, in fetch t = self.tokenSource.nextToken() File "/usr/lib/python3.6/site-packages/antlr4/Lexer.py", line 130, in nextToken self.notifyListeners(e) # report error File "/usr/lib/python3.6/site-packages/antlr4/Lexer.py", line 285, in notifyListeners listener.syntaxError(self, None, self._tokenStartLine, self._tokenStartColumn, msg, e) File "/usr/lib/python3.6/site-packages/antlr4/error/ErrorListener.py", line 60, in syntaxError delegate.syntaxError(recognizer, offendingSymbol, line, column, msg, e) File "/usr/lib/python3.6/site-packages/radb/parse.py", line 75, in syntaxError raise ParsingError('line {}:{} {}'.format(line, column, msg)) radb.parse.ParsingError: line 1:7 token recognition error at: '{'

Meffi42 commented 6 years ago

OK, seems I need to escape the backslash for it to work:

radb.parse.one_statement_fromstring('\rename{s2} (Serves);')