File modules/dsl/DslToken.class.php
Last commit: Fri Jul 1 18:09:05 2022 +0200 Jan Dankert New: Bugfixes and much more string and array functions for the DSL.
1 <?php 2 namespace dsl; 3 4 class DslToken 5 { 6 7 8 const T_NONE = 0; 9 const T_STRING = 1; 10 const T_BRACKET_OPEN = 3; 11 const T_BRACKET_CLOSE = 4; 12 const T_BLOCK_BEGIN = 5; 13 const T_BLOCK_END = 6; 14 const T_TEXT = 7; 15 const T_NUMBER = 8; 16 const T_OPERATOR = 9; 17 const T_FUNCTION = 10; 18 const T_FOR = 11; 19 const T_IF = 12; 20 const T_ELSE = 13; 21 const T_LET = 14; 22 const T_RETURN = 15; 23 const T_DOT = 16; 24 const T_STATEMENT_END = 17; 25 const T_NEGATION = 18; 26 const T_COMMA = 19; 27 const T_NEW = 20; 28 const T_THROW = 21; 29 const T_TRUE = 22; 30 const T_FALSE = 23; 31 const T_NULL = 24; 32 33 public $lineNumber; 34 public $type; 35 public $value; 36 37 /** 38 * DslToken constructor. 39 * @param $lineNumber 40 * @param $type 41 * @param $value 42 */ 43 public function __construct($lineNumber, $type, $value) 44 { 45 $this->lineNumber = $lineNumber; 46 $this->type = $type; 47 $this->value = $value; 48 } 49 50 public function __toString() 51 { 52 return '#'.$this->lineNumber.':'.$this->type.':"'.$this->value.'"'; 53 } 54 55 56 /** 57 * @return bool 58 */ 59 public function isOperator( $value = null ) { 60 if ( ! $value ) 61 return $this->type == self::T_OPERATOR; 62 63 return $this->type == self::T_OPERATOR && $this->value == $value; 64 } 65 }
Downloadmodules/dsl/DslToken.class.php
History Fri, 1 Jul 2022 18:09:05 +0200 Jan Dankert New: Bugfixes and much more string and array functions for the DSL. Sun, 26 Jun 2022 15:46:54 +0200 Jan Dankert Fix: Another, little better, hack for parameterless functions. Shunting yard seems to be unable to handle empty parentheses. Sun, 26 Jun 2022 12:51:07 +0200 Jan Dankert New: DSL can be controlled by flags; support for error messages; support for negativ numbers. Tue, 7 Jun 2022 23:30:20 +0200 Jan Dankert New: DSL is now supporting throw statements. Sat, 28 May 2022 18:00:13 +0200 Jan Dankert New: DSL with a much better syntax parsing and support for assignments, conditions, ... Wed, 25 May 2022 22:47:17 +0200 Jan Dankert New: DSL (domain specific language) for code elements. The old way with PHP code ist not sandboxed and unsecure. This approach is a minimalistic, javascript-like, scripting engine. For now only simple function calls are possible, for example: alert("example");