1. Wez Furlong
  2. JLexPHP

Commits

Wez Furlong  committed bf0a343

add comment handling

  • Participants
  • Parent commits c25ccca
  • Branches JLexPHP

Comments (0)

Files changed (2)

File c.lex

View file
 
 %%
 
-<YYINITIAL> "/*"			{ $this->yybegin(self::COMMENT); }
-<YYINITIAL> "//[^\r\n]*"    { /* C++ comment */ }
+<YYINITIAL> "/*"			{ 
+								$this->commentTok = $this->createToken(CParser::TK_COMMENT);
+								$this->yybegin(self::COMMENT);
+						    }
+<YYINITIAL> //[^\r\n]*      { return $this->createToken(CParser::TK_COMMENT); }
 
-<COMMENT>   "*/"            { $this->yybegin(self::YYINITIAL); }
-<COMMENT>   [.\n]           { }
+<COMMENT>   "*/"            { 
+								$this->commentTok->value .= $this->yytext();
+							    $this->yybegin(self::YYINITIAL); 
+							    return $this->commentTok;
+							}
+<COMMENT>   (.|[\r\n])      { $this->commentTok->value .= $this->yytext(); }
 
 <YYINITIAL> #[^\r\n]*       { return $this->createToken(CParser::TK_PRAGMA); }
 

File jlex.php

View file
 }
 
 class JLexBase {
+  const YY_F = -1;
+  const YY_NO_STATE = -1;
+  const YY_NOT_ACCEPT = 0;
+  const YY_START = 1;
+  const YY_END = 2;
+  const YY_NO_ANCHOR = 4;
+  const YYEOF = -1;
+
+  protected $YY_BOL;
+  protected $YY_EOF;
+
   protected $yy_reader;
   protected $yy_buffer;
   protected $yy_buffer_read;
     $this->yy_buffer_start = 0;
     $this->yy_buffer_end = 0;
     $this->yychar = 0;
-    $this->yyline = 0;
+    $this->yyline = 1;
     $this->yy_at_bol = true;
   }
 
 
   protected function yy_advance() {
     if ($this->yy_buffer_index < $this->yy_buffer_read) {
+      if (!isset($this->yy_buffer[$this->yy_buffer_index])) {
+        return $this->YY_EOF;
+      }
       return ord($this->yy_buffer[$this->yy_buffer_index++]);
     }
     if ($this->yy_buffer_start != 0) {