Value of properties can be expression.
authorStaf Verhaegen <staf@stafverhaegen.be>
Wed, 3 Jan 2018 20:36:22 +0000 (20:36 +0000)
committerStaf Verhaegen <staf@stafverhaegen.be>
Wed, 3 Jan 2018 21:37:17 +0000 (21:37 +0000)
Example found in the 2007.03 Liberty Reference Manual that was also found
in the wild:

    input_voltage(CMOS) {
        vil : 0.3 * VDD ;
        vih : 0.7 * VDD ;
        vimin : -0.5 ;
        vimax : VDD + 0.5 ;
    }

Current implementation just parses the expression but no interpretation is done.

passes/techmap/libparse.cc

index d5254c029b59693250e5319cf125069c4f8e0f5e..d3b1ff02f5db0464e0a25f8bd6f2bd02c92647da 100644 (file)
@@ -100,8 +100,15 @@ int LibertyParser::lexer(std::string &str)
                                break;
                }
                f.unget();
-               // fprintf(stderr, "LEX: identifier >>%s<<\n", str.c_str());
-               return 'v';
+               if (str == "+" || str == "-") {
+                       /* Single operator is not an identifier */
+                       // fprintf(stderr, "LEX: char >>%s<<\n", str.c_str());
+                       return str[0];
+               }
+               else {
+                       // fprintf(stderr, "LEX: identifier >>%s<<\n", str.c_str());
+                       return 'v';
+               }
        }
 
        if (c == '"') {
@@ -191,6 +198,19 @@ LibertyAst *LibertyParser::parse()
                        tok = lexer(ast->value);
                        if (tok != 'v')
                                error();
+                       tok = lexer(str);
+                       while (tok == '+' || tok == '-' || tok == '*' || tok == '/') {
+                               ast->value += tok;
+                               tok = lexer(str);
+                               if (tok != 'v')
+                                       error();
+                               ast->value += str;
+                               tok = lexer(str);
+                       }
+                       if (tok == ';')
+                               break;
+                       else
+                               error();
                        continue;
                }