elea9003-emu/caratteri.py

99 lines
2.1 KiB
Python
Raw Blame 히스토리

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# coding=utf8
from pprint import pprint
caratteri = [
('0', 'CAR_ZERO'),
('1', 'CAR_UNO'),
('~', 'CAR_ONDA'),
('2', 'CAR_DUE'),
('4', 'CAR_QUATTRO'),
('+', 'CAR_PIU'),
('#', 'CAR_DIESIS'),
('3', 'CAR_TRE'),
('5', 'CAR_CINQUE'),
('6', 'CAR_SEI'),
('/', 'CAR_BARRA'),
('-', 'CAR_MENO'),
('7', 'CAR_SETTE'),
('9', 'CAR_NOVE'),
('÷', 'CAR_DIVISO'),
('8', 'CAR_OTTO'),
('Φ', 'CAR_PHI'),
('A', 'CAR_A'),
('δ', 'CAR_DELTA'),
('B', 'CAR_B'),
('D', 'CAR_D'),
('=', 'CAR_UGUALE'),
('α', 'CAR_ALFA'),
('C', 'CAR_C'),
('E', 'CAR_E'),
('F', 'CAR_F'),
('%', 'CAR_PERCENTO'),
(',', 'CAR_VIRGOLA'),
('G', 'CAR_G'),
('I', 'CAR_I'),
('γ', 'CAR_GAMMA'),
('H', 'CAR_H'),
('.', 'CAR_PUNTO'),
('S', 'CAR_S'),
('θ', 'CAR_TETA'),
('T', 'CAR_T'),
('V', 'CAR_V'),
('!', 'CAR_ESCLAMATIVO'),
(')', 'CAR_CHIUSA_PARENTESI'),
('U', 'CAR_U'),
('W', 'CAR_W'),
('X', 'CAR_X'),
('?', 'CAR_INTERROGATIVO'),
('&', 'CAR_E_COMMERCIALE'),
('Y', 'CAR_Y'),
("'", 'CAR_APOSTROFO'),
('', 'CAR_MOLTIPLICATO_PER'),
('Z', 'CAR_Z'),
('ε', 'CAR_EPSILON'),
('J', 'CAR_J'),
('*', 'CAR_ASTERISCO'),
('K', 'CAR_K'),
('M', 'CAR_M'),
('(', 'CAR_APERTA_PARENTESI'),
('β', 'CAR_BETA'),
('L', 'CAR_L'),
('N', 'CAR_N'),
('O', 'CAR_O'),
('$', 'CAR_DOLLARO'),
('P', 'CAR_P'),
('η', 'CAR_ETA'),
('R', 'CAR_R'),
('π', 'CAR_PI'),
('Q', 'CAR_Q'),
]
caratteri_python_a_elea = {
caratteri[i][0].decode('utf-8'): caratteri[i] + (i,)
for i in xrange(len(caratteri)) }
def stringa_python_a_elea(string):
s = []
for i in string.decode('utf-8'):
if i in (' ', '\n'):
continue
xx = caratteri_python_a_elea.get(i, None)
if xx is None:
print "NO", repr(i)
continue
s.append(xx)
return s
hello_world = """
11 017 # Φ
0X XXX # 0
HELLO.WORLD
"""
pprint(stringa_python_a_elea(hello_world))