@@ -20,20 +20,69 @@ printResults :: Effect Unit
20
20
printResults = do
21
21
log " " -- empty blank line to separate output from function call
22
22
23
- log " ### Example Content 1 ###"
24
- doBoth " fail" ((fail " example failure message" ) :: Parser Unit ) exampleContent1
25
- doBoth " numberOfAs" numberOfAs exampleContent1
26
- doBoth " removePunctuation" removePunctuation exampleContent1
27
- doBoth " replaceVowelsWithUnderscore" replaceVowelsWithUnderscore exampleContent1
28
- doBoth " tokenizeContentBySpaceChars" tokenizeContentBySpaceChars exampleContent1
29
- doBoth " extractWords" extractWords exampleContent1
30
- doBoth " badExtractWords" badExtractWords exampleContent1
31
- doBoth " quotedLetterExists" quotedLetterExists exampleContent1
32
-
33
- log
34
- " \n \
35
- \### Example Content 2 ###"
36
- doBoth " parseCSV" parseCSV exampleContent2
23
+ -- Parse the NuttX Stack Dump
24
+ doRunParser " parseStackDump" parseStackDump " [ 6.242000] stack_dump: 0xc02027e0: c0202010 00000000 00000001 00000000 00000000 00000000 8000ad8a 00000000"
25
+
26
+ -- log "### Example Content 1 ###"
27
+ -- doBoth "fail" ((fail "example failure message") :: Parser Unit) exampleContent1
28
+ -- doBoth "numberOfAs" numberOfAs exampleContent1
29
+ -- doBoth "removePunctuation" removePunctuation exampleContent1
30
+ -- doBoth "replaceVowelsWithUnderscore" replaceVowelsWithUnderscore exampleContent1
31
+ -- doBoth "tokenizeContentBySpaceChars" tokenizeContentBySpaceChars exampleContent1
32
+ -- doBoth "extractWords" extractWords exampleContent1
33
+ -- doBoth "badExtractWords" badExtractWords exampleContent1
34
+ -- doBoth "quotedLetterExists" quotedLetterExists exampleContent1
35
+
36
+ -- log
37
+ -- "\n\
38
+ -- \### Example Content 2 ###"
39
+ -- doBoth "parseCSV" parseCSV exampleContent2
40
+
41
+ -- parseStackDump :: Parser CsvContent
42
+ parseStackDump = do
43
+ let
44
+ commaThenSpaces = string " ," *> skipSpaces
45
+ csvColumn = regex " [^,]+"
46
+
47
+ -- now we're on line 2
48
+ idNumber <- csvColumn
49
+ -- idNumber <- csvColumn <* commaThenSpaces
50
+ -- firstName <- csvColumn <* commaThenSpaces
51
+ -- lastName <- csvColumn <* commaThenSpaces
52
+ -- age <- csvColumn <* commaThenSpaces
53
+
54
+ -- lookAhead will parse the content ahead of us,
55
+ -- then reset the position of the string
56
+ -- to what it was before it.
57
+ -- originalEmail <- lookAhead $ regex "[^\n]+"
58
+
59
+ -- let
60
+ -- parseAlphanumericChars = regex "[a-zA-Z0-9]+"
61
+ -- parsePeriodsAndPlusesAsEmptyStrings =
62
+ -- "" <$ ((string ".") <|> (string "+"))
63
+ -- parseListOfParts =
64
+ -- many1
65
+ -- ( parseAlphanumericChars
66
+ -- <|> parsePeriodsAndPlusesAsEmptyStrings
67
+ -- )
68
+
69
+ -- usernameWithoutPeriodsOrPluses <- fold <$> parseListOfParts
70
+ -- void $ string "@"
71
+ -- domainName <- fold <$> (many1 ((regex "[a-zA-Z0-9]+") <|> (string ".")))
72
+ -- void $ string "\n"
73
+
74
+ -- -- Ensure we hit the end of the string content via 'end-of-file'
75
+ -- void eof
76
+
77
+ -- now return the parsed content
78
+ pure
79
+ { idNumber
80
+ -- , firstName
81
+ -- , lastName
82
+ -- , age
83
+ -- , originalEmail
84
+ -- , modifiedEmail: usernameWithoutPeriodsOrPluses <> "@" <> domainName
85
+ }
37
86
38
87
-- Example Content 1
39
88
0 commit comments