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

georgia-tech-db / eva / #758

04 Sep 2023 08:37PM UTC coverage: 0.0% (-78.3%) from 78.333%
#758

push

circle-ci

hershd23
Increased underline length in at line 75 in text_summarization.rst
	modified:   docs/source/benchmarks/text_summarization.rst

0 of 11303 relevant lines covered (0.0%)

0.0 hits per line

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

0.0
/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
×
16

17
from lark import Lark
×
18

19
from evadb.parser.lark_visitor import LarkInterpreter
×
20

21

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

27
    _parser = None
×
28

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

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

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

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

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

52
        # convert output to list if it is a single element
53
        if isinstance(output, list):
×
54
            return output
×
55
        else:
56
            return [output]
×
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

© 2025 Coveralls, Inc