unoidl2

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/unoidl2.git/
Log | Files | Refs

scan.ll (5008B)


      1 /* uno idl file lexer */
      2 /*
      3    This file is part of unoidl2.
      4 
      5    unoidl2 is free software: you can redistribute it and/or modify
      6    it under the terms of the GNU General Public License as published by
      7    the Free Software Foundation, either version 3 of the License, or
      8    (at your option) any later version.
      9 
     10    unoidl2 is distributed in the hope that it will be useful,
     11    but WITHOUT ANY WARRANTY; without even the implied warranty of
     12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13    GNU General Public License for more details.
     14 
     15    You should have received a copy of the GNU General Public License
     16    along with unoidl2.  If not, see <http://www.gnu.org/licenses/>.
     17 */
     18 
     19 %{
     20 #include "unoidl2.h"
     21 
     22 #define YYSTYPE Any
     23 
     24 #include "parse.c.h"
     25 #include <stdio.h>
     26 
     27 int yycolumn = 1;
     28 
     29 Kind tok(Kind kind, char *token) {
     30      //printf("{%s}\n", token);
     31      yylval = mk(kind, token);
     32      return kind;
     33 }
     34 
     35 %}
     36 
     37 %option noyywrap
     38 %option never-interactive
     39 
     40 DIGIT           [0-9]
     41 OCT_DIGIT       [0-7]
     42 HEX_DIGIT       [a-fA-F0-9]
     43 CAPITAL         [A-Z]
     44 ALPHA           [a-zA-Z]
     45 INT             [1-9][0-9]*
     46 OCT             0{OCT_DIGIT}*
     47 HEX             (0x|0X){HEX_DIGIT}*
     48 REAL            [+-]?{DIGIT}+[.]{DIGIT}+
     49 
     50 IDENTIFIER_NEW  ({ALPHA}({ALPHA}|{DIGIT})*)|({CAPITAL}("_"?({ALPHA}|{DIGIT})+)*)
     51 IDENTIFIER      ("_"?({ALPHA}|{DIGIT})+)*
     52 
     53 %%
     54 
     55 [ \t\r]+	; /* eat up whitespace */
     56 [\n]           {
     57        yycolumn = 1;
     58        yylineno++;
     59 }
     60 
     61 "="     return tok(EQ, "=");
     62 "<"     return tok(LT, "<");
     63 "<="    return tok(LE, "<=");
     64 ">"     return tok(GT, ">");
     65 ">="    return tok(GE, ">=");
     66 "+"     return tok(PLUS, "+");
     67 "-"     return tok(MINUS, "-");
     68 "*"     return tok(MUL, "*");
     69 "/"     return tok(DIV, "/");
     70 "%"     return tok(MOD, "%");
     71 "|"     return tok(OR, "or");
     72 "^"     return tok(XOR, "xor");
     73 "&"     return tok(AND, "and");
     74 "<<"    return tok(LSHIFT, "<<");
     75 ">>"    return tok(RSHIFT, ">>");
     76 "~"     return tok(NOT, "~");
     77 "::"    return tok(SCOPE, "::");
     78 "{"     return tok(LCURLY, "{");
     79 "}"     return tok(RCURLY, "}");
     80 "["     return tok(LSQUARE, "[");
     81 "]"     return tok(RSQUARE, "]");
     82 "("     return tok(LPAR, "(");
     83 ")"     return tok(RPAR, ")");
     84 ","     return tok(COMMA, ",");
     85 ";"     return tok(SEMICOLON, ";");
     86 ":"     return tok(COLON, ":");
     87 
     88 attribute       return tok(ATTRIBUTE, "attribute");
     89 bound           return tok(BOUND, "bound");
     90 case            return tok(CASE, "case");
     91 const           return tok(CONST, "const");
     92 constants       return tok(CONSTANTS, "constants");
     93 constrained     return tok(CONSTRAINED, "constrained");
     94 default         return tok(DEFAULT, "default");
     95 enum            return tok(ENUM, "enum");
     96 exception       return tok(EXCEPTION, "exception");
     97 interface       return tok(INTERFACE, "interface");
     98 maybeambiguous  return tok(MAYBEAMBIGUOUS, "maybeambiguous");
     99 maybedefault    return tok(MAYBEDEFAULT, "maybedefault");
    100 maybevoid       return tok(MAYBEVOID, "maybevoid");
    101 module          return tok(MODULE, "module");
    102 needs           return tok(NEEDS, "needs");
    103 observes        return tok(OBSERVES, "observes");
    104 optional        return tok(OPTIONAL, "optional");
    105 property        return tok(PROPERTY, "property");
    106 raises          return tok(RAISES, "raises");
    107 readonly        return tok(READONLY, "readonly");
    108 removable       return tok(REMOVEABLE, "removable");
    109 service         return tok(SERVICE, "service");
    110 sequence        return tok(SEQUENCE, "sequence");
    111 singleton       return tok(SINGLETON, "singleton");
    112 struct          return tok(STRUCT, "struct");
    113 switch          return tok(SWITCH, "switch");
    114 transient       return tok(TRANSIENT, "transient");
    115 typedef         return tok(TYPEDEF, "typedef");
    116 union           return tok(UNION, "union");
    117 
    118 any             return tok(ANY, "any");
    119 boolean         return tok(BOOLEAN, "boolean");
    120 byte            return tok(BYTE, "byte");
    121 char            return tok(CHAR, "char");
    122 double          return tok(DOUBLE, "double");
    123 float           return tok(FLOAT, "float");
    124 hyper           return tok(HYPER, "hyper");
    125 long            return tok(LONG, "long");
    126 short           return tok(SHORT, "short");
    127 string          return tok(STRING, "string");
    128 type            return tok(TYPE, "type");
    129 unsigned        return tok(UNSIGNED, "unsigned");
    130 void            return tok(VOID, "void");
    131 
    132 TRUE            return tok(TRUE, "true");
    133 True            return tok(TRUE, "true");
    134 FALSE           return tok(FALSE, "false");
    135 False           return tok(FALSE, "false");
    136 
    137 in              return tok(IN, "in");
    138 out             return tok(OUT, "out");
    139 inout           return tok(INOUT, "inout");
    140 oneway          return tok(ONEWAY, "oneway");
    141 
    142 get             return tok(GET, "get");
    143 set             return tok(SET, "set");
    144 
    145 published       return tok(PUBLISHED, "published");
    146 
    147 "..."           return tok(ELLIPSIS, "ellipsis");
    148 
    149 {INT}           return tok(INT, yytext);
    150 {OCT}           return tok(OCT, yytext);
    151 {HEX}           return tok(HEX, yytext);
    152 {REAL}          return tok(REAL, yytext);
    153 
    154 {IDENTIFIER}    return tok(ID, yytext);
    155 
    156 %%