{"action":"opened","issue":{"url":"https://api.github.com/repos/svstuff/systemverilog/issues/11","labels_url":"https://api.github.com/repos/svstuff/systemverilog/issues/11/labels{/name}","comments_url":"https://api.github.com/repos/svstuff/systemverilog/issues/11/comments","events_url":"https://api.github.com/repos/svstuff/systemverilog/issues/11/events","html_url":"https://github.com/svstuff/systemverilog/issues/11","id":107389651,"number":11,"title":"token concatenation is buggy","user":{"login":"eriklovlie","id":152405,"avatar_url":"https://avatars.githubusercontent.com/u/152405?v=3","gravatar_id":"","url":"https://api.github.com/users/eriklovlie","html_url":"https://github.com/eriklovlie","followers_url":"https://api.github.com/users/eriklovlie/followers","following_url":"https://api.github.com/users/eriklovlie/following{/other_user}","gists_url":"https://api.github.com/users/eriklovlie/gists{/gist_id}","starred_url":"https://api.github.com/users/eriklovlie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eriklovlie/subscriptions","organizations_url":"https://api.github.com/users/eriklovlie/orgs","repos_url":"https://api.github.com/users/eriklovlie/repos","events_url":"https://api.github.com/users/eriklovlie/events{/privacy}","received_events_url":"https://api.github.com/users/eriklovlie/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-09-20T11:53:19Z","updated_at":"2015-09-20T11:53:19Z","closed_at":null,"body":"The following test fails:\r\n\r\n```\r\n`define SIZE 42\r\n`define D(a) `SIZE``a\r\n`D('d0)\r\n```\r\n\r\nIt fails during macro expansion because `SIZE'd0` is used as the full macro target, and not just `SIZE`. The reason is the logic that deals with the following (i.e. concatenation which leads to a recursive macro call):\r\n\r\n```\r\n`define FOO(TYPE,ARG,FLAG) `M_UVM_``TYPE(ARG,FLAG)\r\n`define M_UVM_ARRAY(arg1, arg2) yo\r\n`FOO(ARRAY, byte_valid, UVM_NOPACK)\r\n```\r\n\r\nSo the former currently fails and the latter works. Obviously `SIZE'd0` cannot be a legal macro name, but that's irrelevant here. When the macro text in `D` is scanned we can't know whether it will expand to a new macro call `SIZE_rest_of_macro_name` or `42'd0`.\r\n\r\nThe LRM doesn't appear to be very clear on the rules here and there is not much available example code except for the latter example above (from the uvm reference implementation)."}}