]> Joshua Wise's Git repositories - snipe.git/blobdiff - parse/l5.grm
Add string pasting support to the gramamr.
[snipe.git] / parse / l5.grm
index 7195271967c36fc6e62d3c8e700402ba9966bdc8..75c8bc9d484c1198cfc912e795614bd7a1adefc4 100644 (file)
@@ -35,6 +35,7 @@ fun make_lval (A.Var(id)) ext = id
  | SEMI
  | INTNUM of Word32.word
  | IDENT of Symbol.symbol
+ | STRING of string
  | RETURN
  | PLUS | MINUS | STAR | SLASH | PERCENT | LSH | RSH | LOGOR | LOGAND | BITAND | BITXOR | BITOR | BITNOT | BANG
  | ASSIGN | PLUSEQ | MINUSEQ | STAREQ | SLASHEQ | PERCENTEQ | LSHEQ | RSHEQ | BITANDEQ | BITXOREQ | BITOREQ
@@ -43,13 +44,14 @@ fun make_lval (A.Var(id)) ext = id
  | LBRACE | RBRACE
  | LPAREN | RPAREN
  | UNARY | ASNOP (* dummy *)
- | EXTERN | VAR | INT | QUESTION | COLON | COMMA | STRUCT | NULL | LBRACKET | RBRACKET | ARROW | DOT | NEW
+ | EXTERN | VAR | INT | TSTRING | QUESTION | COLON | COMMA | STRUCT | NULL | LBRACKET | RBRACKET | ARROW | DOT | NEW
  | PLUSPLUS | MINUSMINUS
 
 %nonterm 
    program of A.program
  | programx of A.program
  | stms of A.stm list
+ | stringcat of string
  | stm of A.stm
  | simp of A.stm
  | return of A.stm
@@ -103,6 +105,7 @@ programx   : decls                  (decls)
            | programx function      (AUP.append_function programx function)
 
 vtype      : INT                    (T.Int)
+           | TSTRING                (T.String)
            | IDENT                  (T.Typedef IDENT)
            | vtype STAR             (T.Pointer vtype)
            | vtype LBRACKET RBRACKET
@@ -182,9 +185,14 @@ simpoption :                        (NONE)
 block      : stm                    ([stm])
            | LBRACE stms RBRACE     (stms)
 
+stringcat  : STRING                 (STRING)
+           | STRING stringcat       (STRING ^ stringcat)
+
 exp        : LPAREN exp RPAREN      (exp)
            | INTNUM                 (mark (A.ConstExp(INTNUM),(INTNUMleft,INTNUMright)))
+           | stringcat              (mark (A.StringExp(stringcat),(stringcatleft,stringcatright)))
            | IDENT                  (mark (A.Var(IDENT), (IDENTleft,IDENTright)))
+           | LBRACKET vtype RBRACKET exp %prec UNARY (mark (A.Cast (vtype, exp), (LBRACKETleft, expright)))
            | exp DOT IDENT          (mark (A.Member(exp, IDENT), (expleft, IDENTright)))
            | exp ARROW IDENT        (mark (A.DerefMember(exp, IDENT), (expleft, IDENTright)))
            | STAR exp %prec UNARY   (mark (A.Dereference(exp), (STARleft, expright)))
This page took 0.031148 seconds and 4 git commands to generate.