ecma262 | Status , process , and documents for ECMA-262

Β by Β  tc39 HTML Version: es2023-candidate-2023-04 License: Non-SPDX

kandi X-RAY | ecma262 Summary

kandi X-RAY | ecma262 Summary

ecma262 is a HTML library. ecma262 has no bugs, it has no vulnerabilities and it has medium support. However ecma262 has a Non-SPDX License. You can download it from GitHub.

Status, process, and documents for ECMA-262
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              ecma262 has a medium active ecosystem.
              It has 14171 star(s) with 1329 fork(s). There are 955 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 287 open issues and 872 have been closed. On average issues are closed in 481 days. There are 99 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of ecma262 is es2023-candidate-2023-04

            kandi-Quality Quality

              ecma262 has no bugs reported.

            kandi-Security Security

              ecma262 has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.

            kandi-License License

              ecma262 has a Non-SPDX License.
              Non-SPDX licenses can be open source with a non SPDX compliant license, or non open source licenses, and you need to review them closely before use.

            kandi-Reuse Reuse

              ecma262 releases are available to install and integrate.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of ecma262
            Get all kandi verified functions for this library.

            ecma262 Key Features

            No Key Features are available at this moment for ecma262.

            ecma262 Examples and Code Snippets

            No Code Snippets are available at this moment for ecma262.

            Community Discussions

            QUESTION

            What is the meaning of an alternative according to ecma262?
            Asked 2022-Feb-05 at 15:56

            I've been wondering what's the meaning of "alternative" in ecma262.

            i've seen that the term "alternative" was used many times in the spec.

            here are some examples:

            quote taken from this section

            so, in this example, the nonterminal ForStatement actually has four alternative right-hand sides.

            quote taken from this section

            A production that has multiple alternative definitions will typically have a distinct algorithm for each alternative

            quote taken from this section

            a production that has multiple alternative definitions will typically have for each alternative a distinct algorithm for each applicable named static semantic rule.

            what does it mean "production that has multiple alternative definitions" ?

            i assume that alternative mean the right hand side of a production, here is a simple picture that shows what i mean.

            on the picture we can see that the area covered by Pink is the whole Production.

            and the area covered by Red is the Nonterminal

            finally i'm assuming that the area covered by purple is the Alternative

            A production that has multiple alternative definitions will typically have a distinct algorithm for each alternative

            however it's still doesn't sounds right, because how can a one individual production have multiple alternatives ?

            ...

            ANSWER

            Answered 2022-Jan-13 at 15:29

            The word has its normal, English meaning:

            offering or expressing a choice

            So to take the first instance:

            so, in this example, the nonterminal ForStatement actually has four alternative right-hand sides.

            And just before that it lists them:

            Source https://stackoverflow.com/questions/70698839

            QUESTION

            Early Error in annex semantics of GlobalDeclarationInstantiation
            Asked 2022-Jan-23 at 01:37

            I couldn't find any sources speaking about the next point in specification (let it be GlobalDeclarationInstantiation):

            ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for script, then

            I don't understand this step, what would it be demonstrating this error?

            I am trying to figure out this step in annex. So if we don't do replacements FunctionDeclartion with the VariableStatement, we won't get the error. Conversily we will get the error, if we do this replacements. What is example of it then?

            ...

            ANSWER

            Answered 2022-Jan-23 at 01:37

            The only of the Script early errors that I can see possibly applying to that replacement is

            It is a Syntax Error if any element of the LexicallyDeclaredNames of ScriptBody also occurs in the VarDeclaredNames of ScriptBody.

            So let's assume the script

            Source https://stackoverflow.com/questions/70817151

            QUESTION

            Where in the ECMAScript spec for the Date() constructor does the time value get converted to epoch time?
            Asked 2022-Jan-18 at 01:11

            I understand that an ECMAScript date just stores a time value in epoch time (the number of milliseconds since midnight on 1 January 1970 UTC).

            But looking over the algorithm for the Date() constructor, I only see where the argument values are converted to milliseconds; I don't see where the millisecond value is converted to epoch time. Where does that step happen?

            ...

            ANSWER

            Answered 2022-Jan-18 at 01:11

            The Date constructor algorithm calls MakeDay, which returns the number of days since epoch for the argument values. MakeDate then does convert that number of days to the number milliseconds by simple multiplication.
            MakeDay contains the following step:

            1. Find a finite time value t such that YearFromTime(t) is ym and MonthFromTime(t) is mn and DateFromTime(t) is 1𝔽;

            This is a rather obscure definition, using the operations defined in 21.4.1.3 "Year Number". There we can find the formula

            DayFromYear(y) = 𝔽(365 Γ— (ℝ(y) - 1970) + floor((ℝ(y) - 1969) / 4) - floor((ℝ(y) - 1901) / 100) + floor((ℝ(y) - 1601) / 400))

            This comes out to have "day 0" as the first day of 1970.

            But rather than deriving that from this formula, we can just read 21.4.1.1 "Time Values and Time Range":

            The exact moment of midnight at the beginning of 1 January 1970 UTC is represented by the time value +0𝔽.

            Source https://stackoverflow.com/questions/70748075

            QUESTION

            Why can we define a setter with [[set]] if [[writable]] is false?
            Asked 2022-Jan-14 at 15:37

            The ECMAScript language specification defines the [[writable]] attribute of Object.defineProperty() as following:

            • If false, attempts by ECMAScript code to change the property's [[Value]] attribute using [[Set]] will not succeed.

            However, this definition doesn't make any sense. There it says that if [[writable]] is false, any attempts to use [[set]] will not work. So in other words: if [[writable]] is false then we can't change it to an accessor property of a setter.

            However, in the example below we have an object where we are able to define [[set]] despite [[writable]] being false:

            ...

            ANSWER

            Answered 2022-Jan-14 at 15:17

            writable: false means that value: "handsome-and-SKINNY" is constant:

            Source https://stackoverflow.com/questions/70712364

            QUESTION

            Extra execution context in async functions
            Asked 2022-Jan-11 at 08:39

            When I was reading spec I saw next part:

            1. NOTE: Copying the execution state is required for AsyncBlockStart to resume its execution. It is ill-defined to resume a currently executing context.

            I don't understand this. Why do we need to copy execution context? Can't we do it without extra execution context or what will be broken without copying in that case?

            ...

            ANSWER

            Answered 2022-Jan-11 at 08:39

            Evaluation of an async function body happens in a separate execution context that can be repeatedly resumed and suspended. The algorithm steps executed in this context are given in AsyncBlockStart #3.
            On await (in Await #8) and completion (i.e. return/throw, in AsyncBlockStart #3.g), the execution context is popped off the stack (and in case of await, suspended to resume where it left off, in Await #9). On promise fulfillment/rejection (in Await #3.c/5.c) and when starting the async function (in AsyncBlockStart #4), it is pushed onto the stack and resumed.
            These push/pop operations need to symmetrically correspond to each other, both when starting and resuming the code it may run into either a suspension or the end of the code; and in all four cases the stack must have the same running execution context on top before and after.

            In case of a resumption from promise settlement, that running execution context will be the current promise job. In case of AsyncFunctionStart, that running execution context will be the one created and pushed by the PrepareForOrdinaryCall steps during the [[Call]] to the async function (which goes through OrdinaryCallEvaluateBody, EvaluateBody to EvaluateAsyncFunctionBody which creates the promise and performs AsyncFunctionStart). It will afterwards be popped from the stack in [[Call]] #7 like for any other function.
            So why do we need an extra execution context? Because if we didn't create a new one (as a copy of the current), it would have been popped off already when AsyncFunctionStart ends, and [[Call]] would fail to pop it again. (Or worse, pop one too many). Of course, an alternative solution to this problem would have been to not make a copy of the current execution context, reuse the suspendable execution context instead, and just push it again onto the stack (without resuming it, only setting it as the running execution context) after the AsyncBlockStart in AsyncFunctionStart #4. But that would've been weird, no?
            After all, it doesn't matter which way it's specified, the outcome would be the same. The execution context is not observable from user code.

            Note: re-using the same execution context is in fact what generators do. GeneratorStart #2 (which is called from EvaluateGeneratorBody, where the parameter declarations are evaluated and the Generator instance is created) does use the running execution context as the genContext that is repeatedly resumed and suspended. The main difference is that the start ("first resumption") doesn't already happen during the function call for generators (as it does happen for async functions), it will only happen later in the first next() call.

            And actually "It is ill-defined to resume a currently executing context." doesn't apply here. The currently executing context would get implicitly suspended in AsyncBlockStart #3 by setting "the code evaluation state of asyncContext such that when evaluation is resumed […]", just like it does happen in GeneratorStart #4.

            Source https://stackoverflow.com/questions/70662098

            QUESTION

            Which nonterminal is the start symbol?
            Asked 2021-Dec-01 at 21:24

            While i was reading the spec(ECMAScript 2022) i've wondered which nonterminal symbol is the start symbol ? in other words the first place that is being evaluated in ECMAScript 2022

            ...

            ANSWER

            Answered 2021-Dec-01 at 21:24

            It depends. The abstract operation ParseText is called from 14 places, with different goalSymbols (from the perspective of a bottom-up parser the start symbol of the generative grammar is the goal). The call you are probably looking for comes from ParseScript and passes in the Script non-terminal symbol (though it might also be Module passed in from ParseModule).

            Source https://stackoverflow.com/questions/70190695

            QUESTION

            Does context-sensitive tokenisation require multiple goal symbols in the lexical grammar?
            Asked 2021-Nov-18 at 02:41

            According to the ECMAScript spec:

            There are several situations where the identification of lexical input elements is sensitive to the syntactic grammar context that is consuming the input elements. This requires multiple goal symbols for the lexical grammar.

            Two such symbols are InputElementDiv and InputElementRegExp.

            In ECMAScript, the meaning of / depends on the context in which it appears. Depending on the context, a / can either be a division operator, the start of a regex literal or a comment delimiter. The lexer cannot distinguish between a division operator and regex literal on its own, so it must rely on context information from the parser.

            I'd like to understand why this requires the use of multiple goal symbols in the lexical grammar. I don't know much about language design so I don't know if this is due to some formal requirement of a grammar or if it's just convention.

            Questions

            • Why not just use a single goal symbol like so:
            ...

            ANSWER

            Answered 2021-Nov-16 at 05:08

            Saying that the lexical production is "sensitive to the syntactic grammar context that is consuming the input elements" does not make the grammar context-sensitive, in the formal-languages definition of that term. Indeed, there are productions which are "sensitive to the syntactic grammar context" in just about every non-trivial grammar. It's the essence of parsing: the syntactic context effectively provides the set of potentially expandable non-terminals, and those will differ in different syntactic contexts, meaning that, for example, in most languages a statement cannot be entered where an expression is expected (although it's often the case that an expression is one of the manifestations of a statement).

            However, the difference does not involve different expansions for the same non-terminal. What's required in a "context-free" language is that the set of possible derivations of a non-terminal is the same set regardless of where that non-terminal appears. So the context can provide a different selection of non-terminals, but every non-terminal can be expanded without regard to its context. That is the sense in which the grammar is free of context.

            As you note, context-sensitivity is usually abstracted in a grammar by a grammar with a pattern on the left-hand side rather than a single non-terminal. In the original definition, the context --everything other than the non-terminal to be expanded-- needed to be passed through the production untouched; only a single non-terminal could be expanded, but the possible expansions depend on the context, as indicated by the productions. Implicit in the above is that there are grammars which can be written in BNF which don't even conform to that rule for context-sensitivity (or some other equivalent rule). So it's not a binary division, either context-free or context-sensitive. It's possible for a grammar to be neither (and, since the empty context is still a context, any context-free grammar is also context-sensitive). The bottom line is that when mathematicians talk, the way they use words is sometimes unexpected. But it always has a clear underlying definition.

            In formal language theory, there are not lexical and syntactic productions; just productions. If both the lexical productions and the syntactic productions are free of context, then the total grammar is free of context. From a practical viewpoint, though, combined grammars are harder to parse, for a variety of reasons which I'm not going to go into here. It turns out that it is somewhat easier to write the grammars for a language, and to parse them, with a division between lexical and syntactic parsers.

            In the classic model, the lexical analysis is done first, so that the parser doesn't see individual characters. Rather, the syntactic analysis is done with an "alphabet" (in a very expanded sense) of "lexical tokens". This is very convenient -- it means, for example, that the lexical analysis can simply drop whitespace and comments, which greatly simplifies writing a syntactic grammar. But it also reduces generality, precisely because the syntactic parser cannot "direct" the lexical analyser to do anything. The lexical analyser has already done what it is going to do before the syntactic parser is aware of its needs.

            If the parser were able to direct the lexical analyser, it would do so in the same way as it directs itself. In some productions, the token non-terminals would include InputElementDiv and while in other productions InputElementRegExp would be the acceptable non-terminal. As I noted, that's not context-sensitivity --it's just the normal functioning of a context-free grammar-- but it does require a modification to the organization of the program to allow the parser's goals to be taken into account by the lexical analyser. This is often referred to (by practitioners, not theorists) as "lexical feedback" and sometimes by terms which are rather less value neutral; it's sometimes considered a weakness in the design of the language, because the neatly segregated lexer/parser architecture is violated. C++ is a pretty intense example, and indeed there are C++ programs which are hard for humans to parse as well, which is some kind of indication. But ECMAScript does not really suffer from that problem; human beings usually distinguish between the division operator and the regexp delimiter without exerting any noticeable intellectual effort. And, while the lexical feedback required to implement an ECMAScript parser does make the architecture a little less tidy, it's really not a difficult task, either.

            Anyway, a "goal symbol" in the lexical grammar is just a phrase which the authors of the ECMAScript reference decided to use. Those "goal symbols" are just ordinary lexical non-terminals, like any other production, so there's no difference between saying that there are "multiple goal symbols" and saying that the "parser directs the lexer to use a different production", which I hope addresses the question you asked.

            Notes
            1. The lexical difference in the two contexts is not just that / has a different meaning. If that were all that it was, there would be no need for lexical feedback at all. The problem is that the tokenization itself changes. If an operator is possible, then the /= in

            Source https://stackoverflow.com/questions/69983078

            QUESTION

            Is `==` still called the "abstract equality operator"?
            Asked 2021-Oct-20 at 11:37

            == used to be called the abstract equality operator, and its abstract equality comparison algorithm was defined in the ECMAScript specification.

            This algorithm is now named IsLooselyEqual in the specification, and the term "abstract equality" is no longer used in the specification.

            Has the operator been renamed?

            ...

            ANSWER

            Answered 2021-Oct-20 at 11:36

            In ECMAScript 5, the == operator was called the "equals operator", and === was called the "strict equals operator".

            In ES2022, the term "equality operators" is used to encompass both (and the word-pairing "equals operator" does not occur).

            The term "loose equality operator" does not appear in ES2022, although the algorithm used to define its behavior is called IsLooselyEqual.

            The term "strict equality operator" does not appear in ES2022, although the algorithm used to define its behavior is called IsStrictlyEqual.

            On this basis, I would say == was never* officially called the "abstract equality operator". It was the "equals operator". However, given that this term is no longer used in the specification, perhaps its name has changed to the "equality operator" or possibly the "loose equality operator" (with the converse being the "strict equality operator").

            *need to check prior to ES5

            Source https://stackoverflow.com/questions/69644896

            QUESTION

            assignment expression in ecma262
            Asked 2021-Oct-17 at 11:22

            consider the following code

            ...

            ANSWER

            Answered 2021-Oct-10 at 11:49

            Within the block statement, all defined variables are local, so myVar within the block will be "Hello". Outside, the variable defined with var is global, and its value never changed as the inner myVar was a totally different variable, just with the same name. So the outer myVar defined with var never changed from its initial value of "Hola".

            Source https://stackoverflow.com/questions/69511751

            QUESTION

            confusion in ecmascript productions
            Asked 2021-Oct-16 at 17:00

            I've been confused lately about productions in ecma262 spec.

            There are productions based on my assumption that can be other productions.

            for example, Statement

            Statement can be a Block it can also be an IfStatement.

            my confusion begins with algorithms that looks like that

            a. Let stmtCompletion be the result of evaluating the first Statement.

            evaluating Statement? What does it mean?

            if a Statement, for example, is an IfStatement will it go to the 14.6 The if Statement 14.6.2 Runtime Semantics: Evaluation ?

            I'm mostly confused because there are productions that have their RS: Evaluation like IfStatement and some don't have the RS: Evaluation like Statement,Declaration, etc...

            ...

            ANSWER

            Answered 2021-Oct-16 at 17:00

            If a Statement, for example, is an IfStatement will it go to the 14.6 The if Statement 14.6.2 Runtime Semantics: Evaluation ?

            Yes.

            I'm mostly confused because there are productions that have their RS: Evaluation like IfStatement and some don't have the RS: Evaluation like Statement,Declaration, etc...

            What does it mean?

            This is (in recent revisions of the spec) even explained in Β§5.2.2 Syntax-Directed Operations. In particular,

            Unless explicitly specified otherwise, all chain productions have an implicit definition for every operation that might be applied to that production's left-hand side nonterminal. The implicit definition simply reapplies the same operation with the same parameters, if any, to the chain production's sole right-hand side nonterminal and then returns the result. For example, assume that some algorithm has a step of the form: β€œReturn the result of evaluating Block” and that there is a production:

            Block : { StatementList }

            but the Evaluation operation does not associate an algorithm with that production. In that case, the Evaluation operation implicitly includes an association of the form:

            Runtime Semantics: Evaluation

            Block : { StatementList }

            1. Return the result of evaluating StatementList.

            So since there are no "Runtime Semantics: Evaluation" for the Statement production, it gets implicit semantics that will simply evaluate the respective statement kind.

            Source https://stackoverflow.com/questions/69596172

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install ecma262

            You can download it from GitHub.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries