Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
Hercules
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
llvm
Hercules
Commits
fff93f4e
Commit
fff93f4e
authored
1 year ago
by
Russel Arbore
Browse files
Options
Downloads
Patches
Plain Diff
Parse more characters in identifier
parent
bab57b3e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hercules_ir/src/parse.rs
+18
-9
18 additions, 9 deletions
hercules_ir/src/parse.rs
with
18 additions
and
9 deletions
hercules_ir/src/parse.rs
+
18
−
9
View file @
fff93f4e
...
@@ -129,7 +129,7 @@ fn parse_function<'a>(
...
@@ -129,7 +129,7 @@ fn parse_function<'a>(
let
ir_text
=
nom
::
character
::
complete
::
multispace0
(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
multispace0
(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
bytes
::
complete
::
tag
(
"fn"
)(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
bytes
::
complete
::
tag
(
"fn"
)(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
multispace0
(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
multispace0
(
ir_text
)
?
.0
;
let
(
ir_text
,
function_name
)
=
nom
::
character
::
complete
::
alphanumeric1
(
ir_text
)
?
;
let
(
ir_text
,
function_name
)
=
parse_identifier
(
ir_text
)
?
;
let
parse_num_dynamic_constants
=
|
ir_text
:
&
'a
str
|
->
nom
::
IResult
<&
'a
str
,
u32
>
{
let
parse_num_dynamic_constants
=
|
ir_text
:
&
'a
str
|
->
nom
::
IResult
<&
'a
str
,
u32
>
{
let
ir_text
=
nom
::
character
::
complete
::
multispace0
(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
multispace0
(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
char
(
'<'
)(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
char
(
'<'
)(
ir_text
)
?
.0
;
...
@@ -148,7 +148,7 @@ fn parse_function<'a>(
...
@@ -148,7 +148,7 @@ fn parse_function<'a>(
nom
::
character
::
complete
::
char
(
','
),
nom
::
character
::
complete
::
char
(
','
),
nom
::
sequence
::
tuple
((
nom
::
sequence
::
tuple
((
nom
::
character
::
complete
::
multispace0
,
nom
::
character
::
complete
::
multispace0
,
nom
::
character
::
complete
::
alphanumeric1
,
parse_identifier
,
nom
::
character
::
complete
::
multispace0
,
nom
::
character
::
complete
::
multispace0
,
nom
::
character
::
complete
::
char
(
':'
),
nom
::
character
::
complete
::
char
(
':'
),
nom
::
character
::
complete
::
multispace0
,
nom
::
character
::
complete
::
multispace0
,
...
@@ -197,11 +197,11 @@ fn parse_node<'a>(
...
@@ -197,11 +197,11 @@ fn parse_node<'a>(
context
:
&
RefCell
<
Context
<
'a
>>
,
context
:
&
RefCell
<
Context
<
'a
>>
,
)
->
nom
::
IResult
<&
'a
str
,
(
&
'a
str
,
Node
)
>
{
)
->
nom
::
IResult
<&
'a
str
,
(
&
'a
str
,
Node
)
>
{
let
ir_text
=
nom
::
character
::
complete
::
multispace0
(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
multispace0
(
ir_text
)
?
.0
;
let
(
ir_text
,
node_name
)
=
nom
::
character
::
complete
::
alphanumeric1
(
ir_text
)
?
;
let
(
ir_text
,
node_name
)
=
parse_identifier
(
ir_text
)
?
;
let
ir_text
=
nom
::
character
::
complete
::
multispace0
(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
multispace0
(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
char
(
'='
)(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
char
(
'='
)(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
multispace0
(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
multispace0
(
ir_text
)
?
.0
;
let
(
ir_text
,
node_kind
)
=
nom
::
character
::
complete
::
alphanumeric1
(
ir_text
)
?
;
let
(
ir_text
,
node_kind
)
=
parse_identifier
(
ir_text
)
?
;
let
(
ir_text
,
node
)
=
match
node_kind
{
let
(
ir_text
,
node
)
=
match
node_kind
{
"return"
=>
parse_return
(
ir_text
,
context
)
?
,
"return"
=>
parse_return
(
ir_text
,
context
)
?
,
"constant"
=>
parse_constant_node
(
ir_text
,
context
)
?
,
"constant"
=>
parse_constant_node
(
ir_text
,
context
)
?
,
...
@@ -220,11 +220,11 @@ fn parse_return<'a>(
...
@@ -220,11 +220,11 @@ fn parse_return<'a>(
let
ir_text
=
nom
::
character
::
complete
::
multispace0
(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
multispace0
(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
char
(
'('
)(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
char
(
'('
)(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
multispace0
(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
multispace0
(
ir_text
)
?
.0
;
let
(
ir_text
,
control
)
=
nom
::
character
::
complete
::
alphanumeric1
(
ir_text
)
?
;
let
(
ir_text
,
control
)
=
parse_identifier
(
ir_text
)
?
;
let
ir_text
=
nom
::
character
::
complete
::
multispace0
(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
multispace0
(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
char
(
','
)(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
char
(
','
)(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
multispace0
(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
multispace0
(
ir_text
)
?
.0
;
let
(
ir_text
,
value
)
=
nom
::
character
::
complete
::
alphanumeric1
(
ir_text
)
?
;
let
(
ir_text
,
value
)
=
parse_identifier
(
ir_text
)
?
;
let
ir_text
=
nom
::
character
::
complete
::
multispace0
(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
multispace0
(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
char
(
')'
)(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
char
(
')'
)(
ir_text
)
?
.0
;
let
control
=
context
.borrow_mut
()
.get_node_id
(
control
);
let
control
=
context
.borrow_mut
()
.get_node_id
(
control
);
...
@@ -253,11 +253,11 @@ fn parse_add<'a>(ir_text: &'a str, context: &RefCell<Context<'a>>) -> nom::IResu
...
@@ -253,11 +253,11 @@ fn parse_add<'a>(ir_text: &'a str, context: &RefCell<Context<'a>>) -> nom::IResu
let
ir_text
=
nom
::
character
::
complete
::
multispace0
(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
multispace0
(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
char
(
'('
)(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
char
(
'('
)(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
multispace0
(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
multispace0
(
ir_text
)
?
.0
;
let
(
ir_text
,
left
)
=
nom
::
character
::
complete
::
alphanumeric1
(
ir_text
)
?
;
let
(
ir_text
,
left
)
=
parse_identifier
(
ir_text
)
?
;
let
ir_text
=
nom
::
character
::
complete
::
multispace0
(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
multispace0
(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
char
(
','
)(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
char
(
','
)(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
multispace0
(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
multispace0
(
ir_text
)
?
.0
;
let
(
ir_text
,
right
)
=
nom
::
character
::
complete
::
alphanumeric1
(
ir_text
)
?
;
let
(
ir_text
,
right
)
=
parse_identifier
(
ir_text
)
?
;
let
ir_text
=
nom
::
character
::
complete
::
multispace0
(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
multispace0
(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
char
(
')'
)(
ir_text
)
?
.0
;
let
ir_text
=
nom
::
character
::
complete
::
char
(
')'
)(
ir_text
)
?
.0
;
let
left
=
context
.borrow_mut
()
.get_node_id
(
left
);
let
left
=
context
.borrow_mut
()
.get_node_id
(
left
);
...
@@ -293,7 +293,7 @@ fn parse_call<'a>(ir_text: &'a str, context: &RefCell<Context<'a>>) -> nom::IRes
...
@@ -293,7 +293,7 @@ fn parse_call<'a>(ir_text: &'a str, context: &RefCell<Context<'a>>) -> nom::IRes
nom
::
character
::
complete
::
char
(
','
),
nom
::
character
::
complete
::
char
(
','
),
nom
::
character
::
complete
::
multispace0
,
nom
::
character
::
complete
::
multispace0
,
)),
)),
nom
::
character
::
complete
::
alphanumeric1
,
parse_identifier
,
)(
ir_text
)
?
;
)(
ir_text
)
?
;
let
function
=
function_and_args
.remove
(
0
);
let
function
=
function_and_args
.remove
(
0
);
let
args
:
Vec
<
NodeID
>
=
function_and_args
let
args
:
Vec
<
NodeID
>
=
function_and_args
...
@@ -714,6 +714,15 @@ fn parse_array_constant_helper<'a>(
...
@@ -714,6 +714,15 @@ fn parse_array_constant_helper<'a>(
}
}
}
}
fn
parse_identifier
<
'a
>
(
ir_text
:
&
'a
str
)
->
nom
::
IResult
<&
'a
str
,
&
'a
str
>
{
nom
::
combinator
::
verify
(
nom
::
bytes
::
complete
::
is_a
(
"1234567890_@ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
,
),
|
s
:
&
str
|
s
.len
()
>
0
,
)(
ir_text
)
}
mod
tests
{
mod
tests
{
#[allow(unused_imports)]
#[allow(unused_imports)]
use
super
::
*
;
use
super
::
*
;
...
...
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