UNPKG

@openfisca/json-model

Version:

Library to handle informations extracted in JSON or YAML format from OpenFisca parameters, variables, etc

266 lines (265 loc) 9.74 kB
import type { Entity } from "../entities"; import type { PeriodUnit } from "../periods"; export interface OpenfiscaAstNodeBase { ast_class: OpenfiscaAstClass; } export type OpenfiscaAstNode = OpenfiscaAstBuiltIn | OpenfiscaAstCog | OpenfiscaAstCogCall | OpenfiscaAstEntity | OpenfiscaAstFormula | OpenfiscaAstInstantOrPeriodExpression | OpenfiscaAstParameter | OpenfiscaAstParameterAtInstant | OpenfiscaAstPeriod | PythonAstNode; export type OpenfiscaAstClass = "built_in" | "cog" | "cog_call" | "entity" | "formula" | "instant_or_period_expression" | "parameter" | "parameter_at_instant" | "period"; export interface OpenfiscaAstBuiltIn extends OpenfiscaAstNodeBase { ast_class: "built_in"; name: OpenfiscaAstCogCallOperation | "Famille" | "FoyerFiscal" | "max" | "Menage" | "min" | "not"; } export interface OpenfiscaAstCog extends OpenfiscaAstNodeBase { ast_class: "cog"; entity: Entity; name: string; periodUnit: PeriodUnit; } export interface OpenfiscaAstCogCall extends OpenfiscaAstNodeBase { ast_class: "cog_call"; cog: OpenfiscaAstCog; operation?: OpenfiscaAstCogCallOperation; period: OpenfiscaAstInstantOrPeriodExpression | OpenfiscaAstPeriod; } export type OpenfiscaAstCogCallOperation = "ADD" | "DIVIDE"; export interface OpenfiscaAstEntity extends OpenfiscaAstNodeBase { ast_class: "entity"; key: string; } export interface OpenfiscaAstFormula extends OpenfiscaAstNodeBase { ast_class: "formula"; returnValue: { input: PythonAstNode; output: OpenfiscaAstNode; error?: unknown; }; } export interface OpenfiscaAstInstantOrPeriodExpression extends OpenfiscaAstNodeBase { ast_class: "instant_or_period_expression"; expression: OpenfiscaAstInstantOrPeriodExpression | PythonAstNode; } export interface OpenfiscaAstParameter extends OpenfiscaAstNodeBase { ast_class: "parameter"; ids: string[]; } export interface OpenfiscaAstParameterAtInstant extends OpenfiscaAstNodeBase { ast_class: "parameter_at_instant"; ids: string[]; instant: OpenfiscaAstNode; } export interface OpenfiscaAstPeriod extends OpenfiscaAstNodeBase { ast_class: "period"; } export interface PythonAstNodeBase { ast_class: PythonAstClass; col_offset?: number; end_col_offset?: number; end_lineno?: number; lineno?: number; } export type PythonAstClass = "Add" | "Arg" | "Arguments" | "Assign" | "Attribute" | "AugAssign" | "BinOp" | "BitAnd" | "BitOr" | "Call" | "Compare" | "comprehension" | "Constant" | "Del" | "Delete" | "Div" | "Eq" | "For" | "FunctionDef" | "GeneratorExp" | "Gt" | "GtE" | "In" | "Invert" | "Is" | "IsNot" | "keyword" | "List" | "ListComp" | "Load" | "Lt" | "LtE" | "Mult" | "Name" | "Not" | "NotEq" | "NotIn" | "Return" | "SetComp" | "Store" | "Sub" | "Subscript" | "Tuple" | "UAdd" | "UnaryOp" | "USub"; export type PythonAstNode = PythonAstArg | PythonAstArguments | PythonAstAssign | PythonAstAttribute | PythonAstAugAssign | PythonAstBinOp | PythonAstBinaryOperator | PythonAstCall | PythonAstCompare | PythonAstComparisonOperator | PythonAstComprehension | PythonAstConstant | PythonAstDel | PythonAstDelete | PythonAstFor | PythonAstFunctionDef | PythonAstGeneratorExp | PythonAstKeyword | PythonAstList | PythonAstListComp | PythonAstLoad | PythonAstName | PythonAstReturn | PythonAstSetComp | PythonAstStore | PythonAstSubscript | PythonAstTuple | PythonAstUnaryOp | PythonAstUnaryOperator; export interface PythonAstAdd extends PythonAstNodeBase { ast_class: "Add"; } export interface PythonAstArg extends PythonAstNodeBase { ast_class: "Arg"; annotation?: PythonAstNode[]; arg: string; } export interface PythonAstArguments extends PythonAstNodeBase { ast_class: "Arguments"; args: PythonAstArg[]; defaults: PythonAstNode[]; kw_defaults: PythonAstNode[]; kwarg?: PythonAstArg; kwonlyargs: PythonAstArg[]; posonlyargs: PythonAstArg[]; vararg?: PythonAstArg; } export interface PythonAstAssign extends PythonAstNodeBase { ast_class: "Assign"; targets: OpenfiscaAstNode[]; value: OpenfiscaAstNode; } export interface PythonAstAttribute extends PythonAstNodeBase { ast_class: "Attribute"; attr: string; ctx: PythonAstDel | PythonAstLoad | PythonAstStore; value: OpenfiscaAstNode; } export interface PythonAstAugAssign extends PythonAstNodeBase { ast_class: "AugAssign"; op: PythonAstNode; target: PythonAstName; value: PythonAstNode; } export type PythonAstBinaryOperator = PythonAstAdd | PythonAstBitAnd | PythonAstBitOr | PythonAstDiv | PythonAstMult | PythonAstSub; export interface PythonAstBinOp extends PythonAstNodeBase { ast_class: "BinOp"; left: PythonAstNode; op: PythonAstBinaryOperator; right: PythonAstNode; } export interface PythonAstBitAnd extends PythonAstNodeBase { ast_class: "BitAnd"; } export interface PythonAstBitOr extends PythonAstNodeBase { ast_class: "BitOr"; } export interface PythonAstCall extends PythonAstNodeBase { args: OpenfiscaAstNode[]; ast_class: "Call"; func: OpenfiscaAstNode; keywords: PythonAstKeyword[]; } export interface PythonAstCompare extends PythonAstNodeBase { ast_class: "Compare"; comparators: PythonAstNode[]; left: PythonAstNode; ops: PythonAstComparisonOperator[]; } export type PythonAstComparisonOperator = PythonAstEq | PythonAstGt | PythonAstGtE | PythonAstIn | PythonAstIs | PythonAstIsNot | PythonAstLt | PythonAstLtE | PythonAstNotEq | PythonAstNotIn; export interface PythonAstComprehension extends PythonAstNodeBase { ast_class: "comprehension"; ifs: PythonAstNode[]; is_async: number; iter: PythonAstNode; target: PythonAstNode; value: PythonAstNode; } export interface PythonAstConstant extends PythonAstNodeBase { ast_class: "Constant"; value?: number | string; } export interface PythonAstDel extends PythonAstNodeBase { ast_class: "Del"; } export interface PythonAstDelete extends PythonAstNodeBase { ast_class: "Delete"; targets: PythonAstNode[]; } export interface PythonAstDiv extends PythonAstNodeBase { ast_class: "Div"; } export interface PythonAstEq extends PythonAstNodeBase { ast_class: "Eq"; } export interface PythonAstFor extends PythonAstNodeBase { ast_class: "For"; body: PythonAstNode[]; iter: PythonAstNode; orelse: PythonAstNode[]; target: PythonAstNode; type_comment?: string; } export interface PythonAstFunctionDef extends PythonAstNodeBase { ast_class: "FunctionDef"; args: PythonAstArguments; body: PythonAstNode[]; decorator_list: unknown; name: string; return: unknown; } export interface PythonAstGeneratorExp extends PythonAstNodeBase { ast_class: "GeneratorExp"; elt: PythonAstNode; generators: PythonAstComprehension[]; } export interface PythonAstGt extends PythonAstNodeBase { ast_class: "Gt"; } export interface PythonAstGtE extends PythonAstNodeBase { ast_class: "GtE"; } export interface PythonAstIn extends PythonAstNodeBase { ast_class: "In"; } export interface PythonAstInvert extends PythonAstNodeBase { ast_class: "Invert"; } export interface PythonAstIs extends PythonAstNodeBase { ast_class: "Is"; } export interface PythonAstIsNot extends PythonAstNodeBase { ast_class: "IsNot"; } export interface PythonAstKeyword extends PythonAstNodeBase { arg?: string; ast_class: "keyword"; value: OpenfiscaAstNode; } export interface PythonAstList extends PythonAstNodeBase { ast_class: "List"; ctx: PythonAstLoad | PythonAstStore; elts: PythonAstNode[]; } export interface PythonAstListComp extends PythonAstNodeBase { ast_class: "ListComp"; elt: PythonAstNode; generators: PythonAstComprehension[]; } export interface PythonAstLoad extends PythonAstNodeBase { ast_class: "Load"; } export interface PythonAstLt extends PythonAstNodeBase { ast_class: "Lt"; } export interface PythonAstLtE extends PythonAstNodeBase { ast_class: "LtE"; } export interface PythonAstMult extends PythonAstNodeBase { ast_class: "Mult"; } export interface PythonAstName extends PythonAstNodeBase { ast_class: "Name"; ctx: PythonAstDel | PythonAstLoad | PythonAstStore; id: string; } export interface PythonAstNot extends PythonAstNodeBase { ast_class: "Not"; } export interface PythonAstNotEq extends PythonAstNodeBase { ast_class: "NotEq"; } export interface PythonAstNotIn extends PythonAstNodeBase { ast_class: "NotIn"; } export interface PythonAstReturn extends PythonAstNodeBase { ast_class: "Return"; value?: OpenfiscaAstNode | undefined; } export interface PythonAstSetComp extends PythonAstNodeBase { ast_class: "SetComp"; elt: PythonAstNode; generators: PythonAstComprehension[]; } export interface PythonAstStore extends PythonAstNodeBase { ast_class: "Store"; } export interface PythonAstSub extends PythonAstNodeBase { ast_class: "Sub"; } export interface PythonAstSubscript extends PythonAstNodeBase { ast_class: "Subscript"; ctx: PythonAstDel | PythonAstLoad | PythonAstStore; slice: OpenfiscaAstNode; value: OpenfiscaAstNode; } export interface PythonAstTuple extends PythonAstNodeBase { ast_class: "Tuple"; ctx: PythonAstLoad | PythonAstStore; elts: PythonAstNode[]; } export interface PythonAstUAdd extends PythonAstNodeBase { ast_class: "UAdd"; } export interface PythonAstUnaryOp extends PythonAstNodeBase { ast_class: "UnaryOp"; operand: PythonAstNode; op: PythonAstUnaryOperator; } export type PythonAstUnaryOperator = PythonAstInvert | PythonAstNot | PythonAstUAdd | PythonAstUSub; export interface PythonAstUSub extends PythonAstNodeBase { ast_class: "USub"; }