Skip to content

Commit

Permalink
Merge pull request #19 from skit-ai/exercise-parsing
Browse files Browse the repository at this point in the history
Exercise parsing
  • Loading branch information
lepisma authored Jan 13, 2024
2 parents 5b31140 + 813353a commit 57407e5
Show file tree
Hide file tree
Showing 3 changed files with 368 additions and 291 deletions.
36 changes: 36 additions & 0 deletions docs/misc/01-parsing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Ink Language Parser

Develop a simple parser in your preferred programming language that can read and
interpret basic constructs of the [Ink narrative
language](https://www.inklestudios.com/ink/) which is n English like language to
write interactive fictions.

The idea of this exercise is to learn writing parsers and understand connected
challenges. The recommended way to go about this exercise is to try writing the
parser both from scratch (starting from pure RegEx) and using common parsing
framework or approach.

Here are a few expectations from your program:

+ Your parser library (or cli tool) should expose two functions, `parse` for
taking Ink string and returning a structured data, and `format` for taking
structured Ink data and returning formatted Ink string.
+ It should be able to recognize and handle basic Ink syntax, such as:
+ Knots and Diverts (e.g., `== knot_name -> divert_target`)
+ Choices (e.g., `* [Choice 1] Text of choice 1`)
+ Conditional logic (e.g., `{ condition: True branch | False branch }`)
+ Implement informative error handling for unrecognized syntax.

!!! warning "Testing"

There are no tests for this exercise as of now. You should write your own example Ink
samples and check something like `format(parse(original_text)) == original_text`

!!! tip

Since you are writing the parser for Ink, you can also make a CLI tool that executes
the story. You can take design inspiration from [Inky](https://github.com/inkle/inky).

## Resources
1. [Ink Homepage](https://github.com/inkle/ink)
2. [Reference implementations in C#](https://github.com/inkle/ink/tree/master/compiler/InkParser)
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ nav:
- deploying/index.md
- Part 3:
- misc/index.md
- misc/01-parsing.md
- Part 4:
- misc/np.md

Expand Down
Loading

0 comments on commit 57407e5

Please sign in to comment.