1
|
|
|
<?php |
2
|
|
|
namespace POData\Common\Messages; |
3
|
|
|
|
4
|
|
|
trait expressionLexer |
5
|
|
|
{ |
6
|
|
|
/** |
7
|
|
|
* Format message for unterminated string literal error. |
8
|
|
|
* |
9
|
|
|
* @param int $pos Position of unterminated string literal in the text |
10
|
|
|
* @param string $text The text with unterminated string literal |
11
|
|
|
* |
12
|
|
|
* @return string The formatted message |
13
|
|
|
*/ |
14
|
|
|
public static function expressionLexerUnterminatedStringLiteral($pos, $text) |
15
|
|
|
{ |
16
|
|
|
return 'Unterminated string literal at position ' . $pos . ' in ' . $text; |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Format message for digit expected error. |
21
|
|
|
* |
22
|
|
|
* @param int $pos Position at which digit is expected |
23
|
|
|
* |
24
|
|
|
* @return string The formatted message |
25
|
|
|
*/ |
26
|
|
|
public static function expressionLexerDigitExpected($pos) |
27
|
|
|
{ |
28
|
|
|
return 'Digit expected at position ' . $pos; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Format message for syntax error. |
33
|
|
|
* |
34
|
|
|
* @param int $pos Position at which syntax error found |
35
|
|
|
* |
36
|
|
|
* @return string The formatted message |
37
|
|
|
*/ |
38
|
|
|
public static function expressionLexerSyntaxError($pos) |
39
|
|
|
{ |
40
|
|
|
return 'Syntax Error at position ' . $pos; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Format message for invalid character error. |
45
|
|
|
* |
46
|
|
|
* @param string $ch The invalid character found |
47
|
|
|
* @param int $pos Position at which invalid character found |
48
|
|
|
* |
49
|
|
|
* @return string The formatted message |
50
|
|
|
*/ |
51
|
|
|
public static function expressionLexerInvalidCharacter($ch, $pos) |
52
|
|
|
{ |
53
|
|
|
return "Invalid character '$ch' at position $pos"; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Format message for not applicable function error. |
59
|
|
|
* |
60
|
|
|
* @param string $functionName The name of the function called |
61
|
|
|
* @param string $protoTypes Prototype of the functions considered |
62
|
|
|
* @param int $position Position at which function-call found |
63
|
|
|
* |
64
|
|
|
* @return string The formatted message |
65
|
|
|
*/ |
66
|
|
|
public static function expressionLexerNoApplicableFunctionsFound( |
67
|
|
|
$functionName, |
68
|
|
|
$protoTypes, |
69
|
|
|
$position |
70
|
|
|
) { |
71
|
|
|
return "No applicable function found for '$functionName' at position $position with the specified arguments. The functions considered are: $protoTypes"; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Format message for property not found error. |
76
|
|
|
* |
77
|
|
|
* @param string $property The name of the property |
78
|
|
|
* @param string $type The parent type in which property searched for |
79
|
|
|
* @param int $position Position at which property mentioned |
80
|
|
|
* |
81
|
|
|
* @return string The formatted message |
82
|
|
|
*/ |
83
|
|
|
public static function expressionLexerNoPropertyInType($property, $type, $position) |
84
|
|
|
{ |
85
|
|
|
return "No property '$property' exists in type '$type' at position $position"; |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|