📄 parser.c
字号:
snoswitch , snotype , snotype_name ;#define dnocatch snocatch#define dnodecl snodecl#define dnoexpression snoexpression#define dnoexpression_l snoexpression_l#define dnofield snofield#define dnoimport snoimport#define dnostatement snostatement#define dnoswitch snoswitch#define dnotype snotype#define dnotype_name snotype_name#else#define dnocatch mnocatch ()#define dnodecl mnodecl ()#define dnoexpression mnoexpression (NoPosition)#define dnoexpression_l mnoexpression_l ()#define dnofield mnofield ()#define dnoimport mnoimport ()#define dnostatement mnostatement ()#define dnoswitch mnoswitch ()#define dnotype mnotype ()#define dnotype_name mnotype_name ()#endifstatic rbool is_initialized = rfalse;static rbool report = rfalse;static rbool graphic = rfalse;static void get_options ARGS ((void)){ char * arg = getenv ("PAF_JAVA"); if (arg == NULL) return; while (* arg) { if (* arg == '-') { switch (* ++ arg) { case 'f': report = rtrue; break; case 'g': graphic = rtrue; break; case 'h': (void) printf ("\nsyntax of PAF_JAVA:\n\n"); (void) printf (" [-f] [-h]\n\n"); (void) printf (" f : report error messages (default: do not report)\n"); (void) printf (" h : help\n\n"); break; } } arg ++; }}void start_parser (fname, parse_cplpl, highl_fp, highlight) char * fname; int parse_cplpl; FILE * highl_fp; int highlight;{ current_file = fname; hlfp = highl_fp; hl = highlight; if (! is_initialized) { get_options (); is_initialized = rtrue; } StoreMessages (rtrue); InitStringMemory (); InitIdents (); init_deftab (); if (fname) Attribute.Position.FileName = MakeIdent (fname, strlen (fname)); else Attribute.Position.FileName = NoIdent; BeginFile (""); (void) Parser (); /* (void) CheckTree (TreeRoot); */ if (cross_ref_fp != NULL) { Eval (TreeRoot); Traverse (TreeRoot); }#ifdef DRAWTREE if (graphic) DrawTree (TreeRoot);#endif ReleaseTreeModule (); CloseStringMemory (); if (report) WriteMessages (stderr);}static int class_stack_ptr = 0;static char * class_stack [32] = { NIL };#define push(ident) { class_stack [++ class_stack_ptr] = current_class; \ current_class = GetCStr (ident); }#define pop() { current_class = class_stack [class_stack_ptr --]; }#define top() class_stack [class_stack_ptr]static void get_bpos (tree, l, c) tTree tree; int * l; int * c;{ while (tree->Kind == kqualification) tree = tree->qualification.qualified_symbol; * l = tree->ident.pos.Line; * c = tree->ident.pos.Column - 1;}static void put_extends (tree) tTree tree;{ while (tree->Kind == ktype_name) { tTree symbol = tree->type_name.named_type->named_type.qualified_symbol; to_types (symbol, current_string); if (symbol->Kind == kident) put_symbol (PAF_CLASS_INHERIT, current_class, current_string, current_file, (int) symbol->ident.pos.Line, (int) symbol->ident.pos.Column - 1, (int) symbol->ident.pos.Line, (int) (symbol->ident.pos.Column + LengthSt (GetStringRef (symbol->ident.ident)) - 1), (unsigned long) PAF_PUBLIC, NIL, NIL, NIL, NIL, 0, 0, 0, 0); else { int l, c; get_bpos (symbol->qualification.qualified_symbol, & l, & c); put_symbol (PAF_CLASS_INHERIT, current_class, current_string, current_file, l, c, (int) symbol->qualification.pos.Line, (int) (symbol->qualification.pos.Column + LengthSt (GetStringRef (symbol->qualification.ident)) - 1), (unsigned long) PAF_PUBLIC, NIL, NIL, NIL, NIL, 0, 0, 0, 0); } tree = tree->type_name.next; }}typedef struct { tTree tree; } zzType;typedef struct { tTree tree; } zzPrimitiveType;typedef struct { tTree tree; } zzReferenceType;typedef struct { tTree tree; tPosition bpos; tPosition epos; } zzClassOrInterfaceType;typedef struct { tTree tree; tPosition bpos; tPosition epos; } zzClassType;typedef struct { tTree tree; } zzInterfaceType;typedef struct { tTree tree; } zzArrayType;typedef struct { tTree tree; tPosition bpos; tPosition epos; } zzName;typedef struct { tTree tree; } zzImportDeclarations;typedef struct { tTree tree; } zzTypeDeclarations;typedef struct { tTree tree; } zzPackageDeclaration;typedef struct { tTree tree; } zzImportDeclaration;typedef struct { tTree tree; } zzTypeDeclaration;typedef struct { long attr; } zzModifiers;typedef struct { long attr; } zzModifier;typedef struct { tTree tree; } zzClassDeclaration;typedef struct { tTree tree; } zzSuper;typedef struct { tTree tree; } zzInterfaces;typedef struct { tTree tree; } zzInterfaceTypeList;typedef struct { tTree tree; tPosition epos; } zzClassBody;typedef struct { tTree tree; } zzClassBodyDeclarations;typedef struct { tTree tree; } zzClassBodyDeclaration;typedef struct { tTree tree; } zzFieldDeclaration;typedef struct { tTree tree; } zzVariableDeclarators;typedef struct { tTree tree; } zzVariableDeclarator;typedef struct { tTree tree; tIdent ident; tPosition Position; } zzVariableDeclaratorId;typedef struct { tTree tree; } zzLocalVariableDeclaration;typedef struct { tTree tree; } zzLocalVariableDeclarators;typedef struct { tTree tree; } zzLocalVariableDeclarator;typedef struct { tTree tree; } zzMethodDeclaration;typedef struct { tTree tree; tIdent ident; tPosition Position; tTree array; long attr; tTree type; tTree throws; } zzMethodHeader;typedef struct { tTree tree; tIdent ident; tPosition Position; tTree array; } zzMethodDeclarator;typedef struct { tTree tree; tPosition epos; } zzMethodBody;typedef struct { tTree tree; } zzFormalParameterListOpt;typedef struct { tTree tree; } zzFormalParameterList;typedef struct { tTree tree; } zzFormalParameter;typedef struct { tTree tree; } zzThrowsOpt;typedef struct { tTree tree; } zzClassTypeList;typedef struct { tTree tree; } zzClassInitializer;typedef struct { tTree tree; } zzConstructorDeclaration;typedef struct { tTree tree; tIdent ident; tPosition Position; } zzConstructorDeclarator;typedef struct { tTree tree; tPosition epos; } zzConstructorBody;typedef struct { tTree tree; } zzExplicitConstructorInvocation;typedef struct { tTree tree; } zzInterfaceDeclaration;typedef struct { tTree tree; } zzExtendsInterfacesOpt;typedef struct { tTree tree; } zzExtendsInterfaces;typedef struct { tTree tree; tPosition epos; } zzInterfaceBody;typedef struct { tTree tree; } zzInterfaceMemberDeclarations;typedef struct { tTree tree; } zzInterfaceMemberDeclaration;typedef struct { tTree tree; } zzVariableInitializerOpt;typedef struct { tTree tree; } zzVariableInitializer;typedef struct { tTree tree; } zzVariableInitializersOpt;typedef struct { tTree tree; } zzVariableInitializers;typedef struct { tTree tree; } zzArrayInitializerOpt;typedef struct { tTree tree; tPosition epos; } zzBlock;typedef struct { tTree tree; } zzBlockStatements;typedef struct { tTree tree; } zzBlockStatement;typedef struct { tTree tree; } zzStatementNoShortIf;typedef struct { tTree tree; } zzStatementWithoutTrailingSubstatement;typedef struct { tTree tree; } zzStatementExpression;typedef struct { tTree tree; } zzSwitchBlock;typedef struct { tTree tree; } zzSwitchBlockStatementGroups;typedef struct { tTree tree; } zzSwitchBlockStatementGroup;typedef struct { tTree tree; } zzSwitchLabels;typedef struct { tTree tree; } zzSwitchLabel;typedef struct { tTree tree; } zzForInit;typedef struct { tTree tree; } zzExpressionOpt;typedef struct { tTree tree; } zzForUpdate;typedef struct { tTree tree; } zzStatementExpressionList;typedef struct { tTree tree; } zzCatchesOpt;typedef struct { tTree tree; } zzCatches;typedef struct { tTree tree; } zzCatchClause;typedef struct { tTree tree; } zzFinally;typedef struct { tTree tree; } zzPrimary;typedef struct { tTree tree; } zzDimExprs;typedef struct { tTree tree; } zzDimExpr;typedef struct { tTree tree; } zzDims;typedef struct { tTree tree; } zzArgumentListOpt;typedef struct { tTree tree; } zzArgumentList;typedef struct { tTree tree; } zzcExpression;typedef struct { tTree tree; } zzExpression;typedef struct { tTree tree; } zzLeftHandSide;typedef struct { int operator; tPosition Position; } zzAssignmentOperator;typedef union {tScanAttribute Scan;zzType Type;zzPrimitiveType PrimitiveType;zzReferenceType ReferenceType;zzClassOrInterfaceType ClassOrInterfaceType;zzClassType ClassType;zzInterfaceType InterfaceType;zzArrayType ArrayType;zzName Name;zzImportDeclarations ImportDeclarations;zzTypeDeclarations TypeDeclarations;zzPackageDeclaration PackageDeclaration;zzImportDeclaration ImportDeclaration;zzTypeDeclaration TypeDeclaration;zzModifiers Modifiers;zzModifier Modifier;zzClassDeclaration ClassDeclaration;zzSuper Super;zzInterfaces Interfaces;zzInterfaceTypeList InterfaceTypeList;zzClassBody ClassBody;zzClassBodyDeclarations ClassBodyDeclarations;zzClassBodyDeclaration ClassBodyDeclaration;zzFieldDeclaration FieldDeclaration;zzVariableDeclarators VariableDeclarators;zzVariableDeclarator VariableDeclarator;zzVariableDeclaratorId VariableDeclaratorId;zzLocalVariableDeclaration LocalVariableDeclaration;zzLocalVariableDeclarators LocalVariableDeclarators;zzLocalVariableDeclarator LocalVariableDeclarator;zzMethodDeclaration MethodDeclaration;zzMethodHeader MethodHeader;zzMethodDeclarator MethodDeclarator;zzMethodBody MethodBody;zzFormalParameterListOpt FormalParameterListOpt;zzFormalParameterList FormalParameterList;zzFormalParameter FormalParameter;zzThrowsOpt ThrowsOpt;zzClassTypeList ClassTypeList;zzClassInitializer ClassInitializer;zzConstructorDeclaration ConstructorDeclaration;zzConstructorDeclarator ConstructorDeclarator;zzConstructorBody ConstructorBody;zzExplicitConstructorInvocation ExplicitConstructorInvocation;zzInterfaceDeclaration InterfaceDeclaration;zzExtendsInterfacesOpt ExtendsInterfacesOpt;zzExtendsInterfaces ExtendsInterfaces;zzInterfaceBody InterfaceBody;zzInterfaceMemberDeclarations InterfaceMemberDeclarations;zzInterfaceMemberDeclaration InterfaceMemberDeclaration;zzVariableInitializerOpt VariableInitializerOpt;zzVariableInitializer VariableInitializer;zzVariableInitializersOpt VariableInitializersOpt;zzVariableInitializers VariableInitializers;zzArrayInitializerOpt ArrayInitializerOpt;zzBlock Block;zzBlockStatements BlockStatements;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -