|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T l
Length: 10057 (0x2749) Types: TextFile Names: »lex.l.gnrc«
└─⟦3d0c2be1b⟧ Bits:30001254 ISODE-5.0 Tape └─⟦eba4602b1⟧ »./isode-5.0.tar.Z« └─⟦d3ac74d73⟧ └─⟦this⟧ »isode-5.0/pepy/lex.l.gnrc«
/* lex.l - lex ASN.1 analyzer */ /* %WARNING% */ %{ #ifndef lint static char *RCSid = "$Header: /f/osi/pepy/RCS/lex.l.gnrc,v 6.0 89/03/18 23:37:30 mrose Rel $"; #endif /* * $Header: /f/osi/pepy/RCS/lex.l.gnrc,v 6.0 89/03/18 23:37:30 mrose Rel $ * * * $Log: lex.l.gnrc,v $ * Revision 6.0 89/03/18 23:37:30 mrose * Release 5.0 * */ /* * NOTICE * * Acquisition, use, and distribution of this module and related * materials are subject to the restrictions of a license agreement. * Consult the Preface in the User's Manual for the full terms of * this agreement. * * */ struct table { char *t_keyword; int t_value; }; static struct table reserved[] = { "ABSENT", ABSENT, "ANY", ANY, "APPLICATION", APPLICATION, "BEGIN", BGIN, "BIT", BIT, "BITSTRING", BITSTRING, "BOOLEAN", BOOLEAN, "BY", BY, "CHOICE", CHOICE, "COMPONENT", COMPONENT, "COMPONENTS", COMPONENTS, "COMPONENTSOF", COMPONENTSOF, "DECODER", DECODER, "DEFAULT", DEFAULT, "DEFINED", DEFINED, "DEFINITIONS", DEFINITIONS, "ENCODER", ENCODER, "ENCRYPTED", ENCRYPTED, "END", END, "ENUMERATED", ENUMERATED, "EXPLICIT", EXPLICIT, "EXPORTS", EXPORTS, "FALSE", FALSE, "FROM", FROM, "IDENTIFIER", IDENTIFIER, "IMPLICIT", IMPLICIT, "IMPORTS", IMPORTS, "INCLUDE", INCLUDES, "INTEGER", INTEGER, "MIN", MIN, "MAX", MAX, "NULL", NIL, "OBJECT", OBJECT, "OCTET", OCTET, "OCTETSTRING", OCTETSTRING, "OF", OF, "OPTIONAL", OPTIONAL, "PREFIXES", PREFIXES, "PRESENT", PRESENT, "PRINTER", PRINTER, "PRIVATE", PRIVATE, "REAL", REAL, "SECTIONS", SECTIONS, "SEQUENCE", SEQUENCE, "SEQUENCEOF", SEQUENCEOF, "SET", SET, "SETOF", SETOF, "SIZE", SIZE, "STRING", STRING, "TAGS", TAGS, "TRUE", TRUE, "UNIVERSAL", UNIVERSAL, "WITH", WITH, %BEGIN(ROSY)% "OPERATION", OPERATION, "ARGUMENT", ARGUMENT, "RESULT", RESULT, "ERRORS", ERRORS, "LINKED", LINKED, "ERROR", ERROR, "PARAMETER", PARAMETER, /* start new stuff */ "ABSTRACT-OPERATION", OPERATION, "ABSTRACT-ERROR", ERROR, "ABSTRACT", ABSTRACT, "OPERATIONS", OPERATIONS, "CONSUMER", CONSUMER, "SUPPLIER", SUPPLIER, "INVOKES", INVOKES, "PORT", PORT, "PORTS", PORTS, /* refine is beyond me! (JPO) "REFINE", REFINE, "AS", AS, "RECURRING", RECURRING, "VISIBLE", VISIBLE, "PAIRED", PAIRED, */ /* end new stuff */ %END(ROSY)% %BEGIN(MOSY)% "OBJECT-TYPE", OBJECTYPE, "SYNTAX", SYNTAX, "ACCESS", ACCESS, "STATUS", STATUS, %END(MOSY)% NULL, 0 }; %} %% "--" { register int c, d; for (d = 0; c = input (); d = c == '-') if (c == '\n' || (d && c == '-')) break; } [ \t]* { if (yydebug) fprintf (stderr, "WT\n"); } \n { if (yydebug) fprintf (stderr, "NL\n"); } "::=" { if (yydebug) fprintf (stderr, "SY: CCE\n"); return CCE; } "..." { if (yydebug) fprintf (stderr, "SY: DOTDOTDOT\n"); return DOTDOTDOT; } ".." { if (yydebug) fprintf (stderr, "SY: DOTDOT\n"); return DOTDOT; } "." { if (yydebug) fprintf (stderr, "SY: DOT\n"); return DOT; } ";" { if (yydebug) fprintf (stderr, "SY: SEMICOLON"); return SEMICOLON; } "," { if (yydebug) fprintf (stderr, "SY: COMMA\n"); return COMMA; } "{" { if (yydebug) fprintf (stderr, "SY: LBRACE\n"); return LBRACE; } "}" { if (yydebug) fprintf (stderr, "SY: RBRACE\n"); return RBRACE; } "|" { if (yydebug) fprintf (stderr, "SY: BAR\n"); return BAR; } %BEGIN(ROSY)% "[S]" { if (yydebug) fprintf (stderr, "SY: OBJECTSUPPLIER\n"); return OBJECTSUPPLIER; } "[C]" { if (yydebug) fprintf (stderr, "SY: OBJECTCONSUMER\n"); return OBJECTCONSUMER; } %END(ROSY)% "[["|"$"|"<<" { register int tok, c, d, len; register char *cp, *ep, *pp; if (*yytext == '$') tok = VLENGTH; else if (*yytext == '<') tok = CONTROL; else { while((c = input()) == ' ' || c =='\t') continue; switch (c) { case 'a': tok = VALA; break; case 'b': tok = VALB; break; case 'i': tok = VALI; break; case 's': tok = VALS; break; case 'o': tok = VALO; break; case 'x': tok = VALX; break; case 'p': tok = VALP; break; case 'q': tok = VALQ; break; case 'O': tok = VALOID; break; case 'P': tok = PARAMETERTYPE; break; default : myyerror ("unknown token: \"%s\"", yytext); break; } if ((c = input()) != ' ' && c != '\t' && c != '\n') yyerror ("syntax error in [[ ... ]]"); } if ((pp = malloc ((unsigned) (len = BUFSIZ))) == NULL) yyerror ("out of memory"); for (ep = (cp = pp) + len - 1, d = NULL;; d = c) { if ((c = input ()) == NULL) yyerror ("end-of-file while reading value"); if ((d == ']' && c == ']' && tok !=CONTROL) || (c == '$' && (tok ==VALX || tok ==VALO)) || (d == '>' && c == '>' && tok ==CONTROL)) { if ((tok == VALX || tok == VALO) && (c != '$')) yyerror("Missing '$' in [[ - ]]"); if (c == '$') {unput(c); *cp = NULL;} else *--cp = NULL; yylval.yy_string = pp; if (yydebug) fprintf (stderr, "VAL: \"%s\"\n", yylval.yy_string); return tok; } if (cp >= ep) { register int curlen = cp - pp; register char *dp; if ((dp = realloc (pp, (unsigned) (len += BUFSIZ))) == NULL) yyerror ("out of memory"); cp = dp + curlen; ep = (pp = dp) + len - 1; } *cp++ = c; } } "[" { if (yydebug) fprintf (stderr, "SY: LBRACKET\n"); return LBRACKET; } "]" { if (yydebug) fprintf (stderr, "SY: RBRACKET\n"); return RBRACKET; } "<" { if (yydebug) fprintf (stderr, "SY: LANGLE\n"); return LANGLE; } "(" { if (yydebug) fprintf (stderr, "SY: LPAREN\n"); return LPAREN; } ")" { if (yydebug) fprintf (stderr, "SY: RPAREN\n"); return RPAREN; } [0-9]+ { (void) sscanf (yytext, "%d", &yylval.yy_number); if (yydebug) fprintf (stderr, "LIT: 0x%x\n", yylval.yy_number); return LITNUMBER; } -[0-9]+ { (void) sscanf (yytext, "%d", &yylval.yy_number); if (yydebug) fprintf (stderr, "LIT: 0x%x\n", yylval.yy_number); return LITNUMBER; } '[^'$]*'[BbHh] { register char *cp; register int i; switch (*(cp = yytext + strlen (yytext) - 1)) { case 'H': case 'h': *cp = NULL; (void) sscanf (yytext + 1, "%x", &yylval.yy_number); break; case 'B': case 'b': *cp-- = NULL, *cp = NULL; for (i = 0, cp = yytext + 1; *cp; ) { i <<= 1; i += *cp++ - '0'; } yylval.yy_number = i; break; } if (yydebug) fprintf (stderr, "LIT: 0x%x\n", yylval.yy_number); return LITNUMBER; } \"[^\"$]*\" { yytext[strlen (yytext) - 1] = NULL; yylval.yy_string = new_string (yytext + 1); if (yydebug) fprintf (stderr, "LIT: \"%s\"\n", yylval.yy_string); return LITSTRING; } [A-Z][A-Za-z0-9-]* { register struct table *t; for (t = reserved; t -> t_keyword; t++) if (strcmp (t -> t_keyword, yytext) == 0) { if (yydebug) fprintf (stderr, "KE: \"%s\"\n", yytext); return t -> t_value; } yylval.yy_string = new_string (yytext); if (yydebug) fprintf (stderr, "ID: \"%s\"\n", yylval.yy_string); return ID; } [a-z][A-Za-z0-9-]* { yylval.yy_string = new_string (yytext); if (yydebug) fprintf (stderr, "NAME: \"%s\"\n", yylval.yy_string); return NAME; } "%[" { register int c, d, len; register char *cp, *ep, *pp; if ((pp = malloc ((unsigned) (len = BUFSIZ))) == NULL) yyerror ("out of memory"); for (ep = (cp = pp) + len - 1, d = NULL;; d = c) { if ((c = input ()) == NULL) yyerror ("end-of-file while reading value"); if (d == '%' && c == ']' ) { *--cp = NULL; yylval.yy_string = pp; if (yydebug) fprintf (stderr, "VAL: \"%s\"\n", yylval.yy_string); return SCTRL; } if (d == '\n') yyerror ("newline in %[ %] construct"); if (cp >= ep) { register int curlen = cp - pp; register char *dp; if ((dp = realloc (pp, (unsigned) (len += BUFSIZ))) == NULL) yyerror ("out of memory"); cp = dp + curlen; ep = (pp = dp) + len - 1; } *cp++ = c; } } "%{" { register int c, d, len; int mylineno; register char *cp, *ep, *pp; mylineno = yylineno; if ((pp = malloc ((unsigned) (len = BUFSIZ))) == NULL) yyerror ("out of memory"); for (ep = (cp = pp) + len - 1, d = NULL;; d = c) { if ((c = input ()) == NULL) yyerror ("end-of-file while reading action"); if (d == '%' && c == '}') { *--cp = NULL; yylval.yy_action = new_action (pp, mylineno);; if (yydebug) fprintf (stderr, "ACTION: \"%s\", %d\n", yylval.yy_action -> ya_text, yylval.yy_action -> ya_lineno); return ACTION; } if (cp >= ep) { register int curlen = cp - pp; register char *dp; if ((dp = realloc (pp, (unsigned) (len += BUFSIZ))) == NULL) yyerror ("out of memory"); cp = dp + curlen; ep = (pp = dp) + len - 1; } *cp++ = c; } } . { myyerror ("unknown token: \"%s\"", yytext); } %%