Git Product home page Git Product logo

Comments (10)

kylebarron avatar kylebarron commented on May 30, 2024

https://gist.github.com/kylebarron/e46ce79911976c3aae9d7e98309b9222

from stata_kernel.

kylebarron avatar kylebarron commented on May 30, 2024

@mcaceresb Check out https://github.com/kylebarron/stata_kernel/blob/dev-stata-lexer/stata_kernel/stata_lexer.py

from stata_kernel.

kylebarron avatar kylebarron commented on May 30, 2024

I believe I've implemented correct comments. Working on strings then writing some tests.

from stata_kernel.

kylebarron avatar kylebarron commented on May 30, 2024

And yes I know some of those regexes could be cleaned up. It was mostly a port from language-stata.

from stata_kernel.

mcaceresb avatar mcaceresb commented on May 30, 2024

One issue that comes to mind with the lexer is that * in mata de-references a pointer, and is not a comment. I wonder if it has a way to implement different rules for different environments (this might also come in handy for #delimit ;, where the notion of a line changes).

from stata_kernel.

kylebarron avatar kylebarron commented on May 30, 2024

Yes that should be possible. Since Mata is only started with mata and ended with end (is this true?), I can easily find when Mata starts and ends and then just write a different lexer for Mata and use the Mata tokenizer on the Mata code.

from stata_kernel.

mcaceresb avatar mcaceresb commented on May 30, 2024

You need to be careful in that

  1. mata can be preceded by any number of CAPture, QUIetly, or Noisily
  2. mata can be followed by any number of spaces, :, and any number of spaces thereafter.
  3. If there is anything else following mata, it is evaluated inline, and does not enter the mata environment
  4. end can be preceded by any number of spaces and followed by anything
  5. It doesn't matter where end appears. In a loop, a function, etc. The mata environment will end at that point.
  6. mata is not nested, as mata itself is a valid mata command.

from stata_kernel.

kylebarron avatar kylebarron commented on May 30, 2024

Thanks. I'll have to look at the mata syntax more closely.

from stata_kernel.

mcaceresb avatar mcaceresb commented on May 30, 2024

Comments are just C-style comments, except they can be nested. Rules for locals, etc. are the same. I don't think there is much to look out for within a mata block per se, other than the prompts are different.

from stata_kernel.

kylebarron avatar kylebarron commented on May 30, 2024

I'll come back to Mata once I progress on some other stuff. You're welcome to submit a PR with a Mata lexer if you'd like. All it needs to support is comments and strings.

from stata_kernel.

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.