Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for PHP 5.6 #3

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.class
*.jar
*.lex.php
16 changes: 11 additions & 5 deletions JLexPHP/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ class CEmit
m_outstream.println("\tconst YY_F = -1;");
m_outstream.println("\tconst YY_NO_STATE = -1;");

m_outstream.println("\tconst CMAP_CHUNK_SIZE = 1024;");
m_outstream.println("\tconst YY_NOT_ACCEPT = 0;");
m_outstream.println("\tconst YY_START = 1;");
m_outstream.println("\tconst YY_END = 2;");
Expand Down Expand Up @@ -1255,12 +1256,17 @@ else if (is_end)
// m_outstream.print("\tprotected function yy_build_tables() {\n");

// CSA: modified yy_cmap to use string packing 9-Aug-1999
int[] yy_cmap = new int[m_spec.m_ccls_map.length];
for (i = 0; i < m_spec.m_ccls_map.length; ++i)
yy_cmap[i] = m_spec.m_col_map[m_spec.m_ccls_map[i]];
int[][] yy_cmap = new int[(int) Math.ceil(m_spec.m_ccls_map.length / 1024.0)][1024];
int index = 0;
int modulo = 0;
for (i = 0; i < m_spec.m_ccls_map.length; ++i) {
index = (int) Math.floor(i / 1024);
modulo = i % 1024;
yy_cmap[index][modulo] = m_spec.m_col_map[m_spec.m_ccls_map[i]];
}
m_outstream.print("\t\tstatic $yy_cmap = ");
// emit_table_as_string(new int[][] { yy_cmap });
emit_table_as_array(yy_cmap);
emit_table_as_array_2d(yy_cmap);
// m_outstream.println(");");
m_outstream.println();

Expand Down Expand Up @@ -1489,7 +1495,7 @@ else if (m_spec.m_intwrap_type)
/*m_outstream.println("\t\t\t\tyy_next_state = "
+ "yy_next(yy_state,yy_lookahead);");*/
m_outstream.println("\t\t\t$yy_next_state = "
+ "self::$yy_nxt[self::$yy_rmap[$yy_state]][self::$yy_cmap[$yy_lookahead]];");
+ "self::$yy_nxt[self::$yy_rmap[$yy_state]][self::$yy_cmap[floor($yy_lookahead / self::CMAP_CHUNK_SIZE)][$yy_lookahead % self::CMAP_CHUNK_SIZE]];");

if (NOT_EDBG)
{
Expand Down
12 changes: 6 additions & 6 deletions jlex.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ protected function yy_advance() {
$data = fread($this->yy_reader, 8192);
if ($data === false || !strlen($data)) return $this->YY_EOF;
$this->yy_buffer .= $data;
$this->yy_buffer_read .= strlen($data);
$this->yy_buffer_read += strlen($data);
}

while ($this->yy_buffer_index >= $this->yy_buffer_read) {
$data = fread($this->yy_reader, 8192);
if ($data === false || !strlen($data)) return $this->YY_EOF;
$this->yy_buffer .= $data;
$this->yy_buffer_read .= strlen($data);
$this->yy_buffer_read += strlen($data);
}
return ord($this->yy_buffer[$this->yy_buffer_index++]);
}
Expand Down Expand Up @@ -190,16 +190,16 @@ protected function yy_error($code, $fatal) {
}

/* creates an annotated token */
function createToken($type = null) {
function createToken($type = null, $value = null) {
if ($type === null) $type = $this->yytext();
$tok = new JLexToken($type);
$this->annotateToken($tok);
$this->annotateToken($tok, $value);
return $tok;
}

/* annotates a token with a value and source positioning */
function annotateToken(JLexToken $tok) {
$tok->value = $this->yytext();
function annotateToken(JLexToken $tok, $value = null) {
$tok->value = is_null($value) ? $this->yytext() : $value;
$tok->col = $this->yycol;
$tok->line = $this->yyline;
$tok->filename = $this->yyfilename;
Expand Down