{"action":"created","issue":{"url":"https://api.github.com/repos/phorward/phorward/issues/7","repository_url":"https://api.github.com/repos/phorward/phorward","labels_url":"https://api.github.com/repos/phorward/phorward/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/phorward/phorward/issues/7/comments","events_url":"https://api.github.com/repos/phorward/phorward/issues/7/events","html_url":"https://github.com/phorward/phorward/issues/7","id":317795785,"number":7,"title":"Push parsing","user":{"login":"phorward","id":16870072,"avatar_url":"https://avatars1.githubusercontent.com/u/16870072?v=4","gravatar_id":"","url":"https://api.github.com/users/phorward","html_url":"https://github.com/phorward","followers_url":"https://api.github.com/users/phorward/followers","following_url":"https://api.github.com/users/phorward/following{/other_user}","gists_url":"https://api.github.com/users/phorward/gists{/gist_id}","starred_url":"https://api.github.com/users/phorward/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phorward/subscriptions","organizations_url":"https://api.github.com/users/phorward/orgs","repos_url":"https://api.github.com/users/phorward/repos","events_url":"https://api.github.com/users/phorward/events{/privacy}","received_events_url":"https://api.github.com/users/phorward/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-04-25T21:12:26Z","updated_at":"2018-05-16T10:09:29Z","closed_at":null,"author_association":"OWNER","body":"Originally from issue #6, by @FreeBASIC-programmer\r\n---\r\nI looked at the way parsing (lalr1) is performed in libphorward. And I have something of a feature request. \r\n\r\nWould it be possible to have an external scanner call the parser ('push parsing')? The interface to the libphorward generated parser would consist of a single function that should get called by the scanner for every token that the parser should parse.\r\n\r\nHaving an external scanner call the parser could make it a lot easier to parse input from anything besides a static string (eg stream-ish style parsing). Also the parser could be part of a 'larger' parser that would decide what subparser would get fed a certain token. It would be great to use x subparsers to parse some 'exotic' language (for example C++ :)). \r\n\r\n\r\nParsing one token using push parsing could look something like this.\r\n```\r\ntoken = get_token(scanner)\r\nparse(parse_state,token)\r\nif (parse_state->error_) then\r\n  ''error message\r\nend if\r\n```\r\nI am assuming the parser needs a place (parse_state) to keep track of parsing state. The numbering scheme for tokens could be straightforward: first token to appear in the grammar would get assigned a possible user defined number (or 1 or something else). Subsequent tokens appearing in the grammar would get numbered upward (or downward) from that first , possible user defined number.\r\n\r\nparse_state could be used to store other, user-defined  information (pppar could be extended to contain some user defined data in the shape of an any ptr or a plist or...?)."},"comment":{"url":"https://api.github.com/repos/phorward/phorward/issues/comments/389467109","html_url":"https://github.com/phorward/phorward/issues/7#issuecomment-389467109","issue_url":"https://api.github.com/repos/phorward/phorward/issues/7","id":389467109,"user":{"login":"phorward","id":16870072,"avatar_url":"https://avatars1.githubusercontent.com/u/16870072?v=4","gravatar_id":"","url":"https://api.github.com/users/phorward","html_url":"https://github.com/phorward","followers_url":"https://api.github.com/users/phorward/followers","following_url":"https://api.github.com/users/phorward/following{/other_user}","gists_url":"https://api.github.com/users/phorward/gists{/gist_id}","starred_url":"https://api.github.com/users/phorward/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phorward/subscriptions","organizations_url":"https://api.github.com/users/phorward/orgs","repos_url":"https://api.github.com/users/phorward/repos","events_url":"https://api.github.com/users/phorward/events{/privacy}","received_events_url":"https://api.github.com/users/phorward/received_events","type":"User","site_admin":false},"created_at":"2018-05-16T10:09:29Z","updated_at":"2018-05-16T10:09:29Z","author_association":"OWNER","body":"Hey @FreeBASIC-programmer,\r\nI've created a bunch of new functions and made push-parsing the general parsing method that is used by libphorward in branch push-parsing. See [here](https://github.com/phorward/phorward/blob/push-parsing/src/parse/parse.c#L181) for the new functions.\r\n\r\n- `pp_par_next()` does push parsing like `pp_par_pushparse()` before\r\n- `pp_par_next_by_name()` allows to specifiy the identifiying name the way as you described. Just call it with the names you used for your Terminals, like `INT`, `PLUS`, `ADD...\r\n- `pp_par_next_by_idx()` can be used with plex to specify the terminal by its index.\r\n- `pp_par_parse()` is called the same way as before, but auto-constructs a lexer and runs this on a string\r\n- `pp_par_autolex()` returns a plex object with the auto-constructed lexer now, so it's not part of the pppar object anymore.\r\n\r\nI hope you like the new changes. It makes the full thing very flexible and the prevous calls work like before with only minor changes. Stay tuned, more will follow soon.\r\n\r\n"}}
{"actor":{"display_login":"phorward"}}