@@ -16,28 +16,17 @@ import * as Data_String_Regex_Flags from "https://compile.purescript.org/output/
1616import * as Data_String_Regex_Unsafe from "https://compile.purescript.org/output/Data.String.Regex.Unsafe/index.js" ;
1717import * as Effect_Console from "https://compile.purescript.org/output/Effect.Console/index.js" ;
1818import * as StringParser_CodePoints from "https://compile.purescript.org/output/StringParser.CodePoints/index.js" ;
19+ import * as StringParser_Combinators from "https://compile.purescript.org/output/StringParser.Combinators/index.js" ;
1920import * as StringParser_Parser from "https://compile.purescript.org/output/StringParser.Parser/index.js" ;
2021var discard = /* #__PURE__ */ Control_Bind . discard ( Control_Bind . discardUnit ) ;
2122var discard1 = /* #__PURE__ */ discard ( StringParser_Parser . bindParser ) ;
23+ var applyFirst = /* #__PURE__ */ Control_Apply . applyFirst ( StringParser_Parser . applyParser ) ;
2224
23- // To parse the line: `stack_dump: 0xc02027e0: c0202010 00000000 00000001 00000000 00000000 00000000 8000ad8a 00000000`
24- // If the line begins with a Timestamp: `[ 6.242000] `
25- // Skip `[ `
26- // `void` means ignore the Text Captured
27- // `$ something something` is shortcut for `( something something )`
28- // `<*` is the Delimiter between Patterns
29- // void $
30- // string "[" -- Match the string `[`
31- // <* skipSpaces -- Skip the following spaces
32- // <* regex "[.0-9]+" -- Skip the number
33- // <* string "]" -- Match the string `]`
34- // <* skipSpaces -- Skip the following spaces
3525// Skip `stack_dump: `
3626// `void` means ignore the Text Captured
3727// `$ something something` is shortcut for `( something something )`
3828// `<*` is the Delimiter between Patterns
3929var $$void = /* #__PURE__ */ Data_Functor [ "void" ] ( StringParser_Parser . functorParser ) ;
40- var applyFirst = /* #__PURE__ */ Control_Apply . applyFirst ( StringParser_Parser . applyParser ) ;
4130var bind = /* #__PURE__ */ Control_Bind . bind ( StringParser_Parser . bindParser ) ;
4231var pure = /* #__PURE__ */ Control_Applicative . pure ( StringParser_Parser . applicativeParser ) ;
4332var show = /* #__PURE__ */ Data_Show . show ( Data_Show . showInt ) ;
@@ -103,7 +92,7 @@ var showAddressType = {
10392 if ( v instanceof Heap ) {
10493 return "Heap" ;
10594 } ;
106- throw new Error ( "Failed pattern match at Main (line 73 , column 1 - line 77 , column 21): " + [ v . constructor . name ] ) ;
95+ throw new Error ( "Failed pattern match at Main (line 79 , column 1 - line 83 , column 21): " + [ v . constructor . name ] ) ;
10796 }
10897} ;
10998
@@ -123,27 +112,29 @@ var logShow1 = /* #__PURE__ */ Effect_Console.logShow(/* #__PURE__ */ Data_Maybe
123112// Given this line of NuttX Stack Dump: `stack_dump: 0xc02027e0: c0202010 00000000 00000001 00000000 00000000 00000000 8000ad8a 00000000`
124113// Result: { addr: "c02027e0", timestamp: "6.242000", v1: "c0202010", v2: "00000000", v3: "00000001", v4: "00000000", v5: "00000000", v6: "00000000", v7: "8000ad8a", v8: "00000000" }
125114// The next line declares the Function Type. We can actually erase it, VSCode PureScript Extension will helpfully suggest it for us.
126- var parseStackDump = /* #__PURE__ */ discard1 ( /* #__PURE__ */ $$void ( /* #__PURE__ */ applyFirst ( /* #__PURE__ */ StringParser_CodePoints . string ( "stack_dump:" ) ) ( StringParser_CodePoints . skipSpaces ) ) ) ( function ( ) {
127- return discard1 ( $$void ( StringParser_CodePoints . string ( "0x" ) ) ) ( function ( ) {
128- return bind ( applyFirst ( applyFirst ( StringParser_CodePoints . regex ( "[0-9a-f]+" ) ) ( StringParser_CodePoints . string ( ":" ) ) ) ( StringParser_CodePoints . skipSpaces ) ) ( function ( addr ) {
129- return bind ( applyFirst ( StringParser_CodePoints . regex ( "[0-9a-f]+" ) ) ( StringParser_CodePoints . skipSpaces ) ) ( function ( v1 ) {
130- return bind ( applyFirst ( StringParser_CodePoints . regex ( "[0-9a-f]+" ) ) ( StringParser_CodePoints . skipSpaces ) ) ( function ( v2 ) {
131- return bind ( applyFirst ( StringParser_CodePoints . regex ( "[0-9a-f]+" ) ) ( StringParser_CodePoints . skipSpaces ) ) ( function ( v3 ) {
132- return bind ( applyFirst ( StringParser_CodePoints . regex ( "[0-9a-f]+" ) ) ( StringParser_CodePoints . skipSpaces ) ) ( function ( v4 ) {
133- return bind ( applyFirst ( StringParser_CodePoints . regex ( "[0-9a-f]+" ) ) ( StringParser_CodePoints . skipSpaces ) ) ( function ( v5 ) {
134- return bind ( applyFirst ( StringParser_CodePoints . regex ( "[0-9a-f]+" ) ) ( StringParser_CodePoints . skipSpaces ) ) ( function ( v6 ) {
135- return bind ( applyFirst ( StringParser_CodePoints . regex ( "[0-9a-f]+" ) ) ( StringParser_CodePoints . skipSpaces ) ) ( function ( v7 ) {
136- return bind ( applyFirst ( StringParser_CodePoints . regex ( "[0-9a-f]+" ) ) ( StringParser_CodePoints . skipSpaces ) ) ( function ( v8 ) {
137- return pure ( {
138- addr : addr ,
139- v1 : v1 ,
140- v2 : v2 ,
141- v3 : v3 ,
142- v4 : v4 ,
143- v5 : v5 ,
144- v6 : v6 ,
145- v7 : v7 ,
146- v8 : v8
115+ var parseStackDump = /* #__PURE__ */ discard1 ( /* #__PURE__ */ StringParser_Combinators . optional ( /* #__PURE__ */ applyFirst ( /* #__PURE__ */ applyFirst ( /* #__PURE__ */ applyFirst ( /* #__PURE__ */ applyFirst ( /* #__PURE__ */ StringParser_CodePoints . string ( "[" ) ) ( StringParser_CodePoints . skipSpaces ) ) ( /* #__PURE__ */ StringParser_CodePoints . regex ( "[.0-9]+" ) ) ) ( /* #__PURE__ */ StringParser_CodePoints . string ( "]" ) ) ) ( StringParser_CodePoints . skipSpaces ) ) ) ( function ( ) {
116+ return discard1 ( $$void ( applyFirst ( StringParser_CodePoints . string ( "stack_dump:" ) ) ( StringParser_CodePoints . skipSpaces ) ) ) ( function ( ) {
117+ return discard1 ( $$void ( StringParser_CodePoints . string ( "0x" ) ) ) ( function ( ) {
118+ return bind ( applyFirst ( applyFirst ( StringParser_CodePoints . regex ( "[0-9a-f]+" ) ) ( StringParser_CodePoints . string ( ":" ) ) ) ( StringParser_CodePoints . skipSpaces ) ) ( function ( addr ) {
119+ return bind ( applyFirst ( StringParser_CodePoints . regex ( "[0-9a-f]+" ) ) ( StringParser_CodePoints . skipSpaces ) ) ( function ( v1 ) {
120+ return bind ( applyFirst ( StringParser_CodePoints . regex ( "[0-9a-f]+" ) ) ( StringParser_CodePoints . skipSpaces ) ) ( function ( v2 ) {
121+ return bind ( applyFirst ( StringParser_CodePoints . regex ( "[0-9a-f]+" ) ) ( StringParser_CodePoints . skipSpaces ) ) ( function ( v3 ) {
122+ return bind ( applyFirst ( StringParser_CodePoints . regex ( "[0-9a-f]+" ) ) ( StringParser_CodePoints . skipSpaces ) ) ( function ( v4 ) {
123+ return bind ( applyFirst ( StringParser_CodePoints . regex ( "[0-9a-f]+" ) ) ( StringParser_CodePoints . skipSpaces ) ) ( function ( v5 ) {
124+ return bind ( applyFirst ( StringParser_CodePoints . regex ( "[0-9a-f]+" ) ) ( StringParser_CodePoints . skipSpaces ) ) ( function ( v6 ) {
125+ return bind ( applyFirst ( StringParser_CodePoints . regex ( "[0-9a-f]+" ) ) ( StringParser_CodePoints . skipSpaces ) ) ( function ( v7 ) {
126+ return bind ( applyFirst ( StringParser_CodePoints . regex ( "[0-9a-f]+" ) ) ( StringParser_CodePoints . skipSpaces ) ) ( function ( v8 ) {
127+ return pure ( {
128+ addr : addr ,
129+ v1 : v1 ,
130+ v2 : v2 ,
131+ v3 : v3 ,
132+ v4 : v4 ,
133+ v5 : v5 ,
134+ v6 : v6 ,
135+ v7 : v7 ,
136+ v8 : v8
137+ } ) ;
147138 } ) ;
148139 } ) ;
149140 } ) ;
@@ -157,10 +148,6 @@ var parseStackDump = /* #__PURE__ */ discard1(/* #__PURE__ */ $$void(/* #__PURE_
157148 } ) ;
158149} ) ;
159150
160- // Parse the line of NuttX Stack Dump with Timestamp
161- // Result: { addr: "c02027e0", v1: "c0202010", v2: "00000000", v3: "00000001", v4: "00000000", v5: "00000000", v6: "00000000", v7: "8000ad8a", v8: "00000000" }
162- // doRunParser "parseStackDump" parseStackDump
163- // "[ 6.242000] stack_dump: 0xc02027e0: c0202010 00000000 00000001 00000000 00000000 00000000 8000ad8a 00000000"
164151// Parse the NuttX Exception.
165152// Given this NuttX Exception: `riscv_exception: EXCEPTION: Instruction page fault. MCAUSE: 000000000000000c, EPC: 000000008000ad8a, MTVAL: 000000008000ad8a`
166153// Result: { epc: "8000ad8a", exception: "Instruction page fault", mcause: 12, mtval: "8000ad8a" }
@@ -214,7 +201,7 @@ var identifyAddress = function (addr) {
214201 if ( Data_Boolean . otherwise ) {
215202 return Data_Maybe . Nothing . value ;
216203 } ;
217- throw new Error ( "Failed pattern match at Main (line 57, column 1 - line 57 , column 74 ): " + [ addr . constructor . name ] ) ;
204+ throw new Error ( "Failed pattern match at Main (line 57, column 1 - line 63 , column 6 ): " + [ addr . constructor . name ] ) ;
218205} ;
219206
220207// Given this NuttX Exception: `riscv_exception: EXCEPTION: Load page fault. MCAUSE: 000000000000000d, EPC: 000000008000a0e4, MTVAL: 0000000880203b88`
@@ -252,7 +239,7 @@ var doRunParser = function (dictShow) {
252239 if ( v instanceof Data_Either . Right ) {
253240 return Effect_Console . log ( "Result: " + show1 ( v . value0 ) ) ( ) ;
254241 } ;
255- throw new Error ( "Failed pattern match at Main (line 262 , column 3 - line 264 , column 52): " + [ v . constructor . name ] ) ;
242+ throw new Error ( "Failed pattern match at Main (line 282 , column 3 - line 284 , column 52): " + [ v . constructor . name ] ) ;
256243 } ) ( ) ;
257244 return Effect_Console . log ( "-----" ) ( ) ;
258245 } ;
@@ -327,7 +314,8 @@ var printResults = function __do() {
327314 logShow1 ( identifyAddress ( "8000a0e4" ) ) ( ) ;
328315 logShow1 ( identifyAddress ( "0000000800203b88" ) ) ( ) ;
329316 doRunParser1 ( "parseException" ) ( parseException ) ( "riscv_exception: EXCEPTION: Instruction page fault. MCAUSE: 000000000000000c, EPC: 000000008000ad8a, MTVAL: 000000008000ad8a" ) ( ) ;
330- return doRunParser2 ( "parseStackDump" ) ( parseStackDump ) ( "stack_dump: 0xc02027e0: c0202010 00000000 00000001 00000000 00000000 00000000 8000ad8a 00000000" ) ( ) ;
317+ doRunParser2 ( "parseStackDump" ) ( parseStackDump ) ( "stack_dump: 0xc02027e0: c0202010 00000000 00000001 00000000 00000000 00000000 8000ad8a 00000000" ) ( ) ;
318+ return doRunParser2 ( "parseStackDump" ) ( parseStackDump ) ( "[ 6.242000] stack_dump: 0xc02027e0: c0202010 00000000 00000001 00000000 00000000 00000000 8000ad8a 00000000" ) ( ) ;
331319} ;
332320
333321// Main Function that will run our Test Code.
0 commit comments