• R/O
  • SSH
  • HTTPS

yash: Commit


Commit MetaInfo

Revision3864 (tree)
Time2018-09-19 00:55:03
Authormagicant

Log Message

Define token type

Change Summary

Incremental Difference

--- yash/branches/token_based_parser/parser.c (revision 3863)
+++ yash/branches/token_based_parser/parser.c (revision 3864)
@@ -242,6 +242,24 @@
242242
243243 /********** Auxiliary Functions for Parser **********/
244244
245+typedef enum tokentype_T {
246+ TT_UNKNOWN,
247+ TT_END_OF_INPUT,
248+ TT_WORD,
249+ TT_IO_NUMBER,
250+ /* operators */
251+ TT_NEWLINE,
252+ TT_AMP, TT_AMPAMP, TT_LPAREN, TT_RPAREN, TT_SEMICOLON, TT_DOUBLE_SEMICOLON,
253+ TT_PIPE, TT_PIPEPIPE, TT_LESS, TT_LESSLESS, TT_LESSAMP, TT_LESSLESSDASH,
254+ TT_LESSLESSLESS, TT_LESSGREATER, TT_LESSLPAREN, TT_GREATER,
255+ TT_GREATERGREATER, TT_GREATERGREATERPIPE, TT_GREATERPIPE, TT_GREATERAMP,
256+ TT_GREATERLPAREN,
257+ /* reserved words */
258+ TT_IF, TT_THEN, TT_ELSE, TT_ELIF, TT_FI, TT_DO, TT_DONE, TT_CASE, TT_ESAC,
259+ TT_WHILE, TT_UNTIL, TT_FOR, TT_LBRACE, TT_RBRACE, TT_BANG, TT_IN,
260+ TT_FUNCTION,
261+} tokentype_T;
262+
245263 static wchar_t *skip_name(const wchar_t *s, bool predicate(wchar_t))
246264 __attribute__((pure,nonnull));
247265 static bool is_name_by_predicate(const wchar_t *s, bool predicate(wchar_t))
@@ -397,6 +415,8 @@
397415 bool error;
398416 struct xwcsbuf_T src;
399417 size_t index;
418+ tokentype_T tokentype;
419+ wordunit_T *token;
400420 struct plist_T pending_heredocs;
401421 bool enable_alias, reparse;
402422 struct aliaslist_T *aliases;
@@ -573,6 +593,8 @@
573593 .info = info,
574594 .error = false,
575595 .index = 0,
596+ .tokentype = TT_UNKNOWN,
597+ .token = NULL,
576598 .enable_alias = info->enable_alias,
577599 .reparse = false,
578600 .aliases = NULL,
@@ -594,6 +616,7 @@
594616 wb_destroy(&ps.src);
595617 pl_destroy(&ps.pending_heredocs);
596618 destroy_aliaslist(ps.aliases);
619+ wordfree(ps.token);
597620
598621 switch (ps.info->lastinputresult) {
599622 case INPUT_OK:
@@ -2721,6 +2744,8 @@
27212744 .info = info,
27222745 .error = false,
27232746 .index = 0,
2747+ .tokentype = TT_UNKNOWN,
2748+ .token = NULL,
27242749 .enable_alias = false,
27252750 .reparse = false,
27262751 .aliases = NULL,
@@ -2738,6 +2763,8 @@
27382763 pl_destroy(&ps.pending_heredocs);
27392764 assert(ps.aliases == NULL);
27402765 //destroy_aliaslist(ps.aliases);
2766+ wordfree(ps.token);
2767+
27412768 if (ps.info->lastinputresult != INPUT_EOF || ps.error) {
27422769 wordfree(*resultp);
27432770 return false;
Show on old repository browser