Mercurial > repos > rhope
diff countstring.rhope @ 131:0a4682be2db2
Modify lexer and new parser to work in compiler
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 05 Nov 2010 02:43:34 +0000 |
parents | 73e978d590c7 |
children |
line wrap: on
line diff
--- a/countstring.rhope Fri Nov 05 02:42:45 2010 +0000 +++ b/countstring.rhope Fri Nov 05 02:43:34 2010 +0000 @@ -13,7 +13,7 @@ Count String At Pos[text,line,col:out] { - out <- [[[Build["Count String"]]Text <<[text]]Line <<[line]]Column <<[col] + out <- [[[Build[Count String()]]Text <<[text]]Line <<[line]]Column <<[col] } Slice@Count String[string,index:left,right] @@ -45,11 +45,21 @@ out <- Length[[string]Text >>] } +Byte Length@Count String[string:out] +{ + out <- Byte Length[[string]Text >>] +} + +Byte@Count String[string,index:out,invalid] +{ + out,invalid <- Byte[[string]Text >>, index] +} + Append@Count String[left,right:out] { If[[[left]Length] > [0]] { - out <- [left]Text << [ [To String[left]]Append[To String[right]] ] + out <- [left]Text << [ [String[left]]Append[String[right]] ] }{ out <- right } @@ -57,13 +67,44 @@ =@Count String[left,right:out] { - out <- [To String[left]] = [To String[right]] + out <- [String[left]] = [String[right]] +} + +_Slice=@Count String[left,right:out] +{ + out <- _Slice=[String[left], String[right]] +} + +_Flat=@Count String[left,right:out] +{ + out <- _Flat=[String[left], String[right]] +} + +_Flatten@Count String[string,dest,offset,count:out] +{ + out <- _Flatten[[string]Text >>, dest, offset, count] } -Get DString@Count String[string, delims:after,before,delim,nomatch] +/*Partition@Count String[string, delims:before,delim,after,nomatch] { - ,,delim,nomatch <- [[string]Text >>]Get DString[delims] + ,delim,,nomatch <- [[string]Text >>]Partition[delims] { + before <- [string]Text <<[~] + bparts <- [~]Split["\n"] + preblines <- [[bparts]Length] - [1] + If[[preblines] > [-1]] + { + blines <- Val[preblines] + bcols <- Length[[bparts]Index[blines]] + }{ + bcols <- 0 + blines <- 0 + } + }{ + dparts <- [~]Split["\n"] + dlines <- [[dparts]Length]-[1] + dcols <- Length[[dparts]Index[dlines]] + }{ If[[dlines] > [0]] { cols <- Val[dcols] @@ -76,26 +117,10 @@ } } after <- Count String At Pos[~, [[blines]+[dlines]] + [[string]Line >>], cols] - }{ - before <- [string]Text <<[~] - bparts <- [~]Split["\n"] - preblines <- [[bparts]Length] - [1] - If[[preblines] > [-1]] - { - blines <- Val[preblines] - bcols <- Length[[bparts]Index[blines]] - }{ - bcols <- 0 - blines <- 0 - } - }{ - dparts <- [~]Split["\n"] - dlines <- [[dparts]Length] - [1] - dcols <- Length[[dparts]Index[dlines]] } -} +}*/ -To String@Count String[string:out] +String@Count String[string:out] { out <- [string]Text >> } @@ -104,3 +129,4 @@ { out <- Count String[""] } +