Skip to content

Instantly share code, notes, and snippets.

@joebo
Last active January 3, 2016 05:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joebo/61e0841fbf511e1aab4d to your computer and use it in GitHub Desktop.
Save joebo/61e0841fbf511e1aab4d to your computer and use it in GitHub Desktop.
ChrCls=: '#;';(' ',TAB);LF;a.-.'#; ',TAB,LF
NB. comment, space, line, other
tokens=: (0;(0 10#:10*".;._2]0 :0);<ChrCls)&;:
1.0 0.0 0.0 2.1 NB. 0: skip whitespace (start here)
1.0 1.0 0.0 1.0 NB. 1: comment
3.3 4.3 5.2 2.0 NB. 2: word
3.0 3.0 5.1 3.0 NB. 3: comment after word
3.0 4.0 5.1 2.1 NB. 4: space after word
1.3 0.3 0.3 2.1 NB. 5: line end after word
)
readConf=: ({.,<@(;:inv)@}.);._2@tokens@fread
go=: 3 : 0
readConf 'c:\temp\test.conf'
)
goTime=: 3 : 0
10000 (6!:2) 'go '''' '
exit''
)
parse=:deb L:0@:(({.~ ; [: < [: ;^:(1=#) ',' cut (}.~>:)) i.&1@:e.&' =')&>@(#~a:&~: > ';#'e.~{.&>)@:(dlb&.>)@:(LF&cut)
go2=: 3 : 0
readConf 'c:\temp\test.conf'
)
go2Time=: 3 : 0
10000 (6!:2) 'go2 '''' '
exit''
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment