summaryrefslogtreecommitdiff
path: root/tests/test_hdl.py
Commit message (Collapse)AuthorAgeFilesLines
* Replace tests that assert on token output with auto-updatable samples (#1649)Oleh Prypin2021-01-181-686/+0
|
* Run pyupgrade across codebase to modernize syntax and patterns (#1622)Jon Dufresne2021-01-171-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | pyupgrade is a tool to automatically upgrade syntax for newer versions of the Python language. The project has been Python 3 only since 35544e2fc6eed0ce4a27ec7285aac71ff0ddc473, allowing for several cleanups: - Remove unnecessary "-*- coding: utf-8 -*-" cookie. Python 3 reads all source files as utf-8 by default. - Replace IOError/EnvironmentError with OSError. Python 3 unified these exceptions. The old names are aliases only. - Use the Python 3 shorter super() syntax. - Remove "utf8" argument form encode/decode. In Python 3, this value is the default. - Remove "r" from open() calls. In Python 3, this value is the default. - Remove u prefix from Unicode strings. In Python 3, all strings are Unicode. - Replace io.open() with builtin open(). In Python 3, these functions are functionally equivalent. Co-authored-by: Matthäus G. Chajdas <Anteru@users.noreply.github.com>
* Bump copyright year.Matthäus G. Chajdas2021-01-031-1/+1
|
* Update copyright year (fixes #1514.)Matthäus G. Chajdas2020-08-221-1/+1
|
* Improve SystemVerilog class/endclass lexer rules (#1471)Chris Drake2020-06-061-0/+93
| | | | | | | | | | | The class looks like: class class_identifier [#(param_decls)] [extends class_identifier #(params)]; ... endclass [: class_identifier] Using the same Java convention of Keyword.Declaration and Name.Class. Add a test_systemverilog_classes unit test to test_hdl.
* SystemVerilog keyword/operator improvements (#1464)Chris Drake2020-06-011-0/+249
| | | | | | | | | | | | | | | | | | | | | | | | | * Move SystemVerilog type keywords Put them next to the generic keywords list. * Change a couple SystemVerilog keywords to operators The 'inside' and 'dist' keywords are described as operators in the SystemVerilog standard, below unary increment/decrement, and above concatenation in precedence. See 1800-2017 tables 11-1 and 11-2 for a list of operators. This matches the description of pygemnts Operator.Word token: "For any operator that is a word (e.g. not)." * Add a SystemVerilog operators unit test Copy/paste the contents of 1800-2017 Table 11-2, and see what the SV lexer chops it up into. I made lots of comments for potential improvements. Some operators, such as '[' and '.' are being labeled as punctuation. Also, multi-character operators such as '<<<=' are being split up into multiple, single-character tokens, eg '<' '<' '<' '='.
* Refactor SystemVerilog unit testsChris Drake2020-05-261-250/+252
| | | | | | | | | | | | Most of the contents of these two unit tests are static. Move things around so the entire test fits on a single page, for better readability/maintainability. Name the code part <TEST_NAME>_TEXT, and the tokens part <TEST_NAME>_TOKENS. Choosing "text" b/c it's the parameter name to the lexer.get_tokens(text) method.
* Update SystemVerilog literal constants (#1460)Chris Drake2020-05-261-8/+144
| | | | | | | | | | | | | | | | The original implementation was missing some of the more arcane features such as underbars, the character 's' for signed/unsigned, support for spaces before/after the base specifier, capital letter base specifiers (ie 'B 'D 'H), and the 4-state 'xXzZ?' characters. For regular integers, the 'l' and 'L' suffixes are not valid. That is, unlike C, in Verilog '42L' is not a valid int literal. Create a new test that exercises most of the interesting kinds of SystemVerilog numbers. This fixes a couple minor issues with what type of number the lexer returns. For example, Numbers like '42' used to return Integer.Hex, but now return Integer.Decimal.
* Fix a few SystemVerilog type keywords (#1454)Chris Drake2020-05-221-7/+7
| | | | | | | | | | | | | | | | | * Fix a few SystemVerilog type keywords First, add a few missing type keywords: chandle, const, event, string, time, type, var, void These are most of the 'variable' types listed in 1800-2017 6.8 "Variable declarations". Currently, this 'Keyword.Type' is not taking effect because the lexer is finding these keywords in the 'Keyword' list above. Remove the double declaration so we get the more specific token type. * Change signed/unsigned to Keyword.Type This is what the C/C++ lexer does, so it seems legit.
* Add a basic SystemVerilog unit test (#1452)Chris Drake2020-05-181-0/+207
* Add a basic SystemVerilog unit test * Fix docstring Calling it a "complete fragment" didn't make much sense.