aboutsummaryrefslogtreecommitdiff
path: root/src/HaddockParse.y
diff options
context:
space:
mode:
authorsimonmar <unknown>2002-04-04 16:24:10 +0000
committersimonmar <unknown>2002-04-04 16:24:10 +0000
commit99ede94f5e3965620becbc8a9eeaa45f009b2116 (patch)
tree9c04107ce0ef61346b6d11fea889572dfce97605 /src/HaddockParse.y
parent2b39cd941c80d2603f2480684c45dd31f9256831 (diff)
[haddock @ 2002-04-04 16:24:10 by simonmar]
forgot one file
Diffstat (limited to 'src/HaddockParse.y')
-rw-r--r--src/HaddockParse.y55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/HaddockParse.y b/src/HaddockParse.y
new file mode 100644
index 00000000..2402452c
--- /dev/null
+++ b/src/HaddockParse.y
@@ -0,0 +1,55 @@
+{
+module HaddockParse (parseParas, parseString) where
+
+import HaddockLex
+import HaddockTypes
+}
+
+%tokentype { Token }
+
+%token SQUO { TokSpecial '\'' }
+ DQUO { TokSpecial '\"' }
+ '/' { TokSpecial '/' }
+ '[' { TokSpecial '[' }
+ ']' { TokSpecial ']' }
+ '*' { TokBullet }
+ '(n)' { TokNumber }
+ PARA { TokPara }
+ STRING { TokString $$ }
+
+%name parseParas doc
+%name parseString seq
+
+%%
+
+doc :: { ParsedDoc }
+ : apara PARA doc { docAppend $1 $3 }
+ | apara { $1 }
+
+apara :: { ParsedDoc }
+ : ulpara { DocUnorderedList [$1] }
+ | olpara { DocOrderedList [$1] }
+ | para { $1 }
+
+ulpara :: { ParsedDoc }
+ : '*' para { $2 }
+
+olpara :: { ParsedDoc }
+ : '(n)' para { $2 }
+
+para : seq { docParagraph $1 }
+
+seq :: { ParsedDoc }
+ : elem seq { DocAppend $1 $2 }
+ | elem { $1 }
+
+elem :: { ParsedDoc }
+ : STRING { DocString $1 }
+ | '/' STRING '/' { DocEmphasis (DocString $2) }
+ | SQUO STRING SQUO { DocIdentifier $2 }
+ | DQUO STRING DQUO { DocModule $2 }
+ | '[' seq ']' { DocMonospaced $2 }
+
+{
+happyError = error "Parse error in doc string"
+}