Git Product home page Git Product logo

Comments (17)

SwiftStudies avatar SwiftStudies commented on July 19, 2024 1

It won't like the - in whitespace-item and you've correctly defined it as whitespaceItem a little further down.

In multilineCommentTextItem what are you trying to do? The lookahead will only apply to the first terminal. Did you mean >>!( "/*" | "*/") (Lookahead and only proceed if the next two characters aren't /* or */)?

from oysterkit.

eimantas avatar eimantas commented on July 19, 2024 1

Did you mean >>!( "/" | "/") (Lookahead and only proceed if the next two characters aren't /* or */)?

This is exactly what I was trying to achieve! 👍

Sadly, still the same error. The grammar file now is:

grammar SwiftComments

whitespace = whitespaceItem whitespace?

lineBreak = .newLine

whitespaceItem = lineBreak | comment | multilineComment

comment = "//" commentText lineBreak
multilineComment = "/*" multilineCommentText "*/"

commentText = commentTextItem commentText?
commentTextItem = /[^\r\n]/

multilineCommentText = multitlineCommentTextItem multitlineCommentText?
multilineCommentTextItem = >>!( "/*" | "*/") (multilineComment | commentTextItem)

Another question: how would i go about negative lookahead for the .newLine? Would something like this work:

commentTextItem = >>!.newLine

(i.e. process everything up to the new line)

from oysterkit.

SwiftStudies avatar SwiftStudies commented on July 19, 2024 1

Do please keep letting me know about problems. I'm sorry the error reporting is so bad at the moment. I was literally sitting here making notes on what I wanted for the new architecture to make this better. I might do a quick push to the 0.6 branch to make it at least dump all the error messages out not just the top one.

from oysterkit.

eimantas avatar eimantas commented on July 19, 2024 1

I'm still getting the same error though .(

from oysterkit.

SwiftStudies avatar SwiftStudies commented on July 19, 2024 1
grammar SwiftComments

whitespace = whitespaceItem whitespace?

lineBreak = .newline

whitespaceItem = lineBreak | comment | multilineComment

comment = "//" commentText lineBreak
multilineComment = "/*" multilineCommentText "*/"

commentText = commentTextItem commentText?
commentTextItem = /[^\r\n]/

multilineCommentText = multitlineCommentTextItem multitlineCommentText?
multilineCommentTextItem = >>!("/*" | "*/") (multilineComment | commentTextItem)

from oysterkit.

SwiftStudies avatar SwiftStudies commented on July 19, 2024 1

I've just pushed to development/0.6 some changes that at least mean all the error messages that stop parsing get out to the message. The results are quite overwhelming at the moment but I wanted to at least get you something that would keep you moving forward.

from oysterkit.

eimantas avatar eimantas commented on July 19, 2024 1

Epic! Checking out development/0.6, using the latest stlr file and running the command works as a charm!

Thank you very much for your help!

from oysterkit.

SwiftStudies avatar SwiftStudies commented on July 19, 2024 1

I'm working on improving error descriptions right now keep an eye on #87 when its closed it will be worth updating from development/0.6 again.

from oysterkit.

SwiftStudies avatar SwiftStudies commented on July 19, 2024

Apologies for the confusing error message, with all the refactoring some things have been lost.

Right in your STLR there are a couple of issues. At the moment STLR doesn't support the Unicode characters in "\uXXXX". If you'd be good enough to raise an enhancement request I'll try and get it in the next PR (which should be at the end of the the weekend). In the short term you can achieve it with a regular expression (e.g. /\x{0000}/). For brevity it may be worth wrapping all of the UTF-8 codes in a single regular expression

lineBreak = /\x{000A}|\x{000D}|\x{000D}\x{000A}/

Although there again... you can actually do that more easily with .newline

Please let me know how you get on

from oysterkit.

eimantas avatar eimantas commented on July 19, 2024

Thanks for the explanation!

I've simplified stlr file to the following and still receive the same error:

grammar SwiftComments

whitespace = whitespace-item whitespace?

lineBreak = .newLine

whitespaceItem = lineBreak | comment | multiline-comment

comment = "//" commentText lineBreak
multilineComment = "/*" multilineCommentText "*/"

commentText = commentTextItem commentText?
commentTextItem = /[^\r\n]/

multilineCommentText = multitlineCommentTextItem multitlineCommentText?
multilineCommentTextItem = (>> !"/*" | !"*/") (multilineComment | commentTextItem)

from oysterkit.

SwiftStudies avatar SwiftStudies commented on July 19, 2024

Yes I'm just trying to figure out why... Next error is it's .newline not .newLine but running it through the debugger again to see if there's anything after that.

from oysterkit.

SwiftStudies avatar SwiftStudies commented on July 19, 2024

I'll get an improvement to error reporting pushed to development/0.6 first thing tomorrow, there's a little bit of complexity to it that I'd forgotten about, so I just want to take some careful steps... but the above works.

Note if you want to generate the rules AND the structure (you should use the 0.6 branch) you should use:

stlrc -g swift.stlr -l swiftIR -ot ~/Desktop/

from oysterkit.

eimantas avatar eimantas commented on July 19, 2024

Alright, the latest grammar file seems to be working, however your offered command doesn't work:

~/Desktop % stlrc -g ./swift.stlr -l swiftIR -ot .  
Option provided is not a valid option.
For more information run:stlrc help or -h or --help

from oysterkit.

SwiftStudies avatar SwiftStudies commented on July 19, 2024

Are you on the development/0.6 branch?

Parameters if you are running from the Desktop would be

stlrc generate -g swift.stlr -ot ~/Desktop/ -l swiftIR

You can also generate just the rules with

stlrc generate -g swift.stlr -ot ~/Desktop/ -l swift

But you will have to add

import Foundation
import OysterKit

At the top of the generated file

from oysterkit.

SwiftStudies avatar SwiftStudies commented on July 19, 2024

Note I've also fixed my guidance on what command line parameters to use... should have been

stlrc generate -g swift.stlr -ot ~/Desktop/ -l swiftIR

from oysterkit.

SwiftStudies avatar SwiftStudies commented on July 19, 2024

I've corrected a couple more typos in the grammar

grammar SwiftComments

whitespace = whitespaceItem whitespace?

lineBreak = .newline

whitespaceItem = lineBreak | comment | multilineComment

comment = "//" commentText lineBreak
multilineComment = "/*" multilineCommentText "*/"

commentText = commentTextItem commentText?
commentTextItem = >>!.endOfFile !lineBreak 

multilineCommentText = multilineCommentTextItem multilineCommentText?
multilineCommentTextItem = >>!("/*" | "*/") (multilineComment | commentTextItem)

Now your grammar goes into an infinite loop causes a segfault... Your commentText rule looks overly complex, I think it could just resolve down to !lineBreak* lineBreak? Anyhow, I've also put a check for the end of the file in there too. It scans to the end but fails there because there's not really an "exit" condition probably because the rest of the grammar isn't there. So it will match what you type then hit the end of the file and fail.

from oysterkit.

SwiftStudies avatar SwiftStudies commented on July 19, 2024

Just pushed some pretty significant improvements up into development/0.6. Well worth picking up.

from oysterkit.

Related Issues (20)

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.