代码拉取完成,页面将自动刷新
package io.nop.xlang.ast;
import io.nop.api.core.annotations.meta.PropMeta;
import io.nop.api.core.beans.TreeBean;
import java.util.List;
import java.util.Set;
public class XLangAST {
enum PropertyKind {
init,
get,
set
}
enum VariableKind {
CONST,
LET,
}
enum XLangClassKind {
}
enum XLangOperator {
}
enum XLangOutputMode {
}
abstract class XLangASTNode {
}
abstract class Expression {
}
abstract class Statement extends Expression {
}
interface IdentifierOrPattern {
}
abstract class ModuleDeclaration extends Statement {
}
abstract class Declaration extends Statement {
}
class CompilationUnit{
@PropMeta(mandatory=true)
String packageName;
List<Statement> statements;
}
class Program extends Expression {
String sourceType; //: "script" | "module";
@PropMeta(mandatory = true)
List<XLangASTNode> body; //: [ Statement | ModuleDeclaration ];
}
class Identifier extends Expression implements IdentifierOrPattern {
@PropMeta(mandatory = true)
String name;
}
class Literal extends Expression {
Object value;
}
class TemplateStringLiteral extends Literal {
}
class RegExpLiteral extends Literal {
String pattern;
String flags;
}
class BlockStatement extends Statement {
@PropMeta(mandatory = true)
List<Expression> body;
}
class EmptyStatement extends Statement {
}
class ReturnStatement extends Statement {
Expression argument;
}
class BreakStatement extends Statement {
}
class ContinueStatement extends Statement {
}
class IfStatement extends Statement {
Expression test;
Expression consequent;
Expression alternate;
boolean ternaryExpr;
}
// class TernaryExpression extends Expression {
// Expression test;
// Expression consequent;
// Expression alternate;
// }
class SwitchStatement extends Statement {
@PropMeta(mandatory = true)
Expression discriminant;
boolean asExpr;
List<SwitchCase> cases;
Expression defaultCase;
}
class SwitchCase {
@PropMeta(mandatory = true)
Expression test;
Expression consequent;
boolean fallthrough;
}
class ThrowStatement extends Statement {
@PropMeta(mandatory = true)
Expression argument;
}
class TryStatement extends Statement {
@PropMeta(mandatory = true)
Expression block;
CatchClause catchHandler;
Expression finalizer;
}
class CatchClause {
@PropMeta(mandatory = true)
Identifier name;
NamedTypeNode varType;
@PropMeta(mandatory = true)
Expression body;
}
class WhileStatement extends Statement {
@PropMeta(mandatory = true)
Expression test;
@PropMeta(mandatory = true)
Expression body;
}
class DoWhileStatement extends Statement {
@PropMeta(mandatory = true)
Expression body;
@PropMeta(mandatory = true)
Expression test;
}
class VariableDeclarator {
XLangASTNode id; // IdentifierOrPattern
NamedTypeNode varType;
Expression init;
}
class VariableDeclaration extends Declaration {
@PropMeta(mandatory = true)
VariableKind kind; // kind: "var";
@PropMeta(mandatory = true, minItems = 1)
List<VariableDeclarator> declarators;
}
class ForStatement extends Statement {
Expression init; // init:VariableDeclaration |Expression |null;
Expression test;
Expression update;
@PropMeta(mandatory = true)
Expression body;
}
class ForOfStatement extends Statement {
Identifier index;
@PropMeta(mandatory = true)
Expression left; //: VariableDeclaration | Pattern;
@PropMeta(mandatory = true)
Expression right;
@PropMeta(mandatory = true)
Expression body;
}
class ForRangeStatement extends Statement {
Identifier var;
Identifier index;
@PropMeta(mandatory = true)
Expression begin;
@PropMeta(mandatory = true)
Expression end;
@PropMeta(mandatory = true)
Expression step;
@PropMeta(mandatory = true)
Expression body;
}
class ForInStatement extends Statement {
Identifier index;
@PropMeta(mandatory = true)
Expression left;
@PropMeta(mandatory = true)
Expression right;
@PropMeta(mandatory = true)
Expression body;
}
// class WithStatement extends Statement {
// Expression object;
// Expression body;
// }
class DeleteStatement extends Statement {
@PropMeta(mandatory = true)
Expression argument;
}
abstract class OptionalExpression extends Expression {
boolean optional;
}
class ChainExpression extends OptionalExpression {
@PropMeta(mandatory = true)
Expression expr;
String target;
boolean notEmpty;
}
class ThisExpression extends Expression {
}
class SuperExpression extends Expression {
}
class TemplateStringExpression extends Expression {
@PropMeta(mandatory = true)
Identifier id;
@PropMeta(mandatory = true)
TemplateStringLiteral value;
}
class ArrayExpression extends Expression {
// spread element is not expression
List<XLangASTNode> elements;
}
class ObjectExpression extends Expression {
List<XLangASTNode> properties;
}
class PropertyAssignment extends Expression {
@PropMeta(mandatory = true)
Expression key; //: Literal | Identifier | Expression;
@PropMeta(mandatory = true)
Expression value; //: Expression;
PropertyKind kind; //"init" | "get" | "set";
boolean method;
boolean shorthand;
boolean computed;
}
class ParameterDeclaration {
Decorators decorators;
@PropMeta(mandatory = true)
XLangASTNode name; // IdentifierOrPattern
NamedTypeNode type;
Expression initializer;
boolean implicit;
}
class FunctionDeclaration extends DecoratedDeclaration {
@PropMeta(mandatory = true)
Identifier name;
@PropMeta(mandatory = true)
List<ParameterDeclaration> params; //:[Pattern ];
NamedTypeNode returnType;
boolean resultOptional;
@PropMeta(mandatory = true)
Expression body;
int modifiers;
}
class ArrowFunctionExpression extends Expression {
@PropMeta(mandatory = true)
List<ParameterDeclaration> params; //:[Pattern ];
NamedTypeNode returnType;
@PropMeta(mandatory = true)
Expression body; // : FunctionBody | Expression;
}
/*
enum UnaryOperator {
"-" | "+" | "!" | "~" | "typeof" | "void" | "delete"
}*/
class UnaryExpression extends Expression {
//type: "UnaryExpression";
@PropMeta(mandatory = true)
XLangOperator operator; //: UnaryOperator;
//prefix: boolean;
@PropMeta(mandatory = true)
Expression argument; //: Expression;
}
class UpdateExpression extends Expression {
//type: "UpdateExpression";
@PropMeta(mandatory = true)
XLangOperator operator;
@PropMeta(mandatory = true)
Expression argument;
boolean prefix;
}
/*
enum BinaryOperator {
"==" | "!=" | "===" | "!=="
| "<" | "<=" | ">" | ">="
| "<<" | ">>" | ">>>"
| "+" | "-" | "*" | "/" | "%"
| "|" | "^" | "&" | "in"
| "instanceof"
}
enum LogicalOperator {
"||" | "&&" | "??"
}
Nullish Coalescing
*/
class BinaryExpression extends Expression {
//type: "BinaryExpression";
@PropMeta(mandatory = true)
XLangOperator operator; //: BinaryOperator;
@PropMeta(mandatory = true)
Expression left;
@PropMeta(mandatory = true)
Expression right;
}
class InExpression extends Expression {
@PropMeta(mandatory = true)
Expression left;
@PropMeta(mandatory = true)
Expression right;
}
class ExpressionStatement extends Statement {
@PropMeta(mandatory = true)
Expression expression;
}
/**
* enum AssignmentOperator {
* "=" | "+=" | "-=" | "*=" | "/=" | "%="
* | "<<=" | ">>=" | ">>>="
* | "|=" | "^=" | "&="
* }
*/
class AssignmentExpression extends Statement {
//type: "AssignmentExpression";
@PropMeta(mandatory = true)
XLangOperator operator; //: AssignmentOperator;
@PropMeta(mandatory = true)
Expression left;
@PropMeta(mandatory = true)
Expression right;
}
class LogicalExpression extends Expression {
//type: "LogicalExpression";
@PropMeta(mandatory = true)
XLangOperator operator;
@PropMeta(mandatory = true)
Expression left;
@PropMeta(mandatory = true)
Expression right;
}
class MemberExpression extends OptionalExpression {
//type: "MemberExpression";
@PropMeta(mandatory = true)
Expression object;
@PropMeta(mandatory = true)
Expression property;
boolean computed; // computed 为true 对应于a[b], 而为false时,对应a.b, b为Identifier
}
class EvalExpression extends Expression {
String lang;
Literal source;
}
class CallExpression extends OptionalExpression {
String xplLibPath;
//type: "CallExpression";
@PropMeta(mandatory = true)
Expression callee;
@PropMeta(mandatory = true)
List<Expression> arguments;
}
class NewExpression extends Expression {
//type: "NewExpression";
@PropMeta(mandatory = true)
NamedTypeNode callee;
List<Expression> arguments;
}
class SpreadElement {
@PropMeta(mandatory = true)
Expression argument;
}
//
// // a ternary ?/: expression.
// class ConditionalExpression extends Expression {
// Expression test;
// Expression alternate;
// Expression consequent;
// }
// for(x=1,y=2;;)这种通过逗号分隔的表达式
class SequenceExpression extends Expression {
//type: "SequenceExpression";
@PropMeta(mandatory = true)
List<Expression> expressions;
}
class ConcatExpression extends Expression {
//type: "SequenceExpression";
@PropMeta(mandatory = true)
List<Expression> expressions;
}
class TemplateExpression extends Expression{
String prefix;
String postfix;
@PropMeta(mandatory = true)
List<Expression> expressions;
}
class BraceExpression extends Expression {
@PropMeta(mandatory = true)
Expression expr;
}
class ObjectBinding implements IdentifierOrPattern {
List<PropertyBinding> properties;
RestBinding restBinding;
}
class PropertyBinding {
String propName;
@PropMeta(mandatory = true)
Identifier identifier;
Expression initializer;
}
class RestBinding {
@PropMeta(mandatory = true)
Identifier identifier;
Expression initializer;
}
class ArrayBinding implements IdentifierOrPattern {
List<ArrayElementBinding> elements;
RestBinding restBinding;
}
class ArrayElementBinding {
@PropMeta(mandatory = true)
Identifier identifier;
Expression initializer;
}
abstract class ModuleSpecifier {
}
// export const foo = 1;
class ExportDeclaration extends Declaration {
@PropMeta(mandatory = true)
Declaration declaration;
}
// export {foo} from "mod";
class ExportNamedDeclaration extends ModuleDeclaration {
@PropMeta(mandatory = true)
List<ExportSpecifier> specifiers;
@PropMeta(mandatory = true)
Literal source;
}
// export * from "mod"
class ExportAllDeclaration extends ModuleDeclaration {
@PropMeta(mandatory = true)
Literal source;
}
// export {bar as foo}
class ExportSpecifier extends ModuleSpecifier {
Identifier local;
@PropMeta(mandatory = true)
Identifier exported;
}
class ImportDeclaration extends ModuleDeclaration {
//type: "ImportDeclaration";
@PropMeta(mandatory = true, minItems = 1)
List<ModuleSpecifier> specifiers; // [ ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier ];
@PropMeta(mandatory = true)
Literal source;
}
// import java.util.List as JavaList;
// import "/nop/core/c.xlib";
class ImportAsDeclaration extends ModuleDeclaration {
@PropMeta(mandatory = true)
XLangASTNode source;
Identifier local;
boolean staticImport;
}
//import {foo as bar} from "mod"
class ImportSpecifier extends ModuleSpecifier {
//type: "ImportSpecifier";
Identifier local;
@PropMeta(mandatory = true)
Identifier imported;
}
// import foo from "mod.js"
class ImportDefaultSpecifier extends ModuleSpecifier {
//type: "ImportDefaultSpecifier";
Identifier local;
}
// import * as foo from "mod.js"
class ImportNamespaceSpecifier extends ModuleSpecifier {
//type: "ImportNamespaceSpecifier";
@PropMeta(mandatory = true)
Identifier local;
}
// [...obj]
class AwaitExpression extends Expression {
//type: "AwaitExpression";
@PropMeta(mandatory = true)
Expression argument;
}
class Decorators {
List<Decorator> decorators;
}
class QualifiedName {
@PropMeta(mandatory = true)
String name;
QualifiedName next;
}
class Decorator {
QualifiedName name;
MetaObject value;
}
class MetaObject {
List<MetaProperty> properties;
}
class MetaProperty {
@PropMeta(mandatory = true)
Identifier name;
@PropMeta(mandatory = true)
XLangASTNode value;
}
class MetaArray {
List<XLangASTNode> elements;
}
class UsingStatement extends Statement {
@PropMeta(mandatory = true)
VariableDeclaration vars; //: VariableDeclaration | Pattern;
@PropMeta(mandatory = true)
Expression body;
}
// class XplNodeExpression extends Expression {
// @PropMetaAnnotation(mandatory = true)
// String tagName;
//
// @PropMetaAnnotation(mandatory = true)
// List<XplAttrExpression> attrs;
// }
//
// class XplAttrExpression {
// @PropMetaAnnotation(mandatory = true)
// String name;
//
// @PropMetaAnnotation(mandatory = true)
// Expression value;
// }
class MacroExpression extends Expression {
@PropMeta(mandatory = true)
Expression expr;
}
// 忽略表达式的返回值,通过scope.output输出
abstract class OutputExpression extends Expression {
}
enum XLangEscapeMode {
}
class TextOutputExpression extends OutputExpression {
String text;
}
class EscapeOutputExpression extends OutputExpression {
@PropMeta(mandatory = true)
XLangEscapeMode escapeMode;
@PropMeta(mandatory = true)
Expression text;
}
class CollectOutputExpression extends Expression {
boolean singleNode;
@PropMeta(mandatory = true)
XLangOutputMode outputMode;
@PropMeta(mandatory = true)
Expression body;
}
abstract class FilterOpExpression extends Expression {
String op;
String errorCode;
String label;
}
class CompareOpExpression extends FilterOpExpression {
@PropMeta(mandatory = true)
Expression left;
@PropMeta(mandatory = true)
Expression right;
}
class AssertOpExpression extends FilterOpExpression {
@PropMeta(mandatory = true)
Expression value;
}
class BetweenOpExpression extends FilterOpExpression {
@PropMeta(mandatory = true)
Expression value;
Expression min;
Expression max;
boolean excludeMin;
boolean excludeMax;
}
class GenNodeExpression extends OutputExpression {
Expression tagName;
Expression extAttrs;
List<GenNodeAttrExpression> attrs;
Expression body;
// textNode仅body属性有效
boolean textNode;
}
class GenNodeAttrExpression extends OutputExpression {
@PropMeta(mandatory = true)
String name;
@PropMeta(mandatory = true)
Expression value;
}
class OutputXmlAttrExpression extends OutputExpression {
@PropMeta(mandatory = true)
String name;
@PropMeta(mandatory = true)
Expression value;
}
class OutputXmlExtAttrsExpression extends OutputExpression {
@PropMeta(mandatory = true)
Set<String> excludeNames;
@PropMeta(mandatory = true)
Expression extAttrs;
}
class TypeOfExpression extends Expression {
@PropMeta(mandatory = true)
Expression argument;
}
class InstanceOfExpression extends Expression {
@PropMeta(mandatory = true)
Expression value;
NamedTypeNode refType;
}
class CastExpression extends Expression {
@PropMeta(mandatory = true)
Expression value;
@PropMeta(mandatory = true)
NamedTypeNode asType;
}
abstract class TypeNode {
boolean notNull;
}
abstract class NamedTypeNode extends TypeNode {
}
class ArrayTypeNode extends NamedTypeNode {
@PropMeta(mandatory = true)
NamedTypeNode componentType;
}
class ParameterizedTypeNode extends NamedTypeNode {
@PropMeta(mandatory = true)
String typeName;
@PropMeta(mandatory = true)
List<NamedTypeNode> typeArgs;
}
class TypeNameNode extends NamedTypeNode {
@PropMeta(mandatory = true)
String typeName;
}
abstract class StructuredTypeDef extends TypeNode {
}
class UnionTypeDef extends StructuredTypeDef {
@PropMeta(mandatory = true)
List<NamedTypeNode> types;
}
class IntersectionTypeDef extends StructuredTypeDef {
@PropMeta(mandatory = true)
List<NamedTypeNode> types;
}
class ObjectTypeDef extends StructuredTypeDef {
@PropMeta(mandatory = true)
List<PropertyTypeDef> types;
}
// [key:string]: number, propA?: MyType
class PropertyTypeDef extends StructuredTypeDef {
@PropMeta(mandatory = true)
String name;
@PropMeta(mandatory = true)
TypeNode valueType;
boolean anyName; // true for indexSignature, eg. [key:string]:type
boolean readonly;
boolean optional;
}
class TupleTypeDef extends StructuredTypeDef {
@PropMeta(mandatory = true)
List<TypeNode> types;
}
class TypeParameterNode {
@PropMeta(mandatory = true)
Identifier name;
NamedTypeNode upperBound;
NamedTypeNode lowerBound;
}
class TypeAliasDeclaration extends Declaration {
@PropMeta(mandatory = true)
Identifier typeName;
List<TypeParameterNode> typeParams;
@PropMeta(mandatory = true)
TypeNode defType;
}
class FunctionTypeDef extends StructuredTypeDef {
List<TypeParameterNode> typeParams;
@PropMeta(mandatory = true)
List<FunctionArgTypeDef> args;
boolean varArgs;
@PropMeta(mandatory = true)
NamedTypeNode returnType;
}
class FunctionArgTypeDef extends StructuredTypeDef {
@PropMeta(mandatory = true)
Identifier argName;
@PropMeta(mandatory = true)
NamedTypeNode argType;
boolean optional;
}
class EnumDeclaration extends Declaration {
@PropMeta(mandatory = true)
Identifier name;
@PropMeta(mandatory = true)
List<EnumMember> members;
}
class EnumMember {
@PropMeta(mandatory = true)
Identifier name;
@PropMeta(mandatory = true)
Literal value;
}
abstract class DecoratedDeclaration extends Declaration {
Decorators decorators;
}
class ClassDefinition extends DecoratedDeclaration {
@PropMeta(mandatory = true)
Identifier name;
@PropMeta(mandatory = true)
XLangClassKind classKind;
List<TypeParameterNode> typeParams;
ParameterizedTypeNode extendsType;
List<ParameterizedTypeNode> implementTypes;
@PropMeta(mandatory = true)
List<FieldDeclaration> fields;
@PropMeta(mandatory = true)
List<FunctionDeclaration> methods;
@PropMeta(mandatory = true)
List<ClassDefinition> classDefinitions;
}
class FieldDeclaration extends DecoratedDeclaration {
@PropMeta(mandatory = true)
Identifier name;
@PropMeta(mandatory = true)
NamedTypeNode type;
boolean optional;
Expression initializer;
int modifiers;
}
class CustomExpression extends Expression {
String source;
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。