def varSmToken(code,list_pt):
    nameFormat=r'^[\w\.]+'
    name=re.match(nameFormat,code).group()
    if name=='':
        raise Exception('Error! Invalid name!')
    code=re.sub(nameFormat,'',code)
    if code=='' or code[0]!='=':
        raise Exception('Error! Every variable must be assigned by some values.')
    code=code[1:]
    [code,content]=conSmToken(code)
    var=NetP(name)
    list_pt.append(var)
    var.m_text=content
    return [code,var]
def SmileiToken(code,title,list_pt=None):
    if list_pt==None:
        list_pt=[]
    point=NetP('smilei')
    point.m_text=title
    list_pt.append(point)
    code=re.sub(r'[ \t]','',code)
    code=re.sub(r'#.*\n','',code)
    while code!='':
        code=re.sub(r'^\n*','',code)
        if code=='':
            break
        else:
            [code,line_pt]=lineSmToken(code,list_pt)
            con=NetP('in')
            list_pt.append(con)
            con.con(point,line_pt)
    return [code,list_pt]
def lineSmToken(code,list_pt):
    nameFormat=r'^[\w\.]+'
    name=re.match(nameFormat,code).group()
    if name=='':
        raise Exception('Error! Invalid name of function or variable!')
    code=re.sub(nameFormat,'',code)
    line_pt=NetP(name)
    list_pt.append(line_pt)
    if code!='' and code[0]=='=':
        code=code[1:]
        [code,content]=conSmToken(code)
        if content=='':
            raise Exception('Error! Invalid assignment value!')
        line_pt.m_text=content
    elif code!='' and code[0]=='(':
        code=code[1:]
        code=re.sub(r'^\n*','',code)
        [code,var]=varSmToken(code,list_pt)
        con=NetP('in')
        list_pt.append(con)
        con.con(line_pt,var)
        while True:
            if code!='' and code[0]==',':
                code=code[1:]
            else:
                break
            code=re.sub(r'^\n*','',code)
            if code!='' and code[0]==')':
                break
            [code,var]=varSmToken(code,list_pt)
            con=NetP('in')
            list_pt.append(con)
            con.con(line_pt,var)
        code=re.sub(r'^\n*','',code)
        if code=='' or code[0]!=')':
            raise Exception('Error! Unbalanced bracket!')
        code=code[1:]
    return [code,line_pt]