Esempio n. 1
0
File: lexer.c Progetto: Saruta/a2c
void getalnum(struct token *tok)
{
  tok->val = getalnumstr();

  if (strcmp(tok->val, keywords[current_lang][0]) == 0)
    tok->type = ALGORITHM;
  else if (strcmp(tok->val, keywords[current_lang][1]) == 0)
    tok->type = BEGIN;
  else if (strcmp(tok->val, keywords[current_lang][2]) == 0)
    tok->type = TYPES;
  else if (strcmp(tok->val, keywords[current_lang][3]) == 0)
    tok->type = CONST;
  else if (strcmp(tok->val, keywords[current_lang][4]) == 0)
    tok->type = OR;
  else if (strcmp(tok->val, keywords[current_lang][5]) == 0)
    tok->type = XOR;
  else if (strcmp(tok->val, keywords[current_lang][6]) == 0)
    tok->type = AND;
  else if (strcmp(tok->val, keywords[current_lang][7]) == 0)
    tok->type = DIV;
  else if (strcmp(tok->val, keywords[current_lang][8]) == 0)
    tok->type = MOD;
  else if (strcmp(tok->val, keywords[current_lang][9]) == 0)
    tok->type = NOT;
  else if (strcmp(tok->val, keywords[current_lang][10]) == 0)
    tok->type = WHILE;
  else if (strcmp(tok->val, keywords[current_lang][11]) == 0)
    tok->type = SO;
  else if (strcmp(tok->val, keywords[current_lang][12]) == 0)
    tok->type = DO;
  else if (strcmp(tok->val, keywords[current_lang][13]) == 0)
    tok->type = END;
  else if (strcmp(tok->val, keywords[current_lang][14]) == 0)
    tok->type = RETURN;
  else if (strcmp(tok->val, keywords[current_lang][15]) == 0)
    tok->type = FOR;
  else if (strcmp(tok->val, keywords[current_lang][16]) == 0)
    tok->type = UNTIL;
  else if (strcmp(tok->val, keywords[current_lang][17]) == 0)
    tok->type = DECREASING;
  else if (strcmp(tok->val, keywords[current_lang][18]) == 0)
    tok->type = IF;
  else if (strcmp(tok->val, keywords[current_lang][19]) == 0)
    tok->type = ELSE;
  else if (strcmp(tok->val, keywords[current_lang][20]) == 0)
    tok->type = THEN;
  else if (strcmp(tok->val, keywords[current_lang][21]) == 0)
    tok->type = SWITCH;
  else if (strcmp(tok->val, keywords[current_lang][22]) == 0)
    tok->type = OTHERWISE;
  else if (strcmp(tok->val, keywords[current_lang][23]) == 0)
    tok->type = PROCEDURE;
  else if (strcmp(tok->val, keywords[current_lang][24]) == 0)
    tok->type = VARIABLES;
  else if (strcmp(tok->val, keywords[current_lang][25]) == 0)
    tok->type = FUNCTION;
  else if (strcmp(tok->val, keywords[current_lang][26]) == 0)
    tok->type = TRUE;
  else if (strcmp(tok->val, keywords[current_lang][27]) == 0)
    tok->type = FALSE;
  else if (strcmp(tok->val, keywords[current_lang][28]) == 0)
    tok->type = PARAM;
  else if (strcmp(tok->val, keywords[current_lang][29]) == 0)
    tok->type = LOCAL;
  else if (strcmp(tok->val, keywords[current_lang][30]) == 0)
    tok->type = GLOBAL;
  else if (strcmp(tok->val, keywords[current_lang][31]) == 0)
    tok->type = RECORD;
  else if (strcmp(tok->val, keywords[current_lang][32]) == 0)
    tok->type = NULLKW;
  else
    tok->type = IDENTIFIER;
}
Esempio n. 2
0
void getalnum(struct token *tok)
{
  tok->val = getalnumstr();

  if (strcmp(tok->val, "algorithme") == 0)
    tok->type = ALGORITHM;
  else if (strcmp(tok->val, "debut") == 0)
    tok->type = BEGIN;
  else if (strcmp(tok->val, "types") == 0)
    tok->type = TYPES;
  else if (strcmp(tok->val, "constantes") == 0)
    tok->type = CONST;
  else if (strcmp(tok->val, "ou") == 0)
    tok->type = OR;
  else if (strcmp(tok->val, "oue") == 0)
    tok->type = XOR;
  else if (strcmp(tok->val, "et") == 0)
    tok->type = AND;
  else if (strcmp(tok->val, "div") == 0)
    tok->type = DIV;
  else if (strcmp(tok->val, "mod") == 0)
    tok->type = MOD;
  else if (strcmp(tok->val, "non") == 0)
    tok->type = NOT;
  else if (strcmp(tok->val, "tant") == 0)
    tok->type = WHILE;
  else if (strcmp(tok->val, "que") == 0)
    tok->type = SO;
  else if (strcmp(tok->val, "faire") == 0)
    tok->type = DO;
  else if (strcmp(tok->val, "fin") == 0)
    tok->type = END;
  else if (strcmp(tok->val, "retourne") == 0)
    tok->type = RETURN;
  else if (strcmp(tok->val, "pour") == 0)
    tok->type = FOR;
  else if (strcmp(tok->val, "jusqu'a") == 0)
    tok->type = UNTIL;
  else if (strcmp(tok->val, "decroissant") == 0)
    tok->type = DECREASING;
  else if (strcmp(tok->val, "si") == 0)
    tok->type = IF;
  else if (strcmp(tok->val, "sinon") == 0)
    tok->type = ELSE;
  else if (strcmp(tok->val, "alors") == 0)
    tok->type = THEN;
  else if (strcmp(tok->val, "selon") == 0)
    tok->type = SWITCH;
  else if (strcmp(tok->val, "autrement") == 0)
    tok->type = OTHERWISE;
  else if (strcmp(tok->val, "procedure") == 0)
    tok->type = PROCEDURE;
  else if (strcmp(tok->val, "variables") == 0)
    tok->type = VARIABLES;
  else if (strcmp(tok->val, "fonction") == 0)
    tok->type = FUNCTION;
  else if (strcmp(tok->val, "vrai") == 0)
    tok->type = TRUE;
  else if (strcmp(tok->val, "faux") == 0)
    tok->type = FALSE;
  else if (strcmp(tok->val, "parametres") == 0)
    tok->type = PARAM;
  else if (strcmp(tok->val, "locaux") == 0)
    tok->type = LOCAL;
  else if (strcmp(tok->val, "globaux") == 0)
    tok->type = GLOBAL;
  else if (strcmp(tok->val, "enregistrement") == 0)
    tok->type = RECORD;
  else if (strcmp(tok->val, "NUL") == 0)
    tok->type = NULLKW;
  else
    tok->type = IDENTIFIER;
}