Mercurial > repos > rhope
comparison 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 |
comparison
equal
deleted
inserted
replaced
130:147dfc703161 | 131:0a4682be2db2 |
---|---|
11 out <- Count String At Pos[text, 0, 0] | 11 out <- Count String At Pos[text, 0, 0] |
12 } | 12 } |
13 | 13 |
14 Count String At Pos[text,line,col:out] | 14 Count String At Pos[text,line,col:out] |
15 { | 15 { |
16 out <- [[[Build["Count String"]]Text <<[text]]Line <<[line]]Column <<[col] | 16 out <- [[[Build[Count String()]]Text <<[text]]Line <<[line]]Column <<[col] |
17 } | 17 } |
18 | 18 |
19 Slice@Count String[string,index:left,right] | 19 Slice@Count String[string,index:left,right] |
20 { | 20 { |
21 | 21 |
43 Length@Count String[string:out] | 43 Length@Count String[string:out] |
44 { | 44 { |
45 out <- Length[[string]Text >>] | 45 out <- Length[[string]Text >>] |
46 } | 46 } |
47 | 47 |
48 Byte Length@Count String[string:out] | |
49 { | |
50 out <- Byte Length[[string]Text >>] | |
51 } | |
52 | |
53 Byte@Count String[string,index:out,invalid] | |
54 { | |
55 out,invalid <- Byte[[string]Text >>, index] | |
56 } | |
57 | |
48 Append@Count String[left,right:out] | 58 Append@Count String[left,right:out] |
49 { | 59 { |
50 If[[[left]Length] > [0]] | 60 If[[[left]Length] > [0]] |
51 { | 61 { |
52 out <- [left]Text << [ [To String[left]]Append[To String[right]] ] | 62 out <- [left]Text << [ [String[left]]Append[String[right]] ] |
53 }{ | 63 }{ |
54 out <- right | 64 out <- right |
55 } | 65 } |
56 } | 66 } |
57 | 67 |
58 =@Count String[left,right:out] | 68 =@Count String[left,right:out] |
59 { | 69 { |
60 out <- [To String[left]] = [To String[right]] | 70 out <- [String[left]] = [String[right]] |
61 } | 71 } |
62 | 72 |
63 Get DString@Count String[string, delims:after,before,delim,nomatch] | 73 _Slice=@Count String[left,right:out] |
64 { | 74 { |
65 ,,delim,nomatch <- [[string]Text >>]Get DString[delims] | 75 out <- _Slice=[String[left], String[right]] |
76 } | |
77 | |
78 _Flat=@Count String[left,right:out] | |
79 { | |
80 out <- _Flat=[String[left], String[right]] | |
81 } | |
82 | |
83 _Flatten@Count String[string,dest,offset,count:out] | |
84 { | |
85 out <- _Flatten[[string]Text >>, dest, offset, count] | |
86 } | |
87 | |
88 /*Partition@Count String[string, delims:before,delim,after,nomatch] | |
89 { | |
90 ,delim,,nomatch <- [[string]Text >>]Partition[delims] | |
66 { | 91 { |
92 before <- [string]Text <<[~] | |
93 bparts <- [~]Split["\n"] | |
94 preblines <- [[bparts]Length] - [1] | |
95 If[[preblines] > [-1]] | |
96 { | |
97 blines <- Val[preblines] | |
98 bcols <- Length[[bparts]Index[blines]] | |
99 }{ | |
100 bcols <- 0 | |
101 blines <- 0 | |
102 } | |
103 }{ | |
104 dparts <- [~]Split["\n"] | |
105 dlines <- [[dparts]Length]-[1] | |
106 dcols <- Length[[dparts]Index[dlines]] | |
107 }{ | |
67 If[[dlines] > [0]] | 108 If[[dlines] > [0]] |
68 { | 109 { |
69 cols <- Val[dcols] | 110 cols <- Val[dcols] |
70 }{ | 111 }{ |
71 If[[blines] > [0]] | 112 If[[blines] > [0]] |
74 }{ | 115 }{ |
75 cols <- [[bcols] + [dcols]] + [[string]Column >>] | 116 cols <- [[bcols] + [dcols]] + [[string]Column >>] |
76 } | 117 } |
77 } | 118 } |
78 after <- Count String At Pos[~, [[blines]+[dlines]] + [[string]Line >>], cols] | 119 after <- Count String At Pos[~, [[blines]+[dlines]] + [[string]Line >>], cols] |
79 }{ | |
80 before <- [string]Text <<[~] | |
81 bparts <- [~]Split["\n"] | |
82 preblines <- [[bparts]Length] - [1] | |
83 If[[preblines] > [-1]] | |
84 { | |
85 blines <- Val[preblines] | |
86 bcols <- Length[[bparts]Index[blines]] | |
87 }{ | |
88 bcols <- 0 | |
89 blines <- 0 | |
90 } | |
91 }{ | |
92 dparts <- [~]Split["\n"] | |
93 dlines <- [[dparts]Length] - [1] | |
94 dcols <- Length[[dparts]Index[dlines]] | |
95 } | 120 } |
96 } | 121 }*/ |
97 | 122 |
98 To String@Count String[string:out] | 123 String@Count String[string:out] |
99 { | 124 { |
100 out <- [string]Text >> | 125 out <- [string]Text >> |
101 } | 126 } |
102 | 127 |
103 Empty@Count String[string:out] | 128 Empty@Count String[string:out] |
104 { | 129 { |
105 out <- Count String[""] | 130 out <- Count String[""] |
106 } | 131 } |
132 |