Commit edf80cc7 authored by Victor Yacovlev's avatar Victor Yacovlev

Fixed python3 resources symlinks

parent 5fc0e5c2
/home/victor/Projects/NIISI/kumir/python3_static_analyzer/analizer_instance.py
\ No newline at end of file
"""
Analizer instance module
NOTE: Each analizer instance runs in it's own interpreter
"""
from kumir_constants import *
SOURCE_DIR_NAME = ""
SOURCE_TEXT = ""
ERRORS = []
LINE_PROPERTIES = []
LINE_RANKS = []
class Error:
""" One error message """
def __init__(self, line_no, start_pos, length, message):
"""
line_no -- line number (int)
start_pos -- start position from 0 (int)
length -- error block length (int)
message -- a string (ASCII symbols only) identificating error message
"""
assert isinstance(line_no, int)
assert isinstance(start_pos, int)
assert isinstance(length, int)
assert isinstance(message, str)
self.line_no = line_no
self.start_pos = start_pos
self.length = length
self.message = message
def set_source_dir_name(path):
"""
Set the source file location (directory name) to help searching imported modules
path -- directory path in platform dependent format (str)
"""
assert isinstance(path, str)
global SOURCE_DIR_NAME
SOURCE_DIR_NAME = path
def set_source_text(text):
"""
Set the source text and require complete analisis
text -- complete python program source; line delimiter is '\n' (str)
"""
assert isinstance(text, str)
global SOURCE_TEXT
SOURCE_TEXT = text
def get_errors():
"""
Get a list of errors generated while 'set_source_text'
returns a list of Error class instances
"""
global ERRORS
return ERRORS
def get_line_properties():
"""
Get a list of line highlight properties generated while 'set_source_text'
returns a list:
- each item corresponds one text line
- each item is a list:
- each item corresponds one character in line
- each item is an integer number, see 'kumir_constants.py'
"""
global LINE_PROPERTIES
return LINE_PROPERTIES
def get_line_ranks():
"""
Get a list of line indentation ranks generated while 'set_source_text'
returns a list:
- each item corresponds one text line
- each item is a tuple (start, end), where:
- start is a line start indentation rank
- end is a terminal indentation rank
"""
global LINE_RANKS
return LINE_RANKS
def get_line_property(line_no, line_text):
"""
Get line property of one text line, currently editing and possible not complete
line_no -- editable line number (from 0)
line_text -- one text line while in edit progress
returns a list:
- each item corresponds one character in line
- each item is an integer number, see 'kumir_constants.py'
"""
assert isinstance(line_no, int)
assert isinstance(line_text, str)
return []
\ No newline at end of file
/home/victor/Projects/NIISI/kumir/python3_static_analyzer/kumir_constants.py
\ No newline at end of file
"""
Kumir constants defining code highlighting
LxTypeEmpty -- typically used for spaces and other non-significant stuff
LxTypeComment -- comments starts with #
LxTypeName -- a 'generic' name lexem in case if there is not possible to
get name meaning
LxTypeSecondaryKwd -- 'secondary' keyword, which do not define statement type
Examples: in, as, is, and, or
LxTypePrimaryKwd -- 'primary' keyword, which defines statement type
Examples: def, for, import, from, with, global
LxTypeConstant -- a 'generic' constant in case if there is not possible to
get constant type
LxTypeOperator -- operator lexem
LxTypeError -- error lexem; it is optional flag
LxNameClass -- type or class name
LxNameVar -- local or global variable name
LxNameAlg -- function or method name
LxNameModule -- module name
LxConstInteger -- integer constant
LxConstReal -- floating-point constant
LxConstBoolTrue -- boolean True constant
LxConstBoolFalse -- boolean False constant
LxConstLiteral -- literal (char of string) constant
"""
LxTypeEmpty = 0x00000000 # empty mask
LxTypeComment = 0x00000001 # bit 0
LxTypeName = 0x0000001C # bits [2..4]
LxTypeSecondaryKwd = 0x000001E0 # bits [5..8]
LxTypePrimaryKwd = 0x0000F800 # bits [11..15]
LxTypeConstant = 0x001E0000 # bits [17..20]
LxTypeOperator = 0x01F00000 # bits [21..25]
LxTypeError = 0x80000000 # bit 31
# LxTypeName values
LxNameClass = 0x4
LxNameVar = 0x8
LxNameAlg = 0xc
LxNameModule = 0x10
# LxTypeConstant values
LxConstInteger = 0x20000
LxConstReal = 0x40000
LxConstBoolTrue = 0x60000
LxConstBoolFalse = 0x80000
LxConstLiteral = 0xa0000
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment