曾与蒿藜同雨露,한때 잡초와 쑥과 함께 비와 이슬을 나누던 곳이 이제는 소나무와 삼나무와 함께 서리와 눈을 견뎌내고 있다.终随松柏到冰霜.かつては雑草やヨモギと共に雨や露を分かち合っていたが、今では松やヒノキと共に霜や雪に耐えている。曾与蒿藜同雨露,Once sharing rain and dew with weeds and wormwood, now enduring frost and snow with pines and cypresses.终随松柏到冰霜.曾与蒿藜同雨露한때 잡초와 쑥과 함께 비와 이슬을 나누던 곳이 이제는 소나무와 삼나무와 함께 서리와 눈을 견뎌내고 있다.,终随松柏到冰霜.譖セ荳手珍阯懷酔髮ィ髴イ�檎サ磯囂譚セ譟丞芦蜀ー髴�曾与蒿藜同雨露,鏇句笌钂胯棞鍚岄洦闇诧紝缁堥殢鏉炬煆鍒板啺闇�终随松柏到冰霜.曾与蒿藜同雨露,한때 잡초와 쑥과 함께 비와 이슬을 나누던 곳이 이제는 소나무와 삼나무와 함께 서리와 눈을 견뎌내고 있다.终随松柏到冰霜.曾与蒿藜同雨露,终随松柏到冰霜. rahbord-ins.ir - GrazzMean-Shell
Uname: Linux server18.dn-server.com 3.10.0-962.3.2.lve1.5.88.el7.x86_64 #1 SMP Fri Sep 26 14:06:42 UTC 2025 x86_64
Software: LiteSpeed
PHP version: 7.4.33 [ PHP INFO ] PHP os: Linux
Server Ip: 185.126.202.122
Your Ip: 216.73.216.193
User: rahbordf (4876) | Group: rahbordf (4881)
Safe Mode: OFF
Disable Function:
show_source, system, shell_exec, passthru, exec, popen, proc_open

name : Lexicons.py
#=======================================================================
#
#   Python Lexical Analyser
#
#   Lexical Analyser Specification
#
#=======================================================================

from __future__ import absolute_import

import types

from . import Actions
from . import DFA
from . import Errors
from . import Machines
from . import Regexps

# debug_flags for Lexicon constructor
DUMP_NFA = 1
DUMP_DFA = 2


class State(object):
    """
    This class is used as part of a Plex.Lexicon specification to
    introduce a user-defined state.

    Constructor:

       State(name, token_specifications)
    """

    name = None
    tokens = None

    def __init__(self, name, tokens):
        self.name = name
        self.tokens = tokens


class Lexicon(object):
    """
    Lexicon(specification) builds a lexical analyser from the given
    |specification|. The specification consists of a list of
    specification items. Each specification item may be either:

       1) A token definition, which is a tuple:

             (pattern, action)

          The |pattern| is a regular axpression built using the
          constructors defined in the Plex module.

          The |action| is the action to be performed when this pattern
          is recognised (see below).

       2) A state definition:

             State(name, tokens)

          where |name| is a character string naming the state,
          and |tokens| is a list of token definitions as
          above. The meaning and usage of states is described
          below.

    Actions
    -------

    The |action| in a token specication may be one of three things:

       1) A function, which is called as follows:

             function(scanner, text)

          where |scanner| is the relevant Scanner instance, and |text|
          is the matched text. If the function returns anything
          other than None, that value is returned as the value of the
          token. If it returns None, scanning continues as if the IGNORE
          action were specified (see below).

        2) One of the following special actions:

           IGNORE means that the recognised characters will be treated as
                  white space and ignored. Scanning will continue until
                  the next non-ignored token is recognised before returning.

           TEXT   causes the scanned text itself to be returned as the
                  value of the token.

        3) Any other value, which is returned as the value of the token.

    States
    ------

    At any given time, the scanner is in one of a number of states.
    Associated with each state is a set of possible tokens. When scanning,
    only tokens associated with the current state are recognised.

    There is a default state, whose name is the empty string. Token
    definitions which are not inside any State definition belong to
    the default state.

    The initial state of the scanner is the default state. The state can
    be changed in one of two ways:

       1) Using Begin(state_name) as the action of a token.

       2) Calling the begin(state_name) method of the Scanner.

    To change back to the default state, use '' as the state name.
    """

    machine = None  # Machine
    tables = None   # StateTableMachine

    def __init__(self, specifications, debug=None, debug_flags=7, timings=None):
        if not isinstance(specifications, list):
            raise Errors.InvalidScanner("Scanner definition is not a list")
        if timings:
            from .Timing import time

            total_time = 0.0
            time1 = time()
        nfa = Machines.Machine()
        default_initial_state = nfa.new_initial_state('')
        token_number = 1
        for spec in specifications:
            if isinstance(spec, State):
                user_initial_state = nfa.new_initial_state(spec.name)
                for token in spec.tokens:
                    self.add_token_to_machine(
                        nfa, user_initial_state, token, token_number)
                    token_number += 1
            elif isinstance(spec, tuple):
                self.add_token_to_machine(
                    nfa, default_initial_state, spec, token_number)
                token_number += 1
            else:
                raise Errors.InvalidToken(
                    token_number,
                    "Expected a token definition (tuple) or State instance")
        if timings:
            time2 = time()
            total_time = total_time + (time2 - time1)
            time3 = time()
        if debug and (debug_flags & 1):
            debug.write("\n============= NFA ===========\n")
            nfa.dump(debug)
        dfa = DFA.nfa_to_dfa(nfa, debug=(debug_flags & 3) == 3 and debug)
        if timings:
            time4 = time()
            total_time = total_time + (time4 - time3)
        if debug and (debug_flags & 2):
            debug.write("\n============= DFA ===========\n")
            dfa.dump(debug)
        if timings:
            timings.write("Constructing NFA : %5.2f\n" % (time2 - time1))
            timings.write("Converting to DFA: %5.2f\n" % (time4 - time3))
            timings.write("TOTAL            : %5.2f\n" % total_time)
        self.machine = dfa

    def add_token_to_machine(self, machine, initial_state, token_spec, token_number):
        try:
            (re, action_spec) = self.parse_token_definition(token_spec)
            # Disabled this -- matching empty strings can be useful
            #if re.nullable:
            #  raise Errors.InvalidToken(
            #    token_number, "Pattern can match 0 input symbols")
            if isinstance(action_spec, Actions.Action):
                action = action_spec
            else:
                try:
                    action_spec.__call__
                except AttributeError:
                    action = Actions.Return(action_spec)
                else:
                    action = Actions.Call(action_spec)
            final_state = machine.new_state()
            re.build_machine(machine, initial_state, final_state,
                             match_bol=1, nocase=0)
            final_state.set_action(action, priority=-token_number)
        except Errors.PlexError as e:
            raise e.__class__("Token number %d: %s" % (token_number, e))

    def parse_token_definition(self, token_spec):
        if not isinstance(token_spec, tuple):
            raise Errors.InvalidToken("Token definition is not a tuple")
        if len(token_spec) != 2:
            raise Errors.InvalidToken("Wrong number of items in token definition")
        pattern, action = token_spec
        if not isinstance(pattern, Regexps.RE):
            raise Errors.InvalidToken("Pattern is not an RE instance")
        return (pattern, action)

    def get_initial_state(self, name):
        return self.machine.get_initial_state(name)



© 2026 GrazzMean-Shell