{"action":"closed","issue":{"url":"https://api.github.com/repos/antlr/antlr4/issues/963","labels_url":"https://api.github.com/repos/antlr/antlr4/issues/963/labels{/name}","comments_url":"https://api.github.com/repos/antlr/antlr4/issues/963/comments","events_url":"https://api.github.com/repos/antlr/antlr4/issues/963/events","html_url":"https://github.com/antlr/antlr4/issues/963","id":97706796,"number":963,"title":"function getText() doesn't work properly","user":{"login":"ksudol","id":13416529,"avatar_url":"https://avatars.githubusercontent.com/u/13416529?v=3","gravatar_id":"","url":"https://api.github.com/users/ksudol","html_url":"https://github.com/ksudol","followers_url":"https://api.github.com/users/ksudol/followers","following_url":"https://api.github.com/users/ksudol/following{/other_user}","gists_url":"https://api.github.com/users/ksudol/gists{/gist_id}","starred_url":"https://api.github.com/users/ksudol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ksudol/subscriptions","organizations_url":"https://api.github.com/users/ksudol/orgs","repos_url":"https://api.github.com/users/ksudol/repos","events_url":"https://api.github.com/users/ksudol/events{/privacy}","received_events_url":"https://api.github.com/users/ksudol/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-28T13:31:37Z","updated_at":"2015-07-28T15:23:21Z","closed_at":"2015-07-28T15:23:21Z","body":"Hello, I have the following grammar file for ANTLR4.5.1:\r\n```\r\ngrammar Test;\r\n\r\nstart : NAME+;\r\nNAME :  ('aaa'|'ab') {System.out.println(\"[\"+getText()+\"]\");}'X';\r\nWS : . -> skip;\r\n```\r\nand java file:\r\n```\r\nimport org.antlr.v4.runtime.*;\r\nimport org.antlr.v4.runtime.tree.*;\r\n\r\npublic class ParseTest {\r\n    public static void main(String[] args) throws Exception {\r\n        ANTLRInputStream stream = new ANTLRInputStream(\"aaaX abX aaaX\");\r\n        TestLexer lexer = new TestLexer(stream);\r\n        CommonTokenStream tokens = new CommonTokenStream(lexer);\r\n        TestParser parser = new TestParser(tokens);\r\n        \r\n        ParserRuleContext tree = parser.start();\r\n    }\r\n}\r\n```\r\nFunction getText() returns:\r\n[aaa] // ok\r\n[abX] // wrong, 'X' should be matched after calling the function getText()\r\n[aaa] // ok"}}