jass parser
2025-08-25 13:07:15 0 举报
AI智能生成
JASS Parser是一个用于解析JASS (Just Another Scripting Syntax) 代码的工具。JASS是一种专用于暴雪娱乐公司开发的游戏——尤其是《魔兽争霸III》和其自定义地图的脚本语言。JASS Parser的核心功能包括语法分析、错误检测、代码优化。
作者其他创作
大纲/内容
词法分析
number
0-9
0
0[0-7]+
octal
0[xX][0-9a-fA-F]{1,8}
hex
0\.[0-9]*
float
[1-9]+
number:normal
int:[0-9]{1,10}
float:([0-9]+\. )|([0-9]+\.[0-9]+)
.
(\.[0-9]+)|([0-9]+\. )|([0-9]+\.[0-9]+)
number:float
$
$[0-9a-fA-F]{1,8}
hex
keyword
[a-zA-Z]
[a-zA-Z]+([a-z_A-Z0-9]*[a-zA-Z0-9])?
operator
operator precedence
[] ()
+{expr} -{expr}
* /
+ -
< <= > >=
== !=
=
,
,
separator
comma operator
+
+ {expr}
unary plus operator
{expr} + {epxr}
binary plus operator
-
- {expr}
unary minus operator
{expr} - {epxr}
binary minus operator
*
{expr} * {epxr}
binary multiplication operator
*/
multiple lines comment end
/
//
single line comment start
/*
multiple lines comment start
{expr} / {epxr}
binary division operator
=
==
equality operator
=
assignment operator
<
<
less-than operator
<=
less-than-or-equal-to operator
>
>
greater-than operator
>=
greater-than-or-equal-to operator
!
!=
inequality operator
[]
postfix-expression [ expression ]
subscript operator
()
postfix-expression ( expression-list? )
function call operator
\\
\{\n}
concatline
\{other}
error!
\n
new line
\r
(\r\n|\r+)
new line
\t
space
\x20
space
'
('[.]|[.]{4}')
charator
length:1,4
"
“([^"]|\\")+”
string
escape sequence
\',\",\\,\f,\n,\r,\t,\v
simple escape sequence
\000
octal escape sequence
\xhh
hexadecimal escape sequence
\uXXXX
universal character name
[%?@^_`~:;&|{}#]
Unused visible characters,show error!
([\x1-\x8]|[\xB\xC]|[\xE-\x1F]|[\x7F])
Unused Invisible characters,show error!
[\x80-\xFF]
read utf-8/ascii next charator,show error!
\x0
input eof,exit
语法分析
描述语定义
$value
boolean
true/false/???
integer
hex:0x???
hex:$???
charator
'?'
'????'
real
string
code
function {symbol}
handle
{symbol}
$symbol
variable
native
function
args
{value}
param
type_name
variable_name
code
function
funcion_name
expression
()
{expression}
unary operator
{expression}
constant_value
optional:binary operator
{expression}
symbol_name
optional:binary operator
{expression}
$symbol
variable_name
function_name
$variable
?:constant
type
?:array
name
?:=
{expression}
declaration
type
name
extends
type_name
$native
?:constant
native
name
takes
{param_list}
returns
type_name
$globals
globals
{variable list}
endglobals
$function
?:constant
function
name
takes
{param...}
returns
type_name
{statement}
endfunction
$comment
//
{...}
line end
/*
{...}
*/
statement
local
type
?:array
name
?:=
{expression}
set
variable_name
?:[{expression}]
=
{expression}
call
function_name
(
{args...}
)
if
{expression}
then
elseif*
{expression}
then
else
endif
loop
{new line}
exitwhen*
{expression}
endloop
return
?:{expression}
logic
*:type
*:native
*:globals
*:{variable list}
*:function
*:local
*:set
*:call
*:loop
*:exitwhen
*:loop/if/set/call/return
endloop
*:if
*:loop/if/set/call/return
*:elseif
*:loop/if/set/call/return
?:else
*:loop/if/set/call/return
endif
*:return
*://{line}
*:/*{...}*/
AST
NodeType
Decl
TypeDecl
GlobalVarDecl
NativeDecl
FunctionDecl
ParamList
ReturnType
Block
CommentDecl
Statement
LocalDecl
SetStatement
CallStatement
IfStatement
LoopStatement
ReturnStatement
Expression
Literal(value)
Variable(name)
BinaryOp(op, left, right)
UnaryOp(op, expr)
ArrayAccess(var, index)
FunctionCall(name, args)
语义分析
作用域解析
类型检查
可变性检查
初始化与可达性
控制流完整性
数组/切片边界与维度检查
函数/运算符重载决议
语义限制与方言差异

收藏
0 条评论
下一页