示例#1
0
#! /usr/bin/env python
# -*- coding: utf8 -*-
import os
import sys
sys.path.insert(0, "./")
from track_analysis_single_pattern import choice_str, pattern_db, choice
import quex.engine.state_machine.cut.stem_and_branches as stem_and_branches
import help

if "--hwut-info" in sys.argv:
    print "Paths Analysis: Single Pattern;"
    print choice_str
    sys.exit()

stem_and_branches._unit_test_deactivate_branch_pruning_f = True

sm = help.prepare(pattern_db[choice])

# For DEBUG purposes: specify 'DRAW' on command line
help.if_DRAW_in_sys_argv(sm)
help.test(sm)
示例#2
0
    pattern_list = [
        '0/a/',
        '1/b/',
        '2/[ab]cd/',
    ]
elif "14" in sys.argv:
    #    ┌────┐  a   ┌───┐  c   ┌───┐  d   ┌───┐
    #    │ 0  │ ───▶ │ 1 │ ───▶ │ 2 │ ───▶ │ 3 │
    #    └────┘      └───┘      └───┘      └───┘
    #      │                      ▲
    #      │ b                    │
    #      ▼                      │
    #    ┌────┐  c                │
    #    │ 4  │ ──────────────────┘
    #    └────┘
    #____________________________________________________________________
    pattern_list = [
        '0/a/',
        '1/b/',
        '2/[ab]/',
        '[ab]cd',
    ]
else:
    assert False

sm = help.prepare(pattern_list)

# For DEBUG purposes: specify 'DRAW' on command line
help.if_DRAW_in_sys_argv(sm)
help.test(sm, PrintPRM_F=True)
#! /usr/bin/env python
# -*- coding: utf8 -*-
import os
import sys
sys.path.insert(0, "./")
from   track_analysis_single_pattern                          import choice_str, pattern_db, choice
import quex.engine.state_machine.algorithm.acceptance_pruning as     acceptance_pruning
import help

if "--hwut-info" in sys.argv:
    print "Paths Analysis: Single Pattern;"
    print choice_str
    sys.exit()

acceptance_pruning._deactivated_for_unit_test_f = True

sm = help.prepare(pattern_db[choice])

# For DEBUG purposes: specify 'DRAW' on command line
help.if_DRAW_in_sys_argv(sm)
help.test(sm)

示例#4
0
import help

test = help.test()

def unique_in_order(iterable):
    p = [ x for n, x in enumerate(iterable) if n == 0 or iterable[n-1] != x ]
    return p if p or not iterable else list(iterable[0])


test.assert_equals(unique_in_order('AAAABBBCCDAABBB'), ['A','B','C','D','A','B'])
test.assert_equals(unique_in_order('AAAAAAA'), ['A'])
test.assert_equals(unique_in_order([1,2,2,3,3]), [1,2,3])
test.assert_equals(unique_in_order([]), [])
示例#5
0
import quex.input.regular_expression.engine as regex
import quex.engine.state_machine.algorithm.acceptance_pruning as acceptance_pruning
import quex.engine.analyzer.engine_supply_factory as engine
from quex.blackboard import E_InputActions
import help

if "--hwut-info" in sys.argv:
    print "Track Analyzis: Backwards - For Pre-Context;"
    print "CHOICES: 0, 1;"
    sys.exit()

if "0" in sys.argv:
    pattern_list = [
        'x/a/',
        'y/a/',
    ]
elif "1" in sys.argv:
    pattern_list = [
        'x+/a/',
        'yx+/a/',
    ]
else:
    assert False

sm = help.prepare(pattern_list, GetPreContextSM_F=True)

# For DEBUG purposes: specify 'DRAW' on command line
help.if_DRAW_in_sys_argv(sm)
help.test(sm, EngineType=engine.BACKWARD_PRE_CONTEXT)
示例#6
0
# -*- coding: utf8 -*-
import os
import sys
sys.path.insert(0, os.environ["QUEX_PATH"])

import quex.input.regular_expression.engine as regex
from quex.engine.state_machine.engine_state_machine_set import get_combined_state_machine
import quex.engine.analyzer.engine_supply_factory as engine
from quex.blackboard import E_InputActions
import help

from operator import attrgetter

if "--hwut-info" in sys.argv:
    print "Track Analyzis: Backward Input Position Detection;"
    sys.exit()

# There are no 'special cases'
pattern_list = [
    'ax',
]

state_machine_list = map(lambda x: regex.do(x, {}).sm, pattern_list)
sm = get_combined_state_machine(state_machine_list,
                                False)  # May be 'True' later.
sm = sm.normalized_clone()

# For DEBUG purposes: specify 'DRAW' on command line (in sys.argv)
help.if_DRAW_in_sys_argv(sm)
help.test(sm, engine.Class_BACKWARD_INPUT_POSITION(0))
# -*- coding: utf8 -*-
import os
import sys
sys.path.insert(0, os.environ["QUEX_PATH"])

import quex.input.regular_expression.engine  as regex
from   quex.engine.state_machine.engine_state_machine_set            import get_combined_state_machine
import quex.engine.analyzer.engine_supply_factory      as     engine
from   quex.blackboard                       import E_InputActions
import help

from   operator import attrgetter

if "--hwut-info" in sys.argv:
    print "Track Analyzis: Backward Input Position Detection;"
    sys.exit()

# There are no 'special cases'
pattern_list = [
    'ax',        
]

state_machine_list = map(lambda x: regex.do(x, {}).sm, pattern_list)
sm                 = get_combined_state_machine(state_machine_list, False) # May be 'True' later.
sm                 = sm.normalized_clone()

# For DEBUG purposes: specify 'DRAW' on command line (in sys.argv)
help.if_DRAW_in_sys_argv(sm)
help.test(sm, engine.Class_BACKWARD_INPUT_POSITION(0))

示例#8
0
    pattern_list = [
            "a(b(c(c(cd)*d)*d)*e(fg)?)?"
    ]
elif "5" in sys.argv:
    pattern_list = [
        "0/(bc)|(d)/",
        "1/(b)|(de)/",
        "((bc)|(de))fgh",
    ]
elif "6" in sys.argv:
    pattern_list = [
        "0/(b+c+)|(d+)/",
        "1/(b+)|(d+e+)/",
        "((b+c+)|(d+e+))fgh",
    ]
elif "7" in sys.argv:
    pattern_list = [
        "0/(bc)|(d)/",
        "1/(b)|(de)/",
        "((bc)|(de))f+gh",
    ]
else:
    assert False


sm = help.prepare(pattern_list)

# For DEBUG purposes: specify 'DRAW' on command line
help.if_DRAW_in_sys_argv(sm)
help.test(sm, PrintPRM_F=True)
import quex.input.regular_expression.engine  as regex
import quex.engine.state_machine.algorithm.acceptance_pruning as     acceptance_pruning
import quex.engine.analyzer.engine_supply_factory as     engine
from   quex.blackboard                            import E_InputActions
import help

if "--hwut-info" in sys.argv:
    print "Track Analyzis: Backwards - For Pre-Context;"
    print "CHOICES: 0, 1;"
    sys.exit()

if "0" in sys.argv:
    pattern_list = [
        'x/a/',        
        'y/a/',     
    ]
elif "1" in sys.argv:
    pattern_list = [
        'x+/a/',        
        'yx+/a/',     
    ]
else:
    assert False

sm = help.prepare(pattern_list, GetPreContextSM_F=True)

# For DEBUG purposes: specify 'DRAW' on command line
help.if_DRAW_in_sys_argv(sm)
help.test(sm, EngineType=engine.BACKWARD_PRE_CONTEXT)