Skip to content

Commit 0fbabce

Browse files
committed
reorg to use a ./peg directory
1 parent 46282b8 commit 0fbabce

27 files changed

+79
-1
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
peg
1+
peg1
22
*.dSYM/
33
*.txt
File renamed without changes.
File renamed without changes.

examples/pony.peg

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
module <- STRING? use* class*
2+
3+
use <- -"use" (ID -"=")? (STRING / useffi) (-"if" infix)?
4+
5+
useffi <- "@" (ID / STRING) typeargs -"(" params? -")" "?"?
6+
7+
class <-
8+
("type" / "interface" / "trait" / "primitive" / "class" / "actor")
9+
cap?
10+
ID
11+
typeparams?
12+
("is" type)?
13+
STRING?
14+
members
15+
16+
members <- field* method*
17+
18+
field <- ("var" / "let" / "embed") ID -":" type (-"=" infix)?
19+
20+
method <-
21+
("new" / "fun" / "be") cap? ID typeparams? -"(" params? -")" (-":" type)? "?"?
22+
STRING? (-"if" seq)? (-"=>" seq)?
23+
24+
// TODO: all the clustering stuff
25+
26+
atom <-
27+
("this" !IDCONT) / bool / ID / FLOAT / INT / STRING /
28+
-'(' seq -')' / array / object / lambda / "__loc"
29+
30+
bool <- ("true" !IDCONT) / ("false" !IDCONT)
31+
array <- -'[' (-"as" type -':')? seq -']'
32+
object <- -"object" cap? (-"is" type)? members -"end"
33+
lambda <-
34+
-'{' cap? ID? typeparams? -'(' params? -')' captures? (-':' type)? '?'?
35+
'=>' seq '}' cap?
36+
ffi <- '@' (ID / STRING) typeargs? -'(' positional? named? -')' '?'?
37+
38+
// TODO: ID should reject keywords, or reject them later on?
39+
ID <- IDSTART IDCONT*
40+
IDSTART <- '_' / LETTER
41+
IDCONT <- IDSTART / DIGIT / '\''
42+
LETTER <- 'a'..'z' / 'A'..'Z'
43+
44+
DIGIT19 <- '1'..'9'
45+
DIGIT <- '0'..'9'
46+
DIGITS <- (DIGIT / '_')+
47+
HEX <- DIGIT / 'a'..'f' / 'A'..'F'
48+
BINARY <- '0'..'1'
49+
50+
INT <-
51+
(DIGIT19 DIGITS / DIGIT) /
52+
("0x" HEX (HEX / '_')*) /
53+
("0b" BINARY (BINARY / '_')*) /
54+
'\'' (ESC / !'\'' !'\\' .)* '\''
55+
56+
FRAC <- '.' DIGITS
57+
EXP <- ('e' / 'E') ('-' / '+')? DIGITS
58+
FLOAT <- INT FRAC? EXP?
59+
60+
STRING <-
61+
'\"' (ESC / !'\"' !'\\' .)* '\"' /
62+
TRIPLE (!TRIPLE .)* TRIPLE '\"'*
63+
64+
TRIPLE <- "\"\"\""
65+
66+
ESC <-
67+
'\\'
68+
('a' / 'b' / 'e' / 'f' / 'n' / 'r' / 't' / 'v' / '\\' / '0'/ '\'' / '\"') /
69+
"\\x" HEX HEX /
70+
"\\u" HEX HEX HEX HEX /
71+
"\\U" HEX HEX HEX HEX HEX HEX
72+
73+
whitespace <- (' ' / '\t' / '\r' / '\n')+
74+
linecomment <- "//" (!'\r' !'\n' .)*
75+
nestedcomment <- "/*" ((!"/*" !"*/" .) / nestedcomment)* "*/"
76+
77+
start <- module
78+
hidden <- (whitespace / linecomment / nestedcomment)+
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)