Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sv2v
Overview
Overview
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
sv2v
Commits
317994ed
Commit
317994ed
authored
Mar 30, 2019
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
faster lexing by storing tokens in reverse order
parent
b45217ba
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
src/Language/SystemVerilog/Parser/Lex.x
+3
-3
No files found.
src/Language/SystemVerilog/Parser/Lex.x
View file @
317994ed
...
@@ -314,7 +314,7 @@ data Cond
...
@@ -314,7 +314,7 @@ data Cond
-- our custom lexer state
-- our custom lexer state
data AlexUserState = LS
data AlexUserState = LS
{ lsToks :: [Token] -- tokens read so far
{ lsToks :: [Token] -- tokens read so far
, *in reverse order* for efficiency
, lsCurrFile :: FilePath -- currently active filename
, lsCurrFile :: FilePath -- currently active filename
, lsEnv :: Map.Map String (String, [String]) -- active macro definitions
, lsEnv :: Map.Map String (String, [String]) -- active macro definitions
, lsCondStack :: [Cond] -- if-else cascade state
, lsCondStack :: [Cond] -- if-else cascade state
...
@@ -336,7 +336,7 @@ lexFile includePaths env path = do
...
@@ -336,7 +336,7 @@ lexFile includePaths env path = do
Left msg -> error $ "Lexical Error: " ++ msg
Left msg -> error $ "Lexical Error: " ++ msg
Right finalState ->
Right finalState ->
if null $ lsCondStack finalState
if null $ lsCondStack finalState
then lsToks finalState
then
reverse $
lsToks finalState
else error $ "unfinished conditional directives: " ++
else error $ "unfinished conditional directives: " ++
(show $ length $ lsCondStack finalState)
(show $ length $ lsCondStack finalState)
where
where
...
@@ -749,7 +749,7 @@ removeUntil pattern _ _ = loop
...
@@ -749,7 +749,7 @@ removeUntil pattern _ _ = loop
else loop
else loop
push :: Token -> AlexUserState -> AlexUserState
push :: Token -> AlexUserState -> AlexUserState
push t s = s { lsToks =
(lsToks s) ++ [t]
}
push t s = s { lsToks =
t : (lsToks s)
}
tok :: TokenName -> Action
tok :: TokenName -> Action
tok tokId (pos, _, _, input) len = do
tok tokId (pos, _, _, input) len = do
...
...
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