Skip to content
Snippets Groups Projects

Resolve "Plugin langage Prolog"

Files

"""Module prolog language"""
# ubiquity
# Copyright (C) 2023 INSA Rouen Normandie - CIP
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from typing import List, Tuple, Optional
from ..language_base import Language
from ..lexicon import Lexicon, Token
class PrologLanguage(Language):
"""A prolog language plugin"""
@property
def file_name(self) -> str:
return r'.+\.pl$'
@property
def comments(self) -> List[Tuple[Optional[str], Optional[str]]]:
return [('%', None), ('/*', '*/')]
@property
def prettify_lang(self) -> str:
return 'prolog'
@property
def lexicon(self) -> Lexicon:
return Lexicon({
Token.DELIMITER: r"[\+\-\*\\\/\^<>=~:\.\?#&@]+",
Token.AFFECTATION: r"=|(\:\-)",
Token.OPERATOR: "|".join(
(r"==", r"=:=", r"\\==", r"=\\=", r"\+", r"-", r"\*", r"/", r"//",
r">", r"<", r">=", r"=<", r"=\.\.", r"\.\.\.")),
Token.COMMENT: r"(%.*)|(/\*(.|\s)*?\*/)",
Token.STR: r"'(([^'])|(''))*'",
Token.KEYWORD: r"(" + "|".join([r'is', r'not']) + r")[\W$]"
})
Loading