Coder Social home page Coder Social logo

rssc's People

Contributors

zyxw59 avatar

Watchers

 avatar  avatar

rssc's Issues

Better syntax for complex environments

The current syntax (&(a_b |(c_ _d)) is unintuitive and a bit hard to read. It would be nice to have an infix syntax. The main challenge is grouping — ( is already a valid character to start a regex, so there's some parsing ambiguity if it's also used to group environments.

More helpful errors in tokenization and parsing

Currently, the tokenization and parsing functions return errors saying what went wrong if something fails to tokenize or parse properly, but don't say where it went wrong (e.g. line or character numbers).

Build a custom CFG parser to parse rule files

Currently, the plan is to use LALRPOP to generate a parser for the rule file grammar. However, I don't know how easy it is to use LALRPOP with the custom tokenizer in the token module. Additionally, LALRPOP itself takes a long time to compile and has a lot of requirements, so it would be nice to cut it out.

Bespoke engine for matching sound change rules.

I think using regex (even the current custom implementation) is not actually a great fit for matching sound change rules. A bespoke engine that tracks exactly the state required to confirm or reject a match would be easier to work with and optimize.

The engine should work similarly to the regex engine, stepping thru the input string one token at a time while maintaining the state of the match. It should also handle collapsing identical states to reduce blowup.

The state should include:

  • Current location in the search (like the regex instruction pointer)
  • Current value of any indexed category matches ({0:C} and the like)
  • Start and end points of the part of the match to be replaced.

For a rule with a single positive environment, it should be included in the search. Negative environments probably need to be handled afterward, since a token-by-token approach isn't great at looking for what shouldn't be there. If there are multiple positive environments joined by an 'and', they might also have to be handled afterward, unless we can find a way for the engine to fail a search based on the results of another search.

Implement replacements

The replacement function should take a Vec<rule::re::Engine>, a CategoryMap, and a TokenString, and produce a new TokenString by applying all applicable Engines.

Will need to prune the Engines by only selecting the first applicable Engine for each position in the input, including dealing with overlapping matches.

Add `SyllableBoundary` alternative to `Regex` enum

Syllable boundaries would be represented by some character that could be inserted by rules into words, and also match at word boundaries. I don't think attempting to dynamically syllabify input words is feasible.

Define syntax for token declarations

There needs to be some syntax to declare user-defined tokens (e.g. a user might want to treat sh as a single token if it represents a single phoneme in their language).

I'm not sure how I want to do this. Token declarations have to be parsed before the rule file is tokenized. The options I've thought of are:

  • A section at the top of the rule file. This would need some delimiter to separate it from the rest of the document, perhaps a blank line?
  • Inclusion of an external file (e.g. tokens path/to/file)

These two options are not mutually exclusive though, and it would be nice to allow both forms.

Define grammar for rule files

Currently, src/rssc.lalrpop just defines the syntax for regular expressions, but not syntax for:

  • Rules
  • Category definitions
  • Token declarations
  • Any other constructs that might be added

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.