lukehutch / pikaparser

The Pika Parser reference implementation
MIT License
141 stars 12 forks source link

Minor tweaks #11

Closed psfblair closed 4 years ago

psfblair commented 4 years ago

Small changes that came up while I was working on the Kotlin version: 1) Add unicode escape instead of non-printing character; 2) Use computeIfAbsent for initializing map entries. (This could probably be done in other places as well, but it was near where I was fixing the non-printing character so I put it in.

lukehutch commented 4 years ago

Thanks.

By the way, speaking of computeIfAbsent, the MemoTable.memoTable field used to be a Map<Clause, NavigableMap<Integer, Match>>, which mapped from memoKey.clause to memoKey.startPos to match. I used computeIfAbsent to create a new ConcurrentSkipList<Integer, Match> for the inner maps if they didn't exist. With this data structure, it's very fast to find all neighboring matches of a given rule of interest. This might possibly be useful to you with your whitespace-sensitive parser.

psfblair commented 4 years ago

Thanks!