FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
assemblyscript/tests/tokenizer.js at dcodeIO-patch-1 · deep-stack/assemblyscript · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
deep-stack
/
assemblyscript
Public
forked from
cerc-io/assemblyscript
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
assemblyscript
/
tests
/
tokenizer.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
33 lines (29 loc) · 1.24 KB
Breadcrumbs
assemblyscript
/
tests
/
tokenizer.js
Copy path
File metadata and controls
33 lines (29 loc) · 1.24 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const
fs
=
require
(
"fs"
)
;
const
path
=
require
(
"path"
)
;
require
(
"ts-node"
)
.
register
(
{
project
:
path
.
join
(
__dirname
,
".."
,
"src"
,
"tsconfig.json"
)
}
)
;
require
(
"../src/glue/js"
)
;
const
{
Tokenizer
,
Token
}
=
require
(
"../src/tokenizer"
)
;
const
{
Source
,
SourceKind
}
=
require
(
"../src/ast"
)
;
var
file
=
process
.
argv
.
length
>
2
?
process
.
argv
[
2
]
:
path
.
join
(
__dirname
,
".."
,
"src"
,
"tokenizer.ts"
)
;
const
text
=
fs
.
readFileSync
(
file
)
.
toString
(
)
;
const
tn
=
new
Tokenizer
(
new
Source
(
"compiler.ts"
,
text
,
SourceKind
.
ENTRY
)
)
;
do
{
let
token
=
tn
.
next
(
)
;
let
range
=
tn
.
range
(
)
;
process
.
stdout
.
write
(
Token
[
token
]
+
" @ "
+
range
.
line
+
":"
+
range
.
column
)
;
if
(
token
==
Token
.
IDENTIFIER
)
{
process
.
stdout
.
write
(
" > "
+
tn
.
readIdentifier
(
)
)
;
}
else
if
(
token
==
Token
.
INTEGERLITERAL
)
{
process
.
stdout
.
write
(
" > "
+
tn
.
readInteger
(
)
)
;
}
else
if
(
token
==
Token
.
FLOATLITERAL
)
{
process
.
stdout
.
write
(
" > "
+
tn
.
readFloat
(
)
)
;
}
else
if
(
token
==
Token
.
STRINGLITERAL
)
{
process
.
stdout
.
write
(
" > "
+
tn
.
readString
(
)
)
;
}
else
if
(
token
==
Token
.
ENDOFFILE
)
{
process
.
stdout
.
write
(
"\n"
)
;
break
;
}
else
{
process
.
stdout
.
write
(
" > "
+
range
.
source
.
text
.
substring
(
range
.
start
,
range
.
end
)
)
;
}
process
.
stdout
.
write
(
"\n"
)
;
}
while
(
true
)
;
Back
|
FazBrowse Home
|
New Git URL