Giter VIP home page Giter VIP logo

rattler's People

Contributors

jarhart avatar wconrad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rattler's Issues

Possible problem when parsing utf content

Take this grammar:

require 'rattler'
parser DynagramParser < Rattler::Runtime::ExtendedPackratParser
%whitespace SPACE+
script   <- string EOF
string   <-  @('"' . '"')

Feed it the file

"x"

and you get:

[~/.p/d/ruby] ruby lib/dynagram/bug.rb samples/boxes.dyna
"\"x\""

(which is correct).

Change the input to:

 "∆"

and when you run it, you get:

[~/.p/d/ruby] ruby lib/dynagram/bug.rb samples/boxes.dyna
"\"∆\"\n"

It looks as if somewhere the parser is using the byte length of the match, not the character length. I spent an hour or so poking around, but couldn't see where.

Thanks for a great tool.

@pragdave

Whitespace not handling comments correctly at beginning of parsed source

I'm trying to add comments to my language. So I added a %whitespace directive, similar to the JSON and INI examples. But when my source code starts with a comment, the parser always reports a syntax error, expecting the source code to end with a comment — even if it does end with a comment.

My RTLR file looks something like this:

%start program
%whitespace ( SPACE+ / comment )*
program             <- expression+ EOF          <AST::Program.new>
expression          <- literal_integer
literal_integer     <- @DIGIT+                  <AST::LiteralInteger.new>
comment             <- ~([#] [^\n]*)

If I try to parse this:

# Comment
123

then I get an error like this:

bundler/gems/rattler-5b3806afad53/lib/rattler/runtime/parser.rb:179:in `raise_error': parse error at line 3, column 1: (Rattler::Runtime::SyntaxError)
 comment expected

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.