|
| 1 | +# ----------------------------------------------------------------------- |
| 2 | +# This file is part of MoonScript |
| 3 | +# |
| 4 | +# MoonSript is free software: you can redistribute it and/or modify |
| 5 | +# it under the terms of the GNU General Public License as published by |
| 6 | +# the Free Software Foundation, either version 3 of the License, or |
| 7 | +# (at your option) any later version. |
| 8 | +# |
| 9 | +# MoonSript is distributed in the hope that it will be useful, |
| 10 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | +# GNU General Public License for more details. |
| 13 | +# |
| 14 | +# You should have received a copy of the GNU General Public License |
| 15 | +# along with MoonSript. If not, see <https://www.gnu.org/licenses/>. |
| 16 | +# |
| 17 | +# Copyright (C) 2025 Krisna Pranav, MoonScript Developers |
| 18 | +# ----------------------------------------------------------------------- |
| 19 | + |
| 20 | +module MoonScript |
| 21 | + class MoonJson |
| 22 | + class Parser |
| 23 | + def parse_source_directories : Array(String) |
| 24 | + @parser.location.try do |location| |
| 25 | + directories = %w[] |
| 26 | + |
| 27 | + @parser.read_array do |
| 28 | + directories << parse_source_directory |
| 29 | + end |
| 30 | + |
| 31 | + error! :source_directory_empty do |
| 32 | + end |
| 33 | + |
| 34 | + block do |
| 35 | + end |
| 36 | + |
| 37 | + snippet snippet_data(location) |
| 38 | + end |
| 39 | + end |
| 40 | + |
| 41 | + def parse_source_directory: String |
| 42 | + location = @parser.location |
| 43 | + directory = @parser.read_string |
| 44 | + path = Path[root, directory] |
| 45 | + |
| 46 | + error! :source_directory_not_exists do |
| 47 | + end |
| 48 | + |
| 49 | + snippet snippet_data(location) |
| 50 | + end unless Dir.exists?(path) |
| 51 | + end |
| 52 | + directory |
| 53 | + |
| 54 | + end |
| 55 | +end |
0 commit comments