From 1e1a9b416669a4172da46dd140c03ec93ebe2e4a Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 3 May 2002 18:23:48 +0000 Subject: [PATCH] Allow open/closing curly braces instead of begin/end to define the body of a function llvm-svn: 2451 --- llvm/lib/AsmParser/Lexer.l | 2 +- llvm/lib/AsmParser/llvmAsmParser.y | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/llvm/lib/AsmParser/Lexer.l b/llvm/lib/AsmParser/Lexer.l index 9cfe9fd78e5a..faddcb16d51d 100644 --- a/llvm/lib/AsmParser/Lexer.l +++ b/llvm/lib/AsmParser/Lexer.l @@ -147,7 +147,7 @@ HexFPConstant 0x[0-9A-Fa-f]+ {Comment} { /* Ignore comments for now */ } begin { return BEGINTOK; } -end { return END; } +end { return ENDTOK; } true { return TRUE; } false { return FALSE; } declare { return DECLARE; } diff --git a/llvm/lib/AsmParser/llvmAsmParser.y b/llvm/lib/AsmParser/llvmAsmParser.y index 697609a3fa51..d1feec81e1f3 100644 --- a/llvm/lib/AsmParser/llvmAsmParser.y +++ b/llvm/lib/AsmParser/llvmAsmParser.y @@ -671,7 +671,7 @@ Module *RunVMAsmParser(const string &Filename, FILE *F) { %type OptVAR_ID OptAssign -%token IMPLEMENTATION TRUE FALSE BEGINTOK END DECLARE GLOBAL CONSTANT UNINIT +%token IMPLEMENTATION TRUE FALSE BEGINTOK ENDTOK DECLARE GLOBAL CONSTANT UNINIT %token TO EXCEPT DOTDOTDOT STRING NULL_TOK CONST INTERNAL OPAQUE // Basic Block Terminating Operators @@ -1205,13 +1205,17 @@ FunctionHeaderH : OptInternal TypesV STRINGCONSTANT '(' ArgList ')' { } } -FunctionHeader : FunctionHeaderH ConstPool BEGINTOK { +BEGIN : BEGINTOK | '{'; // Allow BEGIN or '{' to start a function + +FunctionHeader : FunctionHeaderH BEGIN { $$ = CurMeth.CurrentFunction; // Resolve circular types before we parse the body of the method. ResolveTypes(CurMeth.LateResolveTypes); } +END : ENDTOK | '}'; // Allow end of '}' to end a function + Function : BasicBlockList END { $$ = $1; }