Permalink
Browse files

perl6 grammar ported

  • Loading branch information...
1 parent df2c318 commit 5a8c671747f4f7ea55b67c339ed431c6b5dbcaea @ingydotnet committed Oct 1, 2011
Showing with 70 additions and 4 deletions.
  1. +49 −0 cdent-base.pgx
  2. +21 −0 cdent.perl6.pgx
  3. +0 −4 cdent.pgx
View
@@ -0,0 +1,49 @@
+%grammar cdent-base
+%version 0.0.1
+
+module:
+ <module_start>
+ <doc_comment>?
+ <comment>*
+ <include_runtime>?
+ <class>+ %%% <comment>*
+ <module_end>
+ <comment>*
+
+doc_comment:
+ <doc_comment_begin>
+ [ !<doc_comment_end> <doc_comment_line> ]*
+ <doc_comment_end>
+
+class:
+ <class_start>
+ <class_body>
+ <class_end>
+
+class_body:
+ <indent>
+ <method>+ %%% <comment>*
+ <undent>
+
+method:
+ <method_start>
+ <method_body>
+ <method_end>
+
+method_body:
+ <indent>
+ <statement>+ %%% <comment>*
+
+statement: [ <println> | <comment> ]
+
+comment: [ <line_comment> | <blank_line> ]
+
+line_comment: /<line_comment_start>(<line>)/
+
+line: /<ANY>*<EOL>/
+blank_line: /~<EOL>/
+
+module_start: //
+module_end: //
+
+id: /<WORD>+/
View
@@ -0,0 +1,21 @@
+%grammar cdent-perl6
+%extends cdent-base
+%version 0.0.1
+
+line_comment_start: /<HASH>/
+
+doc_comment_begin: /<HASH>{3}<BREAK>/
+doc_comment_line: /<HASH><SPACE>?(<ANY>*<BREAK>)/
+doc_comment_end: /<HASH>{3}<SPACE>/
+
+include_runtime: /use CDent;/
+
+class_start: /class<SPACE>~(<Id>)<WS>~<LCURLY><BREAK>/
+
+class_end: /<RCURLY><BREAK>/
+
+method_start: /method<SPACE>~(<Id>)<SPACE>~<LCURLY><BREAK>/
+
+method_end: /<RCURLY><BREAK>/
+
+println: /say<SPACE>~(<ANY>+)<SEMI><BREAK>/
View
@@ -1,4 +0,0 @@
-# This is the Pegex grammar for cdent
-
-cdent:
- /~Your grammar goes here~/

0 comments on commit 5a8c671

Please sign in to comment.