Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
801f542b
Commit
801f542b
authored
Oct 16, 2008
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove hack now that vector of int works.
R=rsc DELTA=9 (0 added, 3 deleted, 6 changed) OCL=17248 CL=17250
parent
8973e1ff
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
9 deletions
+6
-9
regexp.go
src/lib/regexp/regexp.go
+6
-9
No files found.
src/lib/regexp/regexp.go
View file @
801f542b
...
...
@@ -134,14 +134,12 @@ func NewChar(char int) *Char {
// --- CHARCLASS [a-z]
type
CClassChar
int
;
// BUG: Shouldn't be necessary but 6g won't put ints into vectors
type
CharClass
struct
{
next
Inst
;
index
int
;
char
int
;
negate
bool
;
// is character class negated? ([^a-z])
// Vector of
CClassChar
, stored pairwise: [a-z] is (a,z); x is (x,x):
// Vector of
int
, stored pairwise: [a-z] is (a,z); x is (x,x):
ranges
*
vector
.
Vector
;
}
...
...
@@ -156,8 +154,8 @@ func (cclass *CharClass) Print() {
print
(
" (negated)"
);
}
for
i
:=
0
;
i
<
cclass
.
ranges
.
Len
();
i
+=
2
{
l
:=
cclass
.
ranges
.
At
(
i
)
.
(
CClassChar
);
r
:=
cclass
.
ranges
.
At
(
i
+
1
)
.
(
CClassChar
);
l
:=
cclass
.
ranges
.
At
(
i
)
.
(
int
);
r
:=
cclass
.
ranges
.
At
(
i
+
1
)
.
(
int
);
if
l
==
r
{
print
(
" ["
,
string
(
l
),
"]"
);
}
else
{
...
...
@@ -166,7 +164,7 @@ func (cclass *CharClass) Print() {
}
}
func
(
cclass
*
CharClass
)
AddRange
(
a
,
b
CClassChar
)
{
func
(
cclass
*
CharClass
)
AddRange
(
a
,
b
int
)
{
// range is a through b inclusive
cclass
.
ranges
.
Append
(
a
);
cclass
.
ranges
.
Append
(
b
);
...
...
@@ -174,8 +172,8 @@ func (cclass *CharClass) AddRange(a, b CClassChar) {
func
(
cclass
*
CharClass
)
Matches
(
c
int
)
bool
{
for
i
:=
0
;
i
<
cclass
.
ranges
.
Len
();
i
=
i
+
2
{
min
:=
cclass
.
ranges
.
At
(
i
)
.
(
CClassChar
);
max
:=
cclass
.
ranges
.
At
(
i
+
1
)
.
(
CClassChar
);
min
:=
cclass
.
ranges
.
At
(
i
)
.
(
int
);
max
:=
cclass
.
ranges
.
At
(
i
+
1
)
.
(
int
);
if
min
<=
c
&&
c
<=
max
{
return
!
cclass
.
negate
}
...
...
@@ -323,7 +321,6 @@ Grammar:
func
(
p
*
Parser
)
Regexp
()
(
start
,
end
Inst
)
var
NULL
Inst
type
BUGinter
interface
{}
func
special
(
c
int
)
bool
{
s
:=
`\.+*?()|[]`
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment