SwiftStudies / OysterKit

OysterKit is a framework that provides a native Swift scanning, lexical analysis, and parsing capabilities. In addition it provides a language that can be used to rapidly define the rules used by OysterKit called STLR
BSD 2-Clause "Simplified" License
177 stars 23 forks source link

Bork tutorial example always fails with obscure error #47

Closed MaxDesiatov closed 6 years ago

MaxDesiatov commented 6 years ago

Hi, thanks for the great library!

When I go through the tutorial, I copy the example grammar exactly as given:

//
// A grammar for the Bork text-adventure
//

// Vocabulary
//
@pin verb        = "INVENTORY" | "GO" | "PICKUP" | "DROP" | "ATTACK"
@pin noun        = "NORTH" | "SOUTH" | "KITTEN" | "SNAKE" | "CLUB" | "SWORD"
@pin adjective   = "FLUFFY" | "ANGRY" | "DEAD"
@pin preposition = "WITH" | "USING"

// Commands
//
subject     = (adjective .whitespaces)? noun
command     = verb (.whitespaces subject (.whitespaces preposition .whitespaces subject)? )?

to a file Bork.stlr

After I test this grammar with swift run stlrc -g Bork.stlr I always get this error with any of the tutorial test strings:

Parsing failed: 
constructionFailed([])

The error doesn't give any info on what exactly failed. OysterKit code is from master branch.

MaxDesiatov commented 6 years ago

In fact, any grammar loaded through command-line gives the same error, e.g.:

% swift run stlrc -g Resources/STLR.stlr 
stlr interactive mode. Send a blank line to terminate. Parsing STLR
// test
Parsing failed: 
constructionFailed([])
SwiftStudies commented 6 years ago

Thanks for this. I will take a look, one other thing I need to do following the recent refactoring is get correct error reporting back in as well as some are getting hidden