xref: /OpenGrok/opengrok-indexer/src/main/jflex/analysis/clojure/Clojure.lexh (revision d219b4cea555a12b602d2d5518daa22134ad4879)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * See LICENSE.txt included in this distribution for the specific
9 * language governing permissions and limitations under the License.
10 *
11 * When distributing Covered Code, include this CDDL HEADER in each
12 * file and include the License file at LICENSE.txt.
13 * If applicable, add the following below this CDDL HEADER, with the
14 * fields enclosed by brackets "[]" replaced with your own identifying
15 * information: Portions Copyright [yyyy] [name of copyright owner]
16 *
17 * CDDL HEADER END
18 */
19
20/*
21 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
22 * Portions Copyright (c) 2017, Chris Fraire <cfraire@me.com>.
23 */
24
25Identifier = {Symbol}
26
27Number = ({NumberLong} | {NumberDecimal} | {NumberSci} | {NumberHex} |
28    {NumberBinary} | {NumberCrazy} | {NumberRatio})
29NumberLong = [\-\+]?[0-9]+
30NumberDecimal = [\-\+]?[0-9]*\.[0-9]+
31NumberSci = ({NumberLong} | {NumberDecimal}) ([eE][+-]?[0-9]+)?
32NumberHex = 0[Xx][0-9A-Fa-f]+
33NumberBinary = 2[Rr][01]+
34NumberCrazy = 36[Rr][0-9A-Za-z]+
35NumberRatio = {NumberLong}"/"{NumberLong}
36
37/*
38 * Symbols
39 *
40 * Symbols begin with a non-numeric character and can contain alphanumeric
41 * characters and *, +, !, -, _, ', and ? (other characters may be allowed
42 * eventually).
43 *
44 * N.b. under "Macro Characters", the Quote (') macro is defined -- and that
45 * section implies that Symbols cannot begin with \'
46 */
47Symbol = ({SymbolNormal} | {SymbolSlashed} | {SymbolDotted} | {SymbolColon})
48SymbolNormal = {SymCharLead} {SymCharAny}*
49SymCharSpecial = [\*\+\!\-_\'\?]
50SymCharLead = ([A-Za-z] | [[\*\+\!\-_\'\?]--\']) // i.e. [{SymCharSpecial}--\']
51SymCharAlphanum = [A-Za-z0-9]
52SymCharAny = ({SymCharAlphanum} | {SymCharSpecial})
53/*
54 * '/' has special meaning, it can be used once in the middle of a symbol to
55 * separate the namespace from the name, e.g. my-namespace/foo. '/' by itself
56 * names the division function.
57 */
58SymbolSlashed = {SymbolNormal} "/" {SymCharAny}+
59/*
60 * '.' has special meaning - it can be used one or more times in the middle of
61 * a symbol to designate a fully-qualified class name, e.g. java.util.BitSet,
62 * or in namespace names. Symbols beginning or ending with '.' are reserved by
63 * Clojure. Symbols containing / or . are said to be 'qualified'.
64 */
65SymbolDotted = {SymbolNormal} ("." {SymCharAny}+)+
66/*
67 * Symbols beginning or ending with ':' are reserved by Clojure. A symbol can
68 * contain one or more non-repeating ':'s.
69 */
70SymbolColon = (":" {SymCharAny}+ ":"? | {SymCharAny}+ ":")
71