o
    gi 2                     @   s6   d Z ddlZddlmZ ddlmZ G dd dZdS )a  
In computer science, lexical analysis, lexing or tokenization is the process of converting a sequence of characters
(such as in a computer program or web page) into a sequence of tokens (strings with an assigned and thus identified meaning).
A program that performs lexical analysis may be termed a lexer, tokenizer, or scanner,
although scanner is also a term for the first stage of a lexer.
A lexer is generally combined with a parser, which together analyze the syntax of programming languages, web pages,
and so forth.
    N)Token)	TokenTypec                   @   s,   e Zd ZdZededeje fddZ	dS )	Tokenizera(  
    In computer science, lexical analysis, lexing or tokenization is the process of converting a sequence of characters
    (such as in a computer program or web page) into a sequence of tokens (strings with an assigned and thus identified meaning).
    A program that performs lexical analysis may be termed a lexer, tokenizer, or scanner,
    although scanner is also a term for the first stage of a lexer.
    A lexer is generally combined with a parser, which together analyze the syntax of programming languages, web pages,
    and so forth.
    infix_expressionreturnc              	   C   s  g }d}|t | k r| | dkr|d7 }q| | dkr+|tdtjd |d7 }q| | dkr@|tdtjd |d7 }q| | dkrX|tdtjdd	dd
 |d7 }q| | dkrp|tdtjdd	dd
 |d7 }q| | dkr|tdtjdd	dd
 |d7 }q| | dkr|tdtjdd	dd
 |d7 }q| | dkr|tdtjdd	dd
 |d7 }q| |d dr|tdtjdd	dd
 |d7 }q| |d dr|tdtjdd	dd
 |d7 }q| |d dr
|tdtjdd	dd
 |d7 }q| | dkr#|tdtjdd	dd
 |d7 }q| | dkr<|tdtjdd	dd
 |d7 }q| | dkrU|tdtjdd	dd
 |d7 }q| | dkrn|tdtjdddd
 |d7 }q| | dkr|tdtjdddd
 |tdtjd |d7 }q| | dkr|tdtjdddd
 |td tjd |d7 }q| |d d!r|td!tj	dddd
 |d7 }q| |d d"r|td"tj	dd# |d7 }q| |d d$r|td$tj	dd# |d7 }q| |d d%r|td%tj	dd# |d7 }q| |d d&r8|td&tj	dd# |d7 }q| |d d'rR|td'tj	dd# |d7 }q| |d d(rl|td(tj	dd# |d7 }q| |d d)r|td)tj	dd# |d7 }q| | d*v r|}|t | k r| | d*v r|d7 }|t | k r| | d*v s|t| || tjd |}qt |dkr|d+ 
 tjkrt|d+  |d+  |d+  |d+  | |  |d+ 
 d,|d+< |d7 }q|t| | tjd |d7 }|t | k st|D ]G\}}|| 
 tjkr#q||  dkr.q|dksK||d  
 tjksK||d  
 tjkrYtd	dd-dtjd,||< qq|S ).z
        This function converts an infix expression to a typing.List[Token]
        :param infix_expression:    the infix expression (as str) to tokenize
        :return:                    the typing.List[Token] representing the tokenized output
        r       ()texttype)   ±   T)r
   r   
precedenceis_left_associativenumber_of_arguments+-*   /Nz!=u   ≠z>=u   ≥z<=u   ≤><=^   F   ²2   ³3sqrtsin)r
   r   r   costancotseccscabsz0123456789.)r   r   r   r
   r      )lenappendr   r   LEFT_PARENTHESISRIGHT_PARENTHESISOPERATOR
startswithNUMBERFUNCTIONget_typeVARIABLEget_is_left_associativeget_number_of_argumentsget_precedenceget_text	enumerate)r   outputijt r=   ]/home/ubuntu/.local/lib/python3.10/site-packages/borb/pdf/canvas/layout/equation/tokenizer.pytokenize'   s2  															"




    7

zTokenizer.tokenizeN)
__name__
__module____qualname____doc__staticmethodstrtypingListr   r?   r=   r=   r=   r>   r      s    r   )rC   rF   %borb.pdf.canvas.layout.equation.tokenr   r   r   r=   r=   r=   r>   <module>   s
   