Need some guidance regarding Parsing

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Need some guidance regarding Parsing

Wei Li
Dear All :

I am trying to insert a keyword "zone" . I changed the
"TokenKinds.def" file by adding a line KEYWORD(zone  , KEYALL). Now
when I compile a file with this extension I got the
following error:

------------------------------------------------------------
test.cpp:4:1: error: expected unqualified-id
zone X;
^
Breakpoint 1, clang::TextDiagnosticPrinter::HandleDiagnostic
(this=0x2e8ca70, Level=Error, Info=...) at
TextDiagnosticPrinter.cpp:763
763  uint64_t StartOfLocationInfo = OS.tell();
(gdb) bt
#0  clang::TextDiagnosticPrinter::HandleDiagnostic (this=0x2e8ca70,
Level=Error, Info=...) at TextDiagnosticPrinter.cpp:763
#1  0x0000000001585d1f in clang::Diagnostic::ProcessDiag
(this=0x2e8c2d0) at Diagnostic.cpp:617
#2  0x0000000001585ddc in clang::DiagnosticBuilder::Emit
(this=0x7fffffffbb70) at Diagnostic.cpp:641
#3  0x0000000000e6f5a1 in clang::DiagnosticBuilder::~DiagnosticBuilder
(this=0x7fffffffbb70, __in_chrg=<value optimized out>)
    at /home/cs/ammalik/UIUC/llvm/tools/clang/tools/driver/../../include/clang/Basic/Diagnostic.h:701
#4  0x0000000001132237 in clang::Parser::ParseDirectDeclarator
(this=0x7fffffffcb00, D=...) at ParseDecl.cpp:2793
#5  0x000000000112ca2d in clang::Parser::ParseDeclaratorInternal
(this=0x7fffffffcb00, D=..., DirectDeclParser=
    (void (clang::Parser::*)(clang::Parser *, clang::Declarator &))
0x1131b8c <clang::Parser::ParseDirectDeclarator(clang::Declarator&)>)
at ParseDecl.cpp:2590
#6  0x000000000112ce9a in clang::Parser::ParseDeclarator
(this=0x7fffffffcb00, D=...) at ParseDecl.cpp:2518
#7  0x0000000001133d38 in clang::Parser::ParseDeclGroup
(this=0x7fffffffcb00, DS=..., Context=0,
AllowFunctionDefinitions=true, DeclEnd=0x0) at ParseDecl.cpp:390
#8  0x0000000001124723 in
clang::Parser::ParseDeclarationOrFunctionDefinition
(this=0x7fffffffcb00, DS=..., Attr=0x0, AS=AS_none) at Parser.cpp:620
#9  0x0000000001124791 in
clang::Parser::ParseDeclarationOrFunctionDefinition
(this=0x7fffffffcb00, Attr=0x0, AS=AS_none) at Parser.cpp:627
#10 0x000000000112646a in clang::Parser::ParseExternalDeclaration
(this=0x7fffffffcb00, Attr=..., DS=0x0) at Parser.cpp:508
#11 0x00000000011265c7 in clang::Parser::ParseTopLevelDecl
(this=0x7fffffffcb00, Result=...) at Parser.cpp:374
#12 0x000000000110fa0d in clang::ParseAST (S=..., PrintStats=false) at
ParseAST.cpp:82
#13 0x0000000000ed3858 in clang::ASTFrontendAction::ExecuteAction
(this=0x2e8cac0) at FrontendAction.cpp:264
#14 0x0000000000fd9911 in clang::CodeGenAction::ExecuteAction
(this=0x2e8cac0) at CodeGenAction.cpp:332
#15 0x0000000000ed3960 in clang::FrontendAction::Execute
(this=0x2e8cac0) at FrontendAction.cpp:184
#16 0x0000000000ebf75a in clang::CompilerInstance::ExecuteAction
(this=0x2e862f0, Act=...) at CompilerInstance.cpp:526
#17 0x0000000000e785c0 in clang::ExecuteCompilerInvocation
(Clang=0x2e862f0) at ExecuteCompilerInvocation.cpp:148
#18 0x0000000000e6c322 in cc1_main (ArgBegin=0x7fffffffd658,
ArgEnd=0x7fffffffd760, Argv0=0x2e85568
"/home/cs/ammalik/UIUC/llvm/Debug+Asserts/bin/clang",
    MainAddr=0xe74774) at cc1_main.cpp:160
#19 0x0000000000e74990 in main (argc_=35, argv_=0x7fffffffe5b8) at
driver.cpp:268
---------------------------------------------------------------------------------------------------------------------------------------


Which part of the parser should I look into to make this file
workable? The scope of the keyword is very similar to "int". How can I
have the flow of this keyword?

Thanks,

--
Regards,

Wei Li
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Need some guidance regarding Parsing

Francois Pichet
On Sun, Sep 5, 2010 at 5:36 PM, Wei Li <[hidden email]> wrote:

> Dear All :
>
> I am trying to insert a keyword "zone" . I changed the
> "TokenKinds.def" file by adding a line KEYWORD(zone  , KEYALL). Now
> when I compile a file with this extension I got the
> following error:
>
> ------------------------------------------------------------
> test.cpp:4:1: error: expected unqualified-id
> zone X;
> ^
>
> Which part of the parser should I look into to make this file
> workable? The scope of the keyword is very similar to "int". How can I
> have the flow of this keyword?
>

Look into file ParseDecl.cpp function
Parser::ParseDeclarationSpecifiers. You will need to add a case for
your new keyword there.

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev