pegkit

Case insensitive token matching

余生颓废 提交于 2019-12-14 01:33:23
问题 Is it possible to set the grammar to match case insensitively. so for example a rule: checkName = 'CHECK' Word; would match check name as well as CHECK name 回答1: Creator of PEGKit here. The only way to do this currently is to use a Semantic Predicate in a round-about sort of way: checkName = { MATCHES_IGNORE_CASE(LS(1), @"check") }? Word Word; Some explanations: Semantic Predicates are a feature lifted directly from ANTLR. The Semantic Predicate part is the { ... }? . These can be placed

Custom objects in ParseKit Actions

廉价感情. 提交于 2019-12-11 11:33:38
问题 I am very intrigued by the ability to add actions to ParseKit grammars. There is surprisingly little documentation on what is available in those actions. Say I have two rules like: databaseName = Word; createTableStmt ='CREATE' ('TEMP'| 'TEMPORARY')? 'TABLE' 'IF NOT EXISTS'? databaseName; This obviously isn't a whole grammar but will serve as an example. When parsing i'd like to "return" a CreateTableStmt object that has certain properties. If I understand the tool correctly i'd add an action