Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SableCC STUPS
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
general
stups
SableCC STUPS
Commits
392709d7
Commit
392709d7
authored
1 year ago
by
dgelessus
Browse files
Options
Downloads
Patches
Plain Diff
Prepare sharing code between cases of generated Lexer accept switch
parent
14cdedba
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/org/sablecc/sablecc/lexer/Lexer.java
+124
-160
124 additions, 160 deletions
src/main/java/org/sablecc/sablecc/lexer/Lexer.java
src/main/resources/org/sablecc/sablecc/lexer.txt
+8
-6
8 additions, 6 deletions
src/main/resources/org/sablecc/sablecc/lexer.txt
with
132 additions
and
166 deletions
src/main/java/org/sablecc/sablecc/lexer/Lexer.java
+
124
−
160
View file @
392709d7
...
@@ -174,11 +174,11 @@ public class Lexer
...
@@ -174,11 +174,11 @@ public class Lexer
{
{
if
(
acceptState
!=
-
1
)
if
(
acceptState
!=
-
1
)
{
{
Token
tok
;
switch
(
acceptToken
)
switch
(
acceptToken
)
{
{
case
0
:
case
0
:
{
tok
=
new
TPkgId
(
getText
(
acceptLength
),
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TPkgId
(
getText
(
acceptLength
),
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
...
@@ -187,11 +187,10 @@ public class Lexer
...
@@ -187,11 +187,10 @@ public class Lexer
{
{
case
1
:
state
=
State
.
PACKAGE
;
break
;
case
1
:
state
=
State
.
PACKAGE
;
break
;
}
}
re
turn
to
k
;
b
re
a
k
;
}
case
1
:
case
1
:
{
tok
=
new
TPackage
(
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TPackage
(
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
...
@@ -200,137 +199,122 @@ public class Lexer
...
@@ -200,137 +199,122 @@ public class Lexer
{
{
case
0
:
state
=
State
.
PACKAGE
;
break
;
case
0
:
state
=
State
.
PACKAGE
;
break
;
}
}
re
turn
to
k
;
b
re
a
k
;
}
case
2
:
case
2
:
{
tok
=
new
TStates
(
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TStates
(
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
3
:
case
3
:
{
tok
=
new
THelpers
(
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
THelpers
(
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
4
:
case
4
:
{
tok
=
new
TTokens
(
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TTokens
(
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
5
:
case
5
:
{
tok
=
new
TIgnored
(
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TIgnored
(
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
6
:
case
6
:
{
tok
=
new
TProductions
(
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TProductions
(
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
7
:
case
7
:
{
tok
=
new
TAbstract
(
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TAbstract
(
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
8
:
case
8
:
{
tok
=
new
TSyntax
(
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TSyntax
(
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
9
:
case
9
:
{
tok
=
new
TTree
(
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TTree
(
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
10
:
case
10
:
{
tok
=
new
TNew
(
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TNew
(
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
11
:
case
11
:
{
tok
=
new
TNull
(
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TNull
(
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
12
:
case
12
:
{
tok
=
new
TTokenSpecifier
(
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TTokenSpecifier
(
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
13
:
case
13
:
{
tok
=
new
TProductionSpecifier
(
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TProductionSpecifier
(
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
14
:
case
14
:
{
tok
=
new
TDot
(
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TDot
(
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
15
:
case
15
:
{
tok
=
new
TDDot
(
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TDDot
(
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
16
:
case
16
:
{
tok
=
new
TSemicolon
(
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TSemicolon
(
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
...
@@ -340,216 +324,196 @@ public class Lexer
...
@@ -340,216 +324,196 @@ public class Lexer
case
0
:
state
=
State
.
NORMAL
;
break
;
case
0
:
state
=
State
.
NORMAL
;
break
;
case
1
:
state
=
State
.
NORMAL
;
break
;
case
1
:
state
=
State
.
NORMAL
;
break
;
}
}
re
turn
to
k
;
b
re
a
k
;
}
case
17
:
case
17
:
{
tok
=
new
TEqual
(
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TEqual
(
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
18
:
case
18
:
{
tok
=
new
TLBkt
(
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TLBkt
(
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
19
:
case
19
:
{
tok
=
new
TRBkt
(
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TRBkt
(
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
20
:
case
20
:
{
tok
=
new
TLPar
(
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TLPar
(
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
21
:
case
21
:
{
tok
=
new
TRPar
(
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TRPar
(
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
22
:
case
22
:
{
tok
=
new
TLBrace
(
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TLBrace
(
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
23
:
case
23
:
{
tok
=
new
TRBrace
(
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TRBrace
(
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
24
:
case
24
:
{
tok
=
new
TPlus
(
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TPlus
(
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
25
:
case
25
:
{
tok
=
new
TMinus
(
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TMinus
(
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
26
:
case
26
:
{
tok
=
new
TQMark
(
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TQMark
(
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
27
:
case
27
:
{
tok
=
new
TStar
(
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TStar
(
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
28
:
case
28
:
{
tok
=
new
TBar
(
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TBar
(
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
29
:
case
29
:
{
tok
=
new
TComma
(
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TComma
(
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
30
:
case
30
:
{
tok
=
new
TSlash
(
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TSlash
(
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
31
:
case
31
:
{
tok
=
new
TArrow
(
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TArrow
(
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
32
:
case
32
:
{
tok
=
new
TColon
(
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TColon
(
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
33
:
case
33
:
{
tok
=
new
TId
(
getText
(
acceptLength
),
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TId
(
getText
(
acceptLength
),
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
34
:
case
34
:
{
tok
=
new
TChar
(
getText
(
acceptLength
),
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TChar
(
getText
(
acceptLength
),
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
35
:
case
35
:
{
tok
=
new
TDecChar
(
getText
(
acceptLength
),
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TDecChar
(
getText
(
acceptLength
),
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
36
:
case
36
:
{
tok
=
new
THexChar
(
getText
(
acceptLength
),
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
THexChar
(
getText
(
acceptLength
),
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
37
:
case
37
:
{
tok
=
new
TString
(
getText
(
acceptLength
),
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TString
(
getText
(
acceptLength
),
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
38
:
case
38
:
{
tok
=
new
TBlank
(
getText
(
acceptLength
),
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TBlank
(
getText
(
acceptLength
),
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
re
turn
to
k
;
b
re
a
k
;
}
case
39
:
case
39
:
{
tok
=
new
TComment
(
getText
(
acceptLength
),
startLine
+
1
,
startPos
+
1
);
Token
tok
=
new
TComment
(
getText
(
acceptLength
),
startLine
+
1
,
startPos
+
1
);
pushBack
(
acceptLength
);
pushBack
(
acceptLength
);
this
.
pos
=
acceptPos
;
this
.
pos
=
acceptPos
;
this
.
line
=
acceptLine
;
this
.
line
=
acceptLine
;
this
.
cr
=
acceptCr
;
this
.
cr
=
acceptCr
;
return
tok
;
break
;
}
default
:
throw
new
LexerException
(
"["
+
(
startLine
+
1
)
+
","
+
(
startPos
+
1
)
+
"] Internal lexer error: invalid accept table entry "
+
acceptToken
+
", current text: "
+
this
.
text
);
}
}
return
tok
;
}
}
else
else
{
{
...
...
This diff is collapsed.
Click to expand it.
src/main/resources/org/sablecc/sablecc/lexer.txt
+
8
−
6
View file @
392709d7
...
@@ -198,6 +198,7 @@ public class Lexer
...
@@ -198,6 +198,7 @@ public class Lexer
{
{
if(acceptState != -1)
if(acceptState != -1)
{
{
Token tok;
switch(acceptToken)
switch(acceptToken)
{
{
...
@@ -205,8 +206,7 @@ $
...
@@ -205,8 +206,7 @@ $
Macro:LexerVariableToken
Macro:LexerVariableToken
case $0$:
case $0$:
{
tok = new $1$(getText(acceptLength), startLine + 1, startPos + 1);
Token tok = new $1$(getText(acceptLength), startLine + 1, startPos + 1);
pushBack(acceptLength);
pushBack(acceptLength);
this.pos = acceptPos;
this.pos = acceptPos;
this.line = acceptLine;
this.line = acceptLine;
...
@@ -216,8 +216,7 @@ $
...
@@ -216,8 +216,7 @@ $
Macro:LexerFixedToken
Macro:LexerFixedToken
case $0$:
case $0$:
{
tok = new $1$(startLine + 1, startPos + 1);
Token tok = new $1$(startLine + 1, startPos + 1);
pushBack(acceptLength);
pushBack(acceptLength);
this.pos = acceptPos;
this.pos = acceptPos;
this.line = acceptLine;
this.line = acceptLine;
...
@@ -242,13 +241,16 @@ Macro:TokenSwitchTail
...
@@ -242,13 +241,16 @@ Macro:TokenSwitchTail
$
$
Macro:LexerTokenTail
Macro:LexerTokenTail
re
turn to
k;
b
re
a
k;
}
$
$
Macro:LexerBody
Macro:LexerBody
default:
throw new LexerException("[" + (startLine + 1) + "," + (startPos + 1) + "] Internal lexer error: invalid accept table entry " + acceptToken + ", current text: " + this.text);
}
}
return tok;
}
}
else
else
{
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment