vivjson.error (2025-03-22)
index
https://github.com/benesult/vivjson-python/tree/main/vivjson/error.py

Error for VivJson
 
Error.make_lex_error: Report error information and return LexError.
Error.make_parse_error: Report error information and return
                          ParseError.
Error.make_evaluate_error: Report error information and return
                             EvaluateError.
 
Refer to:
- "Crafting Interpreters"
  https://craftinginterpreters.com/
Note that this code is made from scratch. The source code
of the above WEB site is not used.
 
Environment:
- Python 3.9 or later
 
License:
Copyright 2025 benesult
 
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
 
    http://www.apache.org/licenses/LICENSE-2.0
 
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

 
Modules
       
sys

 
Classes
       
builtins.object
Error

 
class Error(builtins.object)
    Error class
 
  Static methods defined here:
make_evaluate_error(message, statement=None, config=None, eliminate_tag=False)
Make evaluate-error.
 
Report error information and return EvaluateError that is
Exception.
This method does not raise Exception. So caller should raise
Exception if it is needed.
 
Args:
    message (str): Error message
    statement (Statement or NoneType, optional): Statement
            where error occurs. It is used to get location.
            None is given when cause is not Statement.
    config (Config or NoneType, optional): Configuration if
                                           needed.
    eliminate_tag (bool, optional): True if tag is not needed,
                                    False otherwise.
                                    The default is False
 
Returns:
    EvaluateError: Exception for raising.
make_lex_error(message, medium, line, column, config=None)
Make lex-error.
 
Report error information and return LexError that is Exception.
This method does not raise Exception. So caller should raise
Exception if it is needed.
 
Args:
    message (str): Error message
    medium (str or NoneType): The object that has source code.
    line (int): Line number of location where error occurs.
    column (int): Column number of location where error occurs.
    config (Config or NoneType, optional): Configuration if
                                           needed.
 
Returns:
    LexError: Exception for raising.
make_parse_error(message, token=None, config=None)
Make parse-error.
 
Report error information and return ParseError that is
Exception.
This method does not raise Exception. So caller should raise
Exception if it is needed.
 
Args:
    message (str): Error message
    token (Token or NoneType, optional): Token.
                                         None is given when
                                         cause is not Token.
    config (Config or NoneType, optional): Configuration if
                                           needed.
 
Returns:
    ParseError: Exception for raising.
report(tag, message, location=None, config=None, eliminate_tag=False)
Report an error message.
 
Print an error message into stderr according as configuration.
 
Args:
    tag (str): Tag, such as "Lexer", "Parser", or "Evaluator".
    message (str): Main message of Error
    location (Token or str or NoneType, optional): The location
                                                   of error
    config (Config or NoneType, optional): Configuration if
                                           needed.
    eliminate_tag (bool, optional): True if tag is not needed,
                                    False otherwise.
                                    The default is False
 
Returns:
    str: Error message

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes defined here:
EvaluateError = <class 'vivjson.error.Error.EvaluateError'>
Evaluate-error class of Runtime error
LexError = <class 'vivjson.error.Error.LexError'>
Lex-error class of Runtime error
ParseError = <class 'vivjson.error.Error.ParseError'>
Parse-error class of Runtime error
TAG = 'Viv'

 
Author
        Fumiaki Motegi <motegi@benesult.com>