• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

georgia-tech-db / eva / 20a9a0f9-edcc-437c-815d-bcc1a2d22b17

10 Nov 2023 04:50AM UTC coverage: 66.644% (-10.2%) from 76.812%
20a9a0f9-edcc-437c-815d-bcc1a2d22b17

push

circleci

americast
update docs

0 of 1 new or added line in 1 file covered. (0.0%)

1354 existing lines in 113 files now uncovered.

8767 of 13155 relevant lines covered (66.64%)

0.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.83
/evadb/parser/lark_parser.py
1
# coding=utf-8
2
# Copyright 2018-2023 EvaDB
3
#
4
# Licensed under the Apache License, Version 2.0 (the "License");
5
# you may not use this file except in compliance with the License.
6
# You may obtain a copy of the License at
7
#
8
#     http://www.apache.org/licenses/LICENSE-2.0
9
#
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS,
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
# See the License for the specific language governing permissions and
14
# limitations under the License.
15
import os
1✔
16

17
from lark import Lark
1✔
18

19
from evadb.parser.lark_visitor import LarkInterpreter
1✔
20

21

22
class LarkParser(object):
1✔
23
    """
24
    Parser for EvaDB QL based on Lark
25
    """
26

27
    _parser = None
1✔
28

29
    def __new__(cls):
1✔
30
        if not hasattr(cls, "_instance"):
1✔
31
            cls._instance = super(LarkParser, cls).__new__(cls)
1✔
32
        return cls._instance
1✔
33

34
    def __init__(self):
1✔
35
        dir_path = os.path.dirname(os.path.realpath(__file__))
1✔
36
        lark_path = os.path.join(dir_path, "evadb.lark")
1✔
37
        with open(lark_path) as f:
1✔
38
            sql_grammar = f.read()
1✔
39
        self._parser = Lark(sql_grammar, parser="lalr")
1✔
40

41
    def parse(self, query_string: str) -> list:
1✔
42
        # remove trailing white space
43
        query_string = query_string.rstrip()
1✔
44

45
        # add semi-colon if needed
46
        if not query_string.endswith(";"):
1✔
47
            query_string += ";"
1✔
48

49
        tree = self._parser.parse(query_string)
1✔
50
        output = LarkInterpreter(query_string).visit(tree)
1✔
51

52
        # convert output to list if it is a single element
53
        if isinstance(output, list):
1✔
UNCOV
54
            return output
×
55
        else:
56
            return [output]
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc