Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 156 lines (140 sloc) 3.449 kB
fccc685 Initial open-source release
MLstate authored
1 (*
dbb3a62 @BourgerieQuentin [fix] compiler, jsparser: Parse comments optionnaly (avoid useless no…
BourgerieQuentin authored
2 Copyright © 2011, 2012 MLstate
fccc685 Initial open-source release
MLstate authored
3
5bb0f1a @Aqua-Ye [cleanup] compiler: typo on Opa
Aqua-Ye authored
4 This file is part of Opa.
fccc685 Initial open-source release
MLstate authored
5
5bb0f1a @Aqua-Ye [cleanup] compiler: typo on Opa
Aqua-Ye authored
6 Opa is free software: you can redistribute it and/or modify it under the
fccc685 Initial open-source release
MLstate authored
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
5bb0f1a @Aqua-Ye [cleanup] compiler: typo on Opa
Aqua-Ye authored
10 Opa is distributed in the hope that it will be useful, but WITHOUT ANY
fccc685 Initial open-source release
MLstate authored
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
5bb0f1a @Aqua-Ye [cleanup] compiler: typo on Opa
Aqua-Ye authored
16 along with Opa. If not, see <http://www.gnu.org/licenses/>.
fccc685 Initial open-source release
MLstate authored
17 *)
5496ee5 [doc] jslang: adding some comments in the js lexer/parser
Valentin Gatien-Baron authored
18
19 (**
20 The javascript lexer
21
4a836c5 @arthuraa [enhance] jslex: remove global state.
arthuraa authored
22 The lexer is stateful. Thus, after creating a token stream, only
23 one thread can access it.
5496ee5 [doc] jslang: adding some comments in the js lexer/parser
Valentin Gatien-Baron authored
24
25 This module is not meant to be called directly, use instead the high level
26 functions provided in jsParse if you want to parse some javascript.
27 *)
28
9b29bec @arthuraa [enhance] jslex: add position information.
arthuraa authored
29 type pos = FilePos.pos
30
e3fd3c6 @arthuraa [fix] libbsl: new directive lexing corner cases.
arthuraa authored
31 type doc_comment_elt =
9b29bec @arthuraa [enhance] jslex: add position information.
arthuraa authored
32 | CommentLine of pos * string
33 | CommentTag of pos * string * string
e3fd3c6 @arthuraa [fix] libbsl: new directive lexing corner cases.
arthuraa authored
34
9b29bec @arthuraa [enhance] jslex: add position information.
arthuraa authored
35 (* to know what these tokens correspond to, simply look at association
36 * list below *)
fccc685 Initial open-source release
MLstate authored
37 type token =
9b29bec @arthuraa [enhance] jslex: add position information.
arthuraa authored
38 | Yield of pos
39 | With of pos
40 | While of pos
41 | Void of pos
42 | Var of pos
43 | Typeof of pos
44 | Try of pos
45 | True of pos
46 | TimesEqual of pos
47 | Times of pos
48 | Tilda of pos
49 | Throw of pos
50 | This of pos
51 | Switch of pos
52 | Super of pos
53 | String of pos * string
54 | Static of pos
55 | Semic of pos
56 | Rparen of pos
57 | Return of pos
58 | Regexp of pos * string * string
59 | Rcurly of pos
60 | Rbracket of pos
61 | Question of pos
62 | Public of pos
63 | Protected of pos
64 | Private of pos
65 | PlusPlus of pos
66 | PlusEqual of pos
67 | Plus of pos
68 | PercentEqual of pos
69 | Percent of pos
70 | Package of pos
71 | Null of pos
72 | New of pos
73 | MinusMinus of pos
74 | MinusEqual of pos
75 | Minus of pos
76 | LtLtEqual of pos
77 | LtLt of pos
78 | Lt of pos
79 | Lparen of pos
80 | Let of pos
81 | Le of pos
82 | Lcurly of pos
83 | Lbracket of pos
84 | LT of pos
85 | Interface of pos
86 | Integer of pos * string
87 | Instanceof of pos
88 | In of pos
89 | Import of pos
90 | Implements of pos
91 | If of pos
92 | Ident of pos * string
93 | GtGtGtEqual of pos
94 | GtGtGt of pos
95 | GtGtEqual of pos
96 | GtGt of pos
97 | Gt of pos
98 | Ge of pos
99 | Function of pos
100 | For of pos
101 | Finally of pos
102 | False of pos
103 | Extends of pos
104 | Export of pos
105 | EqualEqualEqual of pos
106 | EqualEqual of pos
107 | Equal of pos
108 | Enum of pos
109 | Else of pos
110 | EOF of pos
111 | Dot of pos
112 | Do of pos
113 | DivEqual of pos
114 | Div of pos
115 | Delete of pos
116 | Default of pos
117 | Debugger of pos
118 | Continue of pos
119 | Const of pos
120 | Comma of pos
121 | Colon of pos
122 | Class of pos
123 | ChapeauEqual of pos
124 | Chapeau of pos
125 | Catch of pos
126 | Case of pos
127 | Break of pos
128 | BarEqual of pos
129 | BarBar of pos
130 | Bar of pos
131 | BangEqualEqual of pos
132 | BangEqual of pos
133 | Bang of pos
134 | AmperEqual of pos
135 | AmperAmper of pos
136 | Amper of pos
fccc685 Initial open-source release
MLstate authored
137
9b29bec @arthuraa [enhance] jslex: add position information.
arthuraa authored
138 (* These tokens are used only when parsing comments for bsl files
139 and are not produced in normal lexing*)
4a836c5 @arthuraa [enhance] jslex: remove global state.
arthuraa authored
140 | DocComment of pos * doc_comment_elt list * bool
5746a54 @arthuraa [enhance] js: add doc comments to lexer.
arthuraa authored
141
1f10c50 @arthuraa [enhance] libbsl: first version of new directive parser.
arthuraa authored
142 val string_of_token : token -> string
4a836c5 @arthuraa [enhance] jslex: remove global state.
arthuraa authored
143
144 type state
145
146 val initial_state : (* filename *) string -> (* lex_comments *) bool -> state
147 val lex : state -> Lexing.lexbuf -> token
75e8f2d @arthuraa [enhance] jslex: compute positions.
arthuraa authored
148 val stream : string -> bool -> Lexing.lexbuf -> token Stream.t
fccc685 Initial open-source release
MLstate authored
149
150 (**
5746a54 @arthuraa [enhance] js: add doc comments to lexer.
arthuraa authored
151 These high level functions automatically init the lexer
fccc685 Initial open-source release
MLstate authored
152 when called
153 *)
dbb3a62 @BourgerieQuentin [fix] compiler, jsparser: Parse comments optionnaly (avoid useless no…
BourgerieQuentin authored
154 val stream_of_file : ?comments:bool -> string -> token Stream.t * Lexing.lexbuf
155 val stream_of_string : ?filename:string -> ?comments:bool -> string -> token Stream.t * Lexing.lexbuf
Something went wrong with that request. Please try again.