Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
33069d39
Commit
33069d39
authored
Jul 09, 2008
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- fixed scanner and parser issues to be able to parse math lib
SVN=126501
parent
77e20e8c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
14 deletions
+25
-14
usr/gri/src/parser.go
usr/gri/src/parser.go
+17
-11
usr/gri/src/scanner.go
usr/gri/src/scanner.go
+8
-3
No files found.
usr/gri/src/parser.go
View file @
33069d39
...
@@ -262,12 +262,12 @@ func (P *Parser) ParseImportDecl() {
...
@@ -262,12 +262,12 @@ func (P *Parser) ParseImportDecl() {
P
.
Trace
(
"ImportDecl"
);
P
.
Trace
(
"ImportDecl"
);
P
.
Expect
(
Scanner
.
IMPORT
);
P
.
Expect
(
Scanner
.
IMPORT
);
if
P
.
tok
==
Scanner
.
LPAREN
{
if
P
.
tok
==
Scanner
.
LPAREN
{
P
.
ParseImportSpec
();
P
.
Next
();
for
P
.
tok
==
Scanner
.
SEMICOLON
{
for
P
.
tok
!=
Scanner
.
RPAREN
{
P
.
Next
();
P
.
ParseImportSpec
();
P
.
ParseImportSpec
();
P
.
Optional
(
Scanner
.
SEMICOLON
);
// TODO this seems wrong
}
}
P
.
Optional
(
Scanner
.
SEMICOLON
);
P
.
Next
(
);
}
else
{
}
else
{
P
.
ParseImportSpec
();
P
.
ParseImportSpec
();
}
}
...
@@ -738,12 +738,20 @@ func (P *Parser) ParseFuncDecl() {
...
@@ -738,12 +738,20 @@ func (P *Parser) ParseFuncDecl() {
func
(
P
*
Parser
)
ParseExportDecl
()
{
func
(
P
*
Parser
)
ParseExportDecl
()
{
P
.
Trace
(
"ExportDecl"
);
P
.
Trace
(
"ExportDecl"
);
P
.
Expect
(
Scanner
.
EXPORT
);
P
.
Expect
(
Scanner
.
EXPORT
);
P
.
ParseIdent
();
if
P
.
tok
==
Scanner
.
LPAREN
{
for
P
.
tok
==
Scanner
.
COMMA
{
P
.
Next
();
for
P
.
tok
!=
Scanner
.
RPAREN
{
P
.
ParseIdent
();
P
.
Optional
(
Scanner
.
COMMA
);
// TODO this seems wrong
}
P
.
Next
();
P
.
Next
();
}
else
{
P
.
ParseIdent
();
P
.
ParseIdent
();
for
P
.
tok
==
Scanner
.
COMMA
{
P
.
Next
();
P
.
ParseIdent
();
}
}
}
P
.
Optional
(
Scanner
.
COMMA
);
P
.
Ecart
();
P
.
Ecart
();
}
}
...
@@ -787,14 +795,12 @@ func (P *Parser) ParseOperand() {
...
@@ -787,14 +795,12 @@ func (P *Parser) ParseOperand() {
switch
P
.
tok
{
switch
P
.
tok
{
case
Scanner
.
IDENT
:
case
Scanner
.
IDENT
:
P
.
ParseQualifiedIdent
();
P
.
ParseQualifiedIdent
();
case
Scanner
.
STRING
:
fallthrough
;
case
Scanner
.
NUMBER
:
P
.
Next
();
case
Scanner
.
LPAREN
:
case
Scanner
.
LPAREN
:
P
.
Next
();
P
.
Next
();
P
.
ParseExpression
();
P
.
ParseExpression
();
P
.
Expect
(
Scanner
.
RPAREN
);
P
.
Expect
(
Scanner
.
RPAREN
);
case
Scanner
.
STRING
:
fallthrough
;
case
Scanner
.
NUMBER
:
fallthrough
;
case
Scanner
.
NIL
:
fallthrough
;
case
Scanner
.
NIL
:
fallthrough
;
case
Scanner
.
IOTA
:
fallthrough
;
case
Scanner
.
IOTA
:
fallthrough
;
case
Scanner
.
TRUE
:
fallthrough
;
case
Scanner
.
TRUE
:
fallthrough
;
...
...
usr/gri/src/scanner.go
View file @
33069d39
...
@@ -458,20 +458,25 @@ func (S *Scanner) ScanNumber (seen_decimal_point bool) int {
...
@@ -458,20 +458,25 @@ func (S *Scanner) ScanNumber (seen_decimal_point bool) int {
}
}
if
S
.
ch
==
'0'
{
if
S
.
ch
==
'0'
{
// TODO bug: doesn't accept 09.0 !
// int or float
// int
S
.
Next
();
S
.
Next
();
if
S
.
ch
==
'x'
||
S
.
ch
==
'X'
{
if
S
.
ch
==
'x'
||
S
.
ch
==
'X'
{
// hexadecimal int
// hexadecimal int
S
.
Next
();
S
.
Next
();
S
.
ScanMantissa
(
16
);
S
.
ScanMantissa
(
16
);
}
else
{
}
else
{
// octal int
// octal int
or float
S
.
ScanMantissa
(
8
);
S
.
ScanMantissa
(
8
);
if
digit_val
(
S
.
ch
)
<
10
||
S
.
ch
==
'.'
||
S
.
ch
==
'e'
||
S
.
ch
==
'E'
{
// float
goto
mantissa
;
}
// octal int
}
}
return
NUMBER
;
return
NUMBER
;
}
}
mantissa
:
// decimal int or float
// decimal int or float
S
.
ScanMantissa
(
10
);
S
.
ScanMantissa
(
10
);
...
...
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