ideas on a new script language
The language should define a very basic lexical grammar.
- Lexical Block
- """ any string literal """ that is not escaped
- " string support escape "
xml block (no prefix spaces)
- ( ) block
- [ ] block
- { } block
- other block is seperated by space, tab and cr/lf in token
- two seperator: , ; which cant used as part of token
- Data type definition
- string literal
- position(x y)
- core dialect
- class/field/method
- @var $var %var variable reference
- SQL dialect
- #sql(select * from table1 where field1 = "hello")
- #sql select * from table1 where field1 = @var;
- dialect
- in the core dialect, using #dialect(statement), each dialect is coded as #id object
process flow:
source -> token tree ->(core dialect process) -> objects tree ->(other dialect process) object tree -> (till all precompile complete) -> executable object tree
simple code
class Demo {
function hello() {
prints "hello world";
}
function accessDB(){
%mytable = #sql ( select * from mytable where fid = @fid);
prints "name = $(mytable.fid)"
}
}
How does it works?
0 Comments:
张贴评论
<< Home