11.1.12.6.2. Parser¶
This module implements a parser for Spice expressions.
-
class
PySpice.Spice.Expression.Parser.
Parser
[source]¶ Bases:
object
-
p_binary_operation
(p)[source]¶ expression : expression POWER expression | expression MULTIPLY expression | expression DIVIDE expression | expression MODULO expression | expression INT_DIVIDE expression | expression PLUS expression | expression MINUS expression | expression EQUAL expression | expression NOT_EQUAL expression | expression LESS expression | expression GREATER expression | expression LESS_EQUAL expression | expression GREATER_EQUAL expression | expression AND expression | expression OR expression
-
precedence
= (('left', 'IF'), ('left', 'OR'), ('left', 'AND'), ('left', 'GREATER', 'LESS', 'GREATER_EQUAL', 'LESS_EQUAL', 'NOT_EQUAL', 'EQUAL'), ('left', 'MINUS', 'PLUS'), ('left', 'INT_DIVIDE', 'MODULO', 'DIVIDE', 'MULTIPLY'), ('left', 'POWER'), ('left', 'NOT'))¶
-
reserved
= {}¶
-
start
= 'statement'¶
-
t_AND
= '&&'¶
-
t_COLON
= ':'¶
-
t_DIVIDE
= '/'¶
-
t_EQUAL
= '=='¶
-
t_GREATER
= '>'¶
-
t_GREATER_EQUAL
= '>='¶
-
t_IF
= '\\?'¶
-
t_INT_DIVIDE
= '\\/'¶
-
t_LEFT_PARENTHESIS
= '\\('¶
-
t_LESS
= '<'¶
-
t_LESS_EQUAL
= '<='¶
-
t_MINUS
= '-'¶
-
t_MODULO
= '%'¶
-
t_MULTIPLY
= '\\*'¶
-
t_NOT
= '!'¶
-
t_NOT_EQUAL
= '!='¶
-
t_OR
= '\\|\\|'¶
-
t_PLUS
= '\\+'¶
-
t_POWER
= '\\*\\*'¶
-
t_RIGHT_PARENTHESIS
= '\\)'¶
-
t_SEMICOLON
= ';'¶
-
t_SET
= '='¶
-
t_ignore
= ' \t'¶
-
t_ignore_COMMENT
= '\\#[^\\n]*'¶
-
tokens
= ['NAME', 'NUMBER', 'SEMICOLON', 'LEFT_PARENTHESIS', 'RIGHT_PARENTHESIS', 'SET', 'NOT', 'POWER', 'MULTIPLY', 'DIVIDE', 'INT_DIVIDE', 'MODULO', 'PLUS', 'MINUS', 'EQUAL', 'NOT_EQUAL', 'LESS', 'GREATER', 'LESS_EQUAL', 'GREATER_EQUAL', 'AND', 'OR', 'IF', 'COLON']¶
-