xref: /OpenGrok/opengrok-indexer/src/main/jflex/analysis/javascript/ECMAScript.lexh (revision d219b4cea555a12b602d2d5518daa22134ad4879)
1*d219b4ceSAdam Hornacek/*
2*d219b4ceSAdam Hornacek * CDDL HEADER START
3*d219b4ceSAdam Hornacek *
4*d219b4ceSAdam Hornacek * The contents of this file are subject to the terms of the
5*d219b4ceSAdam Hornacek * Common Development and Distribution License (the "License").
6*d219b4ceSAdam Hornacek * You may not use this file except in compliance with the License.
7*d219b4ceSAdam Hornacek *
8*d219b4ceSAdam Hornacek * See LICENSE.txt included in this distribution for the specific
9*d219b4ceSAdam Hornacek * language governing permissions and limitations under the License.
10*d219b4ceSAdam Hornacek *
11*d219b4ceSAdam Hornacek * When distributing Covered Code, include this CDDL HEADER in each
12*d219b4ceSAdam Hornacek * file and include the License file at LICENSE.txt.
13*d219b4ceSAdam Hornacek * If applicable, add the following below this CDDL HEADER, with the
14*d219b4ceSAdam Hornacek * fields enclosed by brackets "[]" replaced with your own identifying
15*d219b4ceSAdam Hornacek * information: Portions Copyright [yyyy] [name of copyright owner]
16*d219b4ceSAdam Hornacek *
17*d219b4ceSAdam Hornacek * CDDL HEADER END
18*d219b4ceSAdam Hornacek */
19*d219b4ceSAdam Hornacek
20*d219b4ceSAdam Hornacek/*
21*d219b4ceSAdam Hornacek * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
22*d219b4ceSAdam Hornacek * Portions Copyright (c) 2017, 2019, Chris Fraire <cfraire@me.com>.
23*d219b4ceSAdam Hornacek */
24*d219b4ceSAdam Hornacek
25*d219b4ceSAdam Hornacek/*
26*d219b4ceSAdam Hornacek * U+200C	ZERO WIDTH NON-JOINER
27*d219b4ceSAdam Hornacek * U+200D	ZERO WIDTH JOINER
28*d219b4ceSAdam Hornacek * Do not support \UnicodeEscapeSequence (yet?)
29*d219b4ceSAdam Hornacek */
30*d219b4ceSAdam HornacekIdentifier = [\p{XID_Start}_$] [\p{XID_Continue}$\u{200C}\u{200D}]*
31*d219b4ceSAdam Hornacek
32*d219b4ceSAdam HornacekNumericLiteral = ({DecimalLiteral} | {BinaryIntegerLiteral} |
33*d219b4ceSAdam Hornacek    {OctalIntegerLiteral} | {HexIntegerLiteral})
34*d219b4ceSAdam Hornacek
35*d219b4ceSAdam HornacekDecimalLiteral = ({DecimalIntegerLiteral} "." {ExponentPart}? |
36*d219b4ceSAdam Hornacek    {DecimalIntegerLiteral} "." {DecimalDigits} {ExponentPart}? |
37*d219b4ceSAdam Hornacek    "." {DecimalDigits} {ExponentPart}? |
38*d219b4ceSAdam Hornacek    {DecimalIntegerLiteral} {ExponentPart}?)
39*d219b4ceSAdam Hornacek/*
40*d219b4ceSAdam Hornacek * OpenGrok relaxes from the strict ECMA definition of
41*d219b4ceSAdam Hornacek *     DecimalIntegerLiteral::
42*d219b4ceSAdam Hornacek *         0
43*d219b4ceSAdam Hornacek *         NonZeroDigit DecimalDigits?
44*d219b4ceSAdam Hornacek * and thus does not bother supporting LegacyOctalIntegerLiteral,
45*d219b4ceSAdam Hornacek * NonOctalDecimalIntegerLiteral, or LegacyOctalLikeDecimalIntegerLiteral.
46*d219b4ceSAdam Hornacek */
47*d219b4ceSAdam HornacekDecimalIntegerLiteral = {DecimalDigits}
48*d219b4ceSAdam HornacekDecimalDigits = {DecimalDigit}+
49*d219b4ceSAdam HornacekDecimalDigit = [0123456789]
50*d219b4ceSAdam Hornacek// NonZeroDigit = [123456789]
51*d219b4ceSAdam HornacekExponentPart = {ExponentIndicator} {SignedInteger}
52*d219b4ceSAdam HornacekExponentIndicator = [eE]
53*d219b4ceSAdam HornacekSignedInteger = ({DecimalDigits} | "+" {DecimalDigits} | "-" {DecimalDigits})
54*d219b4ceSAdam Hornacek
55*d219b4ceSAdam HornacekBinaryIntegerLiteral = "0" [bB] {BinaryDigits}
56*d219b4ceSAdam HornacekBinaryDigits = {BinaryDigit}+
57*d219b4ceSAdam HornacekBinaryDigit = [01]
58*d219b4ceSAdam Hornacek
59*d219b4ceSAdam HornacekOctalIntegerLiteral = "0" [oO] {OctalDigits}
60*d219b4ceSAdam HornacekOctalDigits = {OctalDigit}+
61*d219b4ceSAdam HornacekOctalDigit = [01234567]
62*d219b4ceSAdam Hornacek
63*d219b4ceSAdam HornacekHexIntegerLiteral = "0" [xX] {HexDigits}
64*d219b4ceSAdam HornacekHexDigits = {HexDigit}+
65*d219b4ceSAdam HornacekHexDigit = [0123456789abcdefABCDEF]
66*d219b4ceSAdam Hornacek
67*d219b4ceSAdam HornacekFile = [a-zA-Z]{FNameChar}* "." ([Js][Ss] |
68*d219b4ceSAdam Hornacek    [Pp][Rr][Oo][Pp][Ee][Rr][Tt][Ii][Ee][Ss] | [Pp][Rr][Oo][Pp][Ss] |
69*d219b4ceSAdam Hornacek    [Xx][Mm][Ll] | [Cc][Oo][Nn][Ff] | [Tt][Xx][Tt] | [Hh][Tt][Mm][Ll]? |
70*d219b4ceSAdam Hornacek    [Ii][Nn][Ii] | [Dd][Ii][Ff][Ff] | [Pp][Aa][Tt][Cc][Hh])
71*d219b4ceSAdam Hornacek
72*d219b4ceSAdam Hornacek/*
73*d219b4ceSAdam Hornacek * STRING: double-quoted literal.
74*d219b4ceSAdam Hornacek * REGEXP: heuristically-detected regular expression bounded by "/" characters.
75*d219b4ceSAdam Hornacek * COMMENT: comment text bounded by "/*" and "*/" and not nestable per ECMA
76*d219b4ceSAdam Hornacek *     documentation.
77*d219b4ceSAdam Hornacek * SCOMMENT: comment text that ends at a line terminator.
78*d219b4ceSAdam Hornacek * QSTRING: single-quoted literal.
79*d219b4ceSAdam Hornacek * TEMPLATE: template literal bounded by "`" characters and supporting
80*d219b4ceSAdam Hornacek *     substitution.
81*d219b4ceSAdam Hornacek */
82*d219b4ceSAdam Hornacek%state STRING REGEXP COMMENT SCOMMENT QSTRING TEMPLATE
83