robrix / Hammer

Parsing and pattern matching in Objective-C
BSD 3-Clause "New" or "Revised" License
75 stars 1 forks source link

Reducible lexers #92

Open robrix opened 10 years ago

robrix commented 10 years ago

Should be able to pipeline lexing and parsing:

[parser parse:[lexer parse:input]]

From the side, that looks like:

[[input red_reduce:lexer usingBlock:^(id into, id each) {
    return produce([into derivative:each]);
}] red_reduce:parser usingBlock:^(id into, id each) {
    return produce([into derivative:each]);
}];

where produce() is some hand-waving which does the incremental magic.