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
cab94922
Commit
cab94922
authored
Jul 09, 2008
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- completed parser - accepts full language (modulo bugs)
SVN=126551
parent
7b454bb1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
2 deletions
+63
-2
parser.go
usr/gri/src/parser.go
+63
-2
No files found.
usr/gri/src/parser.go
View file @
cab94922
...
...
@@ -692,6 +692,67 @@ func (P *Parser) ParseSwitchStat() {
}
func
(
P
*
Parser
)
ParseCommCase
()
{
P
.
Trace
(
"CommCase"
);
if
P
.
tok
==
Scanner
.
CASE
{
P
.
Next
();
if
P
.
tok
==
Scanner
.
GTR
{
// send
P
.
Next
();
P
.
ParseExpression
();
P
.
Expect
(
Scanner
.
EQL
);
P
.
ParseExpression
();
}
else
{
// receive
if
P
.
tok
!=
Scanner
.
LSS
{
P
.
ParseIdent
();
P
.
Expect
(
Scanner
.
ASSIGN
);
}
P
.
Expect
(
Scanner
.
LSS
);
P
.
ParseExpression
();
}
}
else
{
P
.
Expect
(
Scanner
.
DEFAULT
);
}
P
.
Expect
(
Scanner
.
COLON
);
P
.
Ecart
();
}
func
(
P
*
Parser
)
ParseCommClause
()
{
P
.
Trace
(
"CommClause"
);
P
.
ParseCommCase
();
if
P
.
tok
!=
Scanner
.
CASE
&&
P
.
tok
!=
Scanner
.
DEFAULT
&&
P
.
tok
!=
Scanner
.
RBRACE
{
P
.
ParseStatementList
();
P
.
Optional
(
Scanner
.
SEMICOLON
);
}
P
.
Ecart
();
}
func
(
P
*
Parser
)
ParseRangeStat
()
bool
{
P
.
Trace
(
"RangeStat"
);
P
.
Expect
(
Scanner
.
RANGE
);
P
.
ParseIdentList
();
P
.
Expect
(
Scanner
.
DEFINE
);
P
.
ParseExpression
();
P
.
ParseBlock
();
P
.
Ecart
();
}
func
(
P
*
Parser
)
ParseSelectStat
()
bool
{
P
.
Trace
(
"SelectStat"
);
P
.
Expect
(
Scanner
.
SELECT
);
P
.
Expect
(
Scanner
.
LBRACE
);
for
P
.
tok
!=
Scanner
.
RBRACE
{
P
.
ParseCommClause
();
}
P
.
Next
();
P
.
Ecart
();
}
func
(
P
*
Parser
)
TryStatement
()
bool
{
P
.
Trace
(
"Statement (try)"
);
switch
P
.
tok
{
...
...
@@ -724,9 +785,9 @@ func (P *Parser) TryStatement() bool {
case
Scanner
.
SWITCH
:
P
.
ParseSwitchStat
();
case
Scanner
.
RANGE
:
panic
"range statement"
;
P
.
ParseRangeStat
()
;
case
Scanner
.
SELECT
:
panic
"select statement"
;
P
.
ParseSelectStat
()
;
default
:
// no statement found
P
.
Ecart
();
...
...
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