Coder Social home page Coder Social logo

Tweaks to variable syntax about ecmarkdown HOT 16 CLOSED

tc39 avatar tc39 commented on May 24, 2024
Tweaks to variable syntax

from ecmarkdown.

Comments (16)

domenic avatar domenic commented on May 24, 2024

%Math_pow%(_base_, _exponent_)

showed up in https://github.com/rwaldron/exponentiation-operator/blob/master/spec/index.html

Can we do this better via some heuristic? E.g. variables are not allowed to contain % and (? I like that idea.

from ecmarkdown.

jmdyck avatar jmdyck commented on May 24, 2024

You could say that % is yet another format-delimiter, so %Math_pow% is recognized as a percent-format, preventing _pow%(_ from being mis-recognized as an underscore-format.

from ecmarkdown.

jmdyck avatar jmdyck commented on May 24, 2024

Mind you, it is a good idea to restrict the characters allowed in an underscore-format. In the ES spec, I think the only characters in metavariable names are [A-Za-z12].

from ecmarkdown.

bterlson avatar bterlson commented on May 24, 2024

Should I only accept [\w\d] inside var maybe?

from ecmarkdown.

jmdyck avatar jmdyck commented on May 24, 2024

Careful: \w includes underscore, which you don't want to allow.

from ecmarkdown.

bterlson avatar bterlson commented on May 24, 2024

Lol. Good point. But I want to allow word-like Unicode characters... what's the best way to do this?

from ecmarkdown.

jmdyck avatar jmdyck commented on May 24, 2024

In a JavaScript RegExp? I think the only way to do it is to enumerate the code-point ranges, which I imagine would be a pain.

But why would you need anything other than [A-Za-z0-9]? Is someone going to write ES proposal pseudocode in a language other than English?

from ecmarkdown.

bterlson avatar bterlson commented on May 24, 2024

Maybe? :P But I'll go with your suggested ranges for now.

from ecmarkdown.

domenic avatar domenic commented on May 24, 2024

tc39/ecmarkup#27 implies we should allow < and > in the set as well. (I assume ecmarkup passes ecmarkdown <key>, not &lt;key&gt;.)

from ecmarkdown.

bterlson avatar bterlson commented on May 24, 2024

Currently Emu passes <key> but it needs to pass &lt;key&gt; if that's what was written in the source document. Reason being that <key> is clearly an element when the author clearly did not intend that when they wrote the escape characters.

But what is this <key> convention anyway, @caridy?

from ecmarkdown.

domenic avatar domenic commented on May 24, 2024

Currently Emu passes <key> but it needs to pass &lt;key&gt; if that's what was written in the source document.

Yeah I guess this comes down to what level EMD operates at. And we're moving away from it operating on small slices of textContent, instead toward it operating on larger chunks of HTML/EMU. So I agree with you. I guess the allowed set then includes & and ; (and maybe #); good times.

It would be nicer to eliminate variables with < and > in them though.

from ecmarkdown.

bterlson avatar bterlson commented on May 24, 2024

Thoughts on the following:

_foo_bar_ ==> <var>foo_bar</var> or _foo_bar_

from ecmarkdown.

domenic avatar domenic commented on May 24, 2024

I would have thought <var>foo</var>bar_. The first five characters parse great as a variable.

from ecmarkdown.

bterlson avatar bterlson commented on May 24, 2024

The middle _ is not a valid format end since it is followed by alpha-numeric characters. But is what you suggest desirable? I can do that too.

from ecmarkdown.

domenic avatar domenic commented on May 24, 2024

I think it is... We specifically want to allow intra-word variables like _SIMD_Constructor, so this seems to follow automatically.

from ecmarkdown.

bterlson avatar bterlson commented on May 24, 2024

Hmmmm, ok. I had thought SIMD was a sigil they wanted to emit as-is in the output doc (rather than wrapping in var and removing underscores).

from ecmarkdown.

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.