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
b6d0a22d
Commit
b6d0a22d
authored
Nov 05, 2009
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gofmt-ify ebnf
R=r
http://go/go-review/1018050
parent
646a2c5a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
29 deletions
+29
-29
ebnf.go
src/pkg/ebnf/ebnf.go
+26
-26
ebnf_test.go
src/pkg/ebnf/ebnf_test.go
+3
-3
No files found.
src/pkg/ebnf/ebnf.go
View file @
b6d0a22d
...
...
@@ -37,72 +37,72 @@ import (
type
(
// An Expression node represents a production expression.
Expression
interface
{
// Pos is the position of the first character of the syntactic construct
Pos
()
token
.
Position
;
Expression
interface
{
// Pos is the position of the first character of the syntactic construct
Pos
()
token
.
Position
;
};
// An Alternative node represents a non-empty list of alternative expressions.
Alternative
[]
Expression
;
// x | y | z
Alternative
[]
Expression
;
// x | y | z
// A Sequence node represents a non-empty list of sequential expressions.
Sequence
[]
Expression
;
// x y z
Sequence
[]
Expression
;
// x y z
// A Name node represents a production name.
Name
struct
{
Name
struct
{
token
.
Position
;
String
string
;
String
string
;
};
// A Token node represents a literal.
Token
struct
{
Token
struct
{
token
.
Position
;
String
string
;
String
string
;
};
// A List node represents a range of characters.
Range
struct
{
Begin
,
End
*
Token
;
// begin ... end
Range
struct
{
Begin
,
End
*
Token
;
// begin ... end
};
// A Group node represents a grouped expression.
Group
struct
{
Group
struct
{
token
.
Position
;
Body
Expression
;
// (body)
Body
Expression
;
// (body)
};
// An Option node represents an optional expression.
Option
struct
{
Option
struct
{
token
.
Position
;
Body
Expression
;
// [body]
Body
Expression
;
// [body]
};
// A Repetition node represents a repeated expression.
Repetition
struct
{
Repetition
struct
{
token
.
Position
;
Body
Expression
;
// {body}
Body
Expression
;
// {body}
};
// A Production node represents an EBNF production.
Production
struct
{
Name
*
Name
;
Expr
Expression
;
Production
struct
{
Name
*
Name
;
Expr
Expression
;
};
// A Grammar is a set of EBNF productions. The map
// is indexed by production name.
//
Grammar
map
[
string
]
*
Production
;
Grammar
map
[
string
]
*
Production
;
)
func
(
x
Alternative
)
Pos
()
token
.
Position
{
return
x
[
0
]
.
Pos
();
// the parser always generates non-empty Alternative
return
x
[
0
]
.
Pos
();
// the parser always generates non-empty Alternative
}
func
(
x
Sequence
)
Pos
()
token
.
Position
{
return
x
[
0
]
.
Pos
();
// the parser always generates non-empty Sequences
return
x
[
0
]
.
Pos
();
// the parser always generates non-empty Sequences
}
...
...
@@ -127,9 +127,9 @@ func isLexical(name string) bool {
type
verifier
struct
{
scanner
.
ErrorVector
;
worklist
vector
.
Vector
;
reached
Grammar
;
// set of productions reached from (and including) the root production
grammar
Grammar
;
worklist
vector
.
Vector
;
reached
Grammar
;
// set of productions reached from (and including) the root production
grammar
Grammar
;
}
...
...
src/pkg/ebnf/ebnf_test.go
View file @
b6d0a22d
...
...
@@ -11,7 +11,7 @@ import (
)
var
grammars
=
[]
string
{
var
grammars
=
[]
string
{
`Program = .
`
,
...
...
@@ -58,8 +58,8 @@ func TestGrammars(t *testing.T) {
}
var
files
=
[]
string
{
// TODO(gri) add some test files
var
files
=
[]
string
{
// TODO(gri) add some test files
}
...
...
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