Giter Club home page Giter Club logo

grammar-mode's Introduction

CodeMirror 5

NOTE: CodeMirror 6 exists, and is more mobile-friendly, more accessible, better designed, and much more actively maintained.

Build Status

CodeMirror is a versatile text editor implemented in JavaScript for the browser. It is specialized for editing code, and comes with over 100 language modes and various addons that implement more advanced editing functionality. Every language comes with fully-featured code and syntax highlighting to help with reading and editing complex code.

A rich programming API and a CSS theming system are available for customizing CodeMirror to fit your application, and extending it with new functionality.

You can find more information (and the manual) on the project page. For questions and discussion, use the discussion forum.

See CONTRIBUTING.md for contributing guidelines.

The CodeMirror community aims to be welcoming to everybody. We use the Contributor Covenant (1.1) as our code of conduct.

Installation

Either get the zip file with the latest version, or make sure you have Node installed and run:

npm install codemirror@5

NOTE: This is the source repository for the library, and not the distribution channel. Cloning it is not the recommended way to install the library, and will in fact not work unless you also run the build step.

Quickstart

To build the project, make sure you have Node.js installed (at least version 6) and then npm install. To run, just open index.html in your browser (you don't need to run a webserver). Run the tests with npm test.

grammar-mode's People

Contributors

marijnh 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

grammar-mode's Issues

any way to multiplex grammar modes natively?

MultiplexingMode works for the most simple of cases, but for more complicated usages it breaks down. For example, in C++ there's a convention to put string-versions of protocol buffers in special raw strings (see https://reviews.llvm.org/D35943). But if you use the naive approach of implementing this with MultiplexingMode, then even if you comment out such a string, the highlighting will still occur.

It would be great if there was a reasonable solution that would work for grammar modes, even better if the inner mode doesn't have to be a grammar mode but can be any codemirror mode.

How to use the output to create CodeMirror mode?

Hello, more than an issues this is actually a question.
I need to create a mode for a specific grammar for the current project I'm working on.

Our grammar is a little bit specific. It's like the where clause of a sql mode. Before to start to write our own grammar I tried this tool using the first example on the README file.

Using that input I got a .js file containing this:

var e = [/^[0-9]+/, /^(?:(?:[a-zA-Z])(?:[a-zA-Z0-9])*)/, /^(?:[\+\-\/\*])/, [1, " ", "\t", "\n"]]
exports.nodes = [
  [1, 3, 1],
  [/^[^]/, 0],
  [3, "number", e[0], -1,
   3, "variable", e[1], -1,
   e[2], -1,
   /^[^]/, -1],
  [3, "number", e[0], 4,
   3, "variable", e[1], 4,
   2, 6, 4, {"name":"ParenExpr"}],
  [e[3], 4,
   e[2], 5,
   0, -1],
  [e[3], 5,
   1, 3, -1],
  ["(", 7],
  [e[3], 7,
   1, 3, 8],
  [e[3], 8,
   ")", -1]
]
exports.start = 0
exports.token = 2

But I'm not sure how to proceed once I get this. How can I create the mode using this??
My guess is eventually I need to call CodeMirror.defineMode(...) but I'm a little bit lost. I was wondering if you can throw me a hint.

And by the way thanks for the great work. I'm going to give some good feedback to my bosses (my current project is not a personal project) and mention them the idea about share some love... in term$$ of... yeah, $$

v0.1.3 breaks

Not sure what changed, but after upgrading to v0.1.3 I get:
(sjql.mode.js contains the built grammar):

error  in ./resources/frontend/components/sjql-editor/grammar/sjql.mode.js

Syntax Error: Unterminated regular expression (76:8)
  
  74 |   [3, "identifier", e[4], -1],
  75 |   [1, 31, -1,
> 76 |    [0, /^(?=LOOKAHEAD(  _lookahead_3_0 -> _lookahead_3_RET[label="[iI][sS][tT](?![a-zA-Z¡-�])|[iI][sS](?![a-zA-Z¡-�]) TOKEN(operator)"];
     |         ^
  77 |   _lookahead_3_0 -> _lookahead_3_RET[label="[eE][nN][tT][hH][äÄ][lL][tT](?![a-zA-Z¡-�])|[cC][oO][nN][tT][aA][iI][nN][sS](?![a-zA-Z¡-�]) TOKEN(operator)"];
  78 |   _lookahead_3_0 -> _lookahead_3_RET[label="[bB][eE][gG][iI][nN][nN][tT](?![a-zA-Z¡-�])|[bB][eE][gG][iI][nN][sS](?![a-zA-Z¡-�]) TOKEN(operator)"];
  79 |   _lookahead_3_0 -> _lookahead_3_RET[label="[eE][nN][dD][eE][tT](?![a-zA-Z¡-�])|[eE][nN][dD][sS](?![a-zA-Z¡-�]) TOKEN(operator)"];

Getting Grammar mode through npm

Hello,

Would you considere to provide this library as a npm package ?
It will be great to be able to do that, because it makes it difficult to use it when you are going use it through an angular/react application for example.

Thanks :).

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.