Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qt-creator
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
Container Registry
Model registry
Operate
Environments
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
Tobias Hunger
qt-creator
Commits
d685437d
Commit
d685437d
authored
15 years ago
by
Roberto Raggi
Browse files
Options
Downloads
Patches
Plain Diff
Recognize the numeric literals.
parent
7356280c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/shared/cplusplus/Literals.cpp
+94
-2
94 additions, 2 deletions
src/shared/cplusplus/Literals.cpp
src/shared/cplusplus/Literals.h
+23
-0
23 additions, 0 deletions
src/shared/cplusplus/Literals.h
with
117 additions
and
2 deletions
src/shared/cplusplus/Literals.cpp
+
94
−
2
View file @
d685437d
...
@@ -105,13 +105,105 @@ StringLiteral::~StringLiteral()
...
@@ -105,13 +105,105 @@ StringLiteral::~StringLiteral()
{
}
{
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
enum
{
NumericLiteralIsChar
,
NumericLiteralIsWideChar
,
NumericLiteralIsInt
,
NumericLiteralIsFloat
,
NumericLiteralIsDouble
,
NumericLiteralIsLongDouble
,
NumericLiteralIsLong
,
NumericLiteralIsLongLong
,
};
NumericLiteral
::
NumericLiteral
(
const
char
*
chars
,
unsigned
size
)
NumericLiteral
::
NumericLiteral
(
const
char
*
chars
,
unsigned
size
)
:
Literal
(
chars
,
size
)
:
Literal
(
chars
,
size
),
_flags
(
0
)
{
}
{
_type
=
NumericLiteralIsInt
;
if
(
chars
[
0
]
==
'\''
)
{
_type
=
NumericLiteralIsChar
;
}
else
if
(
size
>
1
&&
chars
[
0
]
==
'L'
&&
chars
[
1
]
==
'\''
)
{
_type
=
NumericLiteralIsWideChar
;
}
else
if
(
size
>
1
&&
chars
[
0
]
==
'0'
&&
(
chars
[
1
]
==
'x'
||
chars
[
1
]
==
'X'
))
{
_isHex
=
true
;
}
else
{
const
char
*
begin
=
chars
;
const
char
*
end
=
begin
+
size
;
bool
done
=
false
;
const
char
*
it
=
end
-
1
;
for
(;
it
!=
begin
-
1
&&
!
done
;
--
it
)
{
switch
(
*
it
)
{
case
'l'
:
case
'L'
:
// long suffix
case
'u'
:
case
'U'
:
// unsigned suffix
case
'f'
:
case
'F'
:
// floating suffix
break
;
default:
done
=
true
;
break
;
}
// switch
}
for
(
const
char
*
dot
=
it
;
it
!=
begin
-
1
;
--
it
)
{
if
(
*
dot
==
'.'
)
_type
=
NumericLiteralIsDouble
;
}
for
(
++
it
;
it
!=
end
;
++
it
)
{
if
(
*
it
==
'l'
||
*
it
==
'L'
)
{
if
(
_type
==
NumericLiteralIsDouble
)
{
_type
=
NumericLiteralIsLongDouble
;
}
else
if
(
it
+
1
!=
end
&&
(
it
[
1
]
==
'l'
||
it
[
1
]
==
'L'
))
{
++
it
;
_type
=
NumericLiteralIsLongLong
;
}
else
{
_type
=
NumericLiteralIsLong
;
}
}
else
if
(
*
it
==
'f'
||
*
it
==
'F'
)
{
_type
=
NumericLiteralIsFloat
;
}
else
if
(
*
it
==
'u'
||
*
it
==
'U'
)
{
_isUnsigned
=
true
;
}
}
}
}
NumericLiteral
::~
NumericLiteral
()
NumericLiteral
::~
NumericLiteral
()
{
}
{
}
bool
NumericLiteral
::
isHex
()
const
{
return
_isHex
;
}
bool
NumericLiteral
::
isUnsigned
()
const
{
return
_isUnsigned
;
}
bool
NumericLiteral
::
isChar
()
const
{
return
_type
==
NumericLiteralIsChar
;
}
bool
NumericLiteral
::
isWideChar
()
const
{
return
_type
==
NumericLiteralIsWideChar
;
}
bool
NumericLiteral
::
isInt
()
const
{
return
_type
==
NumericLiteralIsInt
;
}
bool
NumericLiteral
::
isFloat
()
const
{
return
_type
==
NumericLiteralIsFloat
;
}
bool
NumericLiteral
::
isDouble
()
const
{
return
_type
==
NumericLiteralIsDouble
;
}
bool
NumericLiteral
::
isLongDouble
()
const
{
return
_type
==
NumericLiteralIsLongDouble
;
}
bool
NumericLiteral
::
isLong
()
const
{
return
_type
==
NumericLiteralIsLong
;
}
bool
NumericLiteral
::
isLongLong
()
const
{
return
_type
==
NumericLiteralIsLongLong
;
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Identifier
::
Identifier
(
const
char
*
chars
,
unsigned
size
)
Identifier
::
Identifier
(
const
char
*
chars
,
unsigned
size
)
:
Literal
(
chars
,
size
)
:
Literal
(
chars
,
size
)
...
...
This diff is collapsed.
Click to expand it.
src/shared/cplusplus/Literals.h
+
23
−
0
View file @
d685437d
...
@@ -101,6 +101,29 @@ class CPLUSPLUS_EXPORT NumericLiteral: public Literal
...
@@ -101,6 +101,29 @@ class CPLUSPLUS_EXPORT NumericLiteral: public Literal
public:
public:
NumericLiteral
(
const
char
*
chars
,
unsigned
size
);
NumericLiteral
(
const
char
*
chars
,
unsigned
size
);
virtual
~
NumericLiteral
();
virtual
~
NumericLiteral
();
bool
isChar
()
const
;
bool
isWideChar
()
const
;
bool
isInt
()
const
;
bool
isFloat
()
const
;
bool
isDouble
()
const
;
bool
isLongDouble
()
const
;
bool
isLong
()
const
;
bool
isLongLong
()
const
;
bool
isUnsigned
()
const
;
bool
isHex
()
const
;
private:
union
{
unsigned
_flags
;
struct
{
unsigned
_type
:
8
;
unsigned
_isHex
:
1
;
unsigned
_isUnsigned
:
1
;
};
};
};
};
class
CPLUSPLUS_EXPORT
Identifier
:
public
Literal
class
CPLUSPLUS_EXPORT
Identifier
:
public
Literal
...
...
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