Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 115 lines (94 sloc) 3.54 kb
fccc685 Initial open-source release
MLstate authored
1 (*
5aee710 @Aqua-Ye [cleanup] default.trx: fix copyright, removed ws + comment
Aqua-Ye authored
2 Copyright © 2011 MLstate
fccc685 Initial open-source release
MLstate authored
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
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
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
5aee710 @Aqua-Ye [cleanup] default.trx: fix copyright, removed ws + comment
Aqua-Ye authored
18
fccc685 Initial open-source release
MLstate authored
19 hexa <- [0-9A-Fa-f]
20 space <- [ \n\r\t]
21 spacing <- [ \n\r\t]
22 # FIXME: optimiser !eol = ![\r\n]
23 eol <- "\r\n" $ / [\r\n] $
24 eof <- !.
25
26 # FIXME: optimiser string + inverser les appellations
27 string <- stringnosp spacing {{ __1 }}
28 stringnosp <- [\"] stringchar* [\"] {{ Tgrammar.string_of_chars __2 }}
29 # FIXME: optimiser le code genere (= ne pas construire des expressions qui sont jetees)
30 stringquote <- stringnosp $_
31
32 # "\\\\" {{ '\\' }} / "\\\"" {{ '\"' }} / ![\"] .
5aee710 @Aqua-Ye [cleanup] default.trx: fix copyright, removed ws + comment
Aqua-Ye authored
33 stringcharspecial <-
fccc685 Initial open-source release
MLstate authored
34 [n] {{ '\n' }} / [r] {{ '\r' }} / [t] {{ '\t' }}
35 / [\'] {{ '\'' }} / [\"] {{ '\"' }} / [\\] {{ '\\' }}
36 / [0-9]+ {{ char_of_int (Tgrammar.int_of_chars __1) }}
5aee710 @Aqua-Ye [cleanup] default.trx: fix copyright, removed ws + comment
Aqua-Ye authored
37 stringchar <-
fccc685 Initial open-source release
MLstate authored
38 [\\] stringcharspecial {{ __2 }}
39 / ![\\\"] .
5aee710 @Aqua-Ye [cleanup] default.trx: fix copyright, removed ws + comment
Aqua-Ye authored
40 singlequotechar_ <-
fccc685 Initial open-source release
MLstate authored
41 [\\] stringcharspecial {{ __2 }}
42 / ![\\\'] .
43
44
45 # FIXME: fonctions !!!
5aee710 @Aqua-Ye [cleanup] default.trx: fix copyright, removed ws + comment
Aqua-Ye authored
46 charsinglequote <- [\'] singlequotechar_ [\'] {{ __2 }}
fccc685 Initial open-source release
MLstate authored
47
48 stringsinglequote <- [\'] stringsinglechar* [\'] $_
49 stringsinglechar <- "\\\\" {{ '\\' }} / "\\\'" {{ '\'' }} / "\\" stringcharspecial {{ __2 }} / ![\'] .
50
51 # FIXME: parenthèses INCLUES (et le SPACING de rparen !!)
52 parexpr <- lparen (parexpr $/ !rparen . $)* rparen $_
53 parexprexcluded <- lparen ((parexpr $/ !rparen . $)* $_) rparen {{ __2 }}
54 parexprnosp <- lparen (parexpr $/ !rparen . $)* [)] $_
55 # FIXME: parenthèses EXCLUES
56 accolexprcontent <- (accolexpr $ / !raccol . $)* $_
57 accolexpr <- laccol accolexprcontent raccol {{ __2 }}
58 bracketexprcontent <- (bracketexpr $ / !rbracket . $)* $_
59 bracketexpr <- lbracket bracketexprcontent rbracket {{ __2 }}
60
5aee710 @Aqua-Ye [cleanup] default.trx: fix copyright, removed ws + comment
Aqua-Ye authored
61 slash <- [/] spacing $
fccc685 Initial open-source release
MLstate authored
62 equal <- [=] spacing $
63 comma <- [,] spacing $
64 plus <- [+] spacing $
65 laccol <- [{] spacing $
66 raccol <- [}] spacing $
5aee710 @Aqua-Ye [cleanup] default.trx: fix copyright, removed ws + comment
Aqua-Ye authored
67 colon <- [:] spacing $
fccc685 Initial open-source release
MLstate authored
68 semi <- [;] spacing $
69 lparen <- [(] spacing $
70 rparen <- [)] spacing $
71 lbracket <- [\[] spacing $
72 rbracket <- [\]] spacing $
73 times <- [*] spacing $
74 bar <- [|] spacing $
75 bang <- [!] spacing $
76 question <- [?] spacing $
77 question_ <- [?] $
78 dot <- [.] spacing $
79 sharp <- [#] spacing $
80 bar <- [|] spacing $
81 at <- [@] spacing $
82 underscore <- [_] spacing $
5aee710 @Aqua-Ye [cleanup] default.trx: fix copyright, removed ws + comment
Aqua-Ye authored
83 tilde_ <- [~] $
fccc685 Initial open-source release
MLstate authored
84
85 leftarrow <- "<-" spacing $
86 rightarrow <- "->" spacing $
87
88 strbool <- ("true" / "false") $_
89 bool <- strbool {{ bool_of_string __1 }}
90
91 strint64 <- [-]? [0-9]+ $_
92 int64 <- strint64 {{ Int64.of_string __1 }}
93
94 strint <- [-]? [0-9]+ $_
95 int <- strint {{ int_of_string __1 }}
96
97 strfloat <- [-]? ([0-9]+ [.] [0-9]* / [0-9]* [.] [0-9]+) $_
98 float <- strfloat {{ float_of_string __1 }}
99
100 sharpcomment <- [#] (!eol .)* $
101 mlcomment <- mlCOMMENTSTART (!mlCOMMENTSTOP (mlcomment / . $))* mlCOMMENTSTOP $
102 mlCOMMENTSTART <- '(*' $
103 mlCOMMENTSTOP <- '*)' $
104
5aee710 @Aqua-Ye [cleanup] default.trx: fix copyright, removed ws + comment
Aqua-Ye authored
105 humanint <- int [kMG]?
106 {{ match __2 with
fccc685 Initial open-source release
MLstate authored
107 | Some 'k' -> __1 * 1024
108 | Some 'M' -> __1 * 1024 * 1024
109 | Some 'G' -> __1 * 1024 * 1024 * 1024 (* FIXME: overflow !!! *)
110 | _ -> __1
111 }}
112
113 int3 <- [2]([5][0-5] / [0-4][0-9]) / [0-1][0-9][0-9] / [0-9][0-9]?
114 str_ipaddr <- int3 [.] int3 [.] int3 [.] int3 $_
Something went wrong with that request. Please try again.