Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Tomáš Trávníček
doctrine-dbal
Commits
89a62502
Commit
89a62502
authored
Mar 20, 2009
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] Refactored and reenabled Lexer tests.
parent
b718cd1a
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
323 additions
and
9 deletions
+323
-9
Lexer.php
lib/Doctrine/ORM/Query/Lexer.php
+28
-2
Parser.php
lib/Doctrine/ORM/Query/Parser.php
+5
-6
AllTests.php
tests/Doctrine/Tests/ORM/Query/AllTests.php
+2
-1
LexerTest.php
tests/Doctrine/Tests/ORM/Query/LexerTest.php
+288
-0
No files found.
lib/Doctrine/ORM/Query/Lexer.php
View file @
89a62502
...
...
@@ -114,7 +114,7 @@ class Lexer
public
$lookahead
;
/**
* @var array The last matched token.
* @var array The last matched
/seen
token.
*/
public
$token
;
...
...
@@ -151,17 +151,43 @@ class Lexer
*
* @return array|null the next token; null if there is no more tokens left
*/
public
function
n
ext
()
public
function
moveN
ext
()
{
$this
->
token
=
$this
->
lookahead
;
$this
->
_peek
=
0
;
if
(
isset
(
$this
->
_tokens
[
$this
->
_position
]))
{
$this
->
lookahead
=
$this
->
_tokens
[
$this
->
_position
++
];
return
true
;
}
else
{
$this
->
lookahead
=
null
;
return
false
;
}
}
/**
* Attempts to match the given token with the current lookahead token.
*
* If they match, the lexer moves on to the next token, otherwise a syntax error
* is raised.
*
* @param int|string token type or value
* @return bool True, if tokens match; false otherwise.
*/
/*public function match($token)
{
if (is_string($token)) {
$isMatch = ($this->lookahead['value'] === $token);
} else {
$isMatch = ($this->lookahead['type'] === $token);
}
if ( ! $isMatch) {
$this->syntaxError($this->getLiteral($token));
}
$this->moveNext();
}*/
/**
* Checks if an identifier is a keyword and returns its correct type.
*
...
...
lib/Doctrine/ORM/Query/Parser.php
View file @
89a62502
...
...
@@ -60,21 +60,21 @@ class Parser
*
* @var Doctrine_ORM_Query_Scanner
*/
pr
otected
$_lexer
;
pr
ivate
$_lexer
;
/**
* The Parser Result object.
*
* @var Doctrine_ORM_Query_ParserResult
*/
pr
otected
$_parserResult
;
pr
ivate
$_parserResult
;
/**
* The EntityManager.
*
* @var EnityManager
*/
pr
otected
$_em
;
pr
ivate
$_em
;
/**
* Creates a new query parser object.
...
...
@@ -131,8 +131,7 @@ class Parser
$this
->
syntaxError
(
$this
->
_lexer
->
getLiteral
(
$token
));
}
$this
->
_lexer
->
next
();
return
true
;
$this
->
_lexer
->
moveNext
();
}
public
function
isA
(
$value
,
$token
)
...
...
@@ -322,7 +321,7 @@ class Parser
*/
private
function
_QueryLanguage
()
{
$this
->
_lexer
->
n
ext
();
$this
->
_lexer
->
moveN
ext
();
switch
(
$this
->
_lexer
->
lookahead
[
'type'
])
{
case
Lexer
::
T_SELECT
:
return
$this
->
_SelectStatement
();
...
...
tests/Doctrine/Tests/ORM/Query/AllTests.php
View file @
89a62502
...
...
@@ -22,9 +22,10 @@ class AllTests
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\Query\IdentifierRecognitionTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\Query\SelectSqlGenerationTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\Query\LanguageRecognitionTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\Query\LexerTest'
);
/*
$suite->addTestSuite('Orm_Query_ScannerTest');
$suite->addTestSuite('Orm_Query_DqlGenerationTest');
$suite->addTestSuite('Orm_Query_DeleteSqlGenerationTest');
$suite->addTestSuite('Orm_Query_UpdateSqlGenerationTest');*/
...
...
tests/Doctrine/Tests/ORM/Query/
Scann
erTest.php
→
tests/Doctrine/Tests/ORM/Query/
Lex
erTest.php
View file @
89a62502
This diff is collapsed.
Click to expand it.
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