Code Monkey home page Code Monkey logo

ometa-js's People

Contributors

alexwarth avatar anotherquiz avatar drbsg avatar page- avatar propella 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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

ometa-js's Issues

Re-entrant ometa/js?

I am maintaining a fork of ometa/js, https://github.com/keeyip/nodemeta, which aims to make tweaking ometa/js easier.
I want to use Ometa as a common language for creating syntax highlighters for the CodeMirror text editor, but because a highlighter in CodeMirror is fed input line by line, I was hoping there would be a straightforward way of altering the Ometa/JS implementation to allow for pausing/continuing a parse. The best I can think of is to wrap all the rules with a call/cc, do you think this is a reasonable approach?

Example of CodeMirror's syntax highlighting api:

function parseIt(code) {
   return OmetaParser.matchAll(code, 'start')
}

// Note: The real api names are not important
CodeMirror.registerSyntaxHighlighter('mylang', function myHighlighter(singleLineOfCode) {
  // CodeMirror asynchronously dispatches to myHighlighter
  parseIt(singleLineOfCode)
})

Support for exponent form of number literal

Here is my patch (but I think you can write better ;-)):

   number       = ``0x'' hexLit:n                                                     -> [#number, n]
+               | <digit+ (('e' | 'E') ('-' | '+')? digit+)?>:f                       -> [#number, parseFloat(f)]
                | <digit+ ('.' digit+)?>:f                                            -> [#number, parseFloat(f)],

need better error messages

Currently, failing during parsing just leads to something like:

Error: match failed
    at .../node_modules/ometa-js/lib/ometajs/core.js:64:15
    at fail (.../node_modules/ometa-js/lib/ometajs/core.js:11:20)
    at Object.<anonymous> (.../node_modules/ometa-js/lib/ometajs/core.js:16:2)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)

And if you look in ometajs/core.js, those lines are nothing of interest, those are just the definitions of the fail() function, basically. They don't even have access to the token that we were at when we failed.

Project Ometa_Compiler Doesn't Replace Used Compiler

At the end of the file,

// now we'll make sure that our translator actually worked by replacing
// the original OMeta parser and compiler with the ones defined here
BSOMetaParser     = OMetaParser
BSOMetaTranslator = OMetaTranslator

suggests that from then on it will use the presented parser+translator, but it seems that BSJSOMetaParser , not BSOMetaParser is used (same for Translator). If I leave the code as it is, and change the translator source code, the changes have no effect.

Update: For future reference, I got this impression by slightly changing the translator (like disabling the "trans" rule), which didn't have effect on the given "Duh" example).

Parsing issue

I am writing a parser for the smalltalk language and am having an problem with the following equivalent rules. One works (unaryExpr2) and the other (unaryExpr) parses short. Thanks!

ometa STParser { 
  tokRule = ...,
  primary = ...,
  unarySel = ...,
  ...
  // does not work
  unaryObjExpr  = unaryExpr | primary,
  unaryExpr = unaryObjExpr:mexpr tokRule('unarySel'):sel -> [`send, mexpr, sel],

  // works
  unaryExpr2 = (unaryExpr2 | primary):mexpr tokRule('unarySel'):sel -> [`send, mexpr, sel],
  ...
}

STParser.matchAll('56 double factorial', 'unaryExpr') =
[send, [number, 56], [selector, double]]

STParser.matchAll('56 double factorial', 'unaryExpr2') =
[send, [send, [number, 56], [selector, double]], [selector, factorial]]

grammar [ p = 'a' p 'a' | 'a' ] do not parse properly

ometa L  {
  p = 'a' p:x 'a' -> (x+1) | 'a' -> 0
}

alert(L.matchAll("aaa", 'p')) // 1 - ok
alert(L.matchAll("aaaaa", 'p')) // 1 - wrong!
alert(L.matchAll("aaaaaaa", 'p')) // 3 - ok
alert(L.matchAll("aaaaaaaaa", 'p')) // 1 - wrong!
alert(L.matchAll("aaaaaaaaaaa", 'p')) // 3 - wrong!
alert(L.matchAll("aaaaaaaaaaaaa", 'p')) // 5 - wrong!
alert(L.matchAll("aaaaaaaaaaaaaaa", 'p')) // 7 - ok

Ometa runtime

Are all the files that are included in ometa-rhino.js needed for runtime executing of code that is generated?

Missed use cases of 'new' keyword

new keyword can be used not only in form "new" "name":n "(" listOf(#asgnExpr, ','):as ")". Other right use cases:

var n1 = new Bla,
    n2 = Bla.bla(),
    n2 = new ({a: {b: function() { console.log(arguments) }}}).a.b;

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.