qtbindings 4.6.3.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +9 -0
- data/CMakeLists.txt +22 -0
- data/COPYING.LIB.txt +510 -0
- data/COPYING.txt +286 -0
- data/KNOWN_ISSUES.txt +20 -0
- data/README.txt +92 -0
- data/Rakefile +96 -0
- data/TODO.txt +2 -0
- data/bin/1.8/rbrcc.exe +0 -0
- data/bin/1.8/rbuic4.exe +0 -0
- data/bin/1.8/smokeapi.exe +0 -0
- data/bin/1.8/smokedeptool.exe +0 -0
- data/bin/1.9/rbrcc.exe +0 -0
- data/bin/1.9/rbuic4.exe +0 -0
- data/bin/1.9/smokeapi.exe +0 -0
- data/bin/1.9/smokedeptool.exe +0 -0
- data/bin/Qt3Support4.dll +0 -0
- data/bin/QtAssistantClient4.dll +0 -0
- data/bin/QtCLucene4.dll +0 -0
- data/bin/QtCore4.dll +0 -0
- data/bin/QtDesigner4.dll +0 -0
- data/bin/QtDesignerComponents4.dll +0 -0
- data/bin/QtGui4.dll +0 -0
- data/bin/QtHelp4.dll +0 -0
- data/bin/QtMultimedia4.dll +0 -0
- data/bin/QtNetwork4.dll +0 -0
- data/bin/QtOpenGL4.dll +0 -0
- data/bin/QtScript4.dll +0 -0
- data/bin/QtScriptTools4.dll +0 -0
- data/bin/QtSql4.dll +0 -0
- data/bin/QtSvg4.dll +0 -0
- data/bin/QtTest4.dll +0 -0
- data/bin/QtWebKit4.dll +0 -0
- data/bin/QtXml4.dll +0 -0
- data/bin/QtXmlPatterns4.dll +0 -0
- data/bin/libgcc_s_dw2-1.dll +0 -0
- data/bin/mingwm10.dll +0 -0
- data/bin/phonon4.dll +0 -0
- data/bin/plugins/arthurplugin.dll +0 -0
- data/bin/plugins/containerextension.dll +0 -0
- data/bin/plugins/customwidgetplugin.dll +0 -0
- data/bin/plugins/phononwidgets.dll +0 -0
- data/bin/plugins/qcncodecs4.dll +0 -0
- data/bin/plugins/qgif4.dll +0 -0
- data/bin/plugins/qglgraphicssystem4.dll +0 -0
- data/bin/plugins/qico4.dll +0 -0
- data/bin/plugins/qjpcodecs4.dll +0 -0
- data/bin/plugins/qjpeg4.dll +0 -0
- data/bin/plugins/qkrcodecs4.dll +0 -0
- data/bin/plugins/qmng4.dll +0 -0
- data/bin/plugins/qsqlite4.dll +0 -0
- data/bin/plugins/qsqlodbc4.dll +0 -0
- data/bin/plugins/qsvg4.dll +0 -0
- data/bin/plugins/qsvgicon4.dll +0 -0
- data/bin/plugins/qt3supportwidgets.dll +0 -0
- data/bin/plugins/qtaccessiblecompatwidgets4.dll +0 -0
- data/bin/plugins/qtaccessiblewidgets4.dll +0 -0
- data/bin/plugins/qtiff4.dll +0 -0
- data/bin/plugins/qtracegraphicssystem4.dll +0 -0
- data/bin/plugins/qtwcodecs4.dll +0 -0
- data/bin/plugins/qwebview.dll +0 -0
- data/bin/plugins/taskmenuextension.dll +0 -0
- data/bin/plugins/worldtimeclockplugin.dll +0 -0
- data/bin/rbqtapi +152 -0
- data/bin/rbrcc +18 -0
- data/bin/rbuic4 +18 -0
- data/bin/smokeapi +18 -0
- data/bin/smokedeptool +18 -0
- data/examples/base/kicons.rb +54 -0
- data/examples/base/rui.rb +21 -0
- data/examples/designer/calculatorbuilder/calculatorbuilder.qrc +5 -0
- data/examples/designer/calculatorbuilder/calculatorform.rb +60 -0
- data/examples/designer/calculatorbuilder/calculatorform.ui +299 -0
- data/examples/designer/calculatorbuilder/main.rb +34 -0
- data/examples/designer/calculatorbuilder/makefile +2 -0
- data/examples/designer/calculatorform/calculatorform.rb +46 -0
- data/examples/designer/calculatorform/calculatorform.ui +277 -0
- data/examples/designer/calculatorform/main.rb +32 -0
- data/examples/designer/calculatorform/makefile +3 -0
- data/examples/desktop/screenshot/main.rb +32 -0
- data/examples/desktop/screenshot/screenshot.rb +156 -0
- data/examples/desktop/systray/images/bad.svg +64 -0
- data/examples/desktop/systray/images/heart.svg +55 -0
- data/examples/desktop/systray/images/trash.svg +58 -0
- data/examples/desktop/systray/main.rb +41 -0
- data/examples/desktop/systray/makefile +2 -0
- data/examples/desktop/systray/systray.qrc +7 -0
- data/examples/desktop/systray/window.rb +223 -0
- data/examples/dialogs/complexwizard/complexwizard.rb +140 -0
- data/examples/dialogs/complexwizard/licensewizard.rb +294 -0
- data/examples/dialogs/complexwizard/main.rb +31 -0
- data/examples/dialogs/configdialog/configdialog.rb +109 -0
- data/examples/dialogs/configdialog/images/config.png +0 -0
- data/examples/dialogs/configdialog/images/query.png +0 -0
- data/examples/dialogs/configdialog/images/update.png +0 -0
- data/examples/dialogs/configdialog/main.rb +31 -0
- data/examples/dialogs/configdialog/pages.rb +140 -0
- data/examples/dialogs/extension/finddialog.rb +89 -0
- data/examples/dialogs/extension/main.rb +31 -0
- data/examples/dialogs/findfiles/main.rb +32 -0
- data/examples/dialogs/findfiles/window.rb +177 -0
- data/examples/dialogs/simplewizard/classwizard.rb +374 -0
- data/examples/dialogs/simplewizard/main.rb +31 -0
- data/examples/dialogs/simplewizard/simplewizard.rb +110 -0
- data/examples/dialogs/standarddialogs/dialog.rb +340 -0
- data/examples/dialogs/standarddialogs/main.rb +31 -0
- data/examples/dialogs/tabdialog/main.rb +38 -0
- data/examples/dialogs/tabdialog/tabdialog.rb +178 -0
- data/examples/draganddrop/draggableicons/dragwidget.rb +125 -0
- data/examples/draganddrop/draggableicons/images/boat.png +0 -0
- data/examples/draganddrop/draggableicons/images/car.png +0 -0
- data/examples/draganddrop/draggableicons/images/house.png +0 -0
- data/examples/draganddrop/draggableicons/main.rb +41 -0
- data/examples/draganddrop/draggabletext/draglabel.rb +51 -0
- data/examples/draganddrop/draggabletext/dragwidget.rb +94 -0
- data/examples/draganddrop/draggabletext/main.rb +33 -0
- data/examples/draganddrop/draggabletext/words.txt +41 -0
- data/examples/draganddrop/dropsite/dropsitewidget.rb +98 -0
- data/examples/draganddrop/dropsite/dropsitewindow.rb +114 -0
- data/examples/draganddrop/dropsite/main.rb +33 -0
- data/examples/draganddrop/fridgemagnets/draglabel.rb +78 -0
- data/examples/draganddrop/fridgemagnets/dragwidget.rb +130 -0
- data/examples/draganddrop/fridgemagnets/main.rb +33 -0
- data/examples/draganddrop/fridgemagnets/words.txt +48 -0
- data/examples/draganddrop/puzzle/example.jpg +0 -0
- data/examples/draganddrop/puzzle/main.rb +33 -0
- data/examples/draganddrop/puzzle/mainwindow.rb +136 -0
- data/examples/draganddrop/puzzle/pieceslist.rb +95 -0
- data/examples/draganddrop/puzzle/puzzlewidget.rb +190 -0
- data/examples/graphicsview/collidingmice/images/cheese.jpg +0 -0
- data/examples/graphicsview/collidingmice/main.rb +53 -0
- data/examples/graphicsview/collidingmice/makefile +2 -0
- data/examples/graphicsview/collidingmice/mice.qrc +5 -0
- data/examples/graphicsview/collidingmice/mouse.rb +176 -0
- data/examples/graphicsview/dragdroprobot/coloritem.rb +86 -0
- data/examples/graphicsview/dragdroprobot/images/head.png +0 -0
- data/examples/graphicsview/dragdroprobot/main.rb +57 -0
- data/examples/graphicsview/dragdroprobot/makefile +2 -0
- data/examples/graphicsview/dragdroprobot/robot.qrc +5 -0
- data/examples/graphicsview/dragdroprobot/robot.rb +246 -0
- data/examples/itemviews/chart/chart.qrc +5 -0
- data/examples/itemviews/chart/main.rb +33 -0
- data/examples/itemviews/chart/mainwindow.rb +151 -0
- data/examples/itemviews/chart/makefile +2 -0
- data/examples/itemviews/chart/mydata.cht +8 -0
- data/examples/itemviews/chart/pieview.rb +516 -0
- data/examples/itemviews/chart/qtdata.cht +14 -0
- data/examples/itemviews/dirview/main.rb +39 -0
- data/examples/itemviews/pixelator/imagemodel.rb +51 -0
- data/examples/itemviews/pixelator/images.qrc +5 -0
- data/examples/itemviews/pixelator/images/qt.png +0 -0
- data/examples/itemviews/pixelator/main.rb +34 -0
- data/examples/itemviews/pixelator/mainwindow.rb +218 -0
- data/examples/itemviews/pixelator/makefile +3 -0
- data/examples/itemviews/pixelator/pixeldelegate.rb +67 -0
- data/examples/itemviews/puzzle/example.jpg +0 -0
- data/examples/itemviews/puzzle/main.rb +36 -0
- data/examples/itemviews/puzzle/mainwindow.rb +143 -0
- data/examples/itemviews/puzzle/piecesmodel.rb +174 -0
- data/examples/itemviews/puzzle/puzzlewidget.rb +192 -0
- data/examples/itemviews/simpledommodel/domitem.rb +62 -0
- data/examples/itemviews/simpledommodel/dommodel.rb +139 -0
- data/examples/itemviews/simpledommodel/main.rb +33 -0
- data/examples/itemviews/simpledommodel/mainwindow.rb +66 -0
- data/examples/itemviews/simpletreemodel/default.txt +40 -0
- data/examples/itemviews/simpletreemodel/main.rb +41 -0
- data/examples/itemviews/simpletreemodel/makefile +2 -0
- data/examples/itemviews/simpletreemodel/simpletreemodel.qrc +5 -0
- data/examples/itemviews/simpletreemodel/treeitem.rb +67 -0
- data/examples/itemviews/simpletreemodel/treemodel.rb +164 -0
- data/examples/itemviews/sortingmodel/default.txt +40 -0
- data/examples/itemviews/sortingmodel/main.rb +53 -0
- data/examples/itemviews/sortingmodel/treeitem.rb +73 -0
- data/examples/itemviews/sortingmodel/treemodel.rb +166 -0
- data/examples/itemviews/spinboxdelegate/main.rb +47 -0
- data/examples/itemviews/spinboxdelegate/spinboxdelegate.rb +62 -0
- data/examples/killerfilter/killerfilter.rb +55 -0
- data/examples/layouts/basiclayouts/dialog.rb +110 -0
- data/examples/layouts/basiclayouts/main.rb +31 -0
- data/examples/layouts/borderlayout/borderlayout.rb +190 -0
- data/examples/layouts/borderlayout/main.rb +32 -0
- data/examples/layouts/borderlayout/window.rb +52 -0
- data/examples/layouts/flowlayouts/flowlayout.rb +108 -0
- data/examples/layouts/flowlayouts/main.rb +32 -0
- data/examples/layouts/flowlayouts/window.rb +43 -0
- data/examples/mainwindows/application/images/copy.png +0 -0
- data/examples/mainwindows/application/images/cut.png +0 -0
- data/examples/mainwindows/application/images/new.png +0 -0
- data/examples/mainwindows/application/images/open.png +0 -0
- data/examples/mainwindows/application/images/paste.png +0 -0
- data/examples/mainwindows/application/images/save.png +0 -0
- data/examples/mainwindows/application/main.rb +32 -0
- data/examples/mainwindows/application/mainwindow.rb +285 -0
- data/examples/mainwindows/dockwidgets/images/new.png +0 -0
- data/examples/mainwindows/dockwidgets/images/print.png +0 -0
- data/examples/mainwindows/dockwidgets/images/save.png +0 -0
- data/examples/mainwindows/dockwidgets/images/undo.png +0 -0
- data/examples/mainwindows/dockwidgets/main.rb +32 -0
- data/examples/mainwindows/dockwidgets/mainwindow.rb +302 -0
- data/examples/mainwindows/mdi/images/copy.png +0 -0
- data/examples/mainwindows/mdi/images/cut.png +0 -0
- data/examples/mainwindows/mdi/images/new.png +0 -0
- data/examples/mainwindows/mdi/images/open.png +0 -0
- data/examples/mainwindows/mdi/images/paste.png +0 -0
- data/examples/mainwindows/mdi/images/save.png +0 -0
- data/examples/mainwindows/mdi/main.rb +32 -0
- data/examples/mainwindows/mdi/mainwindow.rb +363 -0
- data/examples/mainwindows/mdi/mdichild.rb +152 -0
- data/examples/mainwindows/menus/main.rb +32 -0
- data/examples/mainwindows/menus/mainwindow.rb +327 -0
- data/examples/mainwindows/recentfiles/main.rb +32 -0
- data/examples/mainwindows/recentfiles/mainwindow.rb +258 -0
- data/examples/mainwindows/sdi/images/copy.png +0 -0
- data/examples/mainwindows/sdi/images/cut.png +0 -0
- data/examples/mainwindows/sdi/images/new.png +0 -0
- data/examples/mainwindows/sdi/images/open.png +0 -0
- data/examples/mainwindows/sdi/images/paste.png +0 -0
- data/examples/mainwindows/sdi/images/save.png +0 -0
- data/examples/mainwindows/sdi/main.rb +32 -0
- data/examples/mainwindows/sdi/mainwindow.rb +335 -0
- data/examples/network/broadcastreceiver/main.rb +32 -0
- data/examples/network/broadcastreceiver/receiver.rb +64 -0
- data/examples/network/broadcastsender/main.rb +32 -0
- data/examples/network/broadcastsender/sender.rb +70 -0
- data/examples/network/fortuneclient/client.rb +150 -0
- data/examples/network/fortuneclient/main.rb +32 -0
- data/examples/network/fortuneserver/main.rb +32 -0
- data/examples/network/fortuneserver/server.rb +88 -0
- data/examples/network/ftp/ftpwindow.rb +254 -0
- data/examples/network/ftp/images/cdtoparent.png +0 -0
- data/examples/network/ftp/images/dir.png +0 -0
- data/examples/network/ftp/images/file.png +0 -0
- data/examples/network/ftp/main.rb +32 -0
- data/examples/network/http/httpwindow.rb +187 -0
- data/examples/network/http/main.rb +32 -0
- data/examples/network/loopback/dialog.rb +163 -0
- data/examples/network/loopback/main.rb +32 -0
- data/examples/opengl/grabber/glwidget.rb +265 -0
- data/examples/opengl/grabber/main.rb +32 -0
- data/examples/opengl/grabber/mainwindow.rb +189 -0
- data/examples/opengl/hellogl/glwidget.rb +226 -0
- data/examples/opengl/hellogl/main.rb +32 -0
- data/examples/opengl/hellogl/window.rb +66 -0
- data/examples/opengl/textures/glwidget.rb +151 -0
- data/examples/opengl/textures/images/side1.png +0 -0
- data/examples/opengl/textures/images/side2.png +0 -0
- data/examples/opengl/textures/images/side3.png +0 -0
- data/examples/opengl/textures/images/side4.png +0 -0
- data/examples/opengl/textures/images/side5.png +0 -0
- data/examples/opengl/textures/images/side6.png +0 -0
- data/examples/opengl/textures/main.rb +32 -0
- data/examples/opengl/textures/window.rb +77 -0
- data/examples/painting/basicdrawing/images/brick.png +0 -0
- data/examples/painting/basicdrawing/images/qt-logo.png +0 -0
- data/examples/painting/basicdrawing/main.rb +32 -0
- data/examples/painting/basicdrawing/renderarea.rb +166 -0
- data/examples/painting/basicdrawing/window.rb +215 -0
- data/examples/painting/concentriccircles/circlewidget.rb +88 -0
- data/examples/painting/concentriccircles/main.rb +32 -0
- data/examples/painting/concentriccircles/window.rb +72 -0
- data/examples/painting/fontsampler/main.rb +32 -0
- data/examples/painting/fontsampler/mainwindow.rb +368 -0
- data/examples/painting/fontsampler/mainwindowbase.ui +136 -0
- data/examples/painting/fontsampler/makefile +8 -0
- data/examples/painting/fontsampler/previewdialog.rb +256 -0
- data/examples/painting/fontsampler/previewdialogbase.ui +224 -0
- data/examples/painting/fontsampler/previewlabel.rb +43 -0
- data/examples/painting/imagecomposition/imagecomposer.rb +152 -0
- data/examples/painting/imagecomposition/imagecomposition.qrc +6 -0
- data/examples/painting/imagecomposition/images/background.png +0 -0
- data/examples/painting/imagecomposition/images/blackrectangle.png +0 -0
- data/examples/painting/imagecomposition/images/butterfly.png +0 -0
- data/examples/painting/imagecomposition/images/checker.png +0 -0
- data/examples/painting/imagecomposition/main.rb +33 -0
- data/examples/painting/imagecomposition/makefile +2 -0
- data/examples/painting/painterpaths/main.rb +32 -0
- data/examples/painting/painterpaths/renderarea.rb +97 -0
- data/examples/painting/painterpaths/window.rb +247 -0
- data/examples/painting/svgviewer/files/bubbles.svg +212 -0
- data/examples/painting/svgviewer/files/cubic.svg +77 -0
- data/examples/painting/svgviewer/files/spheres.svg +79 -0
- data/examples/painting/svgviewer/main.rb +38 -0
- data/examples/painting/svgviewer/mainwindow.rb +99 -0
- data/examples/painting/svgviewer/makefile +2 -0
- data/examples/painting/svgviewer/svgview.rb +156 -0
- data/examples/painting/svgviewer/svgviewer.qrc +6 -0
- data/examples/painting/svgviewer/svgwindow.rb +87 -0
- data/examples/painting/transformations/main.rb +32 -0
- data/examples/painting/transformations/renderarea.rb +127 -0
- data/examples/painting/transformations/window.rb +153 -0
- data/examples/passivepopup/passivepopup.rb +38 -0
- data/examples/qdbus/chat/chat.rb +146 -0
- data/examples/qdbus/chat/chat_adaptor.rb +12 -0
- data/examples/qdbus/chat/chat_interface.rb +13 -0
- data/examples/qdbus/chat/chatmainwindow.ui +184 -0
- data/examples/qdbus/chat/chatsetnickname.ui +145 -0
- data/examples/qdbus/chat/makefile +8 -0
- data/examples/qdbus/complexpingpong/complexping.rb +92 -0
- data/examples/qdbus/complexpingpong/complexpong.rb +83 -0
- data/examples/qdbus/complexpingpong/ping-common.rb +1 -0
- data/examples/qdbus/listnames/listnames.rb +69 -0
- data/examples/qdbus/pingpong/ping-common.rb +1 -0
- data/examples/qdbus/pingpong/ping.rb +52 -0
- data/examples/qdbus/pingpong/pong.rb +55 -0
- data/examples/qdbus/remotecontrolledcar/car/car.rb +151 -0
- data/examples/qdbus/remotecontrolledcar/car/main.rb +50 -0
- data/examples/qdbus/remotecontrolledcar/controller/controller.rb +66 -0
- data/examples/qdbus/remotecontrolledcar/controller/controller.ui +61 -0
- data/examples/qdbus/remotecontrolledcar/controller/main.rb +32 -0
- data/examples/qdbus/remotecontrolledcar/controller/makefile +2 -0
- data/examples/qtscribble/scribble.rb +270 -0
- data/examples/richtext/calendar/main.rb +33 -0
- data/examples/richtext/calendar/mainwindow.rb +173 -0
- data/examples/richtext/orderform/detailsdialog.rb +130 -0
- data/examples/richtext/orderform/main.rb +34 -0
- data/examples/richtext/orderform/mainwindow.rb +194 -0
- data/examples/richtext/syntaxhighlighter/examples/example +79 -0
- data/examples/richtext/syntaxhighlighter/highlighter.rb +90 -0
- data/examples/richtext/syntaxhighlighter/main.rb +34 -0
- data/examples/richtext/syntaxhighlighter/mainwindow.rb +105 -0
- data/examples/ruboids/Manifest +26 -0
- data/examples/ruboids/README +53 -0
- data/examples/ruboids/TODO +29 -0
- data/examples/ruboids/boids.properties +33 -0
- data/examples/ruboids/generateManifest.rb +42 -0
- data/examples/ruboids/index.html +147 -0
- data/examples/ruboids/release.rb +152 -0
- data/examples/ruboids/ruboids/Boid.rb +141 -0
- data/examples/ruboids/ruboids/BoidView.rb +159 -0
- data/examples/ruboids/ruboids/Camera.rb +24 -0
- data/examples/ruboids/ruboids/CameraDialog.rb +218 -0
- data/examples/ruboids/ruboids/Canvas.rb +143 -0
- data/examples/ruboids/ruboids/Cloud.rb +61 -0
- data/examples/ruboids/ruboids/CloudView.rb +54 -0
- data/examples/ruboids/ruboids/Flock.rb +47 -0
- data/examples/ruboids/ruboids/Graphics.rb +278 -0
- data/examples/ruboids/ruboids/Params.rb +87 -0
- data/examples/ruboids/ruboids/Point.rb +153 -0
- data/examples/ruboids/ruboids/Thing.rb +34 -0
- data/examples/ruboids/ruboids/Triangle.rb +21 -0
- data/examples/ruboids/ruboids/View.rb +88 -0
- data/examples/ruboids/ruboids/World.rb +82 -0
- data/examples/ruboids/ruboids/WorldWindow.rb +52 -0
- data/examples/ruboids/ruboids/info.rb +12 -0
- data/examples/ruboids/ruboids/ruboids.rb +29 -0
- data/examples/run_all.rb +14 -0
- data/examples/textedit/textedit.rb +150 -0
- data/examples/tutorial/t1/t1.rb +10 -0
- data/examples/tutorial/t10/cannon.rb +72 -0
- data/examples/tutorial/t10/lcdrange.rb +45 -0
- data/examples/tutorial/t10/t10.rb +55 -0
- data/examples/tutorial/t11/cannon.rb +124 -0
- data/examples/tutorial/t11/lcdrange.rb +45 -0
- data/examples/tutorial/t11/t11.rb +65 -0
- data/examples/tutorial/t12/cannon.rb +158 -0
- data/examples/tutorial/t12/lcdrange.rb +59 -0
- data/examples/tutorial/t12/t12.rb +66 -0
- data/examples/tutorial/t13/cannon.rb +208 -0
- data/examples/tutorial/t13/gamebrd.rb +113 -0
- data/examples/tutorial/t13/lcdrange.rb +60 -0
- data/examples/tutorial/t13/t13.rb +11 -0
- data/examples/tutorial/t14/cannon.rb +263 -0
- data/examples/tutorial/t14/gamebrd.rb +123 -0
- data/examples/tutorial/t14/lcdrange.rb +63 -0
- data/examples/tutorial/t14/t14.rb +11 -0
- data/examples/tutorial/t2/t2.rb +16 -0
- data/examples/tutorial/t3/t3.rb +18 -0
- data/examples/tutorial/t4/t4.rb +25 -0
- data/examples/tutorial/t5/t5.rb +37 -0
- data/examples/tutorial/t6/t6.rb +52 -0
- data/examples/tutorial/t7/lcdrange.rb +32 -0
- data/examples/tutorial/t7/t7.rb +42 -0
- data/examples/tutorial/t8/cannon.rb +38 -0
- data/examples/tutorial/t8/lcdrange.rb +45 -0
- data/examples/tutorial/t8/t8.rb +43 -0
- data/examples/tutorial/t9/cannon.rb +45 -0
- data/examples/tutorial/t9/lcdrange.rb +46 -0
- data/examples/tutorial/t9/t9.rb +43 -0
- data/examples/widgets/analogclock/analogclock.rb +94 -0
- data/examples/widgets/analogclock/main.rb +9 -0
- data/examples/widgets/calculator/button.rb +45 -0
- data/examples/widgets/calculator/calculator.rb +382 -0
- data/examples/widgets/calculator/main.rb +32 -0
- data/examples/widgets/charactermap/characterwidget.rb +110 -0
- data/examples/widgets/charactermap/main.rb +32 -0
- data/examples/widgets/charactermap/mainwindow.rb +118 -0
- data/examples/widgets/digitalclock/digitalclock.rb +30 -0
- data/examples/widgets/digitalclock/main.rb +9 -0
- data/examples/widgets/groupbox/main.rb +32 -0
- data/examples/widgets/groupbox/window.rb +134 -0
- data/examples/widgets/icons/iconpreviewarea.rb +111 -0
- data/examples/widgets/icons/iconsizespinbox.rb +39 -0
- data/examples/widgets/icons/imagedelegate.rb +73 -0
- data/examples/widgets/icons/images/designer.png +0 -0
- data/examples/widgets/icons/images/find_disabled.png +0 -0
- data/examples/widgets/icons/images/find_normal.png +0 -0
- data/examples/widgets/icons/images/monkey_off_128x128.png +0 -0
- data/examples/widgets/icons/images/monkey_off_16x16.png +0 -0
- data/examples/widgets/icons/images/monkey_off_32x32.png +0 -0
- data/examples/widgets/icons/images/monkey_off_64x64.png +0 -0
- data/examples/widgets/icons/images/monkey_on_128x128.png +0 -0
- data/examples/widgets/icons/images/monkey_on_16x16.png +0 -0
- data/examples/widgets/icons/images/monkey_on_32x32.png +0 -0
- data/examples/widgets/icons/images/monkey_on_64x64.png +0 -0
- data/examples/widgets/icons/images/qtopia_16x16.png +0 -0
- data/examples/widgets/icons/images/qtopia_32x32.png +0 -0
- data/examples/widgets/icons/images/qtopia_48x48.png +0 -0
- data/examples/widgets/icons/main.rb +32 -0
- data/examples/widgets/icons/mainwindow.rb +351 -0
- data/examples/widgets/imageviewer/imageviewer.rb +219 -0
- data/examples/widgets/imageviewer/main.rb +32 -0
- data/examples/widgets/lineedits/main.rb +32 -0
- data/examples/widgets/lineedits/window.rb +199 -0
- data/examples/widgets/movie/images/open.png +0 -0
- data/examples/widgets/movie/images/pause.png +0 -0
- data/examples/widgets/movie/images/play.png +0 -0
- data/examples/widgets/movie/images/quit.png +0 -0
- data/examples/widgets/movie/images/stop.png +0 -0
- data/examples/widgets/movie/main.rb +32 -0
- data/examples/widgets/movie/movieplayer.rb +201 -0
- data/examples/widgets/movie/movies/fire.mng +0 -0
- data/examples/widgets/screenshot/main.rb +32 -0
- data/examples/widgets/screenshot/screenshot.rb +155 -0
- data/examples/widgets/scribble/main.rb +32 -0
- data/examples/widgets/scribble/mainwindow.rb +202 -0
- data/examples/widgets/scribble/scribblearea.rb +154 -0
- data/examples/widgets/sliders/main.rb +32 -0
- data/examples/widgets/sliders/slidersgroup.rb +97 -0
- data/examples/widgets/sliders/window.rb +124 -0
- data/examples/widgets/spinboxes/main.rb +32 -0
- data/examples/widgets/spinboxes/window.rb +213 -0
- data/examples/widgets/tetrix/main.rb +33 -0
- data/examples/widgets/tetrix/tetrixboard.rb +346 -0
- data/examples/widgets/tetrix/tetrixpiece.rb +135 -0
- data/examples/widgets/tetrix/tetrixwindow.rb +88 -0
- data/examples/widgets/tooltips/images/circle.png +0 -0
- data/examples/widgets/tooltips/images/square.png +0 -0
- data/examples/widgets/tooltips/images/triangle.png +0 -0
- data/examples/widgets/tooltips/main.rb +32 -0
- data/examples/widgets/tooltips/shapeitem.rb +31 -0
- data/examples/widgets/tooltips/sortingbox.rb +222 -0
- data/examples/widgets/wiggly/dialog.rb +48 -0
- data/examples/widgets/wiggly/main.rb +9 -0
- data/examples/widgets/wiggly/wigglywidget.rb +76 -0
- data/examples/widgets/windowflags/controllerwindow.rb +195 -0
- data/examples/widgets/windowflags/main.rb +32 -0
- data/examples/widgets/windowflags/previewwindow.rb +103 -0
- data/examples/xml/dombookmarks/frank.xbel +230 -0
- data/examples/xml/dombookmarks/jennifer.xbel +93 -0
- data/examples/xml/dombookmarks/main.rb +34 -0
- data/examples/xml/dombookmarks/mainwindow.rb +129 -0
- data/examples/xml/dombookmarks/xbeltree.rb +172 -0
- data/examples/xml/saxbookmarks/frank.xbel +230 -0
- data/examples/xml/saxbookmarks/jennifer.xbel +93 -0
- data/examples/xml/saxbookmarks/main.rb +34 -0
- data/examples/xml/saxbookmarks/mainwindow.rb +144 -0
- data/examples/xml/saxbookmarks/xbelgenerator.rb +95 -0
- data/examples/xml/saxbookmarks/xbelhandler.rb +122 -0
- data/ext/CMakeLists.txt +22 -0
- data/ext/cmake/modules/CMakeCSharpCompiler.cmake.in +7 -0
- data/ext/cmake/modules/CMakeCSharpInformation.cmake +366 -0
- data/ext/cmake/modules/CMakeDetermineCSharpCompiler.cmake +85 -0
- data/ext/cmake/modules/CMakeTestCSharpCompiler.cmake +1 -0
- data/ext/cmake/modules/CheckCXXSourceCompiles.cmake +68 -0
- data/ext/cmake/modules/FindMono.cmake +36 -0
- data/ext/cmake/modules/FindPHP5.cmake +179 -0
- data/ext/cmake/modules/FindPerlMore.cmake +78 -0
- data/ext/cmake/modules/FindQScintilla.cmake +57 -0
- data/ext/cmake/modules/FindQt4.cmake +1271 -0
- data/ext/cmake/modules/FindQwt5.cmake +104 -0
- data/ext/cmake/modules/FindRuby.cmake +261 -0
- data/ext/cmake/modules/FindSmoke.cmake +78 -0
- data/ext/cmake/modules/HandleImportedTargetsInCMakeRequiredLibraries.cmake +85 -0
- data/ext/cmake/modules/MacroLogFeature.cmake +146 -0
- data/ext/cmake/modules/MacroOptionalAddBindings.cmake +47 -0
- data/ext/cmake/modules/MacroOptionalFindPackage.cmake +48 -0
- data/ext/cmake/modules/MacroPushRequiredVars.cmake +47 -0
- data/ext/cmake/modules/Qt4ConfigDependentSettings.cmake +384 -0
- data/ext/cmake/modules/Qt4Macros.cmake +414 -0
- data/ext/generator/CMakeLists.txt +38 -0
- data/ext/generator/generator_export.h +31 -0
- data/ext/generator/generatorenvironment.cpp +52 -0
- data/ext/generator/generatorenvironment.h +35 -0
- data/ext/generator/generatorpreprocessor.cpp +242 -0
- data/ext/generator/generatorpreprocessor.h +83 -0
- data/ext/generator/generators/CMakeLists.txt +4 -0
- data/ext/generator/generators/dump/CMakeLists.txt +10 -0
- data/ext/generator/generators/dump/generator_dump.cpp +36 -0
- data/ext/generator/generators/smoke/CMakeLists.txt +13 -0
- data/ext/generator/generators/smoke/generator_smoke.cpp +233 -0
- data/ext/generator/generators/smoke/globals.h +138 -0
- data/ext/generator/generators/smoke/helpers.cpp +773 -0
- data/ext/generator/generators/smoke/writeClasses.cpp +502 -0
- data/ext/generator/generators/smoke/writeSmokeDataFile.cpp +729 -0
- data/ext/generator/generatorvisitor.cpp +922 -0
- data/ext/generator/generatorvisitor.h +119 -0
- data/ext/generator/main.cpp +239 -0
- data/ext/generator/name_compiler.cpp +205 -0
- data/ext/generator/name_compiler.h +76 -0
- data/ext/generator/options.cpp +32 -0
- data/ext/generator/options.h +45 -0
- data/ext/generator/parser/CMakeLists.txt +41 -0
- data/ext/generator/parser/ast.cpp +21 -0
- data/ext/generator/parser/ast.h +923 -0
- data/ext/generator/parser/astutilities.h +65 -0
- data/ext/generator/parser/codegenerator.cpp +867 -0
- data/ext/generator/parser/codegenerator.h +180 -0
- data/ext/generator/parser/codemodel_fwd.h +76 -0
- data/ext/generator/parser/commentformatter.cpp +54 -0
- data/ext/generator/parser/commentformatter.h +45 -0
- data/ext/generator/parser/commentparser.cpp +109 -0
- data/ext/generator/parser/commentparser.h +84 -0
- data/ext/generator/parser/control.cpp +40 -0
- data/ext/generator/parser/control.h +51 -0
- data/ext/generator/parser/cppparser_export.h +33 -0
- data/ext/generator/parser/default_visitor.cpp +470 -0
- data/ext/generator/parser/default_visitor.h +116 -0
- data/ext/generator/parser/dumptree.cpp +146 -0
- data/ext/generator/parser/dumptree.h +50 -0
- data/ext/generator/parser/indexedstring.cpp +213 -0
- data/ext/generator/parser/indexedstring.h +147 -0
- data/ext/generator/parser/kdevelop-parser-rev +1 -0
- data/ext/generator/parser/kdevvarlengtharray.h +346 -0
- data/ext/generator/parser/lexer.cpp +963 -0
- data/ext/generator/parser/lexer.h +308 -0
- data/ext/generator/parser/listnode.cpp +20 -0
- data/ext/generator/parser/listnode.h +97 -0
- data/ext/generator/parser/memorypool.cpp +20 -0
- data/ext/generator/parser/memorypool.h +41 -0
- data/ext/generator/parser/name_compiler.cpp +190 -0
- data/ext/generator/parser/name_compiler.h +77 -0
- data/ext/generator/parser/parser.cpp +4706 -0
- data/ext/generator/parser/parser.h +300 -0
- data/ext/generator/parser/parsesession.cpp +105 -0
- data/ext/generator/parser/parsesession.h +87 -0
- data/ext/generator/parser/problem.h +21 -0
- data/ext/generator/parser/rpp/CMakeLists.txt +39 -0
- data/ext/generator/parser/rpp/Makefile.am +13 -0
- data/ext/generator/parser/rpp/anchor.h +51 -0
- data/ext/generator/parser/rpp/appendedlist.h +363 -0
- data/ext/generator/parser/rpp/chartools.cpp +126 -0
- data/ext/generator/parser/rpp/chartools.h +90 -0
- data/ext/generator/parser/rpp/macrorepository.cpp +44 -0
- data/ext/generator/parser/rpp/macrorepository.h +59 -0
- data/ext/generator/parser/rpp/pp-configuration +86 -0
- data/ext/generator/parser/rpp/pp-engine.cpp +1216 -0
- data/ext/generator/parser/rpp/pp-engine.h +267 -0
- data/ext/generator/parser/rpp/pp-environment.cpp +271 -0
- data/ext/generator/parser/rpp/pp-environment.h +119 -0
- data/ext/generator/parser/rpp/pp-internal.cpp +38 -0
- data/ext/generator/parser/rpp/pp-internal.h +37 -0
- data/ext/generator/parser/rpp/pp-location.cpp +191 -0
- data/ext/generator/parser/rpp/pp-location.h +89 -0
- data/ext/generator/parser/rpp/pp-macro-expander.cpp +568 -0
- data/ext/generator/parser/rpp/pp-macro-expander.cpp.orig +558 -0
- data/ext/generator/parser/rpp/pp-macro-expander.h +130 -0
- data/ext/generator/parser/rpp/pp-macro.cpp +153 -0
- data/ext/generator/parser/rpp/pp-macro.h +176 -0
- data/ext/generator/parser/rpp/pp-scanner.cpp +310 -0
- data/ext/generator/parser/rpp/pp-scanner.h +97 -0
- data/ext/generator/parser/rpp/pp-stream.cpp +425 -0
- data/ext/generator/parser/rpp/pp-stream.h +183 -0
- data/ext/generator/parser/rpp/preprocessor.cpp +65 -0
- data/ext/generator/parser/rpp/preprocessor.h +80 -0
- data/ext/generator/parser/rpp/rpp.pri +2 -0
- data/ext/generator/parser/rpp/test/t001.cpp +23 -0
- data/ext/generator/parser/rpp/test/t002.cpp +15 -0
- data/ext/generator/parser/rpp/test/t003.cpp +10 -0
- data/ext/generator/parser/rpp/test/t004.cpp +9 -0
- data/ext/generator/parser/rpp/test/t005.cpp +10 -0
- data/ext/generator/parser/rpp/test/t006.cpp +10 -0
- data/ext/generator/parser/rpp/test/t007.cpp +6 -0
- data/ext/generator/parser/rpp/test/t008.cpp +6 -0
- data/ext/generator/parser/rpp/test/t009.cpp +5 -0
- data/ext/generator/parser/rpp/test/t010.cpp +15 -0
- data/ext/generator/parser/rpp/test/t011.cpp +9 -0
- data/ext/generator/parser/rpp/tests/CMakeLists.txt +13 -0
- data/ext/generator/parser/rpp/tests/main.cpp +69 -0
- data/ext/generator/parser/rxx.pri +50 -0
- data/ext/generator/parser/rxx_allocator.h +128 -0
- data/ext/generator/parser/safetycounter.h +57 -0
- data/ext/generator/parser/simplecursor.h +74 -0
- data/ext/generator/parser/stringhelpers.cpp +577 -0
- data/ext/generator/parser/stringhelpers.h +118 -0
- data/ext/generator/parser/symbol.h +140 -0
- data/ext/generator/parser/tests/CMakeLists.txt +30 -0
- data/ext/generator/parser/tests/test_generator.cpp +259 -0
- data/ext/generator/parser/tests/test_parser.cpp +474 -0
- data/ext/generator/parser/tests/test_pool.cpp +109 -0
- data/ext/generator/parser/tests/test_pool.h +35 -0
- data/ext/generator/parser/tests/testconfig.h.cmake +4 -0
- data/ext/generator/parser/tokens.cpp +364 -0
- data/ext/generator/parser/tokens.h +147 -0
- data/ext/generator/parser/type_compiler.cpp +135 -0
- data/ext/generator/parser/type_compiler.h +68 -0
- data/ext/generator/parser/visitor.cpp +115 -0
- data/ext/generator/parser/visitor.h +138 -0
- data/ext/generator/type.cpp +195 -0
- data/ext/generator/type.h +497 -0
- data/ext/generator/type_compiler.cpp +275 -0
- data/ext/generator/type_compiler.h +80 -0
- data/ext/ruby/CMakeLists.txt +63 -0
- data/ext/ruby/qtruby/AUTHORS +54 -0
- data/ext/ruby/qtruby/CMakeLists.txt +4 -0
- data/ext/ruby/qtruby/COPYING +355 -0
- data/ext/ruby/qtruby/COPYING.LIB +510 -0
- data/ext/ruby/qtruby/ChangeLog +3732 -0
- data/ext/ruby/qtruby/INSTALL +79 -0
- data/ext/ruby/qtruby/README +264 -0
- data/ext/ruby/qtruby/TODO +8 -0
- data/ext/ruby/qtruby/bin/CMakeLists.txt +1 -0
- data/ext/ruby/qtruby/bin/rbqtapi +152 -0
- data/ext/ruby/qtruby/examples/base/kicons.rb +54 -0
- data/ext/ruby/qtruby/examples/base/rui.rb +21 -0
- data/ext/ruby/qtruby/examples/designer/calculatorbuilder/calculatorbuilder.qrc +5 -0
- data/ext/ruby/qtruby/examples/designer/calculatorbuilder/calculatorform.rb +60 -0
- data/ext/ruby/qtruby/examples/designer/calculatorbuilder/calculatorform.ui +299 -0
- data/ext/ruby/qtruby/examples/designer/calculatorbuilder/main.rb +33 -0
- data/ext/ruby/qtruby/examples/designer/calculatorbuilder/makefile +2 -0
- data/ext/ruby/qtruby/examples/designer/calculatorform/calculatorform.rb +46 -0
- data/ext/ruby/qtruby/examples/designer/calculatorform/calculatorform.ui +277 -0
- data/ext/ruby/qtruby/examples/designer/calculatorform/main.rb +32 -0
- data/ext/ruby/qtruby/examples/designer/calculatorform/makefile +3 -0
- data/ext/ruby/qtruby/examples/desktop/screenshot/main.rb +32 -0
- data/ext/ruby/qtruby/examples/desktop/screenshot/screenshot.rb +156 -0
- data/ext/ruby/qtruby/examples/desktop/systray/images/bad.svg +64 -0
- data/ext/ruby/qtruby/examples/desktop/systray/images/heart.svg +55 -0
- data/ext/ruby/qtruby/examples/desktop/systray/images/trash.svg +58 -0
- data/ext/ruby/qtruby/examples/desktop/systray/main.rb +41 -0
- data/ext/ruby/qtruby/examples/desktop/systray/makefile +2 -0
- data/ext/ruby/qtruby/examples/desktop/systray/systray.qrc +7 -0
- data/ext/ruby/qtruby/examples/desktop/systray/window.rb +223 -0
- data/ext/ruby/qtruby/examples/dialogs/complexwizard/complexwizard.rb +140 -0
- data/ext/ruby/qtruby/examples/dialogs/complexwizard/licensewizard.rb +294 -0
- data/ext/ruby/qtruby/examples/dialogs/complexwizard/main.rb +31 -0
- data/ext/ruby/qtruby/examples/dialogs/configdialog/configdialog.rb +109 -0
- data/ext/ruby/qtruby/examples/dialogs/configdialog/images/config.png +0 -0
- data/ext/ruby/qtruby/examples/dialogs/configdialog/images/query.png +0 -0
- data/ext/ruby/qtruby/examples/dialogs/configdialog/images/update.png +0 -0
- data/ext/ruby/qtruby/examples/dialogs/configdialog/main.rb +31 -0
- data/ext/ruby/qtruby/examples/dialogs/configdialog/pages.rb +140 -0
- data/ext/ruby/qtruby/examples/dialogs/extension/finddialog.rb +89 -0
- data/ext/ruby/qtruby/examples/dialogs/extension/main.rb +31 -0
- data/ext/ruby/qtruby/examples/dialogs/findfiles/main.rb +32 -0
- data/ext/ruby/qtruby/examples/dialogs/findfiles/window.rb +177 -0
- data/ext/ruby/qtruby/examples/dialogs/simplewizard/classwizard.rb +374 -0
- data/ext/ruby/qtruby/examples/dialogs/simplewizard/main.rb +31 -0
- data/ext/ruby/qtruby/examples/dialogs/simplewizard/simplewizard.rb +110 -0
- data/ext/ruby/qtruby/examples/dialogs/standarddialogs/dialog.rb +340 -0
- data/ext/ruby/qtruby/examples/dialogs/standarddialogs/main.rb +31 -0
- data/ext/ruby/qtruby/examples/dialogs/tabdialog/main.rb +38 -0
- data/ext/ruby/qtruby/examples/dialogs/tabdialog/tabdialog.rb +178 -0
- data/ext/ruby/qtruby/examples/draganddrop/draggableicons/dragwidget.rb +125 -0
- data/ext/ruby/qtruby/examples/draganddrop/draggableicons/images/boat.png +0 -0
- data/ext/ruby/qtruby/examples/draganddrop/draggableicons/images/car.png +0 -0
- data/ext/ruby/qtruby/examples/draganddrop/draggableicons/images/house.png +0 -0
- data/ext/ruby/qtruby/examples/draganddrop/draggableicons/main.rb +41 -0
- data/ext/ruby/qtruby/examples/draganddrop/draggabletext/draglabel.rb +51 -0
- data/ext/ruby/qtruby/examples/draganddrop/draggabletext/dragwidget.rb +94 -0
- data/ext/ruby/qtruby/examples/draganddrop/draggabletext/main.rb +33 -0
- data/ext/ruby/qtruby/examples/draganddrop/draggabletext/words.txt +41 -0
- data/ext/ruby/qtruby/examples/draganddrop/dropsite/dropsitewidget.rb +98 -0
- data/ext/ruby/qtruby/examples/draganddrop/dropsite/dropsitewindow.rb +114 -0
- data/ext/ruby/qtruby/examples/draganddrop/dropsite/main.rb +33 -0
- data/ext/ruby/qtruby/examples/draganddrop/fridgemagnets/draglabel.rb +78 -0
- data/ext/ruby/qtruby/examples/draganddrop/fridgemagnets/dragwidget.rb +130 -0
- data/ext/ruby/qtruby/examples/draganddrop/fridgemagnets/main.rb +33 -0
- data/ext/ruby/qtruby/examples/draganddrop/fridgemagnets/words.txt +48 -0
- data/ext/ruby/qtruby/examples/draganddrop/puzzle/example.jpg +0 -0
- data/ext/ruby/qtruby/examples/draganddrop/puzzle/main.rb +33 -0
- data/ext/ruby/qtruby/examples/draganddrop/puzzle/mainwindow.rb +136 -0
- data/ext/ruby/qtruby/examples/draganddrop/puzzle/pieceslist.rb +95 -0
- data/ext/ruby/qtruby/examples/draganddrop/puzzle/puzzlewidget.rb +190 -0
- data/ext/ruby/qtruby/examples/graphicsview/collidingmice/images/cheese.jpg +0 -0
- data/ext/ruby/qtruby/examples/graphicsview/collidingmice/main.rb +53 -0
- data/ext/ruby/qtruby/examples/graphicsview/collidingmice/makefile +2 -0
- data/ext/ruby/qtruby/examples/graphicsview/collidingmice/mice.qrc +5 -0
- data/ext/ruby/qtruby/examples/graphicsview/collidingmice/mouse.rb +176 -0
- data/ext/ruby/qtruby/examples/graphicsview/dragdroprobot/coloritem.rb +86 -0
- data/ext/ruby/qtruby/examples/graphicsview/dragdroprobot/images/head.png +0 -0
- data/ext/ruby/qtruby/examples/graphicsview/dragdroprobot/main.rb +57 -0
- data/ext/ruby/qtruby/examples/graphicsview/dragdroprobot/makefile +2 -0
- data/ext/ruby/qtruby/examples/graphicsview/dragdroprobot/robot.qrc +5 -0
- data/ext/ruby/qtruby/examples/graphicsview/dragdroprobot/robot.rb +246 -0
- data/ext/ruby/qtruby/examples/itemviews/chart/chart.qrc +5 -0
- data/ext/ruby/qtruby/examples/itemviews/chart/main.rb +33 -0
- data/ext/ruby/qtruby/examples/itemviews/chart/mainwindow.rb +151 -0
- data/ext/ruby/qtruby/examples/itemviews/chart/makefile +2 -0
- data/ext/ruby/qtruby/examples/itemviews/chart/mydata.cht +8 -0
- data/ext/ruby/qtruby/examples/itemviews/chart/pieview.rb +516 -0
- data/ext/ruby/qtruby/examples/itemviews/chart/qtdata.cht +14 -0
- data/ext/ruby/qtruby/examples/itemviews/dirview/main.rb +39 -0
- data/ext/ruby/qtruby/examples/itemviews/pixelator/imagemodel.rb +51 -0
- data/ext/ruby/qtruby/examples/itemviews/pixelator/images.qrc +5 -0
- data/ext/ruby/qtruby/examples/itemviews/pixelator/images/qt.png +0 -0
- data/ext/ruby/qtruby/examples/itemviews/pixelator/main.rb +34 -0
- data/ext/ruby/qtruby/examples/itemviews/pixelator/mainwindow.rb +218 -0
- data/ext/ruby/qtruby/examples/itemviews/pixelator/makefile +3 -0
- data/ext/ruby/qtruby/examples/itemviews/pixelator/pixeldelegate.rb +67 -0
- data/ext/ruby/qtruby/examples/itemviews/puzzle/example.jpg +0 -0
- data/ext/ruby/qtruby/examples/itemviews/puzzle/main.rb +36 -0
- data/ext/ruby/qtruby/examples/itemviews/puzzle/mainwindow.rb +143 -0
- data/ext/ruby/qtruby/examples/itemviews/puzzle/piecesmodel.rb +174 -0
- data/ext/ruby/qtruby/examples/itemviews/puzzle/puzzlewidget.rb +192 -0
- data/ext/ruby/qtruby/examples/itemviews/simpledommodel/domitem.rb +62 -0
- data/ext/ruby/qtruby/examples/itemviews/simpledommodel/dommodel.rb +139 -0
- data/ext/ruby/qtruby/examples/itemviews/simpledommodel/main.rb +33 -0
- data/ext/ruby/qtruby/examples/itemviews/simpledommodel/mainwindow.rb +66 -0
- data/ext/ruby/qtruby/examples/itemviews/simpletreemodel/default.txt +40 -0
- data/ext/ruby/qtruby/examples/itemviews/simpletreemodel/main.rb +41 -0
- data/ext/ruby/qtruby/examples/itemviews/simpletreemodel/makefile +2 -0
- data/ext/ruby/qtruby/examples/itemviews/simpletreemodel/simpletreemodel.qrc +5 -0
- data/ext/ruby/qtruby/examples/itemviews/simpletreemodel/treeitem.rb +67 -0
- data/ext/ruby/qtruby/examples/itemviews/simpletreemodel/treemodel.rb +164 -0
- data/ext/ruby/qtruby/examples/itemviews/sortingmodel/default.txt +40 -0
- data/ext/ruby/qtruby/examples/itemviews/sortingmodel/main.rb +53 -0
- data/ext/ruby/qtruby/examples/itemviews/sortingmodel/treeitem.rb +73 -0
- data/ext/ruby/qtruby/examples/itemviews/sortingmodel/treemodel.rb +166 -0
- data/ext/ruby/qtruby/examples/itemviews/spinboxdelegate/main.rb +47 -0
- data/ext/ruby/qtruby/examples/itemviews/spinboxdelegate/spinboxdelegate.rb +62 -0
- data/ext/ruby/qtruby/examples/killerfilter/killerfilter.rb +55 -0
- data/ext/ruby/qtruby/examples/layouts/basiclayouts/dialog.rb +110 -0
- data/ext/ruby/qtruby/examples/layouts/basiclayouts/main.rb +31 -0
- data/ext/ruby/qtruby/examples/layouts/borderlayout/borderlayout.rb +190 -0
- data/ext/ruby/qtruby/examples/layouts/borderlayout/main.rb +32 -0
- data/ext/ruby/qtruby/examples/layouts/borderlayout/window.rb +52 -0
- data/ext/ruby/qtruby/examples/layouts/flowlayouts/flowlayout.rb +108 -0
- data/ext/ruby/qtruby/examples/layouts/flowlayouts/main.rb +32 -0
- data/ext/ruby/qtruby/examples/layouts/flowlayouts/window.rb +43 -0
- data/ext/ruby/qtruby/examples/mainwindows/application/images/copy.png +0 -0
- data/ext/ruby/qtruby/examples/mainwindows/application/images/cut.png +0 -0
- data/ext/ruby/qtruby/examples/mainwindows/application/images/new.png +0 -0
- data/ext/ruby/qtruby/examples/mainwindows/application/images/open.png +0 -0
- data/ext/ruby/qtruby/examples/mainwindows/application/images/paste.png +0 -0
- data/ext/ruby/qtruby/examples/mainwindows/application/images/save.png +0 -0
- data/ext/ruby/qtruby/examples/mainwindows/application/main.rb +32 -0
- data/ext/ruby/qtruby/examples/mainwindows/application/mainwindow.rb +285 -0
- data/ext/ruby/qtruby/examples/mainwindows/dockwidgets/images/new.png +0 -0
- data/ext/ruby/qtruby/examples/mainwindows/dockwidgets/images/print.png +0 -0
- data/ext/ruby/qtruby/examples/mainwindows/dockwidgets/images/save.png +0 -0
- data/ext/ruby/qtruby/examples/mainwindows/dockwidgets/images/undo.png +0 -0
- data/ext/ruby/qtruby/examples/mainwindows/dockwidgets/main.rb +32 -0
- data/ext/ruby/qtruby/examples/mainwindows/dockwidgets/mainwindow.rb +302 -0
- data/ext/ruby/qtruby/examples/mainwindows/mdi/images/copy.png +0 -0
- data/ext/ruby/qtruby/examples/mainwindows/mdi/images/cut.png +0 -0
- data/ext/ruby/qtruby/examples/mainwindows/mdi/images/new.png +0 -0
- data/ext/ruby/qtruby/examples/mainwindows/mdi/images/open.png +0 -0
- data/ext/ruby/qtruby/examples/mainwindows/mdi/images/paste.png +0 -0
- data/ext/ruby/qtruby/examples/mainwindows/mdi/images/save.png +0 -0
- data/ext/ruby/qtruby/examples/mainwindows/mdi/main.rb +32 -0
- data/ext/ruby/qtruby/examples/mainwindows/mdi/mainwindow.rb +363 -0
- data/ext/ruby/qtruby/examples/mainwindows/mdi/mdichild.rb +152 -0
- data/ext/ruby/qtruby/examples/mainwindows/menus/main.rb +32 -0
- data/ext/ruby/qtruby/examples/mainwindows/menus/mainwindow.rb +327 -0
- data/ext/ruby/qtruby/examples/mainwindows/recentfiles/main.rb +32 -0
- data/ext/ruby/qtruby/examples/mainwindows/recentfiles/mainwindow.rb +258 -0
- data/ext/ruby/qtruby/examples/mainwindows/sdi/images/copy.png +0 -0
- data/ext/ruby/qtruby/examples/mainwindows/sdi/images/cut.png +0 -0
- data/ext/ruby/qtruby/examples/mainwindows/sdi/images/new.png +0 -0
- data/ext/ruby/qtruby/examples/mainwindows/sdi/images/open.png +0 -0
- data/ext/ruby/qtruby/examples/mainwindows/sdi/images/paste.png +0 -0
- data/ext/ruby/qtruby/examples/mainwindows/sdi/images/save.png +0 -0
- data/ext/ruby/qtruby/examples/mainwindows/sdi/main.rb +32 -0
- data/ext/ruby/qtruby/examples/mainwindows/sdi/mainwindow.rb +335 -0
- data/ext/ruby/qtruby/examples/network/broadcastreceiver/main.rb +32 -0
- data/ext/ruby/qtruby/examples/network/broadcastreceiver/receiver.rb +64 -0
- data/ext/ruby/qtruby/examples/network/broadcastsender/main.rb +32 -0
- data/ext/ruby/qtruby/examples/network/broadcastsender/sender.rb +70 -0
- data/ext/ruby/qtruby/examples/network/fortuneclient/client.rb +150 -0
- data/ext/ruby/qtruby/examples/network/fortuneclient/main.rb +32 -0
- data/ext/ruby/qtruby/examples/network/fortuneserver/main.rb +32 -0
- data/ext/ruby/qtruby/examples/network/fortuneserver/server.rb +88 -0
- data/ext/ruby/qtruby/examples/network/ftp/ftpwindow.rb +254 -0
- data/ext/ruby/qtruby/examples/network/ftp/images/cdtoparent.png +0 -0
- data/ext/ruby/qtruby/examples/network/ftp/images/dir.png +0 -0
- data/ext/ruby/qtruby/examples/network/ftp/images/file.png +0 -0
- data/ext/ruby/qtruby/examples/network/ftp/main.rb +32 -0
- data/ext/ruby/qtruby/examples/network/http/httpwindow.rb +187 -0
- data/ext/ruby/qtruby/examples/network/http/main.rb +32 -0
- data/ext/ruby/qtruby/examples/network/loopback/dialog.rb +163 -0
- data/ext/ruby/qtruby/examples/network/loopback/main.rb +32 -0
- data/ext/ruby/qtruby/examples/opengl/grabber/glwidget.rb +265 -0
- data/ext/ruby/qtruby/examples/opengl/grabber/main.rb +32 -0
- data/ext/ruby/qtruby/examples/opengl/grabber/mainwindow.rb +189 -0
- data/ext/ruby/qtruby/examples/opengl/hellogl/glwidget.rb +226 -0
- data/ext/ruby/qtruby/examples/opengl/hellogl/main.rb +32 -0
- data/ext/ruby/qtruby/examples/opengl/hellogl/window.rb +66 -0
- data/ext/ruby/qtruby/examples/opengl/textures/glwidget.rb +151 -0
- data/ext/ruby/qtruby/examples/opengl/textures/images/side1.png +0 -0
- data/ext/ruby/qtruby/examples/opengl/textures/images/side2.png +0 -0
- data/ext/ruby/qtruby/examples/opengl/textures/images/side3.png +0 -0
- data/ext/ruby/qtruby/examples/opengl/textures/images/side4.png +0 -0
- data/ext/ruby/qtruby/examples/opengl/textures/images/side5.png +0 -0
- data/ext/ruby/qtruby/examples/opengl/textures/images/side6.png +0 -0
- data/ext/ruby/qtruby/examples/opengl/textures/main.rb +32 -0
- data/ext/ruby/qtruby/examples/opengl/textures/window.rb +77 -0
- data/ext/ruby/qtruby/examples/painting/basicdrawing/images/brick.png +0 -0
- data/ext/ruby/qtruby/examples/painting/basicdrawing/images/qt-logo.png +0 -0
- data/ext/ruby/qtruby/examples/painting/basicdrawing/main.rb +32 -0
- data/ext/ruby/qtruby/examples/painting/basicdrawing/renderarea.rb +166 -0
- data/ext/ruby/qtruby/examples/painting/basicdrawing/window.rb +215 -0
- data/ext/ruby/qtruby/examples/painting/concentriccircles/circlewidget.rb +88 -0
- data/ext/ruby/qtruby/examples/painting/concentriccircles/main.rb +32 -0
- data/ext/ruby/qtruby/examples/painting/concentriccircles/window.rb +72 -0
- data/ext/ruby/qtruby/examples/painting/fontsampler/main.rb +32 -0
- data/ext/ruby/qtruby/examples/painting/fontsampler/mainwindow.rb +368 -0
- data/ext/ruby/qtruby/examples/painting/fontsampler/mainwindowbase.ui +136 -0
- data/ext/ruby/qtruby/examples/painting/fontsampler/makefile +8 -0
- data/ext/ruby/qtruby/examples/painting/fontsampler/previewdialog.rb +256 -0
- data/ext/ruby/qtruby/examples/painting/fontsampler/previewdialogbase.ui +224 -0
- data/ext/ruby/qtruby/examples/painting/fontsampler/previewlabel.rb +43 -0
- data/ext/ruby/qtruby/examples/painting/imagecomposition/imagecomposer.rb +152 -0
- data/ext/ruby/qtruby/examples/painting/imagecomposition/imagecomposition.qrc +6 -0
- data/ext/ruby/qtruby/examples/painting/imagecomposition/images/background.png +0 -0
- data/ext/ruby/qtruby/examples/painting/imagecomposition/images/blackrectangle.png +0 -0
- data/ext/ruby/qtruby/examples/painting/imagecomposition/images/butterfly.png +0 -0
- data/ext/ruby/qtruby/examples/painting/imagecomposition/images/checker.png +0 -0
- data/ext/ruby/qtruby/examples/painting/imagecomposition/main.rb +33 -0
- data/ext/ruby/qtruby/examples/painting/imagecomposition/makefile +2 -0
- data/ext/ruby/qtruby/examples/painting/painterpaths/main.rb +32 -0
- data/ext/ruby/qtruby/examples/painting/painterpaths/renderarea.rb +97 -0
- data/ext/ruby/qtruby/examples/painting/painterpaths/window.rb +247 -0
- data/ext/ruby/qtruby/examples/painting/svgviewer/files/bubbles.svg +212 -0
- data/ext/ruby/qtruby/examples/painting/svgviewer/files/cubic.svg +77 -0
- data/ext/ruby/qtruby/examples/painting/svgviewer/files/spheres.svg +79 -0
- data/ext/ruby/qtruby/examples/painting/svgviewer/main.rb +38 -0
- data/ext/ruby/qtruby/examples/painting/svgviewer/mainwindow.rb +99 -0
- data/ext/ruby/qtruby/examples/painting/svgviewer/makefile +2 -0
- data/ext/ruby/qtruby/examples/painting/svgviewer/svgview.rb +156 -0
- data/ext/ruby/qtruby/examples/painting/svgviewer/svgviewer.qrc +6 -0
- data/ext/ruby/qtruby/examples/painting/svgviewer/svgwindow.rb +87 -0
- data/ext/ruby/qtruby/examples/painting/transformations/main.rb +32 -0
- data/ext/ruby/qtruby/examples/painting/transformations/renderarea.rb +127 -0
- data/ext/ruby/qtruby/examples/painting/transformations/window.rb +153 -0
- data/ext/ruby/qtruby/examples/passivepopup/passivepopup.rb +38 -0
- data/ext/ruby/qtruby/examples/qdbus/chat/chat.rb +146 -0
- data/ext/ruby/qtruby/examples/qdbus/chat/chat_adaptor.rb +12 -0
- data/ext/ruby/qtruby/examples/qdbus/chat/chat_interface.rb +13 -0
- data/ext/ruby/qtruby/examples/qdbus/chat/chatmainwindow.ui +184 -0
- data/ext/ruby/qtruby/examples/qdbus/chat/chatsetnickname.ui +145 -0
- data/ext/ruby/qtruby/examples/qdbus/chat/makefile +8 -0
- data/ext/ruby/qtruby/examples/qdbus/complexpingpong/complexping.rb +92 -0
- data/ext/ruby/qtruby/examples/qdbus/complexpingpong/complexpong.rb +83 -0
- data/ext/ruby/qtruby/examples/qdbus/complexpingpong/ping-common.rb +1 -0
- data/ext/ruby/qtruby/examples/qdbus/listnames/listnames.rb +69 -0
- data/ext/ruby/qtruby/examples/qdbus/pingpong/ping-common.rb +1 -0
- data/ext/ruby/qtruby/examples/qdbus/pingpong/ping.rb +52 -0
- data/ext/ruby/qtruby/examples/qdbus/pingpong/pong.rb +55 -0
- data/ext/ruby/qtruby/examples/qdbus/remotecontrolledcar/car/car.rb +151 -0
- data/ext/ruby/qtruby/examples/qdbus/remotecontrolledcar/car/main.rb +50 -0
- data/ext/ruby/qtruby/examples/qdbus/remotecontrolledcar/controller/controller.rb +66 -0
- data/ext/ruby/qtruby/examples/qdbus/remotecontrolledcar/controller/controller.ui +61 -0
- data/ext/ruby/qtruby/examples/qdbus/remotecontrolledcar/controller/main.rb +32 -0
- data/ext/ruby/qtruby/examples/qdbus/remotecontrolledcar/controller/makefile +2 -0
- data/ext/ruby/qtruby/examples/qtscribble/scribble.rb +270 -0
- data/ext/ruby/qtruby/examples/richtext/calendar/main.rb +33 -0
- data/ext/ruby/qtruby/examples/richtext/calendar/mainwindow.rb +173 -0
- data/ext/ruby/qtruby/examples/richtext/orderform/detailsdialog.rb +130 -0
- data/ext/ruby/qtruby/examples/richtext/orderform/main.rb +34 -0
- data/ext/ruby/qtruby/examples/richtext/orderform/mainwindow.rb +194 -0
- data/ext/ruby/qtruby/examples/richtext/syntaxhighlighter/examples/example +79 -0
- data/ext/ruby/qtruby/examples/richtext/syntaxhighlighter/highlighter.rb +90 -0
- data/ext/ruby/qtruby/examples/richtext/syntaxhighlighter/main.rb +34 -0
- data/ext/ruby/qtruby/examples/richtext/syntaxhighlighter/mainwindow.rb +105 -0
- data/ext/ruby/qtruby/examples/ruboids/Manifest +26 -0
- data/ext/ruby/qtruby/examples/ruboids/README +53 -0
- data/ext/ruby/qtruby/examples/ruboids/TODO +29 -0
- data/ext/ruby/qtruby/examples/ruboids/boids.properties +33 -0
- data/ext/ruby/qtruby/examples/ruboids/generateManifest.rb +42 -0
- data/ext/ruby/qtruby/examples/ruboids/index.html +147 -0
- data/ext/ruby/qtruby/examples/ruboids/release.rb +152 -0
- data/ext/ruby/qtruby/examples/ruboids/ruboids/Boid.rb +141 -0
- data/ext/ruby/qtruby/examples/ruboids/ruboids/BoidView.rb +159 -0
- data/ext/ruby/qtruby/examples/ruboids/ruboids/Camera.rb +24 -0
- data/ext/ruby/qtruby/examples/ruboids/ruboids/CameraDialog.rb +218 -0
- data/ext/ruby/qtruby/examples/ruboids/ruboids/Canvas.rb +143 -0
- data/ext/ruby/qtruby/examples/ruboids/ruboids/Cloud.rb +61 -0
- data/ext/ruby/qtruby/examples/ruboids/ruboids/CloudView.rb +54 -0
- data/ext/ruby/qtruby/examples/ruboids/ruboids/Flock.rb +47 -0
- data/ext/ruby/qtruby/examples/ruboids/ruboids/Graphics.rb +278 -0
- data/ext/ruby/qtruby/examples/ruboids/ruboids/Params.rb +87 -0
- data/ext/ruby/qtruby/examples/ruboids/ruboids/Point.rb +153 -0
- data/ext/ruby/qtruby/examples/ruboids/ruboids/Thing.rb +34 -0
- data/ext/ruby/qtruby/examples/ruboids/ruboids/Triangle.rb +21 -0
- data/ext/ruby/qtruby/examples/ruboids/ruboids/View.rb +88 -0
- data/ext/ruby/qtruby/examples/ruboids/ruboids/World.rb +82 -0
- data/ext/ruby/qtruby/examples/ruboids/ruboids/WorldWindow.rb +52 -0
- data/ext/ruby/qtruby/examples/ruboids/ruboids/info.rb +12 -0
- data/ext/ruby/qtruby/examples/ruboids/ruboids/ruboids.rb +29 -0
- data/ext/ruby/qtruby/examples/textedit/textedit.rb +150 -0
- data/ext/ruby/qtruby/examples/tutorial/t1/t1.rb +10 -0
- data/ext/ruby/qtruby/examples/tutorial/t10/cannon.rb +72 -0
- data/ext/ruby/qtruby/examples/tutorial/t10/lcdrange.rb +45 -0
- data/ext/ruby/qtruby/examples/tutorial/t10/t10.rb +55 -0
- data/ext/ruby/qtruby/examples/tutorial/t11/cannon.rb +124 -0
- data/ext/ruby/qtruby/examples/tutorial/t11/lcdrange.rb +45 -0
- data/ext/ruby/qtruby/examples/tutorial/t11/t11.rb +65 -0
- data/ext/ruby/qtruby/examples/tutorial/t12/cannon.rb +158 -0
- data/ext/ruby/qtruby/examples/tutorial/t12/lcdrange.rb +59 -0
- data/ext/ruby/qtruby/examples/tutorial/t12/t12.rb +66 -0
- data/ext/ruby/qtruby/examples/tutorial/t13/cannon.rb +208 -0
- data/ext/ruby/qtruby/examples/tutorial/t13/gamebrd.rb +113 -0
- data/ext/ruby/qtruby/examples/tutorial/t13/lcdrange.rb +60 -0
- data/ext/ruby/qtruby/examples/tutorial/t13/t13.rb +11 -0
- data/ext/ruby/qtruby/examples/tutorial/t14/cannon.rb +263 -0
- data/ext/ruby/qtruby/examples/tutorial/t14/gamebrd.rb +123 -0
- data/ext/ruby/qtruby/examples/tutorial/t14/lcdrange.rb +63 -0
- data/ext/ruby/qtruby/examples/tutorial/t14/t14.rb +11 -0
- data/ext/ruby/qtruby/examples/tutorial/t2/t2.rb +16 -0
- data/ext/ruby/qtruby/examples/tutorial/t3/t3.rb +18 -0
- data/ext/ruby/qtruby/examples/tutorial/t4/t4.rb +25 -0
- data/ext/ruby/qtruby/examples/tutorial/t5/t5.rb +37 -0
- data/ext/ruby/qtruby/examples/tutorial/t6/t6.rb +52 -0
- data/ext/ruby/qtruby/examples/tutorial/t7/lcdrange.rb +32 -0
- data/ext/ruby/qtruby/examples/tutorial/t7/t7.rb +42 -0
- data/ext/ruby/qtruby/examples/tutorial/t8/cannon.rb +38 -0
- data/ext/ruby/qtruby/examples/tutorial/t8/lcdrange.rb +45 -0
- data/ext/ruby/qtruby/examples/tutorial/t8/t8.rb +43 -0
- data/ext/ruby/qtruby/examples/tutorial/t9/cannon.rb +45 -0
- data/ext/ruby/qtruby/examples/tutorial/t9/lcdrange.rb +46 -0
- data/ext/ruby/qtruby/examples/tutorial/t9/t9.rb +43 -0
- data/ext/ruby/qtruby/examples/widgets/analogclock/analogclock.rb +94 -0
- data/ext/ruby/qtruby/examples/widgets/analogclock/main.rb +9 -0
- data/ext/ruby/qtruby/examples/widgets/calculator/button.rb +45 -0
- data/ext/ruby/qtruby/examples/widgets/calculator/calculator.rb +382 -0
- data/ext/ruby/qtruby/examples/widgets/calculator/main.rb +32 -0
- data/ext/ruby/qtruby/examples/widgets/charactermap/characterwidget.rb +110 -0
- data/ext/ruby/qtruby/examples/widgets/charactermap/main.rb +32 -0
- data/ext/ruby/qtruby/examples/widgets/charactermap/mainwindow.rb +118 -0
- data/ext/ruby/qtruby/examples/widgets/digitalclock/digitalclock.rb +30 -0
- data/ext/ruby/qtruby/examples/widgets/digitalclock/main.rb +9 -0
- data/ext/ruby/qtruby/examples/widgets/groupbox/main.rb +32 -0
- data/ext/ruby/qtruby/examples/widgets/groupbox/window.rb +134 -0
- data/ext/ruby/qtruby/examples/widgets/icons/iconpreviewarea.rb +111 -0
- data/ext/ruby/qtruby/examples/widgets/icons/iconsizespinbox.rb +39 -0
- data/ext/ruby/qtruby/examples/widgets/icons/imagedelegate.rb +73 -0
- data/ext/ruby/qtruby/examples/widgets/icons/images/designer.png +0 -0
- data/ext/ruby/qtruby/examples/widgets/icons/images/find_disabled.png +0 -0
- data/ext/ruby/qtruby/examples/widgets/icons/images/find_normal.png +0 -0
- data/ext/ruby/qtruby/examples/widgets/icons/images/monkey_off_128x128.png +0 -0
- data/ext/ruby/qtruby/examples/widgets/icons/images/monkey_off_16x16.png +0 -0
- data/ext/ruby/qtruby/examples/widgets/icons/images/monkey_off_32x32.png +0 -0
- data/ext/ruby/qtruby/examples/widgets/icons/images/monkey_off_64x64.png +0 -0
- data/ext/ruby/qtruby/examples/widgets/icons/images/monkey_on_128x128.png +0 -0
- data/ext/ruby/qtruby/examples/widgets/icons/images/monkey_on_16x16.png +0 -0
- data/ext/ruby/qtruby/examples/widgets/icons/images/monkey_on_32x32.png +0 -0
- data/ext/ruby/qtruby/examples/widgets/icons/images/monkey_on_64x64.png +0 -0
- data/ext/ruby/qtruby/examples/widgets/icons/images/qtopia_16x16.png +0 -0
- data/ext/ruby/qtruby/examples/widgets/icons/images/qtopia_32x32.png +0 -0
- data/ext/ruby/qtruby/examples/widgets/icons/images/qtopia_48x48.png +0 -0
- data/ext/ruby/qtruby/examples/widgets/icons/main.rb +32 -0
- data/ext/ruby/qtruby/examples/widgets/icons/mainwindow.rb +351 -0
- data/ext/ruby/qtruby/examples/widgets/imageviewer/imageviewer.rb +219 -0
- data/ext/ruby/qtruby/examples/widgets/imageviewer/main.rb +32 -0
- data/ext/ruby/qtruby/examples/widgets/lineedits/main.rb +32 -0
- data/ext/ruby/qtruby/examples/widgets/lineedits/window.rb +199 -0
- data/ext/ruby/qtruby/examples/widgets/movie/images/open.png +0 -0
- data/ext/ruby/qtruby/examples/widgets/movie/images/pause.png +0 -0
- data/ext/ruby/qtruby/examples/widgets/movie/images/play.png +0 -0
- data/ext/ruby/qtruby/examples/widgets/movie/images/quit.png +0 -0
- data/ext/ruby/qtruby/examples/widgets/movie/images/stop.png +0 -0
- data/ext/ruby/qtruby/examples/widgets/movie/main.rb +32 -0
- data/ext/ruby/qtruby/examples/widgets/movie/movieplayer.rb +201 -0
- data/ext/ruby/qtruby/examples/widgets/movie/movies/fire.mng +0 -0
- data/ext/ruby/qtruby/examples/widgets/screenshot/main.rb +32 -0
- data/ext/ruby/qtruby/examples/widgets/screenshot/screenshot.rb +155 -0
- data/ext/ruby/qtruby/examples/widgets/scribble/main.rb +32 -0
- data/ext/ruby/qtruby/examples/widgets/scribble/mainwindow.rb +202 -0
- data/ext/ruby/qtruby/examples/widgets/scribble/scribblearea.rb +154 -0
- data/ext/ruby/qtruby/examples/widgets/sliders/main.rb +32 -0
- data/ext/ruby/qtruby/examples/widgets/sliders/slidersgroup.rb +97 -0
- data/ext/ruby/qtruby/examples/widgets/sliders/window.rb +124 -0
- data/ext/ruby/qtruby/examples/widgets/spinboxes/main.rb +32 -0
- data/ext/ruby/qtruby/examples/widgets/spinboxes/window.rb +213 -0
- data/ext/ruby/qtruby/examples/widgets/tetrix/main.rb +33 -0
- data/ext/ruby/qtruby/examples/widgets/tetrix/tetrixboard.rb +346 -0
- data/ext/ruby/qtruby/examples/widgets/tetrix/tetrixpiece.rb +135 -0
- data/ext/ruby/qtruby/examples/widgets/tetrix/tetrixwindow.rb +88 -0
- data/ext/ruby/qtruby/examples/widgets/tooltips/images/circle.png +0 -0
- data/ext/ruby/qtruby/examples/widgets/tooltips/images/square.png +0 -0
- data/ext/ruby/qtruby/examples/widgets/tooltips/images/triangle.png +0 -0
- data/ext/ruby/qtruby/examples/widgets/tooltips/main.rb +32 -0
- data/ext/ruby/qtruby/examples/widgets/tooltips/shapeitem.rb +31 -0
- data/ext/ruby/qtruby/examples/widgets/tooltips/sortingbox.rb +222 -0
- data/ext/ruby/qtruby/examples/widgets/wiggly/dialog.rb +48 -0
- data/ext/ruby/qtruby/examples/widgets/wiggly/main.rb +9 -0
- data/ext/ruby/qtruby/examples/widgets/wiggly/wigglywidget.rb +76 -0
- data/ext/ruby/qtruby/examples/widgets/windowflags/controllerwindow.rb +195 -0
- data/ext/ruby/qtruby/examples/widgets/windowflags/main.rb +32 -0
- data/ext/ruby/qtruby/examples/widgets/windowflags/previewwindow.rb +103 -0
- data/ext/ruby/qtruby/examples/xml/dombookmarks/frank.xbel +230 -0
- data/ext/ruby/qtruby/examples/xml/dombookmarks/jennifer.xbel +93 -0
- data/ext/ruby/qtruby/examples/xml/dombookmarks/main.rb +34 -0
- data/ext/ruby/qtruby/examples/xml/dombookmarks/mainwindow.rb +129 -0
- data/ext/ruby/qtruby/examples/xml/dombookmarks/xbeltree.rb +172 -0
- data/ext/ruby/qtruby/examples/xml/saxbookmarks/frank.xbel +230 -0
- data/ext/ruby/qtruby/examples/xml/saxbookmarks/jennifer.xbel +93 -0
- data/ext/ruby/qtruby/examples/xml/saxbookmarks/main.rb +34 -0
- data/ext/ruby/qtruby/examples/xml/saxbookmarks/mainwindow.rb +144 -0
- data/ext/ruby/qtruby/examples/xml/saxbookmarks/xbelgenerator.rb +95 -0
- data/ext/ruby/qtruby/examples/xml/saxbookmarks/xbelhandler.rb +122 -0
- data/ext/ruby/qtruby/rails_support/CMakeLists.txt +1 -0
- data/ext/ruby/qtruby/rails_support/active_item_model.rb +234 -0
- data/ext/ruby/qtruby/rails_support/active_table_model.rb +122 -0
- data/ext/ruby/qtruby/src/CMakeLists.txt +103 -0
- data/ext/ruby/qtruby/src/Qt.cpp +1279 -0
- data/ext/ruby/qtruby/src/extconf.rb +11 -0
- data/ext/ruby/qtruby/src/handlers.cpp +2622 -0
- data/ext/ruby/qtruby/src/lib/CMakeLists.txt +16 -0
- data/ext/ruby/qtruby/src/lib/Qt.rb +1 -0
- data/ext/ruby/qtruby/src/lib/Qt/CMakeLists.txt +9 -0
- data/ext/ruby/qtruby/src/lib/Qt/qtruby4.rb +3177 -0
- data/ext/ruby/qtruby/src/lib/Qt3.rb +6 -0
- data/ext/ruby/qtruby/src/lib/Qt4.rb +6 -0
- data/ext/ruby/qtruby/src/marshall.h +66 -0
- data/ext/ruby/qtruby/src/marshall_basetypes.h +208 -0
- data/ext/ruby/qtruby/src/marshall_complex.h +175 -0
- data/ext/ruby/qtruby/src/marshall_macros.h +647 -0
- data/ext/ruby/qtruby/src/marshall_primitives.h +290 -0
- data/ext/ruby/qtruby/src/marshall_types.cpp +815 -0
- data/ext/ruby/qtruby/src/marshall_types.h +240 -0
- data/ext/ruby/qtruby/src/qtruby.cpp +2483 -0
- data/ext/ruby/qtruby/src/qtruby.h +185 -0
- data/ext/ruby/qtruby/src/smokeruby.h +164 -0
- data/ext/ruby/qtruby/test/opoverloading.rb +46 -0
- data/ext/ruby/qtruby/test/unittests.rb +151 -0
- data/ext/ruby/qtruby/tools/CMakeLists.txt +2 -0
- data/ext/ruby/qtruby/tools/rbrcc/CMakeLists.txt +6 -0
- data/ext/ruby/qtruby/tools/rbrcc/Messages.sh +7 -0
- data/ext/ruby/qtruby/tools/rbrcc/main.cpp +173 -0
- data/ext/ruby/qtruby/tools/rbrcc/rbrcc.pro +14 -0
- data/ext/ruby/qtruby/tools/rbrcc/rcc.cpp +648 -0
- data/ext/ruby/qtruby/tools/rbrcc/rcc.h +165 -0
- data/ext/ruby/qtruby/tools/rbuic/CMakeLists.txt +35 -0
- data/ext/ruby/qtruby/tools/rbuic/LICENSE.GPL +280 -0
- data/ext/ruby/qtruby/tools/rbuic/Messages.sh +7 -0
- data/ext/ruby/qtruby/tools/rbuic/TODO +4 -0
- data/ext/ruby/qtruby/tools/rbuic/customwidgetsinfo.cpp +106 -0
- data/ext/ruby/qtruby/tools/rbuic/customwidgetsinfo.h +95 -0
- data/ext/ruby/qtruby/tools/rbuic/databaseinfo.cpp +102 -0
- data/ext/ruby/qtruby/tools/rbuic/databaseinfo.h +85 -0
- data/ext/ruby/qtruby/tools/rbuic/driver.cpp +384 -0
- data/ext/ruby/qtruby/tools/rbuic/driver.h +141 -0
- data/ext/ruby/qtruby/tools/rbuic/globaldefs.h +60 -0
- data/ext/ruby/qtruby/tools/rbuic/main.cpp +201 -0
- data/ext/ruby/qtruby/tools/rbuic/option.h +107 -0
- data/ext/ruby/qtruby/tools/rbuic/rbuic.pri +23 -0
- data/ext/ruby/qtruby/tools/rbuic/rbuic4.pro +43 -0
- data/ext/ruby/qtruby/tools/rbuic/ruby/rbextractimages.cpp +150 -0
- data/ext/ruby/qtruby/tools/rbuic/ruby/rbextractimages.h +83 -0
- data/ext/ruby/qtruby/tools/rbuic/ruby/rbwritedeclaration.cpp +217 -0
- data/ext/ruby/qtruby/tools/rbuic/ruby/rbwritedeclaration.h +85 -0
- data/ext/ruby/qtruby/tools/rbuic/ruby/rbwriteicondata.cpp +185 -0
- data/ext/ruby/qtruby/tools/rbuic/ruby/rbwriteicondata.h +86 -0
- data/ext/ruby/qtruby/tools/rbuic/ruby/rbwriteicondeclaration.cpp +88 -0
- data/ext/ruby/qtruby/tools/rbuic/ruby/rbwriteicondeclaration.h +83 -0
- data/ext/ruby/qtruby/tools/rbuic/ruby/rbwriteiconinitialization.cpp +126 -0
- data/ext/ruby/qtruby/tools/rbuic/ruby/rbwriteiconinitialization.h +87 -0
- data/ext/ruby/qtruby/tools/rbuic/ruby/rbwriteinitialization.cpp +2478 -0
- data/ext/ruby/qtruby/tools/rbuic/ruby/rbwriteinitialization.h +314 -0
- data/ext/ruby/qtruby/tools/rbuic/ruby/ruby.pri +18 -0
- data/ext/ruby/qtruby/tools/rbuic/treewalker.cpp +318 -0
- data/ext/ruby/qtruby/tools/rbuic/treewalker.h +139 -0
- data/ext/ruby/qtruby/tools/rbuic/ui4.cpp +7623 -0
- data/ext/ruby/qtruby/tools/rbuic/ui4.h +3180 -0
- data/ext/ruby/qtruby/tools/rbuic/uic.cpp +438 -0
- data/ext/ruby/qtruby/tools/rbuic/uic.h +154 -0
- data/ext/ruby/qtruby/tools/rbuic/utils.h +125 -0
- data/ext/ruby/qtruby/tools/rbuic/validator.cpp +100 -0
- data/ext/ruby/qtruby/tools/rbuic/validator.h +80 -0
- data/ext/ruby/qtscript/CMakeLists.txt +19 -0
- data/ext/ruby/qtscript/qtscript.cpp +82 -0
- data/ext/ruby/qtscript/qtscript.rb +40 -0
- data/ext/ruby/qtscript/qtscripthandlers.cpp +36 -0
- data/ext/ruby/qtscript/smokedata.cpp +1403 -0
- data/ext/ruby/qttest/CMakeLists.txt +18 -0
- data/ext/ruby/qttest/ChangeLog +9 -0
- data/ext/ruby/qttest/examples/myfirsttest.rb +30 -0
- data/ext/ruby/qttest/qttest.cpp +82 -0
- data/ext/ruby/qttest/qttest.rb +166 -0
- data/ext/ruby/qttest/qttesthandlers.cpp +35 -0
- data/ext/ruby/qtuitools/CMakeLists.txt +16 -0
- data/ext/ruby/qtuitools/qtuitools.cpp +82 -0
- data/ext/ruby/qtuitools/qtuitools.rb +17 -0
- data/ext/ruby/qtuitools/qtuitoolshandlers.cpp +31 -0
- data/ext/ruby/qtwebkit/CMakeLists.txt +17 -0
- data/ext/ruby/qtwebkit/qtwebkit.cpp +66 -0
- data/ext/ruby/qtwebkit/qtwebkit.rb +17 -0
- data/ext/ruby/qtwebkit/qtwebkithandlers.cpp +39 -0
- data/ext/smoke/CMakeLists.txt +35 -0
- data/ext/smoke/deptool/CMakeLists.txt +7 -0
- data/ext/smoke/deptool/main.cpp +128 -0
- data/ext/smoke/qt_smoke.h +16 -0
- data/ext/smoke/qtcore/CMakeLists.txt +88 -0
- data/ext/smoke/qtcore/QtGuess.txt +181 -0
- data/ext/smoke/qtcore/config.xml.cmake +10 -0
- data/ext/smoke/qtcore/qt-config.xml.cmake +21 -0
- data/ext/smoke/qtcore/qtcore_includes.h +1 -0
- data/ext/smoke/qtcore/smokeconfig.xml +189 -0
- data/ext/smoke/qtcore/tests/CMakeLists.txt +13 -0
- data/ext/smoke/qtcore/tests/test.cpp +846 -0
- data/ext/smoke/qtcore_smoke.h +16 -0
- data/ext/smoke/qtdbus/CMakeLists.txt +38 -0
- data/ext/smoke/qtdbus/config.xml.cmake +11 -0
- data/ext/smoke/qtdbus/qtdbus_includes.h +2 -0
- data/ext/smoke/qtdbus/smokeconfig.xml +63 -0
- data/ext/smoke/qtdbus_smoke.h +16 -0
- data/ext/smoke/qtgui/CMakeLists.txt +76 -0
- data/ext/smoke/qtgui/config.xml.cmake +11 -0
- data/ext/smoke/qtgui/qtgui_includes.h +7 -0
- data/ext/smoke/qtgui/smokeconfig.xml +490 -0
- data/ext/smoke/qtgui_smoke.h +16 -0
- data/ext/smoke/qtmultimedia/CMakeLists.txt +42 -0
- data/ext/smoke/qtmultimedia/config.xml.cmake +12 -0
- data/ext/smoke/qtmultimedia/qtmultimedia_includes.h +3 -0
- data/ext/smoke/qtmultimedia/smokeconfig.xml +50 -0
- data/ext/smoke/qtmultimedia_smoke.h +16 -0
- data/ext/smoke/qtnetwork/CMakeLists.txt +38 -0
- data/ext/smoke/qtnetwork/config.xml.cmake +11 -0
- data/ext/smoke/qtnetwork/qtnetwork_includes.h +2 -0
- data/ext/smoke/qtnetwork/smokeconfig.xml +76 -0
- data/ext/smoke/qtnetwork_smoke.h +16 -0
- data/ext/smoke/qtopengl/CMakeLists.txt +43 -0
- data/ext/smoke/qtopengl/config.xml.cmake +12 -0
- data/ext/smoke/qtopengl/qtopengl_includes.h +3 -0
- data/ext/smoke/qtopengl/smokeconfig.xml +56 -0
- data/ext/smoke/qtopengl_smoke.h +16 -0
- data/ext/smoke/qtscript/CMakeLists.txt +31 -0
- data/ext/smoke/qtscript/config.xml.cmake +11 -0
- data/ext/smoke/qtscript/qtscript_includes.h +14 -0
- data/ext/smoke/qtscript/smokeconfig.xml +39 -0
- data/ext/smoke/qtscript_smoke.h +16 -0
- data/ext/smoke/qtsql/CMakeLists.txt +41 -0
- data/ext/smoke/qtsql/config.xml.cmake +11 -0
- data/ext/smoke/qtsql/qtsql_includes.h +2 -0
- data/ext/smoke/qtsql/smokeconfig.xml +56 -0
- data/ext/smoke/qtsql_smoke.h +16 -0
- data/ext/smoke/qtsvg/CMakeLists.txt +43 -0
- data/ext/smoke/qtsvg/config.xml.cmake +12 -0
- data/ext/smoke/qtsvg/qtsvg_includes.h +3 -0
- data/ext/smoke/qtsvg/smokeconfig.xml +45 -0
- data/ext/smoke/qtsvg_smoke.h +16 -0
- data/ext/smoke/qttest/CMakeLists.txt +35 -0
- data/ext/smoke/qttest/config.xml.cmake +12 -0
- data/ext/smoke/qttest/qttest_includes.h +14 -0
- data/ext/smoke/qttest/smokeconfig.xml +36 -0
- data/ext/smoke/qttest_smoke.h +16 -0
- data/ext/smoke/qtuitools/CMakeLists.txt +30 -0
- data/ext/smoke/qtuitools/config.xml.cmake +12 -0
- data/ext/smoke/qtuitools/qtuitools_includes.h +1 -0
- data/ext/smoke/qtuitools/smokeconfig.xml +20 -0
- data/ext/smoke/qtuitools_smoke.h +16 -0
- data/ext/smoke/qtwebkit/CMakeLists.txt +36 -0
- data/ext/smoke/qtwebkit/config.xml.cmake +11 -0
- data/ext/smoke/qtwebkit/qtwebkit_includes.h +1 -0
- data/ext/smoke/qtwebkit/smokeconfig.xml +45 -0
- data/ext/smoke/qtwebkit_smoke.h +16 -0
- data/ext/smoke/qtxml/CMakeLists.txt +41 -0
- data/ext/smoke/qtxml/config.xml.cmake +11 -0
- data/ext/smoke/qtxml/qtxml_includes.h +2 -0
- data/ext/smoke/qtxml/smokeconfig.xml +70 -0
- data/ext/smoke/qtxml_smoke.h +16 -0
- data/ext/smoke/qtxmlpatterns/CMakeLists.txt +42 -0
- data/ext/smoke/qtxmlpatterns/config.xml.cmake +12 -0
- data/ext/smoke/qtxmlpatterns/qtxmlpatterns_includes.h +3 -0
- data/ext/smoke/qtxmlpatterns/smokeconfig.xml +80 -0
- data/ext/smoke/qtxmlpatterns_smoke.h +16 -0
- data/ext/smoke/smoke.h +557 -0
- data/ext/smoke/smokeapi/CMakeLists.txt +9 -0
- data/ext/smoke/smokeapi/main.cpp +309 -0
- data/ext/smoke/smokebase/CMakeLists.txt +11 -0
- data/ext/smoke/smokebase/smokebase.cpp +6 -0
- data/ext/smoke/solid_smoke.h +16 -0
- data/extconf.rb +231 -0
- data/lib/1.8/libqtruby4shared.dll +0 -0
- data/lib/1.8/libsmokebase.dll +0 -0
- data/lib/1.8/libsmokeqtcore.dll +0 -0
- data/lib/1.8/libsmokeqtgui.dll +0 -0
- data/lib/1.8/libsmokeqtmultimedia.dll +0 -0
- data/lib/1.8/libsmokeqtnetwork.dll +0 -0
- data/lib/1.8/libsmokeqtopengl.dll +0 -0
- data/lib/1.8/libsmokeqtscript.dll +0 -0
- data/lib/1.8/libsmokeqtsql.dll +0 -0
- data/lib/1.8/libsmokeqtsvg.dll +0 -0
- data/lib/1.8/libsmokeqttest.dll +0 -0
- data/lib/1.8/libsmokeqtuitools.dll +0 -0
- data/lib/1.8/libsmokeqtwebkit.dll +0 -0
- data/lib/1.8/libsmokeqtxml.dll +0 -0
- data/lib/1.8/libsmokeqtxmlpatterns.dll +0 -0
- data/lib/1.8/qtruby4.so +0 -0
- data/lib/1.8/qtscript.so +0 -0
- data/lib/1.8/qttest.so +0 -0
- data/lib/1.8/qtuitools.so +0 -0
- data/lib/1.8/qtwebkit.so +0 -0
- data/lib/1.9/libqtruby4shared.dll +0 -0
- data/lib/1.9/libsmokebase.dll +0 -0
- data/lib/1.9/libsmokeqtcore.dll +0 -0
- data/lib/1.9/libsmokeqtgui.dll +0 -0
- data/lib/1.9/libsmokeqtmultimedia.dll +0 -0
- data/lib/1.9/libsmokeqtnetwork.dll +0 -0
- data/lib/1.9/libsmokeqtopengl.dll +0 -0
- data/lib/1.9/libsmokeqtscript.dll +0 -0
- data/lib/1.9/libsmokeqtsql.dll +0 -0
- data/lib/1.9/libsmokeqtsvg.dll +0 -0
- data/lib/1.9/libsmokeqttest.dll +0 -0
- data/lib/1.9/libsmokeqtuitools.dll +0 -0
- data/lib/1.9/libsmokeqtwebkit.dll +0 -0
- data/lib/1.9/libsmokeqtxml.dll +0 -0
- data/lib/1.9/libsmokeqtxmlpatterns.dll +0 -0
- data/lib/1.9/qtruby4.so +0 -0
- data/lib/1.9/qtscript.so +0 -0
- data/lib/1.9/qttest.so +0 -0
- data/lib/1.9/qtuitools.so +0 -0
- data/lib/1.9/qtwebkit.so +0 -0
- data/lib/Qt.rb +1 -0
- data/lib/Qt/qtruby4.rb +3177 -0
- data/lib/Qt4.rb +20 -0
- data/lib/qtbindings_version.rb +2 -0
- data/lib/qtscript/qtscript.rb +40 -0
- data/lib/qttest/qttest.rb +166 -0
- data/lib/qtuitools/qtuitools.rb +17 -0
- data/lib/qtwebkit/qtwebkit.rb +17 -0
- data/qtbindings.gemspec +18 -0
- data/qtbindingsnative.gemspec +18 -0
- metadata +1297 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
/* This file is part of KDevelop
|
2
|
+
Copyright 2002-2005 Roberto Raggi <roberto@kdevelop.org>
|
3
|
+
|
4
|
+
This library is free software; you can redistribute it and/or
|
5
|
+
modify it under the terms of the GNU Library General Public
|
6
|
+
License version 2 as published by the Free Software Foundation.
|
7
|
+
|
8
|
+
This library is distributed in the hope that it will be useful,
|
9
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
Library General Public License for more details.
|
12
|
+
|
13
|
+
You should have received a copy of the GNU Library General Public License
|
14
|
+
along with this library; see the file COPYING.LIB. If not, write to
|
15
|
+
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
16
|
+
Boston, MA 02110-1301, USA.
|
17
|
+
*/
|
18
|
+
|
19
|
+
#ifndef MEMORYPOOL_H
|
20
|
+
#define MEMORYPOOL_H
|
21
|
+
|
22
|
+
#include "rxx_allocator.h"
|
23
|
+
#include <cstring>
|
24
|
+
|
25
|
+
/**Memory pool for chars.*/
|
26
|
+
class pool
|
27
|
+
{
|
28
|
+
rxx_allocator<char> __alloc;
|
29
|
+
|
30
|
+
public:
|
31
|
+
/**Allocates the @p size bytes in the pool.*/
|
32
|
+
inline void *allocate(std::size_t __size);
|
33
|
+
};
|
34
|
+
|
35
|
+
inline void *pool::allocate(std::size_t __size)
|
36
|
+
{
|
37
|
+
return __alloc.allocate(__size);
|
38
|
+
}
|
39
|
+
|
40
|
+
#endif // MEMORYPOOL_H
|
41
|
+
|
@@ -0,0 +1,190 @@
|
|
1
|
+
/* This file is part of KDevelop
|
2
|
+
Copyright 2002-2005 Roberto Raggi <roberto@kdevelop.org>
|
3
|
+
|
4
|
+
This library is free software; you can redistribute it and/or
|
5
|
+
modify it under the terms of the GNU Library General Public
|
6
|
+
License version 2 as published by the Free Software Foundation.
|
7
|
+
|
8
|
+
This library is distributed in the hope that it will be useful,
|
9
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
Library General Public License for more details.
|
12
|
+
|
13
|
+
You should have received a copy of the GNU Library General Public License
|
14
|
+
along with this library; see the file COPYING.LIB. If not, write to
|
15
|
+
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
16
|
+
Boston, MA 02110-1301, USA.
|
17
|
+
*/
|
18
|
+
|
19
|
+
//krazy:excludeall=cpp
|
20
|
+
|
21
|
+
#include "name_compiler.h"
|
22
|
+
#include "type_compiler.h"
|
23
|
+
#include "lexer.h"
|
24
|
+
#include "symbol.h"
|
25
|
+
#include "parsesession.h"
|
26
|
+
#include "tokens.h"
|
27
|
+
|
28
|
+
#include <QtCore/qdebug.h>
|
29
|
+
|
30
|
+
///@todo this is very expensive
|
31
|
+
QString decode(ParseSession* session, AST* ast, bool without_spaces = false)
|
32
|
+
{
|
33
|
+
QString ret;
|
34
|
+
if( without_spaces ) {
|
35
|
+
//Decode operator-names without spaces for now, since we rely on it in other places.
|
36
|
+
///@todo change this, here and in all the places that rely on it. Operators should then by written like "operator [ ]"(space between each token)
|
37
|
+
for( size_t a = ast->start_token; a < ast->end_token; a++ ) {
|
38
|
+
ret += session->token_stream->token(a).symbolString();
|
39
|
+
}
|
40
|
+
} else {
|
41
|
+
for( size_t a = ast->start_token; a < ast->end_token; a++ ) {
|
42
|
+
ret += session->token_stream->token(a).symbolString() + ' ';
|
43
|
+
}
|
44
|
+
}
|
45
|
+
return ret;
|
46
|
+
}
|
47
|
+
|
48
|
+
/*uint parseConstVolatile(ParseSession* session, const ListNode<std::size_t> *cv)
|
49
|
+
{
|
50
|
+
uint ret = AbstractType::NoModifiers;
|
51
|
+
|
52
|
+
if (cv) {
|
53
|
+
const ListNode<std::size_t> *it = cv->toFront();
|
54
|
+
const ListNode<std::size_t> *end = it;
|
55
|
+
do {
|
56
|
+
int kind = session->token_stream->kind(it->element);
|
57
|
+
if (kind == Token_const)
|
58
|
+
ret |= AbstractType::ConstModifier;
|
59
|
+
else if (kind == Token_volatile)
|
60
|
+
ret |= AbstractType::VolatileModifier;
|
61
|
+
|
62
|
+
it = it->next;
|
63
|
+
} while (it != end);
|
64
|
+
}
|
65
|
+
|
66
|
+
return ret;
|
67
|
+
}*/
|
68
|
+
|
69
|
+
/*IndexedTypeIdentifier typeIdentifierFromTemplateArgument(ParseSession* session, TemplateArgumentAST *node)
|
70
|
+
{
|
71
|
+
IndexedTypeIdentifier id;
|
72
|
+
if(node->expression) {
|
73
|
+
id = IndexedTypeIdentifier(decode(session, node), true);
|
74
|
+
}else if(node->type_id) {
|
75
|
+
//Parse the pointer operators
|
76
|
+
TypeCompiler tc(session);
|
77
|
+
tc.run(node->type_id->type_specifier);
|
78
|
+
id = IndexedTypeIdentifier(tc.identifier());
|
79
|
+
//node->type_id->type_specifier->cv
|
80
|
+
|
81
|
+
if(node->type_id->type_specifier)
|
82
|
+
id.setIsConstant(parseConstVolatile(session, node->type_id->type_specifier->cv) & AbstractType::ConstModifier);
|
83
|
+
|
84
|
+
if(node->type_id->declarator && node->type_id->declarator->ptr_ops)
|
85
|
+
{
|
86
|
+
const ListNode<PtrOperatorAST*> *it = node->type_id->declarator->ptr_ops->toFront();
|
87
|
+
const ListNode<PtrOperatorAST*> *end = it; ///@todo check ordering, eventually walk the list in reversed order
|
88
|
+
do
|
89
|
+
{
|
90
|
+
if(it->element && it->element->op) { ///@todo What about ptr-to-member?
|
91
|
+
static IndexedString ref('&');
|
92
|
+
if( session->token_stream->token(it->element->op).symbol() == ref) {
|
93
|
+
//We're handling a 'reference'
|
94
|
+
id.setIsReference(true);
|
95
|
+
} else {
|
96
|
+
//We're handling a real pointer
|
97
|
+
id.setPointerDepth(id.pointerDepth()+1);
|
98
|
+
|
99
|
+
if(it->element->cv) {
|
100
|
+
id.setIsConstPointer(id.pointerDepth()-1, parseConstVolatile(session, it->element->cv) & AbstractType::ConstModifier);
|
101
|
+
}
|
102
|
+
}
|
103
|
+
}
|
104
|
+
it = it->next;
|
105
|
+
}
|
106
|
+
while (it != end);
|
107
|
+
}
|
108
|
+
}
|
109
|
+
return id;
|
110
|
+
}*/
|
111
|
+
|
112
|
+
NameCompiler::NameCompiler(ParseSession* session)
|
113
|
+
: m_session(session)
|
114
|
+
{
|
115
|
+
}
|
116
|
+
|
117
|
+
void NameCompiler::internal_run(AST *node)
|
118
|
+
{
|
119
|
+
m_name.clear();
|
120
|
+
visit(node);
|
121
|
+
}
|
122
|
+
|
123
|
+
void NameCompiler::visitUnqualifiedName(UnqualifiedNameAST *node)
|
124
|
+
{
|
125
|
+
IndexedString tmp_name;
|
126
|
+
|
127
|
+
if (node->id)
|
128
|
+
tmp_name = m_session->token_stream->token(node->id).symbol();
|
129
|
+
|
130
|
+
if (node->tilde)
|
131
|
+
tmp_name = IndexedString('~' + tmp_name.byteArray());
|
132
|
+
|
133
|
+
if (OperatorFunctionIdAST *op_id = node->operator_id)
|
134
|
+
{
|
135
|
+
#if defined(__GNUC__)
|
136
|
+
#warning "NameCompiler::visitUnqualifiedName() -- implement me"
|
137
|
+
#endif
|
138
|
+
static QString operatorString("operator");
|
139
|
+
QString tmp = operatorString;
|
140
|
+
|
141
|
+
if (op_id->op && op_id->op->op)
|
142
|
+
tmp += decode(m_session, op_id->op, true);
|
143
|
+
else
|
144
|
+
tmp += QLatin1String("{...cast...}");
|
145
|
+
|
146
|
+
tmp_name = IndexedString(tmp);
|
147
|
+
m_typeSpecifier = op_id->type_specifier;
|
148
|
+
}
|
149
|
+
|
150
|
+
m_currentIdentifier = tmp_name.str();
|
151
|
+
m_name.push_back(m_currentIdentifier);
|
152
|
+
if (node->template_arguments)
|
153
|
+
{
|
154
|
+
visitNodes(this, node->template_arguments);
|
155
|
+
}/*else if(node->end_token == node->start_token + 3 && node->id == node->start_token && m_session->token_stream->token(node->id+1).symbol() == KDevelop::IndexedString('<')) {
|
156
|
+
///@todo Represent this nicer in the AST
|
157
|
+
///It's probably a type-specifier with instantiation of the default-parameter, like "Bla<>".
|
158
|
+
m_currentIdentifier.appendTemplateIdentifier( IndexedTypeIdentifier() );
|
159
|
+
}*/
|
160
|
+
}
|
161
|
+
|
162
|
+
TypeSpecifierAST* NameCompiler::lastTypeSpecifier() const {
|
163
|
+
return m_typeSpecifier;
|
164
|
+
}
|
165
|
+
|
166
|
+
void NameCompiler::visitTemplateArgument(TemplateArgumentAST *node)
|
167
|
+
{
|
168
|
+
TypeCompiler tc(m_session);
|
169
|
+
tc.run(node->type_id->type_specifier);
|
170
|
+
if (tc.isIntegral())
|
171
|
+
m_templateArgs << tc.qualifiedName().join(" ");
|
172
|
+
else
|
173
|
+
m_templateArgs << tc.qualifiedName().join("::");
|
174
|
+
// m_currentIdentifier.appendTemplateIdentifier( typeIdentifierFromTemplateArgument(m_session, node) );
|
175
|
+
}
|
176
|
+
|
177
|
+
/*const QualifiedIdentifier& NameCompiler::identifier() const
|
178
|
+
{
|
179
|
+
return *_M_name;
|
180
|
+
}*/
|
181
|
+
|
182
|
+
void NameCompiler::run(NameAST *node/*, QualifiedIdentifier* target*/)
|
183
|
+
{
|
184
|
+
// if(target)
|
185
|
+
// _M_name = target;
|
186
|
+
// else
|
187
|
+
// _M_name = &m_localName;
|
188
|
+
|
189
|
+
m_typeSpecifier = 0; internal_run(node); /*if(node && node->global) _M_name->setExplicitlyGlobal( node->global );*/
|
190
|
+
}
|
@@ -0,0 +1,77 @@
|
|
1
|
+
/* This file is part of KDevelop
|
2
|
+
Copyright 2002-2005 Roberto Raggi <roberto@kdevelop.org>
|
3
|
+
|
4
|
+
This library is free software; you can redistribute it and/or
|
5
|
+
modify it under the terms of the GNU Library General Public
|
6
|
+
License version 2 as published by the Free Software Foundation.
|
7
|
+
|
8
|
+
This library is distributed in the hope that it will be useful,
|
9
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
Library General Public License for more details.
|
12
|
+
|
13
|
+
You should have received a copy of the GNU Library General Public License
|
14
|
+
along with this library; see the file COPYING.LIB. If not, write to
|
15
|
+
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
16
|
+
Boston, MA 02110-1301, USA.
|
17
|
+
*/
|
18
|
+
|
19
|
+
#ifndef NAME_COMPILER_H
|
20
|
+
#define NAME_COMPILER_H
|
21
|
+
|
22
|
+
#include <QString>
|
23
|
+
#include <QStringList>
|
24
|
+
|
25
|
+
#include "cppparser_export.h"
|
26
|
+
#include "default_visitor.h"
|
27
|
+
// #include <language/duchain/identifier.h>
|
28
|
+
// #include <language/duchain/declaration.h>
|
29
|
+
|
30
|
+
class ParseSession;
|
31
|
+
class OperatorAST;
|
32
|
+
|
33
|
+
class CPPPARSER_EXPORT NameCompiler: protected DefaultVisitor
|
34
|
+
{
|
35
|
+
public:
|
36
|
+
NameCompiler(ParseSession* session);
|
37
|
+
|
38
|
+
///@param target If this is nonzero, the identifier will be written to that place without any copying.
|
39
|
+
void run(NameAST *node/*, KDevelop::QualifiedIdentifier* target = 0*/);
|
40
|
+
void run(UnqualifiedNameAST *node) { m_typeSpecifier = 0; internal_run(node); }
|
41
|
+
|
42
|
+
QString name() const { return m_name.join("::"); }
|
43
|
+
const QStringList& qualifiedName() const { return m_name; }
|
44
|
+
const QStringList& templateArgs() const { return m_templateArgs; }
|
45
|
+
|
46
|
+
// const KDevelop::QualifiedIdentifier& identifier() const;
|
47
|
+
|
48
|
+
/**
|
49
|
+
* When the name contains one type-specifier, this should contain that specifier after the run.
|
50
|
+
* Especially this is the type-specifier of a conversion-operator like "operator int()"
|
51
|
+
* */
|
52
|
+
TypeSpecifierAST* lastTypeSpecifier() const;
|
53
|
+
|
54
|
+
protected:
|
55
|
+
virtual void visitUnqualifiedName(UnqualifiedNameAST *node);
|
56
|
+
virtual void visitTemplateArgument(TemplateArgumentAST *node);
|
57
|
+
|
58
|
+
void internal_run(AST *node);
|
59
|
+
|
60
|
+
private:
|
61
|
+
ParseSession* m_session;
|
62
|
+
TypeSpecifierAST* m_typeSpecifier;
|
63
|
+
QStringList m_name;
|
64
|
+
QStringList m_templateArgs;
|
65
|
+
QString m_currentIdentifier;
|
66
|
+
// KDevelop::QualifiedIdentifier m_base;
|
67
|
+
// KDevelop::Identifier m_currentIdentifier;
|
68
|
+
// KDevelop::QualifiedIdentifier* _M_name;
|
69
|
+
// KDevelop::QualifiedIdentifier m_localName;
|
70
|
+
};
|
71
|
+
|
72
|
+
//Extracts a type-identifier from a template argument
|
73
|
+
// KDevelop::IndexedTypeIdentifier Q_DECL_EXPORT typeIdentifierFromTemplateArgument(ParseSession* session, TemplateArgumentAST *node);
|
74
|
+
uint CPPPARSER_EXPORT parseConstVolatile(ParseSession* session, const ListNode<std::size_t> *cv);
|
75
|
+
|
76
|
+
#endif // NAME_COMPILER_H
|
77
|
+
|
@@ -0,0 +1,4706 @@
|
|
1
|
+
/* This file is part of KDevelop
|
2
|
+
Copyright 2002-2005 Roberto Raggi <roberto@kdevelop.org>
|
3
|
+
Copyright 2007-2008 David Nolden <david.nolden.kdevelop@art-master.de>
|
4
|
+
|
5
|
+
This library is free software; you can redistribute it and/or
|
6
|
+
modify it under the terms of the GNU Library General Public
|
7
|
+
License version 2 as published by the Free Software Foundation.
|
8
|
+
|
9
|
+
This library is distributed in the hope that it will be useful,
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
+
Library General Public License for more details.
|
13
|
+
|
14
|
+
You should have received a copy of the GNU Library General Public License
|
15
|
+
along with this library; see the file COPYING.LIB. If not, write to
|
16
|
+
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
17
|
+
Boston, MA 02110-1301, USA.
|
18
|
+
*/
|
19
|
+
|
20
|
+
//krazy:excludeall=cpp
|
21
|
+
|
22
|
+
// c++ support
|
23
|
+
#include "parser.h"
|
24
|
+
#include "tokens.h"
|
25
|
+
#include "lexer.h"
|
26
|
+
#include "control.h"
|
27
|
+
#include "parsesession.h"
|
28
|
+
|
29
|
+
#include <cstdlib>
|
30
|
+
#include <iostream>
|
31
|
+
#include "rpp/chartools.h"
|
32
|
+
|
33
|
+
#define ADVANCE(tk, descr) \
|
34
|
+
{ \
|
35
|
+
if (session->token_stream->lookAhead() != tk) { \
|
36
|
+
tokenRequiredError(tk); \
|
37
|
+
return false; \
|
38
|
+
} \
|
39
|
+
advance(); \
|
40
|
+
}
|
41
|
+
|
42
|
+
#define ADVANCE_NR(tk, descr) \
|
43
|
+
do { \
|
44
|
+
if (session->token_stream->lookAhead() != tk) { \
|
45
|
+
tokenRequiredError(tk); \
|
46
|
+
} \
|
47
|
+
else \
|
48
|
+
advance(); \
|
49
|
+
} while (0)
|
50
|
+
|
51
|
+
#define CHECK(tk) \
|
52
|
+
do { \
|
53
|
+
if (session->token_stream->lookAhead() != tk) { \
|
54
|
+
return false; \
|
55
|
+
} \
|
56
|
+
advance(); \
|
57
|
+
} while (0)
|
58
|
+
|
59
|
+
#define UPDATE_POS(_node, start, end) \
|
60
|
+
do { \
|
61
|
+
(_node)->start_token = start; \
|
62
|
+
(_node)->end_token = end; \
|
63
|
+
} while (0)
|
64
|
+
|
65
|
+
void Parser::addComment( CommentAST* ast, const Comment& comment ) {
|
66
|
+
if( comment ) {
|
67
|
+
/* kDebug() << "Adding but leaving comment" << session->token_stream->token(comment.token()).symbol();*/
|
68
|
+
ast->comments = snoc(ast->comments, comment.token(), session->mempool);
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
72
|
+
void Parser::moveComments( CommentAST* ast ) {
|
73
|
+
while( m_commentStore.hasComment() ) {
|
74
|
+
size_t token = m_commentStore.takeFirstComment().token();
|
75
|
+
|
76
|
+
/* kDebug() << "Moving comment" << session->token_stream->token(token).symbol();*/
|
77
|
+
|
78
|
+
ast->comments = snoc(ast->comments, token, session->mempool);
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
Parser::Parser(Control *c)
|
83
|
+
: control(c), lexer(control), session(0), _M_last_valid_token(0), _M_last_parsed_comment(0), _M_hadMismatchingCompoundTokens(false), m_primaryExpressionWithTemplateParamsNeedsFunctionCall(true)
|
84
|
+
{
|
85
|
+
_M_max_problem_count = 5;
|
86
|
+
_M_hold_errors = false;
|
87
|
+
}
|
88
|
+
|
89
|
+
Parser::~Parser()
|
90
|
+
{
|
91
|
+
}
|
92
|
+
|
93
|
+
void Parser::rewind(size_t position) {
|
94
|
+
session->token_stream->rewind(position);
|
95
|
+
|
96
|
+
//Search the previous valid token
|
97
|
+
|
98
|
+
_M_last_valid_token = position > 0 ? position-1 : position;
|
99
|
+
|
100
|
+
while( _M_last_valid_token > 0 && session->token_stream->kind(_M_last_valid_token) == Token_comment )
|
101
|
+
--_M_last_valid_token;
|
102
|
+
}
|
103
|
+
|
104
|
+
void Parser::advance( bool skipComment ) {
|
105
|
+
size_t t = session->token_stream->lookAhead();
|
106
|
+
if( t != Token_comment )
|
107
|
+
_M_last_valid_token = session->token_stream->cursor();
|
108
|
+
|
109
|
+
session->token_stream->nextToken();
|
110
|
+
|
111
|
+
if( session->token_stream->lookAhead() == Token_comment ) {
|
112
|
+
if( skipComment ) {
|
113
|
+
processComment();
|
114
|
+
advance();
|
115
|
+
}
|
116
|
+
}
|
117
|
+
}
|
118
|
+
|
119
|
+
Comment Parser::comment() {
|
120
|
+
return m_commentStore.latestComment();
|
121
|
+
}
|
122
|
+
|
123
|
+
void Parser::preparseLineComments( int tokenNumber ) {
|
124
|
+
const Token& token( (*session->token_stream)[tokenNumber] );
|
125
|
+
SimpleCursor tokenPosition = SimpleCursor::invalid();
|
126
|
+
|
127
|
+
for( int a = 0; a < 40; a++ ) {
|
128
|
+
if( !session->token_stream->lookAhead(a) ) break;
|
129
|
+
if( session->token_stream->lookAhead(a) == Token_comment ) {
|
130
|
+
//Make sure the token's line is before the searched token's line
|
131
|
+
const Token& commentToken( (*session->token_stream)[session->token_stream->cursor() + a] );
|
132
|
+
|
133
|
+
if( !tokenPosition.isValid() ) //Get the token line. Only on-demand, because it's not cheap.
|
134
|
+
tokenPosition = session->positionAt(token.position);
|
135
|
+
|
136
|
+
SimpleCursor commentPosition = session->positionAt( commentToken.position );
|
137
|
+
|
138
|
+
if( commentPosition.line < tokenPosition.line ) {
|
139
|
+
continue;
|
140
|
+
} else if( commentPosition.line == tokenPosition.line ) {
|
141
|
+
processComment( a );
|
142
|
+
} else {
|
143
|
+
//Too far
|
144
|
+
break;
|
145
|
+
}
|
146
|
+
}
|
147
|
+
}
|
148
|
+
}
|
149
|
+
|
150
|
+
int Parser::lineFromTokenNumber( size_t tokenNumber ) const {
|
151
|
+
const Token& token( (*session->token_stream)[tokenNumber] );
|
152
|
+
return session->positionAt( token.position ).line;
|
153
|
+
}
|
154
|
+
|
155
|
+
|
156
|
+
void Parser::processComment( int offset, int line ) {
|
157
|
+
size_t tokenNumber = session->token_stream->cursor() + offset;
|
158
|
+
|
159
|
+
if(_M_last_parsed_comment >= tokenNumber)
|
160
|
+
return; //The comment was already parsed. May happen because of pre-parsing
|
161
|
+
|
162
|
+
_M_last_parsed_comment = tokenNumber;
|
163
|
+
|
164
|
+
const Token& commentToken( (*session->token_stream)[tokenNumber] );
|
165
|
+
Q_ASSERT(commentToken.kind == Token_comment);
|
166
|
+
if( line == -1 ) {
|
167
|
+
SimpleCursor position = session->positionAt( commentToken.position );
|
168
|
+
line = position.line;
|
169
|
+
}
|
170
|
+
|
171
|
+
/* kDebug() << "noticing comment" << commentToken.symbol();*/
|
172
|
+
m_commentStore.addComment( Comment( session->token_stream->cursor() + offset, line ) );
|
173
|
+
|
174
|
+
}
|
175
|
+
|
176
|
+
void Parser::clearComment( ) {
|
177
|
+
m_commentStore.clear();
|
178
|
+
}
|
179
|
+
|
180
|
+
TranslationUnitAST *Parser::parse(ParseSession* _session)
|
181
|
+
{
|
182
|
+
clear();
|
183
|
+
session = _session;
|
184
|
+
|
185
|
+
if (!session->token_stream)
|
186
|
+
session->token_stream = new TokenStream;
|
187
|
+
|
188
|
+
lexer.tokenize(session);
|
189
|
+
advance(); // skip the first token
|
190
|
+
|
191
|
+
TranslationUnitAST *ast = 0;
|
192
|
+
parseTranslationUnit(ast);
|
193
|
+
return ast;
|
194
|
+
}
|
195
|
+
|
196
|
+
StatementAST *Parser::parseStatement(ParseSession* _session)
|
197
|
+
{
|
198
|
+
clear();
|
199
|
+
session = _session;
|
200
|
+
|
201
|
+
if (!session->token_stream)
|
202
|
+
session->token_stream = new TokenStream;
|
203
|
+
|
204
|
+
lexer.tokenize(session);
|
205
|
+
advance(); // skip the first token
|
206
|
+
|
207
|
+
StatementAST *ast = 0;
|
208
|
+
parseCompoundStatement(ast);
|
209
|
+
return ast;
|
210
|
+
}
|
211
|
+
|
212
|
+
AST *Parser::parseTypeOrExpression(ParseSession* _session, bool forceExpression)
|
213
|
+
{
|
214
|
+
clear();
|
215
|
+
session = _session;
|
216
|
+
|
217
|
+
if (!session->token_stream)
|
218
|
+
session->token_stream = new TokenStream;
|
219
|
+
|
220
|
+
lexer.tokenize(session);
|
221
|
+
advance(); // skip the first token
|
222
|
+
|
223
|
+
TypeIdAST *ast = 0;
|
224
|
+
if (!forceExpression)
|
225
|
+
parseTypeId(ast);
|
226
|
+
if(!ast) {
|
227
|
+
m_primaryExpressionWithTemplateParamsNeedsFunctionCall = false;
|
228
|
+
ExpressionAST* ast = 0;
|
229
|
+
parseExpression(ast);
|
230
|
+
return ast;
|
231
|
+
}
|
232
|
+
|
233
|
+
return ast;
|
234
|
+
}
|
235
|
+
|
236
|
+
void Parser::clear()
|
237
|
+
{
|
238
|
+
_M_hold_errors = false;
|
239
|
+
m_tokenMarkers.clear();
|
240
|
+
}
|
241
|
+
|
242
|
+
void Parser::addTokenMarkers(size_t tokenNumber, Parser::TokenMarkers markers)
|
243
|
+
{
|
244
|
+
hash_map<size_t, TokenMarkers>::iterator it = m_tokenMarkers.find(tokenNumber);
|
245
|
+
if(it != m_tokenMarkers.end())
|
246
|
+
(*it).second = (TokenMarkers)((*it).second | markers);
|
247
|
+
else
|
248
|
+
m_tokenMarkers.insert(std::make_pair(tokenNumber, markers));
|
249
|
+
}
|
250
|
+
|
251
|
+
Parser::TokenMarkers Parser::tokenMarkers(size_t tokenNumber) const
|
252
|
+
{
|
253
|
+
hash_map<size_t, TokenMarkers>::const_iterator it = m_tokenMarkers.find(tokenNumber);
|
254
|
+
if(it != m_tokenMarkers.end())
|
255
|
+
return (*it).second;
|
256
|
+
else
|
257
|
+
return None;
|
258
|
+
}
|
259
|
+
|
260
|
+
IndexedString declSpecString("__declspec");
|
261
|
+
|
262
|
+
bool Parser::parseWinDeclSpec(WinDeclSpecAST *&node)
|
263
|
+
{
|
264
|
+
if (session->token_stream->lookAhead() != Token_identifier)
|
265
|
+
return false;
|
266
|
+
|
267
|
+
std::size_t start = session->token_stream->cursor();
|
268
|
+
|
269
|
+
IndexedString name = session->token_stream->token(session->token_stream->cursor()).symbol();
|
270
|
+
if (name != declSpecString)
|
271
|
+
return false;
|
272
|
+
std::size_t specifier = session->token_stream->cursor();
|
273
|
+
|
274
|
+
advance();
|
275
|
+
if (session->token_stream->lookAhead() != '(')
|
276
|
+
return false;
|
277
|
+
|
278
|
+
advance();
|
279
|
+
if (session->token_stream->lookAhead() != Token_identifier)
|
280
|
+
return false;
|
281
|
+
std::size_t modifier = session->token_stream->cursor();
|
282
|
+
|
283
|
+
advance();
|
284
|
+
if (session->token_stream->lookAhead() != ')')
|
285
|
+
return false;
|
286
|
+
|
287
|
+
advance();
|
288
|
+
|
289
|
+
node = CreateNode<WinDeclSpecAST>(session->mempool);
|
290
|
+
node->specifier = specifier;
|
291
|
+
node->modifier = modifier;
|
292
|
+
|
293
|
+
UPDATE_POS(node, start, _M_last_valid_token+1);
|
294
|
+
|
295
|
+
return true;
|
296
|
+
}
|
297
|
+
|
298
|
+
void Parser::tokenRequiredError(int token)
|
299
|
+
{
|
300
|
+
QString err;
|
301
|
+
|
302
|
+
err += "Expected token ";
|
303
|
+
err += '\'';
|
304
|
+
err += token_name(token);
|
305
|
+
err += "\' after \'";
|
306
|
+
err += token_name(session->token_stream->lookAhead(-1));
|
307
|
+
err += "\' found \'";
|
308
|
+
err += token_name(session->token_stream->lookAhead());
|
309
|
+
err += '\'';
|
310
|
+
|
311
|
+
if(token == '}' || token == '{')
|
312
|
+
_M_hadMismatchingCompoundTokens = true;
|
313
|
+
|
314
|
+
reportError(err);
|
315
|
+
}
|
316
|
+
|
317
|
+
void Parser::syntaxError()
|
318
|
+
{
|
319
|
+
std::size_t cursor = session->token_stream->cursor();
|
320
|
+
std::size_t kind = session->token_stream->lookAhead();
|
321
|
+
|
322
|
+
if (m_syntaxErrorTokens.contains(cursor))
|
323
|
+
return; // syntax error at this point has already been reported
|
324
|
+
|
325
|
+
m_syntaxErrorTokens.insert(cursor);
|
326
|
+
|
327
|
+
QString err;
|
328
|
+
|
329
|
+
if (kind == Token_EOF)
|
330
|
+
err += "Unexpected end of file";
|
331
|
+
else
|
332
|
+
{
|
333
|
+
err += "Unexpected token ";
|
334
|
+
err += '\'';
|
335
|
+
err += token_name(kind);
|
336
|
+
err += '\'';
|
337
|
+
}
|
338
|
+
|
339
|
+
reportError(err);
|
340
|
+
}
|
341
|
+
|
342
|
+
void Parser::reportPendingErrors()
|
343
|
+
{
|
344
|
+
bool hold = holdErrors(false);
|
345
|
+
|
346
|
+
std::size_t start = session->token_stream->cursor();
|
347
|
+
while (m_pendingErrors.count() > 0)
|
348
|
+
{
|
349
|
+
PendingError error = m_pendingErrors.dequeue();
|
350
|
+
session->token_stream->rewind(error.cursor);
|
351
|
+
reportError(error.message);
|
352
|
+
}
|
353
|
+
rewind(start);
|
354
|
+
|
355
|
+
holdErrors(hold);
|
356
|
+
}
|
357
|
+
|
358
|
+
void Parser::reportError(const QString& msg)
|
359
|
+
{
|
360
|
+
if (!_M_hold_errors && _M_problem_count < _M_max_problem_count)
|
361
|
+
{
|
362
|
+
++_M_problem_count;
|
363
|
+
|
364
|
+
QString fileName;
|
365
|
+
|
366
|
+
std::size_t tok = session->token_stream->cursor();
|
367
|
+
SimpleCursor position = session->positionAt(session->token_stream->position(tok));
|
368
|
+
|
369
|
+
Problem *p = new Problem;
|
370
|
+
p->file = session->url().str();
|
371
|
+
p->position = position;
|
372
|
+
p->description = msg;
|
373
|
+
p->source = Problem::Source_Parser;
|
374
|
+
|
375
|
+
control->reportProblem(p);
|
376
|
+
}
|
377
|
+
else if (_M_hold_errors)
|
378
|
+
{
|
379
|
+
PendingError pending;
|
380
|
+
pending.message = msg;
|
381
|
+
pending.cursor = session->token_stream->cursor();
|
382
|
+
m_pendingErrors.enqueue(pending);
|
383
|
+
}
|
384
|
+
}
|
385
|
+
|
386
|
+
bool Parser::skipUntil(int token)
|
387
|
+
{
|
388
|
+
clearComment();
|
389
|
+
|
390
|
+
while (session->token_stream->lookAhead())
|
391
|
+
{
|
392
|
+
if (session->token_stream->lookAhead() == token)
|
393
|
+
return true;
|
394
|
+
|
395
|
+
advance();
|
396
|
+
}
|
397
|
+
|
398
|
+
return false;
|
399
|
+
}
|
400
|
+
|
401
|
+
bool Parser::skipUntilDeclaration()
|
402
|
+
{
|
403
|
+
while (session->token_stream->lookAhead())
|
404
|
+
{
|
405
|
+
|
406
|
+
switch(session->token_stream->lookAhead())
|
407
|
+
{
|
408
|
+
case ';':
|
409
|
+
case '~':
|
410
|
+
case Token_scope:
|
411
|
+
case Token_identifier:
|
412
|
+
case Token_operator:
|
413
|
+
case Token_char:
|
414
|
+
case Token_wchar_t:
|
415
|
+
case Token_bool:
|
416
|
+
case Token_short:
|
417
|
+
case Token_int:
|
418
|
+
case Token_long:
|
419
|
+
case Token_signed:
|
420
|
+
case Token_unsigned:
|
421
|
+
case Token_float:
|
422
|
+
case Token_double:
|
423
|
+
case Token_void:
|
424
|
+
case Token_extern:
|
425
|
+
case Token_namespace:
|
426
|
+
case Token_using:
|
427
|
+
case Token_typedef:
|
428
|
+
case Token_asm:
|
429
|
+
case Token_template:
|
430
|
+
case Token_export:
|
431
|
+
|
432
|
+
case Token_const: // cv
|
433
|
+
case Token_volatile: // cv
|
434
|
+
|
435
|
+
case Token_public:
|
436
|
+
case Token_protected:
|
437
|
+
case Token_private:
|
438
|
+
case Token_signals: // Qt
|
439
|
+
case Token_slots: // Qt
|
440
|
+
return true;
|
441
|
+
case '}':
|
442
|
+
return false;
|
443
|
+
|
444
|
+
default:
|
445
|
+
advance();
|
446
|
+
}
|
447
|
+
}
|
448
|
+
|
449
|
+
return false;
|
450
|
+
}
|
451
|
+
|
452
|
+
bool Parser::skipUntilStatement()
|
453
|
+
{
|
454
|
+
while (session->token_stream->lookAhead())
|
455
|
+
{
|
456
|
+
switch(session->token_stream->lookAhead())
|
457
|
+
{
|
458
|
+
case ';':
|
459
|
+
case '{':
|
460
|
+
case '}':
|
461
|
+
case Token_const:
|
462
|
+
case Token_volatile:
|
463
|
+
case Token_identifier:
|
464
|
+
case Token_case:
|
465
|
+
case Token_default:
|
466
|
+
case Token_if:
|
467
|
+
case Token_switch:
|
468
|
+
case Token_while:
|
469
|
+
case Token_do:
|
470
|
+
case Token_for:
|
471
|
+
case Token_break:
|
472
|
+
case Token_continue:
|
473
|
+
case Token_return:
|
474
|
+
case Token_goto:
|
475
|
+
case Token_try:
|
476
|
+
case Token_catch:
|
477
|
+
case Token_throw:
|
478
|
+
case Token_char:
|
479
|
+
case Token_wchar_t:
|
480
|
+
case Token_bool:
|
481
|
+
case Token_short:
|
482
|
+
case Token_int:
|
483
|
+
case Token_long:
|
484
|
+
case Token_signed:
|
485
|
+
case Token_unsigned:
|
486
|
+
case Token_float:
|
487
|
+
case Token_double:
|
488
|
+
case Token_void:
|
489
|
+
case Token_class:
|
490
|
+
case Token_struct:
|
491
|
+
case Token_union:
|
492
|
+
case Token_enum:
|
493
|
+
case Token_scope:
|
494
|
+
case Token_template:
|
495
|
+
case Token_using:
|
496
|
+
return true;
|
497
|
+
|
498
|
+
default:
|
499
|
+
advance();
|
500
|
+
}
|
501
|
+
}
|
502
|
+
|
503
|
+
return false;
|
504
|
+
}
|
505
|
+
|
506
|
+
bool Parser::skip(int l, int r)
|
507
|
+
{
|
508
|
+
int count = 0;
|
509
|
+
while (session->token_stream->lookAhead())
|
510
|
+
{
|
511
|
+
int tk = session->token_stream->lookAhead();
|
512
|
+
|
513
|
+
if (tk == l)
|
514
|
+
++count;
|
515
|
+
else if (tk == r)
|
516
|
+
--count;
|
517
|
+
else if (l != '{' && (tk == '{' || tk == '}' || tk == ';'))
|
518
|
+
return false;
|
519
|
+
|
520
|
+
if (count == 0)
|
521
|
+
return true;
|
522
|
+
|
523
|
+
advance();
|
524
|
+
}
|
525
|
+
|
526
|
+
return false;
|
527
|
+
}
|
528
|
+
|
529
|
+
bool Parser::parseName(NameAST*& node, ParseNameAcceptTemplate acceptTemplateId)
|
530
|
+
{
|
531
|
+
std::size_t start = session->token_stream->cursor();
|
532
|
+
|
533
|
+
WinDeclSpecAST *winDeclSpec = 0;
|
534
|
+
parseWinDeclSpec(winDeclSpec);
|
535
|
+
|
536
|
+
NameAST *ast = CreateNode<NameAST>(session->mempool);
|
537
|
+
|
538
|
+
if (session->token_stream->lookAhead() == Token_scope)
|
539
|
+
{
|
540
|
+
ast->global = true;
|
541
|
+
advance();
|
542
|
+
}
|
543
|
+
|
544
|
+
std::size_t idx = session->token_stream->cursor();
|
545
|
+
|
546
|
+
while (true)
|
547
|
+
{
|
548
|
+
UnqualifiedNameAST *n = 0;
|
549
|
+
if (!parseUnqualifiedName(n)) {
|
550
|
+
return false;
|
551
|
+
}
|
552
|
+
|
553
|
+
if (session->token_stream->lookAhead() == Token_scope)
|
554
|
+
{
|
555
|
+
advance();
|
556
|
+
|
557
|
+
ast->qualified_names
|
558
|
+
= snoc(ast->qualified_names, n, session->mempool);
|
559
|
+
|
560
|
+
if (session->token_stream->lookAhead() == Token_template)
|
561
|
+
{
|
562
|
+
/// skip optional template #### @todo CHECK
|
563
|
+
advance();
|
564
|
+
}
|
565
|
+
}
|
566
|
+
else
|
567
|
+
{
|
568
|
+
Q_ASSERT(n != 0);
|
569
|
+
|
570
|
+
if (acceptTemplateId == DontAcceptTemplate ||
|
571
|
+
//Eventually only accept template parameters as primary expression if the expression is followed by a function call
|
572
|
+
(acceptTemplateId == EventuallyAcceptTemplate && n->template_arguments && session->token_stream->lookAhead() != '(' && m_primaryExpressionWithTemplateParamsNeedsFunctionCall))
|
573
|
+
{
|
574
|
+
rewind(n->start_token);
|
575
|
+
parseUnqualifiedName(n, false);
|
576
|
+
}
|
577
|
+
|
578
|
+
ast->unqualified_name = n;
|
579
|
+
break;
|
580
|
+
}
|
581
|
+
}
|
582
|
+
|
583
|
+
if (idx == session->token_stream->cursor())
|
584
|
+
return false;
|
585
|
+
|
586
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
587
|
+
node = ast;
|
588
|
+
|
589
|
+
return true;
|
590
|
+
}
|
591
|
+
|
592
|
+
bool Parser::parseTranslationUnit(TranslationUnitAST *&node)
|
593
|
+
{
|
594
|
+
_M_problem_count = 0;
|
595
|
+
_M_hadMismatchingCompoundTokens = false;
|
596
|
+
|
597
|
+
/* kDebug() << "tokens:";
|
598
|
+
for(size_t a = 0; a < session->token_stream->size(); ++a)
|
599
|
+
kDebug() << token_name(session->token_stream->token(a).kind) << session->token_stream->token(a).symbolString();*/
|
600
|
+
|
601
|
+
std::size_t start = session->token_stream->cursor();
|
602
|
+
TranslationUnitAST *ast = CreateNode<TranslationUnitAST>(session->mempool);
|
603
|
+
|
604
|
+
if( m_commentStore.hasComment() )
|
605
|
+
addComment(ast, m_commentStore.takeFirstComment());
|
606
|
+
|
607
|
+
while (session->token_stream->lookAhead())
|
608
|
+
{
|
609
|
+
std::size_t startDecl = session->token_stream->cursor();
|
610
|
+
|
611
|
+
DeclarationAST *declaration = 0;
|
612
|
+
if (parseDeclaration(declaration))
|
613
|
+
{
|
614
|
+
ast->declarations =
|
615
|
+
snoc(ast->declarations, declaration, session->mempool);
|
616
|
+
}
|
617
|
+
else
|
618
|
+
{
|
619
|
+
// error recovery
|
620
|
+
if (startDecl == session->token_stream->cursor())
|
621
|
+
{
|
622
|
+
// skip at least one token
|
623
|
+
advance();
|
624
|
+
}
|
625
|
+
|
626
|
+
skipUntilDeclaration();
|
627
|
+
}
|
628
|
+
}
|
629
|
+
|
630
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
631
|
+
node = ast;
|
632
|
+
|
633
|
+
ast->hadMissingCompoundTokens = _M_hadMismatchingCompoundTokens;
|
634
|
+
|
635
|
+
return true;
|
636
|
+
}
|
637
|
+
|
638
|
+
bool Parser::parseDeclaration(DeclarationAST *&node)
|
639
|
+
{
|
640
|
+
std::size_t start = session->token_stream->cursor();
|
641
|
+
|
642
|
+
switch(session->token_stream->lookAhead())
|
643
|
+
{
|
644
|
+
case ';':
|
645
|
+
advance();
|
646
|
+
return true;
|
647
|
+
|
648
|
+
case Token_extern:
|
649
|
+
return parseLinkageSpecification(node);
|
650
|
+
|
651
|
+
case Token_namespace:
|
652
|
+
return parseNamespace(node);
|
653
|
+
|
654
|
+
case Token_using:
|
655
|
+
return parseUsing(node);
|
656
|
+
|
657
|
+
case Token_typedef:
|
658
|
+
return parseTypedef(node);
|
659
|
+
|
660
|
+
case Token_asm:
|
661
|
+
return parseAsmDefinition(node);
|
662
|
+
|
663
|
+
case Token_template:
|
664
|
+
case Token_export:
|
665
|
+
return parseTemplateDeclaration(node);
|
666
|
+
|
667
|
+
default:
|
668
|
+
{
|
669
|
+
const ListNode<std::size_t> *cv = 0;
|
670
|
+
parseCvQualify(cv);
|
671
|
+
|
672
|
+
const ListNode<std::size_t> *storageSpec = 0;
|
673
|
+
parseStorageClassSpecifier(storageSpec);
|
674
|
+
|
675
|
+
parseCvQualify(cv);
|
676
|
+
|
677
|
+
Comment mcomment = comment();
|
678
|
+
clearComment();
|
679
|
+
|
680
|
+
TypeSpecifierAST *spec = 0;
|
681
|
+
if (parseEnumSpecifier(spec)
|
682
|
+
|| parseClassSpecifier(spec))
|
683
|
+
{
|
684
|
+
parseCvQualify(cv);
|
685
|
+
|
686
|
+
spec->cv = cv;
|
687
|
+
|
688
|
+
const ListNode<InitDeclaratorAST*> *declarators = 0;
|
689
|
+
parseInitDeclaratorList(declarators);
|
690
|
+
ADVANCE(';', ";");
|
691
|
+
|
692
|
+
SimpleDeclarationAST *ast =
|
693
|
+
CreateNode<SimpleDeclarationAST>(session->mempool);
|
694
|
+
ast->storage_specifiers = storageSpec;
|
695
|
+
ast->type_specifier = spec;
|
696
|
+
ast->init_declarators = declarators;
|
697
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
698
|
+
node = ast;
|
699
|
+
|
700
|
+
if( mcomment )
|
701
|
+
addComment(ast, mcomment);
|
702
|
+
|
703
|
+
preparseLineComments(ast->end_token-1);
|
704
|
+
|
705
|
+
if( m_commentStore.hasComment() )
|
706
|
+
addComment( ast, m_commentStore.takeCommentInRange( lineFromTokenNumber( --ast->end_token ) ) );
|
707
|
+
|
708
|
+
return true;
|
709
|
+
} else {
|
710
|
+
rewind(start);
|
711
|
+
if( parseDeclarationInternal(node) ) {
|
712
|
+
//Add the comments to the declaration
|
713
|
+
if( mcomment )
|
714
|
+
addComment(node, mcomment);
|
715
|
+
|
716
|
+
preparseLineComments(node->end_token-1);
|
717
|
+
|
718
|
+
if( m_commentStore.hasComment() )
|
719
|
+
addComment( node, m_commentStore.takeCommentInRange( lineFromTokenNumber( --node->end_token ) ) );
|
720
|
+
|
721
|
+
return true;
|
722
|
+
}
|
723
|
+
}
|
724
|
+
}
|
725
|
+
} // end switch
|
726
|
+
|
727
|
+
return false;
|
728
|
+
}
|
729
|
+
|
730
|
+
bool Parser::parseLinkageSpecification(DeclarationAST *&node)
|
731
|
+
{
|
732
|
+
std::size_t start = session->token_stream->cursor();
|
733
|
+
|
734
|
+
CHECK(Token_extern);
|
735
|
+
|
736
|
+
LinkageSpecificationAST *ast = CreateNode<LinkageSpecificationAST>(session->mempool);
|
737
|
+
|
738
|
+
if (session->token_stream->lookAhead() == Token_string_literal)
|
739
|
+
{
|
740
|
+
ast->extern_type = session->token_stream->cursor();
|
741
|
+
advance();
|
742
|
+
}
|
743
|
+
|
744
|
+
if (session->token_stream->lookAhead() == '{')
|
745
|
+
{
|
746
|
+
parseLinkageBody(ast->linkage_body);
|
747
|
+
}
|
748
|
+
else if (!parseDeclaration(ast->declaration))
|
749
|
+
{
|
750
|
+
reportError(("Declaration syntax error"));
|
751
|
+
}
|
752
|
+
|
753
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
754
|
+
node = ast;
|
755
|
+
|
756
|
+
return true;
|
757
|
+
}
|
758
|
+
|
759
|
+
bool Parser::parseLinkageBody(LinkageBodyAST *&node)
|
760
|
+
{
|
761
|
+
std::size_t start = session->token_stream->cursor();
|
762
|
+
|
763
|
+
CHECK('{');
|
764
|
+
|
765
|
+
LinkageBodyAST *ast = CreateNode<LinkageBodyAST>(session->mempool);
|
766
|
+
|
767
|
+
while (session->token_stream->lookAhead())
|
768
|
+
{
|
769
|
+
int tk = session->token_stream->lookAhead();
|
770
|
+
|
771
|
+
if (tk == '}')
|
772
|
+
break;
|
773
|
+
|
774
|
+
std::size_t startDecl = session->token_stream->cursor();
|
775
|
+
|
776
|
+
DeclarationAST *declaration = 0;
|
777
|
+
if (parseDeclaration(declaration))
|
778
|
+
{
|
779
|
+
ast->declarations = snoc(ast->declarations, declaration, session->mempool);
|
780
|
+
}
|
781
|
+
else
|
782
|
+
{
|
783
|
+
// error recovery
|
784
|
+
if (startDecl == session->token_stream->cursor())
|
785
|
+
{
|
786
|
+
// skip at least one token
|
787
|
+
advance();
|
788
|
+
}
|
789
|
+
|
790
|
+
skipUntilDeclaration();
|
791
|
+
}
|
792
|
+
}
|
793
|
+
|
794
|
+
clearComment();
|
795
|
+
|
796
|
+
if (session->token_stream->lookAhead() != '}') {
|
797
|
+
reportError(("} expected"));
|
798
|
+
_M_hadMismatchingCompoundTokens = true;
|
799
|
+
} else
|
800
|
+
advance();
|
801
|
+
|
802
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
803
|
+
node = ast;
|
804
|
+
|
805
|
+
return true;
|
806
|
+
}
|
807
|
+
|
808
|
+
bool Parser::parseNamespace(DeclarationAST *&node)
|
809
|
+
{
|
810
|
+
std::size_t start = session->token_stream->cursor();
|
811
|
+
|
812
|
+
CHECK(Token_namespace);
|
813
|
+
|
814
|
+
std::size_t namespace_name = 0;
|
815
|
+
if (session->token_stream->lookAhead() == Token_identifier)
|
816
|
+
{
|
817
|
+
namespace_name = session->token_stream->cursor();
|
818
|
+
advance();
|
819
|
+
}
|
820
|
+
|
821
|
+
if (session->token_stream->lookAhead() == '=')
|
822
|
+
{
|
823
|
+
// namespace alias
|
824
|
+
advance();
|
825
|
+
|
826
|
+
NameAST *name = 0;
|
827
|
+
if (parseName(name))
|
828
|
+
{
|
829
|
+
ADVANCE(';', ";");
|
830
|
+
|
831
|
+
NamespaceAliasDefinitionAST *ast
|
832
|
+
= CreateNode<NamespaceAliasDefinitionAST>(session->mempool);
|
833
|
+
ast->namespace_name = namespace_name;
|
834
|
+
ast->alias_name = name;
|
835
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
836
|
+
|
837
|
+
node = ast;
|
838
|
+
return true;
|
839
|
+
}
|
840
|
+
else
|
841
|
+
{
|
842
|
+
reportError(("Namespace expected"));
|
843
|
+
return false;
|
844
|
+
}
|
845
|
+
}
|
846
|
+
else if (session->token_stream->lookAhead() != '{')
|
847
|
+
{
|
848
|
+
reportError(("{ expected"));
|
849
|
+
_M_hadMismatchingCompoundTokens = true;
|
850
|
+
return false;
|
851
|
+
}
|
852
|
+
|
853
|
+
NamespaceAST *ast = CreateNode<NamespaceAST>(session->mempool);
|
854
|
+
ast->namespace_name = namespace_name;
|
855
|
+
parseLinkageBody(ast->linkage_body);
|
856
|
+
|
857
|
+
UPDATE_POS(ast, start, ast->linkage_body->end_token);
|
858
|
+
node = ast;
|
859
|
+
|
860
|
+
return true;
|
861
|
+
}
|
862
|
+
|
863
|
+
bool Parser::parseUsing(DeclarationAST *&node)
|
864
|
+
{
|
865
|
+
std::size_t start = session->token_stream->cursor();
|
866
|
+
|
867
|
+
CHECK(Token_using);
|
868
|
+
|
869
|
+
if (session->token_stream->lookAhead() == Token_namespace)
|
870
|
+
return parseUsingDirective(node);
|
871
|
+
|
872
|
+
UsingAST *ast = CreateNode<UsingAST>(session->mempool);
|
873
|
+
|
874
|
+
if (session->token_stream->lookAhead() == Token_typename)
|
875
|
+
{
|
876
|
+
ast->type_name = session->token_stream->cursor();
|
877
|
+
advance();
|
878
|
+
}
|
879
|
+
|
880
|
+
if (!parseName(ast->name))
|
881
|
+
return false;
|
882
|
+
|
883
|
+
ADVANCE(';', ";");
|
884
|
+
|
885
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
886
|
+
node = ast;
|
887
|
+
|
888
|
+
return true;
|
889
|
+
}
|
890
|
+
|
891
|
+
bool Parser::parseUsingDirective(DeclarationAST *&node)
|
892
|
+
{
|
893
|
+
std::size_t start = session->token_stream->cursor();
|
894
|
+
|
895
|
+
CHECK(Token_namespace);
|
896
|
+
|
897
|
+
NameAST *name = 0;
|
898
|
+
if (!parseName(name))
|
899
|
+
{
|
900
|
+
reportError(("Namespace name expected"));
|
901
|
+
return false;
|
902
|
+
}
|
903
|
+
|
904
|
+
ADVANCE(';', ";");
|
905
|
+
|
906
|
+
UsingDirectiveAST *ast = CreateNode<UsingDirectiveAST>(session->mempool);
|
907
|
+
ast->name = name;
|
908
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
909
|
+
node = ast;
|
910
|
+
|
911
|
+
return true;
|
912
|
+
}
|
913
|
+
|
914
|
+
|
915
|
+
bool Parser::parseOperatorFunctionId(OperatorFunctionIdAST *&node)
|
916
|
+
{
|
917
|
+
std::size_t start = session->token_stream->cursor();
|
918
|
+
|
919
|
+
CHECK(Token_operator);
|
920
|
+
|
921
|
+
OperatorFunctionIdAST *ast = CreateNode<OperatorFunctionIdAST>(session->mempool);
|
922
|
+
if (!parseOperator(ast->op))
|
923
|
+
{
|
924
|
+
ast->op = 0;
|
925
|
+
|
926
|
+
// parse cast operator
|
927
|
+
const ListNode<std::size_t> *cv = 0;
|
928
|
+
parseCvQualify(cv);
|
929
|
+
|
930
|
+
if (!parseSimpleTypeSpecifier(ast->type_specifier))
|
931
|
+
{
|
932
|
+
syntaxError();
|
933
|
+
return false;
|
934
|
+
}
|
935
|
+
|
936
|
+
parseCvQualify(cv);
|
937
|
+
ast->type_specifier->cv = cv;
|
938
|
+
|
939
|
+
PtrOperatorAST *ptr_op = 0;
|
940
|
+
while (parsePtrOperator(ptr_op))
|
941
|
+
ast->ptr_ops = snoc(ast->ptr_ops, ptr_op, session->mempool);
|
942
|
+
}
|
943
|
+
|
944
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
945
|
+
node = ast;
|
946
|
+
return true;
|
947
|
+
}
|
948
|
+
|
949
|
+
bool Parser::parseTemplateArgumentList(const ListNode<TemplateArgumentAST*> *&node,
|
950
|
+
bool reportError)
|
951
|
+
{
|
952
|
+
TemplateArgumentAST *templArg = 0;
|
953
|
+
if (!parseTemplateArgument(templArg))
|
954
|
+
return false;
|
955
|
+
|
956
|
+
node = snoc(node, templArg, session->mempool);
|
957
|
+
|
958
|
+
while (session->token_stream->lookAhead() == ',')
|
959
|
+
{
|
960
|
+
advance();
|
961
|
+
|
962
|
+
if (!parseTemplateArgument(templArg))
|
963
|
+
{
|
964
|
+
if (reportError)
|
965
|
+
{
|
966
|
+
syntaxError();
|
967
|
+
break;
|
968
|
+
}
|
969
|
+
|
970
|
+
node = 0;
|
971
|
+
return false;
|
972
|
+
}
|
973
|
+
|
974
|
+
node = snoc(node, templArg, session->mempool);
|
975
|
+
}
|
976
|
+
|
977
|
+
return true;
|
978
|
+
}
|
979
|
+
|
980
|
+
bool Parser::parseTypedef(DeclarationAST *&node)
|
981
|
+
{
|
982
|
+
std::size_t start = session->token_stream->cursor();
|
983
|
+
|
984
|
+
Comment mcomment = comment();
|
985
|
+
|
986
|
+
CHECK(Token_typedef);
|
987
|
+
|
988
|
+
TypeSpecifierAST *spec = 0;
|
989
|
+
if (!parseTypeSpecifierOrClassSpec(spec))
|
990
|
+
{
|
991
|
+
reportError(("Need a type specifier to declare"));
|
992
|
+
return false;
|
993
|
+
}
|
994
|
+
|
995
|
+
const ListNode<InitDeclaratorAST*> *declarators = 0;
|
996
|
+
if (!parseInitDeclaratorList(declarators))
|
997
|
+
{
|
998
|
+
//reportError(("Need an identifier to declare"));
|
999
|
+
//return false;
|
1000
|
+
}
|
1001
|
+
clearComment();
|
1002
|
+
|
1003
|
+
TypedefAST *ast = CreateNode<TypedefAST>(session->mempool);
|
1004
|
+
|
1005
|
+
if( mcomment )
|
1006
|
+
addComment( ast, mcomment );
|
1007
|
+
|
1008
|
+
ADVANCE(';', ";");
|
1009
|
+
|
1010
|
+
ast->type_specifier = spec;
|
1011
|
+
ast->init_declarators = declarators;
|
1012
|
+
|
1013
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
1014
|
+
node = ast;
|
1015
|
+
|
1016
|
+
preparseLineComments( ast->end_token-1 );
|
1017
|
+
|
1018
|
+
if( m_commentStore.hasComment() )
|
1019
|
+
addComment( ast, m_commentStore.takeCommentInRange( lineFromTokenNumber( --ast->end_token ) ) );
|
1020
|
+
|
1021
|
+
return true;
|
1022
|
+
}
|
1023
|
+
|
1024
|
+
bool Parser::parseAsmDefinition(DeclarationAST *&node)
|
1025
|
+
{
|
1026
|
+
std::size_t start = session->token_stream->cursor();
|
1027
|
+
|
1028
|
+
ADVANCE(Token_asm, "asm");
|
1029
|
+
|
1030
|
+
const ListNode<std::size_t> *cv = 0;
|
1031
|
+
parseCvQualify(cv);
|
1032
|
+
|
1033
|
+
#if defined(__GNUC__)
|
1034
|
+
#warning "implement me"
|
1035
|
+
#endif
|
1036
|
+
skip('(', ')');
|
1037
|
+
advance();
|
1038
|
+
ADVANCE(';', ";");
|
1039
|
+
|
1040
|
+
AsmDefinitionAST *ast = CreateNode<AsmDefinitionAST>(session->mempool);
|
1041
|
+
ast->cv = cv;
|
1042
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
1043
|
+
node = ast;
|
1044
|
+
|
1045
|
+
return true;
|
1046
|
+
}
|
1047
|
+
|
1048
|
+
bool Parser::parseTemplateDeclaration(DeclarationAST *&node)
|
1049
|
+
{
|
1050
|
+
std::size_t start = session->token_stream->cursor();
|
1051
|
+
|
1052
|
+
std::size_t exported = 0;
|
1053
|
+
if (session->token_stream->lookAhead() == Token_export)
|
1054
|
+
{
|
1055
|
+
exported = session->token_stream->cursor();
|
1056
|
+
advance();
|
1057
|
+
}
|
1058
|
+
|
1059
|
+
CHECK(Token_template);
|
1060
|
+
|
1061
|
+
const ListNode<TemplateParameterAST*> *params = 0;
|
1062
|
+
if (session->token_stream->lookAhead() == '<')
|
1063
|
+
{
|
1064
|
+
advance();
|
1065
|
+
parseTemplateParameterList(params);
|
1066
|
+
|
1067
|
+
ADVANCE('>', ">");
|
1068
|
+
}
|
1069
|
+
|
1070
|
+
DeclarationAST *declaration = 0;
|
1071
|
+
if (!parseDeclaration(declaration))
|
1072
|
+
{
|
1073
|
+
reportError(("Expected a declaration"));
|
1074
|
+
}
|
1075
|
+
|
1076
|
+
TemplateDeclarationAST *ast = CreateNode<TemplateDeclarationAST>(session->mempool);
|
1077
|
+
ast->exported = exported;
|
1078
|
+
ast->template_parameters = params;
|
1079
|
+
ast->declaration = declaration;
|
1080
|
+
|
1081
|
+
UPDATE_POS(ast, start, declaration ? declaration->end_token : _M_last_valid_token+1);
|
1082
|
+
node = ast;
|
1083
|
+
|
1084
|
+
return true;
|
1085
|
+
}
|
1086
|
+
|
1087
|
+
bool Parser::parseOperator(OperatorAST *&node)
|
1088
|
+
{
|
1089
|
+
std::size_t start = session->token_stream->cursor();
|
1090
|
+
|
1091
|
+
OperatorAST *ast = CreateNode<OperatorAST>(session->mempool);
|
1092
|
+
|
1093
|
+
switch(session->token_stream->lookAhead())
|
1094
|
+
{
|
1095
|
+
case Token_new:
|
1096
|
+
case Token_delete:
|
1097
|
+
{
|
1098
|
+
ast->op = session->token_stream->cursor();
|
1099
|
+
advance();
|
1100
|
+
|
1101
|
+
if (session->token_stream->lookAhead() == '['
|
1102
|
+
&& session->token_stream->lookAhead(1) == ']')
|
1103
|
+
{
|
1104
|
+
ast->open = session->token_stream->cursor();
|
1105
|
+
advance();
|
1106
|
+
|
1107
|
+
ast->close = session->token_stream->cursor();
|
1108
|
+
advance();
|
1109
|
+
}
|
1110
|
+
}
|
1111
|
+
break;
|
1112
|
+
|
1113
|
+
case '+':
|
1114
|
+
case '-':
|
1115
|
+
case '*':
|
1116
|
+
case '/':
|
1117
|
+
case '%':
|
1118
|
+
case '^':
|
1119
|
+
case '&':
|
1120
|
+
case '|':
|
1121
|
+
case '~':
|
1122
|
+
case '!':
|
1123
|
+
case '=':
|
1124
|
+
case '<':
|
1125
|
+
case '>':
|
1126
|
+
case ',':
|
1127
|
+
case Token_assign:
|
1128
|
+
case Token_shift:
|
1129
|
+
case Token_eq:
|
1130
|
+
case Token_not:
|
1131
|
+
case Token_not_eq:
|
1132
|
+
case Token_leq:
|
1133
|
+
case Token_geq:
|
1134
|
+
case Token_and:
|
1135
|
+
case Token_or:
|
1136
|
+
case Token_incr:
|
1137
|
+
case Token_decr:
|
1138
|
+
case Token_ptrmem:
|
1139
|
+
case Token_arrow:
|
1140
|
+
ast->op = session->token_stream->cursor();
|
1141
|
+
advance();
|
1142
|
+
break;
|
1143
|
+
|
1144
|
+
default:
|
1145
|
+
if (session->token_stream->lookAhead() == '('
|
1146
|
+
&& session->token_stream->lookAhead(1) == ')')
|
1147
|
+
{
|
1148
|
+
ast->op = ast->open = session->token_stream->cursor();
|
1149
|
+
advance();
|
1150
|
+
ast->close = session->token_stream->cursor();
|
1151
|
+
advance();
|
1152
|
+
}
|
1153
|
+
else if (session->token_stream->lookAhead() == '['
|
1154
|
+
&& session->token_stream->lookAhead(1) == ']')
|
1155
|
+
{
|
1156
|
+
ast->op = ast->open = session->token_stream->cursor();
|
1157
|
+
advance();
|
1158
|
+
ast->close = session->token_stream->cursor();
|
1159
|
+
advance();
|
1160
|
+
}
|
1161
|
+
else
|
1162
|
+
{
|
1163
|
+
return false;
|
1164
|
+
}
|
1165
|
+
}
|
1166
|
+
|
1167
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
1168
|
+
node = ast;
|
1169
|
+
|
1170
|
+
return true;
|
1171
|
+
}
|
1172
|
+
|
1173
|
+
bool Parser::parseCvQualify(const ListNode<std::size_t> *&node)
|
1174
|
+
{
|
1175
|
+
std::size_t start = session->token_stream->cursor();
|
1176
|
+
|
1177
|
+
int tk;
|
1178
|
+
while (0 != (tk = session->token_stream->lookAhead())
|
1179
|
+
&& (tk == Token_const || tk == Token_volatile))
|
1180
|
+
{
|
1181
|
+
node = snoc(node, session->token_stream->cursor(), session->mempool);
|
1182
|
+
advance();
|
1183
|
+
}
|
1184
|
+
|
1185
|
+
return start != session->token_stream->cursor();
|
1186
|
+
}
|
1187
|
+
|
1188
|
+
bool Parser::parseSimpleTypeSpecifier(TypeSpecifierAST *&node,
|
1189
|
+
bool onlyIntegral)
|
1190
|
+
{
|
1191
|
+
std::size_t start = session->token_stream->cursor();
|
1192
|
+
bool isIntegral = false;
|
1193
|
+
bool done = false;
|
1194
|
+
|
1195
|
+
const ListNode<std::size_t> *integrals = 0;
|
1196
|
+
|
1197
|
+
while (!done)
|
1198
|
+
{
|
1199
|
+
switch(session->token_stream->lookAhead())
|
1200
|
+
{
|
1201
|
+
case Token_char:
|
1202
|
+
case Token_wchar_t:
|
1203
|
+
case Token_bool:
|
1204
|
+
case Token_short:
|
1205
|
+
case Token_int:
|
1206
|
+
case Token_long:
|
1207
|
+
case Token_signed:
|
1208
|
+
case Token_unsigned:
|
1209
|
+
case Token_float:
|
1210
|
+
case Token_double:
|
1211
|
+
case Token_void:
|
1212
|
+
integrals = snoc(integrals, session->token_stream->cursor(), session->mempool);
|
1213
|
+
isIntegral = true;
|
1214
|
+
advance();
|
1215
|
+
break;
|
1216
|
+
|
1217
|
+
default:
|
1218
|
+
done = true;
|
1219
|
+
}
|
1220
|
+
}
|
1221
|
+
|
1222
|
+
SimpleTypeSpecifierAST *ast = CreateNode<SimpleTypeSpecifierAST>(session->mempool);
|
1223
|
+
|
1224
|
+
if (isIntegral)
|
1225
|
+
{
|
1226
|
+
ast->integrals = integrals;
|
1227
|
+
}
|
1228
|
+
else if (session->token_stream->lookAhead() == Token___typeof)
|
1229
|
+
{
|
1230
|
+
ast->type_of = session->token_stream->cursor();
|
1231
|
+
advance();
|
1232
|
+
|
1233
|
+
if (session->token_stream->lookAhead() == '(')
|
1234
|
+
{
|
1235
|
+
advance();
|
1236
|
+
|
1237
|
+
std::size_t saved = session->token_stream->cursor();
|
1238
|
+
parseTypeId(ast->type_id);
|
1239
|
+
if (session->token_stream->lookAhead() != ')')
|
1240
|
+
{
|
1241
|
+
ast->type_id = 0;
|
1242
|
+
rewind(saved);
|
1243
|
+
parseUnaryExpression(ast->expression);
|
1244
|
+
}
|
1245
|
+
ADVANCE(')', ")");
|
1246
|
+
}
|
1247
|
+
else
|
1248
|
+
{
|
1249
|
+
parseUnaryExpression(ast->expression);
|
1250
|
+
}
|
1251
|
+
}
|
1252
|
+
else if (onlyIntegral)
|
1253
|
+
{
|
1254
|
+
rewind(start);
|
1255
|
+
return false;
|
1256
|
+
}
|
1257
|
+
else
|
1258
|
+
{
|
1259
|
+
if (!parseName(ast->name, AcceptTemplate))
|
1260
|
+
{
|
1261
|
+
ast->name = 0;
|
1262
|
+
rewind(start);
|
1263
|
+
return false;
|
1264
|
+
}
|
1265
|
+
}
|
1266
|
+
|
1267
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
1268
|
+
node = ast;
|
1269
|
+
|
1270
|
+
return true;
|
1271
|
+
}
|
1272
|
+
|
1273
|
+
bool Parser::parsePtrOperator(PtrOperatorAST *&node)
|
1274
|
+
{
|
1275
|
+
int tk = session->token_stream->lookAhead();
|
1276
|
+
|
1277
|
+
if (tk != '&' && tk != '*'
|
1278
|
+
&& tk != Token_scope && tk != Token_identifier)
|
1279
|
+
{
|
1280
|
+
return false;
|
1281
|
+
}
|
1282
|
+
|
1283
|
+
std::size_t start = session->token_stream->cursor();
|
1284
|
+
|
1285
|
+
PtrOperatorAST *ast = CreateNode<PtrOperatorAST>(session->mempool);
|
1286
|
+
switch (session->token_stream->lookAhead())
|
1287
|
+
{
|
1288
|
+
case '&':
|
1289
|
+
case '*':
|
1290
|
+
ast->op = session->token_stream->cursor();
|
1291
|
+
advance();
|
1292
|
+
break;
|
1293
|
+
|
1294
|
+
case Token_scope:
|
1295
|
+
case Token_identifier:
|
1296
|
+
{
|
1297
|
+
if (!parsePtrToMember(ast->mem_ptr))
|
1298
|
+
{
|
1299
|
+
rewind(start);
|
1300
|
+
return false;
|
1301
|
+
}
|
1302
|
+
}
|
1303
|
+
break;
|
1304
|
+
|
1305
|
+
default:
|
1306
|
+
Q_ASSERT(0);
|
1307
|
+
break;
|
1308
|
+
}
|
1309
|
+
|
1310
|
+
parseCvQualify(ast->cv);
|
1311
|
+
|
1312
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
1313
|
+
node = ast;
|
1314
|
+
|
1315
|
+
return true;
|
1316
|
+
}
|
1317
|
+
|
1318
|
+
bool Parser::parseTemplateArgument(TemplateArgumentAST *&node)
|
1319
|
+
{
|
1320
|
+
std::size_t start = session->token_stream->cursor();
|
1321
|
+
|
1322
|
+
TypeIdAST *typeId = 0;
|
1323
|
+
ExpressionAST *expr = 0;
|
1324
|
+
|
1325
|
+
if (!parseTypeId(typeId) || (session->token_stream->lookAhead() != ','
|
1326
|
+
&& session->token_stream->lookAhead() != '>' && session->token_stream->lookAhead() != ')'))
|
1327
|
+
{
|
1328
|
+
rewind(start);
|
1329
|
+
|
1330
|
+
if (!parseLogicalOrExpression(expr, true))
|
1331
|
+
return false;
|
1332
|
+
}
|
1333
|
+
|
1334
|
+
TemplateArgumentAST *ast = CreateNode<TemplateArgumentAST>(session->mempool);
|
1335
|
+
ast->type_id = typeId;
|
1336
|
+
ast->expression = expr;
|
1337
|
+
|
1338
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
1339
|
+
node = ast;
|
1340
|
+
|
1341
|
+
return true;
|
1342
|
+
}
|
1343
|
+
|
1344
|
+
bool Parser::parseTypeSpecifier(TypeSpecifierAST *&node)
|
1345
|
+
{
|
1346
|
+
std::size_t start = session->token_stream->cursor();
|
1347
|
+
|
1348
|
+
const ListNode<std::size_t> *cv = 0;
|
1349
|
+
parseCvQualify(cv);
|
1350
|
+
|
1351
|
+
TypeSpecifierAST *ast = 0;
|
1352
|
+
if (!parseElaboratedTypeSpecifier(ast) && !parseSimpleTypeSpecifier(ast))
|
1353
|
+
{
|
1354
|
+
rewind(start);
|
1355
|
+
return false;
|
1356
|
+
}
|
1357
|
+
|
1358
|
+
parseCvQualify(cv);
|
1359
|
+
ast->cv = cv;
|
1360
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
1361
|
+
|
1362
|
+
node = ast;
|
1363
|
+
|
1364
|
+
return true;
|
1365
|
+
}
|
1366
|
+
|
1367
|
+
bool Parser::parseDeclarator(DeclaratorAST *&node)
|
1368
|
+
{
|
1369
|
+
std::size_t start = session->token_stream->cursor();
|
1370
|
+
|
1371
|
+
DeclaratorAST *ast = CreateNode<DeclaratorAST>(session->mempool);
|
1372
|
+
DeclaratorAST *decl = 0;
|
1373
|
+
NameAST *declId = 0;
|
1374
|
+
|
1375
|
+
PtrOperatorAST *ptrOp = 0;
|
1376
|
+
while (parsePtrOperator(ptrOp))
|
1377
|
+
{
|
1378
|
+
ast->ptr_ops = snoc(ast->ptr_ops, ptrOp, session->mempool);
|
1379
|
+
}
|
1380
|
+
|
1381
|
+
if (session->token_stream->lookAhead() == '(')
|
1382
|
+
{
|
1383
|
+
advance();
|
1384
|
+
|
1385
|
+
if (!parseDeclarator(decl))
|
1386
|
+
return false;
|
1387
|
+
|
1388
|
+
ast->sub_declarator = decl;
|
1389
|
+
|
1390
|
+
CHECK(')');
|
1391
|
+
}
|
1392
|
+
else
|
1393
|
+
{
|
1394
|
+
if (session->token_stream->lookAhead() == ':')
|
1395
|
+
{
|
1396
|
+
// unnamed bitfield
|
1397
|
+
}
|
1398
|
+
else if (parseName(declId, AcceptTemplate))
|
1399
|
+
{
|
1400
|
+
ast->id = declId;
|
1401
|
+
}
|
1402
|
+
else
|
1403
|
+
{
|
1404
|
+
rewind(start);
|
1405
|
+
return false;
|
1406
|
+
}
|
1407
|
+
|
1408
|
+
if (session->token_stream->lookAhead() == ':')
|
1409
|
+
{
|
1410
|
+
advance();
|
1411
|
+
|
1412
|
+
if (!parseConstantExpression(ast->bit_expression))
|
1413
|
+
{
|
1414
|
+
reportError(("Constant expression expected"));
|
1415
|
+
}
|
1416
|
+
goto update_pos;
|
1417
|
+
}
|
1418
|
+
}
|
1419
|
+
|
1420
|
+
{
|
1421
|
+
bool isVector = false;
|
1422
|
+
|
1423
|
+
while (session->token_stream->lookAhead() == '[')
|
1424
|
+
{
|
1425
|
+
advance();
|
1426
|
+
|
1427
|
+
ExpressionAST *expr = 0;
|
1428
|
+
parseCommaExpression(expr);
|
1429
|
+
|
1430
|
+
ADVANCE(']', "]");
|
1431
|
+
|
1432
|
+
ast->array_dimensions = snoc(ast->array_dimensions, expr, session->mempool);
|
1433
|
+
isVector = true;
|
1434
|
+
}
|
1435
|
+
|
1436
|
+
bool skipParen = false;
|
1437
|
+
if (session->token_stream->lookAhead() == Token_identifier
|
1438
|
+
&& session->token_stream->lookAhead(1) == '('
|
1439
|
+
&& session->token_stream->lookAhead(2) == '(')
|
1440
|
+
{
|
1441
|
+
advance();
|
1442
|
+
advance();
|
1443
|
+
skipParen = true;
|
1444
|
+
}
|
1445
|
+
|
1446
|
+
int tok = session->token_stream->lookAhead();
|
1447
|
+
if (ast->sub_declarator
|
1448
|
+
&& !(isVector || tok == '(' || tok == ','
|
1449
|
+
|| tok == ';' || tok == '='))
|
1450
|
+
{
|
1451
|
+
rewind(start);
|
1452
|
+
return false;
|
1453
|
+
}
|
1454
|
+
|
1455
|
+
std::size_t index = session->token_stream->cursor();
|
1456
|
+
if (session->token_stream->lookAhead() == '(')
|
1457
|
+
{
|
1458
|
+
advance();
|
1459
|
+
///@todo Sometimes something like (test()) is parsed as a parameter declaration clause, although it cannot be one.
|
1460
|
+
ParameterDeclarationClauseAST *params = 0;
|
1461
|
+
if (!parseParameterDeclarationClause(params))
|
1462
|
+
{
|
1463
|
+
rewind(index);
|
1464
|
+
goto update_pos;
|
1465
|
+
}
|
1466
|
+
|
1467
|
+
ast->parameter_declaration_clause = params;
|
1468
|
+
|
1469
|
+
if (session->token_stream->lookAhead() != ')')
|
1470
|
+
{
|
1471
|
+
rewind(index);
|
1472
|
+
goto update_pos;
|
1473
|
+
}
|
1474
|
+
|
1475
|
+
advance(); // skip ')'
|
1476
|
+
|
1477
|
+
parseCvQualify(ast->fun_cv);
|
1478
|
+
parseExceptionSpecification(ast->exception_spec);
|
1479
|
+
|
1480
|
+
if (session->token_stream->lookAhead() == Token___attribute__)
|
1481
|
+
{
|
1482
|
+
advance();
|
1483
|
+
|
1484
|
+
ADVANCE('(', "(");
|
1485
|
+
|
1486
|
+
ExpressionAST *expr = 0;
|
1487
|
+
parseExpression(expr);
|
1488
|
+
|
1489
|
+
if (session->token_stream->lookAhead() != ')')
|
1490
|
+
{
|
1491
|
+
reportError(("')' expected"));
|
1492
|
+
}
|
1493
|
+
else
|
1494
|
+
{
|
1495
|
+
advance();
|
1496
|
+
}
|
1497
|
+
}
|
1498
|
+
}
|
1499
|
+
|
1500
|
+
if (skipParen)
|
1501
|
+
{
|
1502
|
+
if (session->token_stream->lookAhead() != ')')
|
1503
|
+
{
|
1504
|
+
reportError(("')' expected"));
|
1505
|
+
}
|
1506
|
+
else
|
1507
|
+
advance();
|
1508
|
+
}
|
1509
|
+
}
|
1510
|
+
|
1511
|
+
update_pos:
|
1512
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
1513
|
+
node = ast;
|
1514
|
+
|
1515
|
+
return true;
|
1516
|
+
}
|
1517
|
+
|
1518
|
+
bool Parser::parseAbstractDeclarator(DeclaratorAST *&node)
|
1519
|
+
{
|
1520
|
+
std::size_t start = session->token_stream->cursor();
|
1521
|
+
|
1522
|
+
DeclaratorAST *ast = CreateNode<DeclaratorAST>(session->mempool);
|
1523
|
+
DeclaratorAST *decl = 0;
|
1524
|
+
|
1525
|
+
PtrOperatorAST *ptrOp = 0;
|
1526
|
+
while (parsePtrOperator(ptrOp))
|
1527
|
+
{
|
1528
|
+
ast->ptr_ops = snoc(ast->ptr_ops, ptrOp, session->mempool);
|
1529
|
+
}
|
1530
|
+
|
1531
|
+
int index = session->token_stream->cursor();
|
1532
|
+
if (session->token_stream->lookAhead() == '(')
|
1533
|
+
{
|
1534
|
+
advance();
|
1535
|
+
|
1536
|
+
if (!parseAbstractDeclarator(decl))
|
1537
|
+
{
|
1538
|
+
rewind(index);
|
1539
|
+
goto label1;
|
1540
|
+
}
|
1541
|
+
|
1542
|
+
ast->sub_declarator = decl;
|
1543
|
+
|
1544
|
+
if (session->token_stream->lookAhead() != ')')
|
1545
|
+
{
|
1546
|
+
rewind(start);
|
1547
|
+
return false;
|
1548
|
+
}
|
1549
|
+
advance();
|
1550
|
+
}
|
1551
|
+
else if (session->token_stream->lookAhead() == ':')
|
1552
|
+
{
|
1553
|
+
advance();
|
1554
|
+
if (!parseConstantExpression(ast->bit_expression))
|
1555
|
+
{
|
1556
|
+
ast->bit_expression = 0;
|
1557
|
+
reportError(("Constant expression expected"));
|
1558
|
+
}
|
1559
|
+
goto update_pos;
|
1560
|
+
}
|
1561
|
+
|
1562
|
+
label1:
|
1563
|
+
{
|
1564
|
+
bool isVector = false;
|
1565
|
+
|
1566
|
+
while (session->token_stream->lookAhead() == '[')
|
1567
|
+
{
|
1568
|
+
advance();
|
1569
|
+
|
1570
|
+
ExpressionAST *expr = 0;
|
1571
|
+
parseCommaExpression(expr);
|
1572
|
+
|
1573
|
+
ADVANCE(']', "]");
|
1574
|
+
|
1575
|
+
ast->array_dimensions = snoc(ast->array_dimensions, expr, session->mempool);
|
1576
|
+
isVector = true;
|
1577
|
+
}
|
1578
|
+
|
1579
|
+
int tok = session->token_stream->lookAhead();
|
1580
|
+
if (ast->sub_declarator
|
1581
|
+
&& !(isVector || tok == '(' || tok == ','
|
1582
|
+
|| tok == ';' || tok == '='))
|
1583
|
+
{
|
1584
|
+
rewind(start);
|
1585
|
+
return false;
|
1586
|
+
}
|
1587
|
+
|
1588
|
+
int index = session->token_stream->cursor();
|
1589
|
+
if (session->token_stream->lookAhead() == '(')
|
1590
|
+
{
|
1591
|
+
advance();
|
1592
|
+
|
1593
|
+
ParameterDeclarationClauseAST *params = 0;
|
1594
|
+
if (!parseParameterDeclarationClause(params))
|
1595
|
+
{
|
1596
|
+
rewind(index);
|
1597
|
+
goto update_pos;
|
1598
|
+
}
|
1599
|
+
|
1600
|
+
ast->parameter_declaration_clause = params;
|
1601
|
+
|
1602
|
+
if (session->token_stream->lookAhead() != ')')
|
1603
|
+
{
|
1604
|
+
rewind(index);
|
1605
|
+
goto update_pos;
|
1606
|
+
}
|
1607
|
+
|
1608
|
+
advance(); // skip ')'
|
1609
|
+
|
1610
|
+
parseCvQualify(ast->fun_cv);
|
1611
|
+
parseExceptionSpecification(ast->exception_spec);
|
1612
|
+
}
|
1613
|
+
}
|
1614
|
+
|
1615
|
+
update_pos:
|
1616
|
+
if (session->token_stream->cursor() == start)
|
1617
|
+
return false;
|
1618
|
+
|
1619
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
1620
|
+
node = ast;
|
1621
|
+
|
1622
|
+
return true;
|
1623
|
+
}
|
1624
|
+
|
1625
|
+
bool Parser::parseEnumSpecifier(TypeSpecifierAST *&node)
|
1626
|
+
{
|
1627
|
+
std::size_t start = session->token_stream->cursor();
|
1628
|
+
|
1629
|
+
CHECK(Token_enum);
|
1630
|
+
|
1631
|
+
NameAST *name = 0;
|
1632
|
+
parseName(name);
|
1633
|
+
|
1634
|
+
if (session->token_stream->lookAhead() != '{')
|
1635
|
+
{
|
1636
|
+
rewind(start);
|
1637
|
+
return false;
|
1638
|
+
}
|
1639
|
+
advance();
|
1640
|
+
|
1641
|
+
EnumSpecifierAST *ast = CreateNode<EnumSpecifierAST>(session->mempool);
|
1642
|
+
ast->name = name;
|
1643
|
+
|
1644
|
+
EnumeratorAST *enumerator = 0;
|
1645
|
+
if (parseEnumerator(enumerator))
|
1646
|
+
{
|
1647
|
+
|
1648
|
+
ast->enumerators = snoc(ast->enumerators, enumerator, session->mempool);
|
1649
|
+
|
1650
|
+
while (session->token_stream->lookAhead() == ',')
|
1651
|
+
{
|
1652
|
+
advance();
|
1653
|
+
|
1654
|
+
if (!parseEnumerator(enumerator))
|
1655
|
+
{
|
1656
|
+
//reportError(("Enumerator expected"));
|
1657
|
+
break;
|
1658
|
+
}
|
1659
|
+
|
1660
|
+
ast->enumerators = snoc(ast->enumerators, enumerator, session->mempool);
|
1661
|
+
}
|
1662
|
+
}
|
1663
|
+
|
1664
|
+
clearComment();
|
1665
|
+
|
1666
|
+
ADVANCE_NR('}', "}");
|
1667
|
+
|
1668
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
1669
|
+
node = ast;
|
1670
|
+
|
1671
|
+
return true;
|
1672
|
+
}
|
1673
|
+
|
1674
|
+
bool Parser::parseTemplateParameterList(const ListNode<TemplateParameterAST*> *&node)
|
1675
|
+
{
|
1676
|
+
TemplateParameterAST *param = 0;
|
1677
|
+
if (!parseTemplateParameter(param))
|
1678
|
+
return false;
|
1679
|
+
|
1680
|
+
node = snoc(node, param, session->mempool);
|
1681
|
+
|
1682
|
+
while (session->token_stream->lookAhead() == ',')
|
1683
|
+
{
|
1684
|
+
advance();
|
1685
|
+
|
1686
|
+
if (!parseTemplateParameter(param))
|
1687
|
+
{
|
1688
|
+
syntaxError();
|
1689
|
+
break;
|
1690
|
+
}
|
1691
|
+
else
|
1692
|
+
{
|
1693
|
+
node = snoc(node, param, session->mempool);
|
1694
|
+
}
|
1695
|
+
}
|
1696
|
+
|
1697
|
+
return true;
|
1698
|
+
}
|
1699
|
+
|
1700
|
+
bool Parser::parseTemplateParameter(TemplateParameterAST *&node)
|
1701
|
+
{
|
1702
|
+
std::size_t start = session->token_stream->cursor();
|
1703
|
+
TemplateParameterAST *ast = CreateNode<TemplateParameterAST>(session->mempool);
|
1704
|
+
|
1705
|
+
int tk = session->token_stream->lookAhead();
|
1706
|
+
|
1707
|
+
if ((tk == Token_class || tk == Token_typename || tk == Token_template)
|
1708
|
+
&& parseTypeParameter(ast->type_parameter))
|
1709
|
+
{
|
1710
|
+
// nothing to do
|
1711
|
+
}
|
1712
|
+
else if (!parseParameterDeclaration(ast->parameter_declaration))
|
1713
|
+
return false;
|
1714
|
+
|
1715
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
1716
|
+
node = ast;
|
1717
|
+
|
1718
|
+
return true;
|
1719
|
+
}
|
1720
|
+
|
1721
|
+
bool Parser::parseTypeParameter(TypeParameterAST *&node)
|
1722
|
+
{
|
1723
|
+
std::size_t start = session->token_stream->cursor();
|
1724
|
+
|
1725
|
+
TypeParameterAST *ast = CreateNode<TypeParameterAST>(session->mempool);
|
1726
|
+
ast->type = start;
|
1727
|
+
|
1728
|
+
switch(session->token_stream->lookAhead())
|
1729
|
+
{
|
1730
|
+
case Token_class:
|
1731
|
+
case Token_typename:
|
1732
|
+
{
|
1733
|
+
advance(); // skip class
|
1734
|
+
|
1735
|
+
// parse optional name
|
1736
|
+
if(parseName(ast->name, AcceptTemplate))
|
1737
|
+
{
|
1738
|
+
if (session->token_stream->lookAhead() == '=')
|
1739
|
+
{
|
1740
|
+
advance();
|
1741
|
+
|
1742
|
+
if(!parseTypeId(ast->type_id))
|
1743
|
+
{
|
1744
|
+
//syntaxError();
|
1745
|
+
rewind(start);
|
1746
|
+
return false;
|
1747
|
+
}
|
1748
|
+
}
|
1749
|
+
else if (session->token_stream->lookAhead() != ','
|
1750
|
+
&& session->token_stream->lookAhead() != '>')
|
1751
|
+
{
|
1752
|
+
rewind(start);
|
1753
|
+
return false;
|
1754
|
+
}
|
1755
|
+
}
|
1756
|
+
}
|
1757
|
+
break;
|
1758
|
+
|
1759
|
+
case Token_template:
|
1760
|
+
{
|
1761
|
+
advance(); // skip template
|
1762
|
+
ADVANCE('<', "<");
|
1763
|
+
|
1764
|
+
if (!parseTemplateParameterList(ast->template_parameters))
|
1765
|
+
return false;
|
1766
|
+
|
1767
|
+
ADVANCE('>', ">");
|
1768
|
+
|
1769
|
+
// TODO add to AST
|
1770
|
+
if (session->token_stream->lookAhead() == Token_class)
|
1771
|
+
advance();
|
1772
|
+
|
1773
|
+
// parse optional name
|
1774
|
+
if (parseName(ast->name, AcceptTemplate))
|
1775
|
+
{
|
1776
|
+
if (session->token_stream->lookAhead() == '=')
|
1777
|
+
{
|
1778
|
+
advance();
|
1779
|
+
|
1780
|
+
if (!parseTypeId(ast->type_id))
|
1781
|
+
{
|
1782
|
+
syntaxError();
|
1783
|
+
return false;
|
1784
|
+
}
|
1785
|
+
}
|
1786
|
+
}
|
1787
|
+
|
1788
|
+
if (session->token_stream->lookAhead() == '=')
|
1789
|
+
{
|
1790
|
+
advance();
|
1791
|
+
|
1792
|
+
parseName(ast->template_name, AcceptTemplate);
|
1793
|
+
}
|
1794
|
+
}
|
1795
|
+
break;
|
1796
|
+
|
1797
|
+
default:
|
1798
|
+
return false;
|
1799
|
+
|
1800
|
+
} // end switch
|
1801
|
+
|
1802
|
+
|
1803
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
1804
|
+
node = ast;
|
1805
|
+
return true;
|
1806
|
+
}
|
1807
|
+
|
1808
|
+
bool Parser::parseStorageClassSpecifier(const ListNode<std::size_t> *&node)
|
1809
|
+
{
|
1810
|
+
std::size_t start = session->token_stream->cursor();
|
1811
|
+
|
1812
|
+
int tk;
|
1813
|
+
while (0 != (tk = session->token_stream->lookAhead())
|
1814
|
+
&& (tk == Token_friend || tk == Token_auto
|
1815
|
+
|| tk == Token_register || tk == Token_static
|
1816
|
+
|| tk == Token_extern || tk == Token_mutable))
|
1817
|
+
{
|
1818
|
+
node = snoc(node, session->token_stream->cursor(), session->mempool);
|
1819
|
+
advance();
|
1820
|
+
}
|
1821
|
+
|
1822
|
+
return start != session->token_stream->cursor();
|
1823
|
+
}
|
1824
|
+
|
1825
|
+
bool Parser::parseFunctionSpecifier(const ListNode<std::size_t> *&node)
|
1826
|
+
{
|
1827
|
+
std::size_t start = session->token_stream->cursor();
|
1828
|
+
|
1829
|
+
int tk;
|
1830
|
+
while (0 != (tk = session->token_stream->lookAhead())
|
1831
|
+
&& (tk == Token_inline || tk == Token_virtual
|
1832
|
+
|| tk == Token_explicit))
|
1833
|
+
{
|
1834
|
+
node = snoc(node, session->token_stream->cursor(), session->mempool);
|
1835
|
+
advance();
|
1836
|
+
}
|
1837
|
+
|
1838
|
+
return start != session->token_stream->cursor();
|
1839
|
+
}
|
1840
|
+
|
1841
|
+
bool Parser::parseTypeId(TypeIdAST *&node)
|
1842
|
+
{
|
1843
|
+
/// @todo implement the AST for typeId
|
1844
|
+
std::size_t start = session->token_stream->cursor();
|
1845
|
+
|
1846
|
+
TypeSpecifierAST *spec = 0;
|
1847
|
+
if (!parseTypeSpecifier(spec))
|
1848
|
+
{
|
1849
|
+
rewind(start);
|
1850
|
+
return false;
|
1851
|
+
}
|
1852
|
+
|
1853
|
+
DeclaratorAST *decl = 0;
|
1854
|
+
parseAbstractDeclarator(decl);
|
1855
|
+
|
1856
|
+
TypeIdAST *ast = CreateNode<TypeIdAST>(session->mempool);
|
1857
|
+
ast->type_specifier = spec;
|
1858
|
+
ast->declarator = decl;
|
1859
|
+
|
1860
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
1861
|
+
node = ast;
|
1862
|
+
|
1863
|
+
return true;
|
1864
|
+
}
|
1865
|
+
|
1866
|
+
bool Parser::parseInitDeclaratorList(const ListNode<InitDeclaratorAST*> *&node)
|
1867
|
+
{
|
1868
|
+
InitDeclaratorAST *decl = 0;
|
1869
|
+
if (!parseInitDeclarator(decl))
|
1870
|
+
return false;
|
1871
|
+
|
1872
|
+
node = snoc(node, decl, session->mempool);
|
1873
|
+
|
1874
|
+
while (session->token_stream->lookAhead() == ',')
|
1875
|
+
{
|
1876
|
+
advance();
|
1877
|
+
|
1878
|
+
if (!parseInitDeclarator(decl))
|
1879
|
+
{
|
1880
|
+
syntaxError();
|
1881
|
+
break;
|
1882
|
+
}
|
1883
|
+
node = snoc(node, decl, session->mempool);
|
1884
|
+
}
|
1885
|
+
|
1886
|
+
return true;
|
1887
|
+
}
|
1888
|
+
|
1889
|
+
bool Parser::parseParameterDeclarationClause(ParameterDeclarationClauseAST *&node)
|
1890
|
+
{
|
1891
|
+
std::size_t start = session->token_stream->cursor();
|
1892
|
+
|
1893
|
+
ParameterDeclarationClauseAST *ast
|
1894
|
+
= CreateNode<ParameterDeclarationClauseAST>(session->mempool);
|
1895
|
+
|
1896
|
+
if (!parseParameterDeclarationList(ast->parameter_declarations))
|
1897
|
+
{
|
1898
|
+
if (session->token_stream->lookAhead() == ')')
|
1899
|
+
goto good;
|
1900
|
+
|
1901
|
+
if (session->token_stream->lookAhead() == Token_ellipsis
|
1902
|
+
&& session->token_stream->lookAhead(1) == ')')
|
1903
|
+
{
|
1904
|
+
ast->ellipsis = session->token_stream->cursor();
|
1905
|
+
goto good;
|
1906
|
+
}
|
1907
|
+
|
1908
|
+
return false;
|
1909
|
+
}
|
1910
|
+
|
1911
|
+
good:
|
1912
|
+
|
1913
|
+
if (session->token_stream->lookAhead() == Token_ellipsis)
|
1914
|
+
{
|
1915
|
+
ast->ellipsis = session->token_stream->cursor();
|
1916
|
+
advance();
|
1917
|
+
}
|
1918
|
+
|
1919
|
+
/// @todo add ellipsis
|
1920
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
1921
|
+
node = ast;
|
1922
|
+
|
1923
|
+
return true;
|
1924
|
+
}
|
1925
|
+
|
1926
|
+
bool Parser::parseParameterDeclarationList(const ListNode<ParameterDeclarationAST*> *&node)
|
1927
|
+
{
|
1928
|
+
std::size_t start = session->token_stream->cursor();
|
1929
|
+
|
1930
|
+
ParameterDeclarationAST *param = 0;
|
1931
|
+
if (!parseParameterDeclaration(param))
|
1932
|
+
{
|
1933
|
+
rewind(start);
|
1934
|
+
return false;
|
1935
|
+
}
|
1936
|
+
|
1937
|
+
node = snoc(node, param, session->mempool);
|
1938
|
+
|
1939
|
+
while (session->token_stream->lookAhead() == ',')
|
1940
|
+
{
|
1941
|
+
advance();
|
1942
|
+
|
1943
|
+
if (session->token_stream->lookAhead() == Token_ellipsis)
|
1944
|
+
break;
|
1945
|
+
|
1946
|
+
if (!parseParameterDeclaration(param))
|
1947
|
+
{
|
1948
|
+
rewind(start);
|
1949
|
+
return false;
|
1950
|
+
}
|
1951
|
+
node = snoc(node, param, session->mempool);
|
1952
|
+
}
|
1953
|
+
|
1954
|
+
return true;
|
1955
|
+
}
|
1956
|
+
|
1957
|
+
bool Parser::parseParameterDeclaration(ParameterDeclarationAST *&node)
|
1958
|
+
{
|
1959
|
+
std::size_t start = session->token_stream->cursor();
|
1960
|
+
|
1961
|
+
const ListNode<std::size_t> *storage = 0;
|
1962
|
+
parseStorageClassSpecifier(storage);
|
1963
|
+
|
1964
|
+
// parse decl spec
|
1965
|
+
TypeSpecifierAST *spec = 0;
|
1966
|
+
if (!parseTypeSpecifier(spec))
|
1967
|
+
{
|
1968
|
+
rewind(start);
|
1969
|
+
return false;
|
1970
|
+
}
|
1971
|
+
|
1972
|
+
int index = session->token_stream->cursor();
|
1973
|
+
|
1974
|
+
DeclaratorAST *decl = 0;
|
1975
|
+
if (!parseDeclarator(decl))
|
1976
|
+
{
|
1977
|
+
rewind(index);
|
1978
|
+
|
1979
|
+
// try with abstract declarator
|
1980
|
+
parseAbstractDeclarator(decl);
|
1981
|
+
}
|
1982
|
+
|
1983
|
+
ExpressionAST *expr = 0;
|
1984
|
+
if (session->token_stream->lookAhead() == '=')
|
1985
|
+
{
|
1986
|
+
advance();
|
1987
|
+
if (!parseLogicalOrExpression(expr,true))
|
1988
|
+
{
|
1989
|
+
//reportError(("Expression expected"));
|
1990
|
+
}
|
1991
|
+
}
|
1992
|
+
|
1993
|
+
if( session->token_stream->lookAhead() != ',' && session->token_stream->lookAhead() != ')' && session->token_stream->lookAhead() != '>' )
|
1994
|
+
{
|
1995
|
+
//Not a valid parameter declaration
|
1996
|
+
rewind(start);
|
1997
|
+
return false;
|
1998
|
+
}
|
1999
|
+
|
2000
|
+
ParameterDeclarationAST *ast = CreateNode<ParameterDeclarationAST>(session->mempool);
|
2001
|
+
ast->type_specifier = spec;
|
2002
|
+
ast->declarator = decl;
|
2003
|
+
ast->expression = expr;
|
2004
|
+
|
2005
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
2006
|
+
node = ast;
|
2007
|
+
|
2008
|
+
return true;
|
2009
|
+
}
|
2010
|
+
|
2011
|
+
bool Parser::parseClassSpecifier(TypeSpecifierAST *&node)
|
2012
|
+
{
|
2013
|
+
std::size_t start = session->token_stream->cursor();
|
2014
|
+
|
2015
|
+
int kind = session->token_stream->lookAhead();
|
2016
|
+
if (kind != Token_class && kind != Token_struct && kind != Token_union)
|
2017
|
+
return false;
|
2018
|
+
|
2019
|
+
std::size_t class_key = session->token_stream->cursor();
|
2020
|
+
advance();
|
2021
|
+
|
2022
|
+
WinDeclSpecAST *winDeclSpec = 0;
|
2023
|
+
parseWinDeclSpec(winDeclSpec);
|
2024
|
+
|
2025
|
+
while (session->token_stream->lookAhead() == Token_identifier
|
2026
|
+
&& session->token_stream->lookAhead(1) == Token_identifier)
|
2027
|
+
{
|
2028
|
+
advance();
|
2029
|
+
}
|
2030
|
+
|
2031
|
+
NameAST *name = 0;
|
2032
|
+
parseName(name, AcceptTemplate);
|
2033
|
+
|
2034
|
+
BaseClauseAST *bases = 0;
|
2035
|
+
if (session->token_stream->lookAhead() == ':')
|
2036
|
+
{
|
2037
|
+
if (!parseBaseClause(bases))
|
2038
|
+
{
|
2039
|
+
skipUntil('{');
|
2040
|
+
}
|
2041
|
+
}
|
2042
|
+
|
2043
|
+
if (session->token_stream->lookAhead() != '{')
|
2044
|
+
{
|
2045
|
+
rewind(start);
|
2046
|
+
return false;
|
2047
|
+
}
|
2048
|
+
|
2049
|
+
ADVANCE('{', "{");
|
2050
|
+
|
2051
|
+
ClassSpecifierAST *ast = CreateNode<ClassSpecifierAST>(session->mempool);
|
2052
|
+
ast->win_decl_specifiers = winDeclSpec;
|
2053
|
+
ast->class_key = class_key;
|
2054
|
+
ast->name = name;
|
2055
|
+
ast->base_clause = bases;
|
2056
|
+
|
2057
|
+
while (session->token_stream->lookAhead())
|
2058
|
+
{
|
2059
|
+
if (session->token_stream->lookAhead() == '}')
|
2060
|
+
break;
|
2061
|
+
|
2062
|
+
std::size_t startDecl = session->token_stream->cursor();
|
2063
|
+
|
2064
|
+
DeclarationAST *memSpec = 0;
|
2065
|
+
if (!parseMemberSpecification(memSpec))
|
2066
|
+
{
|
2067
|
+
if (startDecl == session->token_stream->cursor())
|
2068
|
+
advance(); // skip at least one token
|
2069
|
+
skipUntilDeclaration();
|
2070
|
+
}
|
2071
|
+
else
|
2072
|
+
ast->member_specs = snoc(ast->member_specs, memSpec, session->mempool);
|
2073
|
+
}
|
2074
|
+
|
2075
|
+
clearComment();
|
2076
|
+
|
2077
|
+
ADVANCE_NR('}', "}");
|
2078
|
+
|
2079
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
2080
|
+
node = ast;
|
2081
|
+
|
2082
|
+
return true;
|
2083
|
+
}
|
2084
|
+
|
2085
|
+
bool Parser::parseAccessSpecifier(DeclarationAST *&node)
|
2086
|
+
{
|
2087
|
+
std::size_t start = session->token_stream->cursor();
|
2088
|
+
|
2089
|
+
const ListNode<std::size_t> *specs = 0;
|
2090
|
+
|
2091
|
+
bool done = false;
|
2092
|
+
while (!done)
|
2093
|
+
{
|
2094
|
+
switch(session->token_stream->lookAhead())
|
2095
|
+
{
|
2096
|
+
case Token_signals:
|
2097
|
+
case Token_slots:
|
2098
|
+
case Token_k_dcop:
|
2099
|
+
case Token_k_dcop_signals:
|
2100
|
+
case Token_public:
|
2101
|
+
case Token_protected:
|
2102
|
+
case Token_private:
|
2103
|
+
specs = snoc(specs, session->token_stream->cursor(), session->mempool);
|
2104
|
+
advance();
|
2105
|
+
break;
|
2106
|
+
|
2107
|
+
default:
|
2108
|
+
done = true;
|
2109
|
+
break;
|
2110
|
+
}
|
2111
|
+
}
|
2112
|
+
|
2113
|
+
if (!specs)
|
2114
|
+
return false;
|
2115
|
+
|
2116
|
+
ADVANCE(':', ":");
|
2117
|
+
|
2118
|
+
AccessSpecifierAST *ast = CreateNode<AccessSpecifierAST>(session->mempool);
|
2119
|
+
ast->specs = specs;
|
2120
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
2121
|
+
node = ast;
|
2122
|
+
|
2123
|
+
return true;
|
2124
|
+
}
|
2125
|
+
|
2126
|
+
bool Parser::parseMemberSpecification(DeclarationAST *&node)
|
2127
|
+
{
|
2128
|
+
std::size_t start = session->token_stream->cursor();
|
2129
|
+
|
2130
|
+
if (session->token_stream->lookAhead() == ';')
|
2131
|
+
{
|
2132
|
+
advance();
|
2133
|
+
return true;
|
2134
|
+
}
|
2135
|
+
else if (session->token_stream->lookAhead() == Token_Q_OBJECT || session->token_stream->lookAhead() == Token_K_DCOP)
|
2136
|
+
{
|
2137
|
+
advance();
|
2138
|
+
return true;
|
2139
|
+
}
|
2140
|
+
else if (parseTypedef(node))
|
2141
|
+
{
|
2142
|
+
return true;
|
2143
|
+
}
|
2144
|
+
else if (parseUsing(node))
|
2145
|
+
{
|
2146
|
+
return true;
|
2147
|
+
}
|
2148
|
+
else if (parseTemplateDeclaration(node))
|
2149
|
+
{
|
2150
|
+
return true;
|
2151
|
+
}
|
2152
|
+
else if (parseAccessSpecifier(node))
|
2153
|
+
{
|
2154
|
+
return true;
|
2155
|
+
}
|
2156
|
+
|
2157
|
+
rewind(start);
|
2158
|
+
|
2159
|
+
const ListNode<std::size_t> *cv = 0;
|
2160
|
+
parseCvQualify(cv);
|
2161
|
+
|
2162
|
+
const ListNode<std::size_t> *storageSpec = 0;
|
2163
|
+
parseStorageClassSpecifier(storageSpec);
|
2164
|
+
|
2165
|
+
parseCvQualify(cv);
|
2166
|
+
|
2167
|
+
Comment mcomment = comment();
|
2168
|
+
clearComment();
|
2169
|
+
|
2170
|
+
TypeSpecifierAST *spec = 0;
|
2171
|
+
if (parseEnumSpecifier(spec) || parseClassSpecifier(spec))
|
2172
|
+
{
|
2173
|
+
parseCvQualify(cv);
|
2174
|
+
spec->cv = cv;
|
2175
|
+
|
2176
|
+
const ListNode<InitDeclaratorAST*> *declarators = 0;
|
2177
|
+
parseInitDeclaratorList(declarators);
|
2178
|
+
ADVANCE(';', ";");
|
2179
|
+
|
2180
|
+
SimpleDeclarationAST *ast = CreateNode<SimpleDeclarationAST>(session->mempool);
|
2181
|
+
ast->storage_specifiers = storageSpec;
|
2182
|
+
ast->type_specifier = spec;
|
2183
|
+
ast->init_declarators = declarators;
|
2184
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
2185
|
+
|
2186
|
+
if( mcomment )
|
2187
|
+
addComment(ast,mcomment);
|
2188
|
+
|
2189
|
+
preparseLineComments(ast->end_token-1);
|
2190
|
+
|
2191
|
+
if( m_commentStore.hasComment() )
|
2192
|
+
addComment( ast, m_commentStore.takeCommentInRange( lineFromTokenNumber( --ast->end_token ) ) );
|
2193
|
+
|
2194
|
+
node = ast;
|
2195
|
+
|
2196
|
+
|
2197
|
+
return true;
|
2198
|
+
} else {
|
2199
|
+
rewind(start);
|
2200
|
+
|
2201
|
+
if( parseDeclarationInternal(node) ) {
|
2202
|
+
//Add the comments to the declaration
|
2203
|
+
if( mcomment )
|
2204
|
+
addComment(node, mcomment);
|
2205
|
+
|
2206
|
+
preparseLineComments(node->end_token-1);
|
2207
|
+
|
2208
|
+
if( m_commentStore.hasComment() )
|
2209
|
+
addComment( node, m_commentStore.takeCommentInRange( lineFromTokenNumber( --node->end_token ) ) );
|
2210
|
+
|
2211
|
+
return true;
|
2212
|
+
}
|
2213
|
+
}
|
2214
|
+
return false;
|
2215
|
+
}
|
2216
|
+
|
2217
|
+
bool Parser::parseCtorInitializer(CtorInitializerAST *&node)
|
2218
|
+
{
|
2219
|
+
std::size_t start = session->token_stream->cursor();
|
2220
|
+
|
2221
|
+
CHECK(':');
|
2222
|
+
|
2223
|
+
CtorInitializerAST *ast = CreateNode<CtorInitializerAST>(session->mempool);
|
2224
|
+
ast->colon = start;
|
2225
|
+
|
2226
|
+
if (!parseMemInitializerList(ast->member_initializers))
|
2227
|
+
{
|
2228
|
+
reportError(("Member initializers expected"));
|
2229
|
+
}
|
2230
|
+
|
2231
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
2232
|
+
node = ast;
|
2233
|
+
|
2234
|
+
return true;
|
2235
|
+
}
|
2236
|
+
|
2237
|
+
bool Parser::parseElaboratedTypeSpecifier(TypeSpecifierAST *&node)
|
2238
|
+
{
|
2239
|
+
std::size_t start = session->token_stream->cursor();
|
2240
|
+
|
2241
|
+
int tk = session->token_stream->lookAhead();
|
2242
|
+
if (tk == Token_class ||
|
2243
|
+
tk == Token_struct ||
|
2244
|
+
tk == Token_union ||
|
2245
|
+
tk == Token_enum ||
|
2246
|
+
tk == Token_typename)
|
2247
|
+
{
|
2248
|
+
std::size_t type = session->token_stream->cursor();
|
2249
|
+
advance();
|
2250
|
+
|
2251
|
+
NameAST *name = 0;
|
2252
|
+
if (parseName(name, AcceptTemplate))
|
2253
|
+
{
|
2254
|
+
ElaboratedTypeSpecifierAST *ast
|
2255
|
+
= CreateNode<ElaboratedTypeSpecifierAST>(session->mempool);
|
2256
|
+
|
2257
|
+
ast->type = type;
|
2258
|
+
ast->name = name;
|
2259
|
+
|
2260
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
2261
|
+
node = ast;
|
2262
|
+
|
2263
|
+
return true;
|
2264
|
+
}
|
2265
|
+
}
|
2266
|
+
|
2267
|
+
rewind(start);
|
2268
|
+
return false;
|
2269
|
+
}
|
2270
|
+
|
2271
|
+
bool Parser::parseExceptionSpecification(ExceptionSpecificationAST *&node)
|
2272
|
+
{
|
2273
|
+
std::size_t start = session->token_stream->cursor();
|
2274
|
+
|
2275
|
+
CHECK(Token_throw);
|
2276
|
+
ADVANCE('(', "(");
|
2277
|
+
|
2278
|
+
ExceptionSpecificationAST *ast
|
2279
|
+
= CreateNode<ExceptionSpecificationAST>(session->mempool);
|
2280
|
+
|
2281
|
+
if (session->token_stream->lookAhead() == Token_ellipsis)
|
2282
|
+
{
|
2283
|
+
ast->ellipsis = session->token_stream->cursor();
|
2284
|
+
advance();
|
2285
|
+
}
|
2286
|
+
else
|
2287
|
+
{
|
2288
|
+
parseTypeIdList(ast->type_ids);
|
2289
|
+
}
|
2290
|
+
|
2291
|
+
ADVANCE(')', ")");
|
2292
|
+
|
2293
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
2294
|
+
node = ast;
|
2295
|
+
|
2296
|
+
return true;
|
2297
|
+
}
|
2298
|
+
|
2299
|
+
bool Parser::parseEnumerator(EnumeratorAST *&node)
|
2300
|
+
{
|
2301
|
+
std::size_t start = session->token_stream->cursor();
|
2302
|
+
|
2303
|
+
CHECK(Token_identifier);
|
2304
|
+
std::size_t id = start;
|
2305
|
+
|
2306
|
+
EnumeratorAST *ast = CreateNode<EnumeratorAST>(session->mempool);
|
2307
|
+
ast->id = id;
|
2308
|
+
|
2309
|
+
|
2310
|
+
if (session->token_stream->lookAhead() == '=')
|
2311
|
+
{
|
2312
|
+
advance();
|
2313
|
+
if (!parseConstantExpression(ast->expression))
|
2314
|
+
{
|
2315
|
+
reportError(("Constant expression expected"));
|
2316
|
+
}
|
2317
|
+
}
|
2318
|
+
|
2319
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
2320
|
+
node = ast;
|
2321
|
+
|
2322
|
+
moveComments(node);
|
2323
|
+
|
2324
|
+
preparseLineComments( ast->end_token-1 );
|
2325
|
+
|
2326
|
+
if( m_commentStore.hasComment() )
|
2327
|
+
addComment( node, m_commentStore.takeCommentInRange( lineFromTokenNumber(--ast->end_token) ) );
|
2328
|
+
|
2329
|
+
return true;
|
2330
|
+
}
|
2331
|
+
|
2332
|
+
bool Parser::parseInitDeclarator(InitDeclaratorAST *&node)
|
2333
|
+
{
|
2334
|
+
std::size_t start = session->token_stream->cursor();
|
2335
|
+
|
2336
|
+
DeclaratorAST *decl = 0;
|
2337
|
+
if (!parseDeclarator(decl))
|
2338
|
+
{
|
2339
|
+
return false;
|
2340
|
+
}
|
2341
|
+
|
2342
|
+
if (session->token_stream->lookAhead(0) == Token_asm)
|
2343
|
+
{
|
2344
|
+
advance();
|
2345
|
+
skip('(', ')');
|
2346
|
+
advance();
|
2347
|
+
}
|
2348
|
+
|
2349
|
+
InitializerAST *init = 0;
|
2350
|
+
parseInitializer(init);
|
2351
|
+
|
2352
|
+
InitDeclaratorAST *ast = CreateNode<InitDeclaratorAST>(session->mempool);
|
2353
|
+
ast->declarator = decl;
|
2354
|
+
ast->initializer = init;
|
2355
|
+
|
2356
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
2357
|
+
node = ast;
|
2358
|
+
|
2359
|
+
return true;
|
2360
|
+
}
|
2361
|
+
|
2362
|
+
bool Parser::parseBaseClause(BaseClauseAST *&node)
|
2363
|
+
{
|
2364
|
+
std::size_t start = session->token_stream->cursor();
|
2365
|
+
|
2366
|
+
CHECK(':');
|
2367
|
+
|
2368
|
+
BaseSpecifierAST *baseSpec = 0;
|
2369
|
+
if (!parseBaseSpecifier(baseSpec))
|
2370
|
+
return false;
|
2371
|
+
|
2372
|
+
BaseClauseAST *ast = CreateNode<BaseClauseAST>(session->mempool);
|
2373
|
+
ast->base_specifiers = snoc(ast->base_specifiers, baseSpec, session->mempool);
|
2374
|
+
|
2375
|
+
while (session->token_stream->lookAhead() == ',')
|
2376
|
+
{
|
2377
|
+
advance();
|
2378
|
+
|
2379
|
+
if (!parseBaseSpecifier(baseSpec))
|
2380
|
+
{
|
2381
|
+
reportError(("Base class specifier expected"));
|
2382
|
+
break;
|
2383
|
+
}
|
2384
|
+
ast->base_specifiers = snoc(ast->base_specifiers, baseSpec, session->mempool);
|
2385
|
+
}
|
2386
|
+
|
2387
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
2388
|
+
node = ast;
|
2389
|
+
|
2390
|
+
return true;
|
2391
|
+
}
|
2392
|
+
|
2393
|
+
bool Parser::parseInitializer(InitializerAST *&node)
|
2394
|
+
{
|
2395
|
+
std::size_t start = session->token_stream->cursor();
|
2396
|
+
|
2397
|
+
int tk = session->token_stream->lookAhead();
|
2398
|
+
if (tk != '=' && tk != '(')
|
2399
|
+
return false;
|
2400
|
+
|
2401
|
+
InitializerAST *ast = CreateNode<InitializerAST>(session->mempool);
|
2402
|
+
|
2403
|
+
if (tk == '=')
|
2404
|
+
{
|
2405
|
+
advance();
|
2406
|
+
|
2407
|
+
if (!parseInitializerClause(ast->initializer_clause))
|
2408
|
+
{
|
2409
|
+
reportError(("Initializer clause expected"));
|
2410
|
+
}
|
2411
|
+
}
|
2412
|
+
else if (tk == '(')
|
2413
|
+
{
|
2414
|
+
advance();
|
2415
|
+
parseCommaExpression(ast->expression);
|
2416
|
+
CHECK(')');
|
2417
|
+
}
|
2418
|
+
|
2419
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
2420
|
+
node = ast;
|
2421
|
+
|
2422
|
+
return true;
|
2423
|
+
}
|
2424
|
+
|
2425
|
+
bool Parser::parseMemInitializerList(const ListNode<MemInitializerAST*> *&node)
|
2426
|
+
{
|
2427
|
+
MemInitializerAST *init = 0;
|
2428
|
+
|
2429
|
+
if (!parseMemInitializer(init))
|
2430
|
+
return false;
|
2431
|
+
|
2432
|
+
node = snoc(node, init, session->mempool);
|
2433
|
+
|
2434
|
+
while (session->token_stream->lookAhead() == ',')
|
2435
|
+
{
|
2436
|
+
advance();
|
2437
|
+
|
2438
|
+
if (!parseMemInitializer(init))
|
2439
|
+
break;
|
2440
|
+
|
2441
|
+
node = snoc(node, init, session->mempool);
|
2442
|
+
}
|
2443
|
+
|
2444
|
+
return true;
|
2445
|
+
}
|
2446
|
+
|
2447
|
+
bool Parser::parseMemInitializer(MemInitializerAST *&node)
|
2448
|
+
{
|
2449
|
+
std::size_t start = session->token_stream->cursor();
|
2450
|
+
|
2451
|
+
NameAST *initId = 0;
|
2452
|
+
if (!parseName(initId, AcceptTemplate))
|
2453
|
+
{
|
2454
|
+
reportError(("Identifier expected"));
|
2455
|
+
return false;
|
2456
|
+
}
|
2457
|
+
|
2458
|
+
ADVANCE('(', "(");
|
2459
|
+
ExpressionAST *expr = 0;
|
2460
|
+
parseCommaExpression(expr);
|
2461
|
+
ADVANCE(')', ")");
|
2462
|
+
|
2463
|
+
MemInitializerAST *ast = CreateNode<MemInitializerAST>(session->mempool);
|
2464
|
+
ast->initializer_id = initId;
|
2465
|
+
ast->expression = expr;
|
2466
|
+
|
2467
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
2468
|
+
node = ast;
|
2469
|
+
|
2470
|
+
return true;
|
2471
|
+
}
|
2472
|
+
|
2473
|
+
bool Parser::parseTypeIdList(const ListNode<TypeIdAST*> *&node)
|
2474
|
+
{
|
2475
|
+
TypeIdAST *typeId = 0;
|
2476
|
+
if (!parseTypeId(typeId))
|
2477
|
+
return false;
|
2478
|
+
|
2479
|
+
node = snoc(node, typeId, session->mempool);
|
2480
|
+
|
2481
|
+
while (session->token_stream->lookAhead() == ',')
|
2482
|
+
{
|
2483
|
+
advance();
|
2484
|
+
if (parseTypeId(typeId))
|
2485
|
+
{
|
2486
|
+
node = snoc(node, typeId, session->mempool);
|
2487
|
+
}
|
2488
|
+
else
|
2489
|
+
{
|
2490
|
+
reportError(("Type id expected"));
|
2491
|
+
break;
|
2492
|
+
}
|
2493
|
+
}
|
2494
|
+
|
2495
|
+
return true;
|
2496
|
+
}
|
2497
|
+
|
2498
|
+
bool Parser::parseBaseSpecifier(BaseSpecifierAST *&node)
|
2499
|
+
{
|
2500
|
+
std::size_t start = session->token_stream->cursor();
|
2501
|
+
|
2502
|
+
BaseSpecifierAST *ast = CreateNode<BaseSpecifierAST>(session->mempool);
|
2503
|
+
|
2504
|
+
if (session->token_stream->lookAhead() == Token_virtual)
|
2505
|
+
{
|
2506
|
+
ast->virt = session->token_stream->cursor();
|
2507
|
+
advance();
|
2508
|
+
|
2509
|
+
int tk = session->token_stream->lookAhead();
|
2510
|
+
if (tk == Token_public || tk == Token_protected
|
2511
|
+
|| tk == Token_private)
|
2512
|
+
{
|
2513
|
+
ast->access_specifier = session->token_stream->cursor();
|
2514
|
+
advance();
|
2515
|
+
}
|
2516
|
+
}
|
2517
|
+
else
|
2518
|
+
{
|
2519
|
+
int tk = session->token_stream->lookAhead();
|
2520
|
+
if (tk == Token_public || tk == Token_protected
|
2521
|
+
|| tk == Token_private)
|
2522
|
+
{
|
2523
|
+
ast->access_specifier = session->token_stream->cursor();
|
2524
|
+
advance();
|
2525
|
+
}
|
2526
|
+
|
2527
|
+
if (session->token_stream->lookAhead() == Token_virtual)
|
2528
|
+
{
|
2529
|
+
ast->virt = session->token_stream->cursor();
|
2530
|
+
advance();
|
2531
|
+
}
|
2532
|
+
}
|
2533
|
+
|
2534
|
+
if (!parseName(ast->name, AcceptTemplate))
|
2535
|
+
reportError(("Class name expected"));
|
2536
|
+
|
2537
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
2538
|
+
node = ast;
|
2539
|
+
|
2540
|
+
return true;
|
2541
|
+
}
|
2542
|
+
|
2543
|
+
bool Parser::parseInitializerList(const ListNode<InitializerClauseAST*> *&node)
|
2544
|
+
{
|
2545
|
+
const ListNode<InitializerClauseAST*> *list = 0;
|
2546
|
+
do
|
2547
|
+
{
|
2548
|
+
if (list)
|
2549
|
+
advance(); // skip ',' separator between clauses
|
2550
|
+
|
2551
|
+
InitializerClauseAST *init_clause = 0;
|
2552
|
+
if (!parseInitializerClause(init_clause))
|
2553
|
+
{
|
2554
|
+
return false;
|
2555
|
+
}
|
2556
|
+
list = snoc(list,init_clause,session->mempool);
|
2557
|
+
} while (session->token_stream->lookAhead() == ',');
|
2558
|
+
|
2559
|
+
node = list;
|
2560
|
+
|
2561
|
+
return true;
|
2562
|
+
}
|
2563
|
+
|
2564
|
+
bool Parser::parseInitializerClause(InitializerClauseAST *&node)
|
2565
|
+
{
|
2566
|
+
std::size_t start = session->token_stream->cursor();
|
2567
|
+
|
2568
|
+
InitializerClauseAST *ast = CreateNode<InitializerClauseAST>(session->mempool);
|
2569
|
+
|
2570
|
+
if (session->token_stream->lookAhead() == '{')
|
2571
|
+
{
|
2572
|
+
advance();
|
2573
|
+
const ListNode<InitializerClauseAST*> *initializer_list = 0;
|
2574
|
+
if (session->token_stream->lookAhead() != '}' &&
|
2575
|
+
!parseInitializerList(initializer_list))
|
2576
|
+
{
|
2577
|
+
return false;
|
2578
|
+
}
|
2579
|
+
ADVANCE('}',"}");
|
2580
|
+
|
2581
|
+
ast->initializer_list = initializer_list;
|
2582
|
+
}
|
2583
|
+
else
|
2584
|
+
{
|
2585
|
+
if (!parseAssignmentExpression(ast->expression))
|
2586
|
+
{
|
2587
|
+
reportError("Expression expected");
|
2588
|
+
return false;
|
2589
|
+
}
|
2590
|
+
}
|
2591
|
+
|
2592
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
2593
|
+
node = ast;
|
2594
|
+
|
2595
|
+
return true;
|
2596
|
+
}
|
2597
|
+
|
2598
|
+
bool Parser::parsePtrToMember(PtrToMemberAST *&node)
|
2599
|
+
{
|
2600
|
+
#if defined(__GNUC__)
|
2601
|
+
#warning "implemente me (AST)"
|
2602
|
+
#endif
|
2603
|
+
|
2604
|
+
std::size_t start = session->token_stream->cursor();
|
2605
|
+
|
2606
|
+
std::size_t global_scope = 0;
|
2607
|
+
if (session->token_stream->lookAhead() == Token_scope)
|
2608
|
+
{
|
2609
|
+
global_scope = session->token_stream->cursor();
|
2610
|
+
advance();
|
2611
|
+
}
|
2612
|
+
|
2613
|
+
UnqualifiedNameAST *name = 0;
|
2614
|
+
while (session->token_stream->lookAhead() == Token_identifier)
|
2615
|
+
{
|
2616
|
+
if (!parseUnqualifiedName(name))
|
2617
|
+
break;
|
2618
|
+
|
2619
|
+
if (session->token_stream->lookAhead() == Token_scope
|
2620
|
+
&& session->token_stream->lookAhead(1) == '*')
|
2621
|
+
{
|
2622
|
+
advance();
|
2623
|
+
advance();
|
2624
|
+
|
2625
|
+
PtrToMemberAST *ast = CreateNode<PtrToMemberAST>(session->mempool);
|
2626
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
2627
|
+
node = ast;
|
2628
|
+
|
2629
|
+
return true;
|
2630
|
+
}
|
2631
|
+
|
2632
|
+
if (session->token_stream->lookAhead() == Token_scope)
|
2633
|
+
advance();
|
2634
|
+
}
|
2635
|
+
|
2636
|
+
rewind(start);
|
2637
|
+
return false;
|
2638
|
+
}
|
2639
|
+
|
2640
|
+
bool Parser::parseUnqualifiedName(UnqualifiedNameAST *&node,
|
2641
|
+
bool parseTemplateId)
|
2642
|
+
{
|
2643
|
+
std::size_t start = session->token_stream->cursor();
|
2644
|
+
|
2645
|
+
std::size_t tilde = 0;
|
2646
|
+
std::size_t id = 0;
|
2647
|
+
OperatorFunctionIdAST *operator_id = 0;
|
2648
|
+
|
2649
|
+
if (session->token_stream->lookAhead() == Token_identifier)
|
2650
|
+
{
|
2651
|
+
id = session->token_stream->cursor();
|
2652
|
+
advance();
|
2653
|
+
}
|
2654
|
+
else if (session->token_stream->lookAhead() == '~'
|
2655
|
+
&& session->token_stream->lookAhead(1) == Token_identifier)
|
2656
|
+
{
|
2657
|
+
tilde = session->token_stream->cursor();
|
2658
|
+
advance(); // skip ~
|
2659
|
+
|
2660
|
+
id = session->token_stream->cursor();
|
2661
|
+
advance(); // skip classname
|
2662
|
+
}
|
2663
|
+
else if (session->token_stream->lookAhead() == Token_operator)
|
2664
|
+
{
|
2665
|
+
if (!parseOperatorFunctionId(operator_id))
|
2666
|
+
return false;
|
2667
|
+
}
|
2668
|
+
else
|
2669
|
+
{
|
2670
|
+
return false;
|
2671
|
+
}
|
2672
|
+
|
2673
|
+
UnqualifiedNameAST *ast = CreateNode<UnqualifiedNameAST>(session->mempool);
|
2674
|
+
ast->tilde = tilde;
|
2675
|
+
ast->id = id;
|
2676
|
+
ast->operator_id = operator_id;
|
2677
|
+
|
2678
|
+
if (parseTemplateId && !tilde)
|
2679
|
+
{
|
2680
|
+
std::size_t index = session->token_stream->cursor();
|
2681
|
+
|
2682
|
+
if (session->token_stream->lookAhead() == '<' && !(tokenMarkers(index) & IsNoTemplateArgumentList))
|
2683
|
+
{
|
2684
|
+
advance();
|
2685
|
+
|
2686
|
+
// optional template arguments
|
2687
|
+
parseTemplateArgumentList(ast->template_arguments);
|
2688
|
+
|
2689
|
+
if (session->token_stream->lookAhead() == '>')
|
2690
|
+
{
|
2691
|
+
advance();
|
2692
|
+
}
|
2693
|
+
else
|
2694
|
+
{
|
2695
|
+
addTokenMarkers(index, IsNoTemplateArgumentList);
|
2696
|
+
ast->template_arguments = 0;
|
2697
|
+
rewind(index);
|
2698
|
+
}
|
2699
|
+
}
|
2700
|
+
}
|
2701
|
+
|
2702
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
2703
|
+
node = ast;
|
2704
|
+
|
2705
|
+
return true;
|
2706
|
+
}
|
2707
|
+
|
2708
|
+
bool Parser::parseStringLiteral(StringLiteralAST *&node)
|
2709
|
+
{
|
2710
|
+
std::size_t start = session->token_stream->cursor();
|
2711
|
+
|
2712
|
+
if (session->token_stream->lookAhead() != Token_string_literal)
|
2713
|
+
return false;
|
2714
|
+
|
2715
|
+
StringLiteralAST *ast = CreateNode<StringLiteralAST>(session->mempool);
|
2716
|
+
|
2717
|
+
while (session->token_stream->lookAhead() == Token_string_literal)
|
2718
|
+
{
|
2719
|
+
ast->literals = snoc(ast->literals, session->token_stream->cursor(), session->mempool);
|
2720
|
+
advance();
|
2721
|
+
}
|
2722
|
+
|
2723
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
2724
|
+
node = ast;
|
2725
|
+
|
2726
|
+
return true;
|
2727
|
+
}
|
2728
|
+
|
2729
|
+
bool Parser::parseExpressionStatement(StatementAST *&node)
|
2730
|
+
{
|
2731
|
+
std::size_t start = session->token_stream->cursor();
|
2732
|
+
|
2733
|
+
ExpressionAST *expr = 0;
|
2734
|
+
parseCommaExpression(expr);
|
2735
|
+
|
2736
|
+
ADVANCE(';', ";");
|
2737
|
+
|
2738
|
+
ExpressionStatementAST *ast = CreateNode<ExpressionStatementAST>(session->mempool);
|
2739
|
+
ast->expression = expr;
|
2740
|
+
|
2741
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
2742
|
+
node = ast;
|
2743
|
+
return true;
|
2744
|
+
}
|
2745
|
+
|
2746
|
+
bool Parser::parseJumpStatement(StatementAST *&node)
|
2747
|
+
{
|
2748
|
+
std::size_t op = session->token_stream->cursor();
|
2749
|
+
std::size_t kind = session->token_stream->lookAhead();
|
2750
|
+
std::size_t identifier = 0;
|
2751
|
+
|
2752
|
+
if (kind != Token_break && kind != Token_continue && kind != Token_goto)
|
2753
|
+
return false;
|
2754
|
+
|
2755
|
+
advance();
|
2756
|
+
if (kind == Token_goto)
|
2757
|
+
{
|
2758
|
+
ADVANCE(Token_identifier,"label");
|
2759
|
+
identifier = op+1;
|
2760
|
+
}
|
2761
|
+
ADVANCE(';',";");
|
2762
|
+
|
2763
|
+
JumpStatementAST* ast = CreateNode<JumpStatementAST>(session->mempool);
|
2764
|
+
ast->op = op;
|
2765
|
+
ast->identifier = identifier;
|
2766
|
+
|
2767
|
+
UPDATE_POS(ast,ast->op,_M_last_valid_token+1);
|
2768
|
+
node = ast;
|
2769
|
+
return true;
|
2770
|
+
}
|
2771
|
+
|
2772
|
+
bool Parser::parseStatement(StatementAST *&node)
|
2773
|
+
{
|
2774
|
+
std::size_t start = session->token_stream->cursor();
|
2775
|
+
|
2776
|
+
switch(session->token_stream->lookAhead())
|
2777
|
+
{
|
2778
|
+
case Token_while:
|
2779
|
+
return parseWhileStatement(node);
|
2780
|
+
|
2781
|
+
case Token_do:
|
2782
|
+
return parseDoStatement(node);
|
2783
|
+
|
2784
|
+
case Token_for:
|
2785
|
+
return parseForStatement(node);
|
2786
|
+
|
2787
|
+
case Token_if:
|
2788
|
+
return parseIfStatement(node);
|
2789
|
+
|
2790
|
+
case Token_switch:
|
2791
|
+
return parseSwitchStatement(node);
|
2792
|
+
|
2793
|
+
case Token_try:
|
2794
|
+
return parseTryBlockStatement(node);
|
2795
|
+
|
2796
|
+
case Token_case:
|
2797
|
+
case Token_default:
|
2798
|
+
return parseLabeledStatement(node);
|
2799
|
+
|
2800
|
+
case Token_break:
|
2801
|
+
case Token_continue:
|
2802
|
+
case Token_goto:
|
2803
|
+
return parseJumpStatement(node);
|
2804
|
+
|
2805
|
+
case Token_return:
|
2806
|
+
{
|
2807
|
+
advance();
|
2808
|
+
ExpressionAST *expr = 0;
|
2809
|
+
parseCommaExpression(expr);
|
2810
|
+
|
2811
|
+
ADVANCE(';', ";");
|
2812
|
+
|
2813
|
+
ReturnStatementAST *ast = CreateNode<ReturnStatementAST>(session->mempool);
|
2814
|
+
ast->expression = expr;
|
2815
|
+
|
2816
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
2817
|
+
|
2818
|
+
node = ast;
|
2819
|
+
}
|
2820
|
+
return true;
|
2821
|
+
|
2822
|
+
case '{':
|
2823
|
+
return parseCompoundStatement(node);
|
2824
|
+
|
2825
|
+
case Token_identifier:
|
2826
|
+
if (parseLabeledStatement(node))
|
2827
|
+
return true;
|
2828
|
+
break;
|
2829
|
+
}
|
2830
|
+
|
2831
|
+
return parseExpressionOrDeclarationStatement(node);
|
2832
|
+
}
|
2833
|
+
|
2834
|
+
bool Parser::parseExpressionOrDeclarationStatement(StatementAST *&node)
|
2835
|
+
{
|
2836
|
+
// hold any errors while the expression/declaration ambiguity is resolved
|
2837
|
+
// for this statement
|
2838
|
+
bool hold = holdErrors(true);
|
2839
|
+
|
2840
|
+
std::size_t start = session->token_stream->cursor();
|
2841
|
+
|
2842
|
+
///@todo solve -1 thing
|
2843
|
+
StatementAST *decl_ast = 0;
|
2844
|
+
bool maybe_amb = parseDeclarationStatement(decl_ast);
|
2845
|
+
maybe_amb &= session->token_stream->kind(session->token_stream->cursor() - 1) == ';';
|
2846
|
+
|
2847
|
+
// if parsing as a declaration succeeded, then any pending errors are genuine.
|
2848
|
+
// Otherwise this is not a declaration so ignore the errors.
|
2849
|
+
if (decl_ast)
|
2850
|
+
reportPendingErrors();
|
2851
|
+
else
|
2852
|
+
m_pendingErrors.clear();
|
2853
|
+
|
2854
|
+
std::size_t end = session->token_stream->cursor();
|
2855
|
+
|
2856
|
+
rewind(start);
|
2857
|
+
StatementAST *expr_ast = 0;
|
2858
|
+
maybe_amb &= parseExpressionStatement(expr_ast);
|
2859
|
+
maybe_amb &= session->token_stream->kind(session->token_stream->cursor() - 1) == ';';
|
2860
|
+
|
2861
|
+
// if parsing as an expression succeeded, then any pending errors are genuine.
|
2862
|
+
// Otherwise this is not an expression so ignore the errors.
|
2863
|
+
if (expr_ast)
|
2864
|
+
reportPendingErrors();
|
2865
|
+
else
|
2866
|
+
m_pendingErrors.clear();
|
2867
|
+
|
2868
|
+
if (maybe_amb)
|
2869
|
+
{
|
2870
|
+
Q_ASSERT(decl_ast != 0 && expr_ast != 0);
|
2871
|
+
ExpressionOrDeclarationStatementAST *ast
|
2872
|
+
= CreateNode<ExpressionOrDeclarationStatementAST>(session->mempool);
|
2873
|
+
ast->declaration = decl_ast;
|
2874
|
+
ast->expression = expr_ast;
|
2875
|
+
|
2876
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
2877
|
+
node = ast;
|
2878
|
+
}
|
2879
|
+
else
|
2880
|
+
{
|
2881
|
+
rewind(std::max(end, session->token_stream->cursor()));
|
2882
|
+
|
2883
|
+
node = decl_ast;
|
2884
|
+
if (!node)
|
2885
|
+
node = expr_ast;
|
2886
|
+
}
|
2887
|
+
|
2888
|
+
holdErrors(hold);
|
2889
|
+
|
2890
|
+
if (!node)
|
2891
|
+
syntaxError();
|
2892
|
+
|
2893
|
+
return node != 0;
|
2894
|
+
}
|
2895
|
+
|
2896
|
+
bool Parser::parseCondition(ConditionAST *&node, bool initRequired)
|
2897
|
+
{
|
2898
|
+
std::size_t start = session->token_stream->cursor();
|
2899
|
+
|
2900
|
+
ConditionAST *ast = CreateNode<ConditionAST>(session->mempool);
|
2901
|
+
TypeSpecifierAST *spec = 0;
|
2902
|
+
|
2903
|
+
if (parseTypeSpecifier(spec))
|
2904
|
+
{
|
2905
|
+
ast->type_specifier = spec;
|
2906
|
+
|
2907
|
+
std::size_t declarator_start = session->token_stream->cursor();
|
2908
|
+
|
2909
|
+
DeclaratorAST *decl = 0;
|
2910
|
+
if (!parseDeclarator(decl))
|
2911
|
+
{
|
2912
|
+
rewind(declarator_start);
|
2913
|
+
if (!initRequired && !parseAbstractDeclarator(decl))
|
2914
|
+
decl = 0;
|
2915
|
+
}
|
2916
|
+
|
2917
|
+
if (decl && (!initRequired || session->token_stream->lookAhead() == '='))
|
2918
|
+
{
|
2919
|
+
ast->declarator = decl;
|
2920
|
+
|
2921
|
+
if (session->token_stream->lookAhead() == '=')
|
2922
|
+
{
|
2923
|
+
advance();
|
2924
|
+
|
2925
|
+
parseExpression(ast->expression);
|
2926
|
+
}
|
2927
|
+
|
2928
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
2929
|
+
node = ast;
|
2930
|
+
return true;
|
2931
|
+
}
|
2932
|
+
}
|
2933
|
+
|
2934
|
+
ast->type_specifier = 0;
|
2935
|
+
|
2936
|
+
rewind(start);
|
2937
|
+
|
2938
|
+
if (!parseCommaExpression(ast->expression)) {
|
2939
|
+
return false;
|
2940
|
+
}
|
2941
|
+
Q_ASSERT(ast->expression);
|
2942
|
+
|
2943
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
2944
|
+
node = ast;
|
2945
|
+
|
2946
|
+
return true;
|
2947
|
+
}
|
2948
|
+
|
2949
|
+
|
2950
|
+
bool Parser::parseWhileStatement(StatementAST *&node)
|
2951
|
+
{
|
2952
|
+
std::size_t start = session->token_stream->cursor();
|
2953
|
+
|
2954
|
+
ADVANCE(Token_while, "while");
|
2955
|
+
ADVANCE('(' , "(");
|
2956
|
+
|
2957
|
+
ConditionAST *cond = 0;
|
2958
|
+
if (!parseCondition(cond))
|
2959
|
+
{
|
2960
|
+
reportError("Condition expected");
|
2961
|
+
return false;
|
2962
|
+
}
|
2963
|
+
ADVANCE(')', ")");
|
2964
|
+
|
2965
|
+
StatementAST *body = 0;
|
2966
|
+
if (!parseStatement(body))
|
2967
|
+
{
|
2968
|
+
reportError("Statement expected");
|
2969
|
+
return false;
|
2970
|
+
}
|
2971
|
+
|
2972
|
+
WhileStatementAST *ast = CreateNode<WhileStatementAST>(session->mempool);
|
2973
|
+
ast->condition = cond;
|
2974
|
+
ast->statement = body;
|
2975
|
+
|
2976
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
2977
|
+
node = ast;
|
2978
|
+
|
2979
|
+
return true;
|
2980
|
+
}
|
2981
|
+
|
2982
|
+
bool Parser::parseDoStatement(StatementAST *&node)
|
2983
|
+
{
|
2984
|
+
std::size_t start = session->token_stream->cursor();
|
2985
|
+
|
2986
|
+
ADVANCE(Token_do, "do");
|
2987
|
+
|
2988
|
+
StatementAST *body = 0;
|
2989
|
+
if (!parseStatement(body))
|
2990
|
+
{
|
2991
|
+
reportError(("Statement expected"));
|
2992
|
+
//return false;
|
2993
|
+
}
|
2994
|
+
|
2995
|
+
ADVANCE_NR(Token_while, "while");
|
2996
|
+
ADVANCE_NR('(' , "(");
|
2997
|
+
|
2998
|
+
ExpressionAST *expr = 0;
|
2999
|
+
if (!parseCommaExpression(expr))
|
3000
|
+
{
|
3001
|
+
reportError(("Expression expected"));
|
3002
|
+
//return false;
|
3003
|
+
}
|
3004
|
+
|
3005
|
+
ADVANCE_NR(')', ")");
|
3006
|
+
ADVANCE_NR(';', ";");
|
3007
|
+
|
3008
|
+
DoStatementAST *ast = CreateNode<DoStatementAST>(session->mempool);
|
3009
|
+
ast->statement = body;
|
3010
|
+
ast->expression = expr;
|
3011
|
+
|
3012
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
3013
|
+
node = ast;
|
3014
|
+
|
3015
|
+
return true;
|
3016
|
+
}
|
3017
|
+
|
3018
|
+
bool Parser::parseForStatement(StatementAST *&node)
|
3019
|
+
{
|
3020
|
+
std::size_t start = session->token_stream->cursor();
|
3021
|
+
|
3022
|
+
ADVANCE(Token_for, "for");
|
3023
|
+
ADVANCE('(', "(");
|
3024
|
+
|
3025
|
+
StatementAST *init = 0;
|
3026
|
+
if (!parseForInitStatement(init))
|
3027
|
+
{
|
3028
|
+
reportError(("'for' initialization expected"));
|
3029
|
+
return false;
|
3030
|
+
}
|
3031
|
+
|
3032
|
+
ConditionAST *cond = 0;
|
3033
|
+
parseCondition(cond);
|
3034
|
+
ADVANCE(';', ";");
|
3035
|
+
|
3036
|
+
ExpressionAST *expr = 0;
|
3037
|
+
parseCommaExpression(expr);
|
3038
|
+
ADVANCE(')', ")");
|
3039
|
+
|
3040
|
+
StatementAST *body = 0;
|
3041
|
+
if (!parseStatement(body))
|
3042
|
+
return false;
|
3043
|
+
|
3044
|
+
ForStatementAST *ast = CreateNode<ForStatementAST>(session->mempool);
|
3045
|
+
ast->init_statement = init;
|
3046
|
+
ast->condition = cond;
|
3047
|
+
ast->expression = expr;
|
3048
|
+
ast->statement = body;
|
3049
|
+
|
3050
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
3051
|
+
node = ast;
|
3052
|
+
|
3053
|
+
return true;
|
3054
|
+
}
|
3055
|
+
|
3056
|
+
bool Parser::parseForInitStatement(StatementAST *&node)
|
3057
|
+
{
|
3058
|
+
if (parseDeclarationStatement(node))
|
3059
|
+
return true;
|
3060
|
+
|
3061
|
+
return parseExpressionStatement(node);
|
3062
|
+
}
|
3063
|
+
|
3064
|
+
bool Parser::parseCompoundStatement(StatementAST *&node)
|
3065
|
+
{
|
3066
|
+
std::size_t start = session->token_stream->cursor();
|
3067
|
+
|
3068
|
+
CHECK('{');
|
3069
|
+
|
3070
|
+
CompoundStatementAST *ast = CreateNode<CompoundStatementAST>(session->mempool);
|
3071
|
+
while (session->token_stream->lookAhead())
|
3072
|
+
{
|
3073
|
+
if (session->token_stream->lookAhead() == '}')
|
3074
|
+
break;
|
3075
|
+
|
3076
|
+
std::size_t startStmt = session->token_stream->cursor();
|
3077
|
+
|
3078
|
+
StatementAST *stmt = 0;
|
3079
|
+
if (!parseStatement(stmt))
|
3080
|
+
{
|
3081
|
+
if (startStmt == session->token_stream->cursor())
|
3082
|
+
advance();
|
3083
|
+
|
3084
|
+
skipUntilStatement();
|
3085
|
+
}
|
3086
|
+
else
|
3087
|
+
{
|
3088
|
+
ast->statements = snoc(ast->statements, stmt, session->mempool);
|
3089
|
+
}
|
3090
|
+
}
|
3091
|
+
|
3092
|
+
clearComment();
|
3093
|
+
ADVANCE_NR('}', "}");
|
3094
|
+
|
3095
|
+
|
3096
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
3097
|
+
node = ast;
|
3098
|
+
|
3099
|
+
return true;
|
3100
|
+
}
|
3101
|
+
|
3102
|
+
bool Parser::parseIfStatement(StatementAST *&node)
|
3103
|
+
{
|
3104
|
+
std::size_t start = session->token_stream->cursor();
|
3105
|
+
|
3106
|
+
ADVANCE(Token_if, "if");
|
3107
|
+
|
3108
|
+
ADVANCE('(' , "(");
|
3109
|
+
IfStatementAST *ast = CreateNode<IfStatementAST>(session->mempool);
|
3110
|
+
|
3111
|
+
ConditionAST *cond = 0;
|
3112
|
+
if (!parseCondition(cond))
|
3113
|
+
{
|
3114
|
+
reportError(("Condition expected"));
|
3115
|
+
return false;
|
3116
|
+
}
|
3117
|
+
|
3118
|
+
ADVANCE(')', ")");
|
3119
|
+
|
3120
|
+
StatementAST *stmt = 0;
|
3121
|
+
if (!parseStatement(stmt))
|
3122
|
+
{
|
3123
|
+
reportError(("Statement expected"));
|
3124
|
+
return false;
|
3125
|
+
}
|
3126
|
+
|
3127
|
+
ast->condition = cond;
|
3128
|
+
ast->statement = stmt;
|
3129
|
+
|
3130
|
+
if (session->token_stream->lookAhead() == Token_else)
|
3131
|
+
{
|
3132
|
+
advance();
|
3133
|
+
|
3134
|
+
if (!parseStatement(ast->else_statement))
|
3135
|
+
{
|
3136
|
+
reportError(("Statement expected"));
|
3137
|
+
return false;
|
3138
|
+
}
|
3139
|
+
}
|
3140
|
+
|
3141
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
3142
|
+
node = ast;
|
3143
|
+
|
3144
|
+
return true;
|
3145
|
+
}
|
3146
|
+
|
3147
|
+
bool Parser::parseSwitchStatement(StatementAST *&node)
|
3148
|
+
{
|
3149
|
+
std::size_t start = session->token_stream->cursor();
|
3150
|
+
ADVANCE(Token_switch, "switch");
|
3151
|
+
|
3152
|
+
ADVANCE('(' , "(");
|
3153
|
+
|
3154
|
+
ConditionAST *cond = 0;
|
3155
|
+
if (!parseCondition(cond))
|
3156
|
+
{
|
3157
|
+
reportError(("Condition expected"));
|
3158
|
+
return false;
|
3159
|
+
}
|
3160
|
+
ADVANCE(')', ")");
|
3161
|
+
|
3162
|
+
StatementAST *stmt = 0;
|
3163
|
+
if (!parseCompoundStatement(stmt))
|
3164
|
+
{
|
3165
|
+
syntaxError();
|
3166
|
+
return false;
|
3167
|
+
}
|
3168
|
+
|
3169
|
+
SwitchStatementAST *ast = CreateNode<SwitchStatementAST>(session->mempool);
|
3170
|
+
ast->condition = cond;
|
3171
|
+
ast->statement = stmt;
|
3172
|
+
|
3173
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
3174
|
+
node = ast;
|
3175
|
+
|
3176
|
+
return true;
|
3177
|
+
}
|
3178
|
+
|
3179
|
+
bool Parser::parseLabeledStatement(StatementAST *&node)
|
3180
|
+
{
|
3181
|
+
switch(session->token_stream->lookAhead())
|
3182
|
+
{
|
3183
|
+
case Token_identifier:
|
3184
|
+
case Token_default:
|
3185
|
+
{
|
3186
|
+
std::size_t start = session->token_stream->cursor();
|
3187
|
+
if (session->token_stream->lookAhead(1) == ':')
|
3188
|
+
{
|
3189
|
+
advance();
|
3190
|
+
advance();
|
3191
|
+
|
3192
|
+
StatementAST *stmt = 0;
|
3193
|
+
if (parseStatement(stmt))
|
3194
|
+
{
|
3195
|
+
LabeledStatementAST* ast = CreateNode<LabeledStatementAST>(session->mempool);
|
3196
|
+
ast->label = start;
|
3197
|
+
ast->statement = stmt;
|
3198
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
3199
|
+
node = ast;
|
3200
|
+
return true;
|
3201
|
+
}
|
3202
|
+
}
|
3203
|
+
break;
|
3204
|
+
}
|
3205
|
+
|
3206
|
+
case Token_case:
|
3207
|
+
{
|
3208
|
+
std::size_t start = session->token_stream->cursor();
|
3209
|
+
|
3210
|
+
advance();
|
3211
|
+
ExpressionAST *expr = 0;
|
3212
|
+
if (!parseConstantExpression(expr))
|
3213
|
+
{
|
3214
|
+
reportError(("Expression expected"));
|
3215
|
+
}
|
3216
|
+
else if (session->token_stream->lookAhead() == Token_ellipsis)
|
3217
|
+
{
|
3218
|
+
advance();
|
3219
|
+
|
3220
|
+
if (!parseConstantExpression(expr))
|
3221
|
+
{
|
3222
|
+
reportError(("Expression expected"));
|
3223
|
+
}
|
3224
|
+
}
|
3225
|
+
ADVANCE(':', ":");
|
3226
|
+
|
3227
|
+
LabeledStatementAST* ast = CreateNode<LabeledStatementAST>(session->mempool);
|
3228
|
+
ast->label = start;
|
3229
|
+
ast->expression = expr;
|
3230
|
+
|
3231
|
+
parseStatement(ast->statement);
|
3232
|
+
|
3233
|
+
if(ast->expression || ast->statement) {
|
3234
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
3235
|
+
node = ast;
|
3236
|
+
return true;
|
3237
|
+
}
|
3238
|
+
}
|
3239
|
+
break;
|
3240
|
+
|
3241
|
+
}
|
3242
|
+
|
3243
|
+
return false;
|
3244
|
+
}
|
3245
|
+
|
3246
|
+
bool Parser::parseBlockDeclaration(DeclarationAST *&node)
|
3247
|
+
{
|
3248
|
+
switch(session->token_stream->lookAhead())
|
3249
|
+
{
|
3250
|
+
case Token_typedef:
|
3251
|
+
return parseTypedef(node);
|
3252
|
+
case Token_using:
|
3253
|
+
return parseUsing(node);
|
3254
|
+
case Token_asm:
|
3255
|
+
return parseAsmDefinition(node);
|
3256
|
+
case Token_namespace:
|
3257
|
+
return parseNamespaceAliasDefinition(node);
|
3258
|
+
}
|
3259
|
+
|
3260
|
+
Comment mcomment = comment();
|
3261
|
+
clearComment();
|
3262
|
+
|
3263
|
+
std::size_t start = session->token_stream->cursor();
|
3264
|
+
|
3265
|
+
const ListNode<std::size_t> *cv = 0;
|
3266
|
+
parseCvQualify(cv);
|
3267
|
+
|
3268
|
+
const ListNode<std::size_t> *storageSpec = 0;
|
3269
|
+
parseStorageClassSpecifier(storageSpec);
|
3270
|
+
|
3271
|
+
parseCvQualify(cv);
|
3272
|
+
|
3273
|
+
TypeSpecifierAST *spec = 0;
|
3274
|
+
if (!parseTypeSpecifierOrClassSpec(spec))
|
3275
|
+
{ // replace with simpleTypeSpecifier?!?!
|
3276
|
+
rewind(start);
|
3277
|
+
return false;
|
3278
|
+
}
|
3279
|
+
|
3280
|
+
parseCvQualify(cv);
|
3281
|
+
spec->cv = cv;
|
3282
|
+
|
3283
|
+
const ListNode<InitDeclaratorAST*> *declarators = 0;
|
3284
|
+
parseInitDeclaratorList(declarators);
|
3285
|
+
|
3286
|
+
if (session->token_stream->lookAhead() != ';')
|
3287
|
+
{
|
3288
|
+
rewind(start);
|
3289
|
+
return false;
|
3290
|
+
}
|
3291
|
+
advance();
|
3292
|
+
|
3293
|
+
SimpleDeclarationAST *ast = CreateNode<SimpleDeclarationAST>(session->mempool);
|
3294
|
+
ast->type_specifier = spec;
|
3295
|
+
ast->init_declarators = declarators;
|
3296
|
+
|
3297
|
+
if(mcomment)
|
3298
|
+
addComment(ast, mcomment);
|
3299
|
+
|
3300
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
3301
|
+
node = ast;
|
3302
|
+
|
3303
|
+
return true;
|
3304
|
+
}
|
3305
|
+
|
3306
|
+
bool Parser::parseNamespaceAliasDefinition(DeclarationAST *&node)
|
3307
|
+
{
|
3308
|
+
std::size_t start = session->token_stream->cursor();
|
3309
|
+
|
3310
|
+
CHECK(Token_namespace);
|
3311
|
+
|
3312
|
+
NamespaceAliasDefinitionAST *ast
|
3313
|
+
= CreateNode<NamespaceAliasDefinitionAST>(session->mempool);
|
3314
|
+
|
3315
|
+
size_t pos = session->token_stream->cursor();
|
3316
|
+
ADVANCE(Token_identifier, "identifier");
|
3317
|
+
ast->namespace_name = pos;
|
3318
|
+
|
3319
|
+
ADVANCE('=', "=");
|
3320
|
+
|
3321
|
+
if (!parseName(ast->alias_name))
|
3322
|
+
{
|
3323
|
+
reportError(("Namespace name expected"));
|
3324
|
+
}
|
3325
|
+
|
3326
|
+
ADVANCE(';', ";");
|
3327
|
+
|
3328
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
3329
|
+
node = ast;
|
3330
|
+
|
3331
|
+
return true;
|
3332
|
+
}
|
3333
|
+
|
3334
|
+
bool Parser::parseDeclarationStatement(StatementAST *&node)
|
3335
|
+
{
|
3336
|
+
std::size_t start = session->token_stream->cursor();
|
3337
|
+
|
3338
|
+
DeclarationAST *decl = 0;
|
3339
|
+
if (!parseBlockDeclaration(decl))
|
3340
|
+
return false;
|
3341
|
+
|
3342
|
+
DeclarationStatementAST *ast = CreateNode<DeclarationStatementAST>(session->mempool);
|
3343
|
+
ast->declaration = decl;
|
3344
|
+
|
3345
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
3346
|
+
node = ast;
|
3347
|
+
|
3348
|
+
return true;
|
3349
|
+
}
|
3350
|
+
|
3351
|
+
bool Parser::parseDeclarationInternal(DeclarationAST *&node)
|
3352
|
+
{
|
3353
|
+
std::size_t start = session->token_stream->cursor();
|
3354
|
+
|
3355
|
+
// that is for the case '__declspec(dllexport) int ...' or
|
3356
|
+
// '__declspec(dllexport) inline int ...', etc.
|
3357
|
+
WinDeclSpecAST *winDeclSpec = 0;
|
3358
|
+
parseWinDeclSpec(winDeclSpec);
|
3359
|
+
|
3360
|
+
const ListNode<std::size_t> *funSpec = 0;
|
3361
|
+
bool hasFunSpec = parseFunctionSpecifier(funSpec);
|
3362
|
+
|
3363
|
+
const ListNode<std::size_t> *cv = 0;
|
3364
|
+
parseCvQualify(cv);
|
3365
|
+
|
3366
|
+
const ListNode<std::size_t> *storageSpec = 0;
|
3367
|
+
bool hasStorageSpec = parseStorageClassSpecifier(storageSpec);
|
3368
|
+
|
3369
|
+
// needed here for 'friend __declspec(dllimport) inline ...'
|
3370
|
+
if (!winDeclSpec)
|
3371
|
+
parseWinDeclSpec(winDeclSpec);
|
3372
|
+
|
3373
|
+
if (hasStorageSpec && !hasFunSpec)
|
3374
|
+
hasFunSpec = parseFunctionSpecifier(funSpec);
|
3375
|
+
|
3376
|
+
// that is for the case 'friend __declspec(dllexport) ....'
|
3377
|
+
if (!winDeclSpec)
|
3378
|
+
parseWinDeclSpec(winDeclSpec);
|
3379
|
+
|
3380
|
+
if (!cv)
|
3381
|
+
parseCvQualify(cv);
|
3382
|
+
|
3383
|
+
int index = session->token_stream->cursor();
|
3384
|
+
NameAST *name = 0;
|
3385
|
+
if (parseName(name, AcceptTemplate) && session->token_stream->lookAhead() == '(')
|
3386
|
+
{
|
3387
|
+
// no type specifier, maybe a constructor or a cast operator??
|
3388
|
+
|
3389
|
+
rewind(index);
|
3390
|
+
|
3391
|
+
InitDeclaratorAST *declarator = 0;
|
3392
|
+
if (parseInitDeclarator(declarator))
|
3393
|
+
{
|
3394
|
+
switch(session->token_stream->lookAhead())
|
3395
|
+
{
|
3396
|
+
case ';':
|
3397
|
+
{
|
3398
|
+
advance();
|
3399
|
+
|
3400
|
+
SimpleDeclarationAST *ast
|
3401
|
+
= CreateNode<SimpleDeclarationAST>(session->mempool);
|
3402
|
+
ast->init_declarators = snoc(ast->init_declarators,
|
3403
|
+
declarator, session->mempool);
|
3404
|
+
ast->function_specifiers = funSpec;
|
3405
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
3406
|
+
node = ast;
|
3407
|
+
}
|
3408
|
+
return true;
|
3409
|
+
|
3410
|
+
case ':':
|
3411
|
+
{
|
3412
|
+
CtorInitializerAST *ctorInit = 0;
|
3413
|
+
StatementAST *funBody = 0;
|
3414
|
+
|
3415
|
+
if (parseCtorInitializer(ctorInit)
|
3416
|
+
&& parseFunctionBody(funBody))
|
3417
|
+
{
|
3418
|
+
FunctionDefinitionAST *ast
|
3419
|
+
= CreateNode<FunctionDefinitionAST>(session->mempool);
|
3420
|
+
|
3421
|
+
ast->storage_specifiers = storageSpec;
|
3422
|
+
ast->function_specifiers = funSpec;
|
3423
|
+
ast->init_declarator = declarator;
|
3424
|
+
ast->function_body = funBody;
|
3425
|
+
ast->constructor_initializers = ctorInit;
|
3426
|
+
|
3427
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
3428
|
+
node = ast;
|
3429
|
+
|
3430
|
+
return true;
|
3431
|
+
}
|
3432
|
+
}
|
3433
|
+
break;
|
3434
|
+
|
3435
|
+
case Token_try:
|
3436
|
+
case '{':
|
3437
|
+
{
|
3438
|
+
StatementAST *funBody = 0;
|
3439
|
+
if (parseFunctionBody(funBody))
|
3440
|
+
{
|
3441
|
+
FunctionDefinitionAST *ast
|
3442
|
+
= CreateNode<FunctionDefinitionAST>(session->mempool);
|
3443
|
+
|
3444
|
+
ast->storage_specifiers = storageSpec;
|
3445
|
+
ast->function_specifiers = funSpec;
|
3446
|
+
ast->init_declarator = declarator;
|
3447
|
+
ast->function_body = funBody;
|
3448
|
+
|
3449
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
3450
|
+
node = ast;
|
3451
|
+
|
3452
|
+
return true;
|
3453
|
+
}
|
3454
|
+
}
|
3455
|
+
break;
|
3456
|
+
|
3457
|
+
case '(':
|
3458
|
+
case '[':
|
3459
|
+
// ops!! it seems a declarator
|
3460
|
+
goto start_decl;
|
3461
|
+
break;
|
3462
|
+
}
|
3463
|
+
|
3464
|
+
}
|
3465
|
+
}
|
3466
|
+
|
3467
|
+
start_decl:
|
3468
|
+
rewind(index);
|
3469
|
+
|
3470
|
+
if (session->token_stream->lookAhead() == Token_const
|
3471
|
+
&& session->token_stream->lookAhead(1) == Token_identifier
|
3472
|
+
&& session->token_stream->lookAhead(2) == '=')
|
3473
|
+
{
|
3474
|
+
// constant definition
|
3475
|
+
advance(); // skip const
|
3476
|
+
|
3477
|
+
const ListNode<InitDeclaratorAST*> *declarators = 0;
|
3478
|
+
if (!parseInitDeclaratorList(declarators))
|
3479
|
+
{
|
3480
|
+
syntaxError();
|
3481
|
+
return false;
|
3482
|
+
}
|
3483
|
+
|
3484
|
+
ADVANCE(';', ";");
|
3485
|
+
|
3486
|
+
#if defined(__GNUC__)
|
3487
|
+
#warning "mark the ast as constant"
|
3488
|
+
#endif
|
3489
|
+
SimpleDeclarationAST *ast = CreateNode<SimpleDeclarationAST>(session->mempool);
|
3490
|
+
ast->init_declarators = declarators;
|
3491
|
+
|
3492
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
3493
|
+
node = ast;
|
3494
|
+
|
3495
|
+
return true;
|
3496
|
+
}
|
3497
|
+
|
3498
|
+
TypeSpecifierAST *spec = 0;
|
3499
|
+
if (parseTypeSpecifier(spec))
|
3500
|
+
{
|
3501
|
+
Q_ASSERT(spec != 0);
|
3502
|
+
|
3503
|
+
if (!hasFunSpec)
|
3504
|
+
parseFunctionSpecifier(funSpec); // e.g. "void inline"
|
3505
|
+
|
3506
|
+
spec->cv = cv;
|
3507
|
+
|
3508
|
+
const ListNode<InitDeclaratorAST*> *declarators = 0;
|
3509
|
+
InitDeclaratorAST *decl = 0;
|
3510
|
+
int startDeclarator = session->token_stream->cursor();
|
3511
|
+
bool maybeFunctionDefinition = false;
|
3512
|
+
|
3513
|
+
if (session->token_stream->lookAhead() != ';')
|
3514
|
+
{
|
3515
|
+
if (parseInitDeclarator(decl) && (session->token_stream->lookAhead() == '{' || session->token_stream->lookAhead() == Token_try))
|
3516
|
+
{
|
3517
|
+
// function definition
|
3518
|
+
maybeFunctionDefinition = true;
|
3519
|
+
}
|
3520
|
+
else
|
3521
|
+
{
|
3522
|
+
rewind(startDeclarator);
|
3523
|
+
if (!parseInitDeclaratorList(declarators))
|
3524
|
+
{
|
3525
|
+
syntaxError();
|
3526
|
+
return false;
|
3527
|
+
}
|
3528
|
+
}
|
3529
|
+
}
|
3530
|
+
|
3531
|
+
switch(session->token_stream->lookAhead())
|
3532
|
+
{
|
3533
|
+
case ';':
|
3534
|
+
{
|
3535
|
+
advance();
|
3536
|
+
SimpleDeclarationAST *ast
|
3537
|
+
= CreateNode<SimpleDeclarationAST>(session->mempool);
|
3538
|
+
|
3539
|
+
ast->storage_specifiers = storageSpec;
|
3540
|
+
ast->function_specifiers = funSpec;
|
3541
|
+
ast->type_specifier = spec;
|
3542
|
+
ast->win_decl_specifiers = winDeclSpec;
|
3543
|
+
ast->init_declarators = declarators;
|
3544
|
+
|
3545
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
3546
|
+
node = ast;
|
3547
|
+
}
|
3548
|
+
return true;
|
3549
|
+
|
3550
|
+
case Token_try:
|
3551
|
+
case '{':
|
3552
|
+
{
|
3553
|
+
if (!maybeFunctionDefinition)
|
3554
|
+
{
|
3555
|
+
syntaxError();
|
3556
|
+
return false;
|
3557
|
+
}
|
3558
|
+
|
3559
|
+
StatementAST *funBody = 0;
|
3560
|
+
if (parseFunctionBody(funBody))
|
3561
|
+
{
|
3562
|
+
FunctionDefinitionAST *ast
|
3563
|
+
= CreateNode<FunctionDefinitionAST>(session->mempool);
|
3564
|
+
|
3565
|
+
ast->win_decl_specifiers = winDeclSpec;
|
3566
|
+
ast->storage_specifiers = storageSpec;
|
3567
|
+
ast->function_specifiers = funSpec;
|
3568
|
+
ast->type_specifier = spec;
|
3569
|
+
ast->init_declarator = decl;
|
3570
|
+
ast->function_body = funBody;
|
3571
|
+
|
3572
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
3573
|
+
node = ast;
|
3574
|
+
|
3575
|
+
return true;
|
3576
|
+
}
|
3577
|
+
}
|
3578
|
+
break;
|
3579
|
+
} // end switch
|
3580
|
+
}
|
3581
|
+
|
3582
|
+
syntaxError();
|
3583
|
+
return false;
|
3584
|
+
}
|
3585
|
+
|
3586
|
+
bool Parser::parseFunctionBody(StatementAST *&node)
|
3587
|
+
{
|
3588
|
+
if (session->token_stream->lookAhead() == Token_try)
|
3589
|
+
return parseTryBlockStatement(node);
|
3590
|
+
|
3591
|
+
return parseCompoundStatement(node);
|
3592
|
+
}
|
3593
|
+
|
3594
|
+
bool Parser::parseTypeSpecifierOrClassSpec(TypeSpecifierAST *&node)
|
3595
|
+
{
|
3596
|
+
if (parseClassSpecifier(node))
|
3597
|
+
return true;
|
3598
|
+
else if (parseEnumSpecifier(node))
|
3599
|
+
return true;
|
3600
|
+
else if (parseTypeSpecifier(node))
|
3601
|
+
return true;
|
3602
|
+
|
3603
|
+
return false;
|
3604
|
+
}
|
3605
|
+
|
3606
|
+
bool Parser::parseTryBlockStatement(StatementAST *&node)
|
3607
|
+
{
|
3608
|
+
std::size_t start = session->token_stream->cursor();
|
3609
|
+
|
3610
|
+
CHECK(Token_try);
|
3611
|
+
|
3612
|
+
TryBlockStatementAST *ast = CreateNode<TryBlockStatementAST>(session->mempool);
|
3613
|
+
|
3614
|
+
StatementAST *stmt = 0;
|
3615
|
+
if (!parseCompoundStatement(stmt))
|
3616
|
+
{
|
3617
|
+
syntaxError();
|
3618
|
+
return false;
|
3619
|
+
}
|
3620
|
+
ast->try_block = stmt;
|
3621
|
+
|
3622
|
+
if (session->token_stream->lookAhead() != Token_catch)
|
3623
|
+
{
|
3624
|
+
reportError(("'catch' expected after try block"));
|
3625
|
+
return false;
|
3626
|
+
}
|
3627
|
+
|
3628
|
+
while (session->token_stream->lookAhead() == Token_catch)
|
3629
|
+
{
|
3630
|
+
std::size_t catchStart = session->token_stream->cursor();
|
3631
|
+
|
3632
|
+
advance();
|
3633
|
+
ADVANCE('(', "(");
|
3634
|
+
ConditionAST *cond = 0;
|
3635
|
+
if (session->token_stream->lookAhead() == Token_ellipsis)
|
3636
|
+
{
|
3637
|
+
advance();
|
3638
|
+
}
|
3639
|
+
else if(session->token_stream->lookAhead() == ')') {
|
3640
|
+
//Do nothing, this is equivalent to ellipsis
|
3641
|
+
} else if (!parseCondition(cond, false))
|
3642
|
+
{
|
3643
|
+
reportError(("condition expected"));
|
3644
|
+
return false;
|
3645
|
+
}
|
3646
|
+
ADVANCE(')', ")");
|
3647
|
+
|
3648
|
+
StatementAST *body = 0;
|
3649
|
+
if (!parseCompoundStatement(body))
|
3650
|
+
{
|
3651
|
+
syntaxError();
|
3652
|
+
return false;
|
3653
|
+
}
|
3654
|
+
|
3655
|
+
CatchStatementAST *catch_ast = CreateNode<CatchStatementAST>(session->mempool);
|
3656
|
+
catch_ast->condition = cond;
|
3657
|
+
catch_ast->statement = body;
|
3658
|
+
UPDATE_POS(catch_ast, catchStart, _M_last_valid_token+1);
|
3659
|
+
|
3660
|
+
ast->catch_blocks = snoc(ast->catch_blocks, catch_ast, session->mempool);
|
3661
|
+
}
|
3662
|
+
|
3663
|
+
node = ast;
|
3664
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
3665
|
+
return true;
|
3666
|
+
}
|
3667
|
+
|
3668
|
+
bool Parser::parsePrimaryExpression(ExpressionAST *&node)
|
3669
|
+
{
|
3670
|
+
std::size_t start = session->token_stream->cursor();
|
3671
|
+
|
3672
|
+
PrimaryExpressionAST *ast = CreateNode<PrimaryExpressionAST>(session->mempool);
|
3673
|
+
|
3674
|
+
switch(session->token_stream->lookAhead())
|
3675
|
+
{
|
3676
|
+
case Token_string_literal:
|
3677
|
+
parseStringLiteral(ast->literal);
|
3678
|
+
break;
|
3679
|
+
|
3680
|
+
case Token_number_literal:
|
3681
|
+
case Token_char_literal:
|
3682
|
+
case Token_true:
|
3683
|
+
case Token_false:
|
3684
|
+
case Token_this:
|
3685
|
+
ast->token = session->token_stream->cursor();
|
3686
|
+
advance();
|
3687
|
+
break;
|
3688
|
+
|
3689
|
+
case '(':
|
3690
|
+
advance();
|
3691
|
+
|
3692
|
+
if (session->token_stream->lookAhead() == '{')
|
3693
|
+
{
|
3694
|
+
if (!parseCompoundStatement(ast->expression_statement))
|
3695
|
+
return false;
|
3696
|
+
}
|
3697
|
+
else
|
3698
|
+
{
|
3699
|
+
if (!parseExpression(ast->sub_expression))
|
3700
|
+
return false;
|
3701
|
+
}
|
3702
|
+
|
3703
|
+
CHECK(')');
|
3704
|
+
break;
|
3705
|
+
|
3706
|
+
default:
|
3707
|
+
if (!parseName(ast->name, EventuallyAcceptTemplate))
|
3708
|
+
return false;
|
3709
|
+
|
3710
|
+
break;
|
3711
|
+
}
|
3712
|
+
|
3713
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
3714
|
+
node = ast;
|
3715
|
+
|
3716
|
+
return true;
|
3717
|
+
}
|
3718
|
+
|
3719
|
+
|
3720
|
+
/*
|
3721
|
+
postfix-expression-internal:
|
3722
|
+
[ expression ]
|
3723
|
+
( expression-list [opt] )
|
3724
|
+
(.|->) template [opt] id-expression
|
3725
|
+
(.|->) pseudo-destructor-name
|
3726
|
+
++
|
3727
|
+
--
|
3728
|
+
*/
|
3729
|
+
bool Parser::parsePostfixExpressionInternal(ExpressionAST *&node)
|
3730
|
+
{
|
3731
|
+
std::size_t start = session->token_stream->cursor();
|
3732
|
+
|
3733
|
+
switch (session->token_stream->lookAhead())
|
3734
|
+
{
|
3735
|
+
case '[':
|
3736
|
+
{
|
3737
|
+
advance();
|
3738
|
+
ExpressionAST *expr = 0;
|
3739
|
+
parseExpression(expr);
|
3740
|
+
CHECK(']');
|
3741
|
+
|
3742
|
+
SubscriptExpressionAST *ast
|
3743
|
+
= CreateNode<SubscriptExpressionAST>(session->mempool);
|
3744
|
+
|
3745
|
+
ast->subscript = expr;
|
3746
|
+
|
3747
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
3748
|
+
node = ast;
|
3749
|
+
}
|
3750
|
+
return true;
|
3751
|
+
|
3752
|
+
case '(':
|
3753
|
+
{
|
3754
|
+
advance();
|
3755
|
+
ExpressionAST *expr = 0;
|
3756
|
+
parseExpression(expr);
|
3757
|
+
CHECK(')');
|
3758
|
+
|
3759
|
+
FunctionCallAST *ast = CreateNode<FunctionCallAST>(session->mempool);
|
3760
|
+
ast->arguments = expr;
|
3761
|
+
|
3762
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
3763
|
+
node = ast;
|
3764
|
+
}
|
3765
|
+
return true;
|
3766
|
+
|
3767
|
+
case '.':
|
3768
|
+
case Token_arrow:
|
3769
|
+
{
|
3770
|
+
std::size_t op = session->token_stream->cursor();
|
3771
|
+
advance();
|
3772
|
+
|
3773
|
+
// std::size_t templ = 0;
|
3774
|
+
// if (session->token_stream->lookAhead() == Token_template)
|
3775
|
+
// {
|
3776
|
+
// templ = session->token_stream->cursor();
|
3777
|
+
// advance();
|
3778
|
+
// }
|
3779
|
+
|
3780
|
+
NameAST *name = 0;
|
3781
|
+
if (!parseName(name, EventuallyAcceptTemplate))
|
3782
|
+
return false;
|
3783
|
+
|
3784
|
+
ClassMemberAccessAST *ast = CreateNode<ClassMemberAccessAST>(session->mempool);
|
3785
|
+
ast->op = op;
|
3786
|
+
ast->name = name;
|
3787
|
+
|
3788
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
3789
|
+
node = ast;
|
3790
|
+
}
|
3791
|
+
return true;
|
3792
|
+
|
3793
|
+
case Token_incr:
|
3794
|
+
case Token_decr:
|
3795
|
+
{
|
3796
|
+
std::size_t op = session->token_stream->cursor();
|
3797
|
+
advance();
|
3798
|
+
|
3799
|
+
IncrDecrExpressionAST *ast = CreateNode<IncrDecrExpressionAST>(session->mempool);
|
3800
|
+
ast->op = op;
|
3801
|
+
|
3802
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
3803
|
+
node = ast;
|
3804
|
+
}
|
3805
|
+
return true;
|
3806
|
+
|
3807
|
+
default:
|
3808
|
+
return false;
|
3809
|
+
}
|
3810
|
+
}
|
3811
|
+
|
3812
|
+
/*
|
3813
|
+
postfix-expression:
|
3814
|
+
simple-type-specifier ( expression-list [opt] )
|
3815
|
+
primary-expression postfix-expression-internal*
|
3816
|
+
*/
|
3817
|
+
bool Parser::parsePostfixExpression(ExpressionAST *&node)
|
3818
|
+
{
|
3819
|
+
std::size_t start = session->token_stream->cursor();
|
3820
|
+
|
3821
|
+
switch (session->token_stream->lookAhead())
|
3822
|
+
{
|
3823
|
+
case Token_dynamic_cast:
|
3824
|
+
case Token_static_cast:
|
3825
|
+
case Token_reinterpret_cast:
|
3826
|
+
case Token_const_cast:
|
3827
|
+
{
|
3828
|
+
std::size_t castOp = session->token_stream->cursor();
|
3829
|
+
advance();
|
3830
|
+
|
3831
|
+
CHECK('<');
|
3832
|
+
TypeIdAST *typeId = 0;
|
3833
|
+
parseTypeId(typeId);
|
3834
|
+
CHECK('>');
|
3835
|
+
|
3836
|
+
CHECK('(');
|
3837
|
+
ExpressionAST *expr = 0;
|
3838
|
+
parseCommaExpression(expr);
|
3839
|
+
CHECK(')');
|
3840
|
+
|
3841
|
+
CppCastExpressionAST *ast = CreateNode<CppCastExpressionAST>(session->mempool);
|
3842
|
+
ast->op = castOp;
|
3843
|
+
ast->type_id = typeId;
|
3844
|
+
ast->expression = expr;
|
3845
|
+
|
3846
|
+
ExpressionAST *e = 0;
|
3847
|
+
while (parsePostfixExpressionInternal(e))
|
3848
|
+
{
|
3849
|
+
ast->sub_expressions = snoc(ast->sub_expressions, e, session->mempool);
|
3850
|
+
}
|
3851
|
+
|
3852
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
3853
|
+
node = ast;
|
3854
|
+
}
|
3855
|
+
return true;
|
3856
|
+
|
3857
|
+
case Token_typename:
|
3858
|
+
{
|
3859
|
+
std::size_t token = session->token_stream->cursor();
|
3860
|
+
advance();
|
3861
|
+
|
3862
|
+
NameAST* name = 0;
|
3863
|
+
if (!parseName(name, AcceptTemplate))
|
3864
|
+
return false;
|
3865
|
+
|
3866
|
+
CHECK('(');
|
3867
|
+
ExpressionAST *expr = 0;
|
3868
|
+
parseCommaExpression(expr);
|
3869
|
+
CHECK(')');
|
3870
|
+
|
3871
|
+
TypeIdentificationAST *ast = CreateNode<TypeIdentificationAST>(session->mempool);
|
3872
|
+
ast->typename_token = token;
|
3873
|
+
ast->name = name;
|
3874
|
+
ast->expression = expr;
|
3875
|
+
|
3876
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
3877
|
+
node = ast;
|
3878
|
+
}
|
3879
|
+
return true;
|
3880
|
+
|
3881
|
+
case Token_typeid:
|
3882
|
+
{
|
3883
|
+
advance();
|
3884
|
+
|
3885
|
+
CHECK('(');
|
3886
|
+
TypeIdAST *typeId = 0;
|
3887
|
+
parseTypeId(typeId);
|
3888
|
+
CHECK(')');
|
3889
|
+
|
3890
|
+
TypeIdentificationAST *ast = CreateNode<TypeIdentificationAST>(session->mempool);
|
3891
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
3892
|
+
node = ast;
|
3893
|
+
}
|
3894
|
+
return true;
|
3895
|
+
|
3896
|
+
default:
|
3897
|
+
break;
|
3898
|
+
}
|
3899
|
+
|
3900
|
+
std::size_t saved_pos = session->token_stream->cursor();
|
3901
|
+
|
3902
|
+
TypeSpecifierAST *typeSpec = 0;
|
3903
|
+
ExpressionAST *expr = 0;
|
3904
|
+
|
3905
|
+
// let's try to parse a type
|
3906
|
+
NameAST *name = 0;
|
3907
|
+
if (parseName(name, AcceptTemplate))
|
3908
|
+
{
|
3909
|
+
Q_ASSERT(name->unqualified_name != 0);
|
3910
|
+
|
3911
|
+
bool has_template_args
|
3912
|
+
= name->unqualified_name->template_arguments != 0;
|
3913
|
+
|
3914
|
+
if (has_template_args && session->token_stream->lookAhead() == '(')
|
3915
|
+
{
|
3916
|
+
ExpressionAST *cast_expr = 0;
|
3917
|
+
if (parseCastExpression(cast_expr)
|
3918
|
+
&& cast_expr->kind == AST::Kind_CastExpression)
|
3919
|
+
{
|
3920
|
+
rewind(saved_pos);
|
3921
|
+
parsePrimaryExpression(expr);
|
3922
|
+
goto L_no_rewind;
|
3923
|
+
}
|
3924
|
+
}
|
3925
|
+
}
|
3926
|
+
|
3927
|
+
rewind(saved_pos);
|
3928
|
+
|
3929
|
+
L_no_rewind:
|
3930
|
+
if (!expr && parseSimpleTypeSpecifier(typeSpec,true)
|
3931
|
+
&& session->token_stream->lookAhead() == '(')
|
3932
|
+
{
|
3933
|
+
advance(); // skip '('
|
3934
|
+
parseCommaExpression(expr);
|
3935
|
+
CHECK(')');
|
3936
|
+
}
|
3937
|
+
else if (expr)
|
3938
|
+
{
|
3939
|
+
typeSpec = 0;
|
3940
|
+
}
|
3941
|
+
else
|
3942
|
+
{
|
3943
|
+
typeSpec = 0;
|
3944
|
+
rewind(start);
|
3945
|
+
|
3946
|
+
if (!parsePrimaryExpression(expr))
|
3947
|
+
return false;
|
3948
|
+
}
|
3949
|
+
|
3950
|
+
const ListNode<ExpressionAST*> *sub_expressions = 0;
|
3951
|
+
|
3952
|
+
ExpressionAST *sub_expression = 0;
|
3953
|
+
while (parsePostfixExpressionInternal(sub_expression))
|
3954
|
+
{
|
3955
|
+
sub_expressions = snoc(sub_expressions, sub_expression, session->mempool);
|
3956
|
+
}
|
3957
|
+
|
3958
|
+
node = expr;
|
3959
|
+
if (sub_expressions || !node)
|
3960
|
+
{
|
3961
|
+
PostfixExpressionAST *ast = CreateNode<PostfixExpressionAST>(session->mempool);
|
3962
|
+
ast->type_specifier = typeSpec;
|
3963
|
+
ast->expression = expr;
|
3964
|
+
ast->sub_expressions = sub_expressions;
|
3965
|
+
|
3966
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
3967
|
+
node = ast;
|
3968
|
+
}
|
3969
|
+
|
3970
|
+
return true;
|
3971
|
+
}
|
3972
|
+
|
3973
|
+
bool Parser::parseUnaryExpression(ExpressionAST *&node)
|
3974
|
+
{
|
3975
|
+
std::size_t start = session->token_stream->cursor();
|
3976
|
+
|
3977
|
+
switch(session->token_stream->lookAhead())
|
3978
|
+
{
|
3979
|
+
case Token_incr:
|
3980
|
+
case Token_decr:
|
3981
|
+
case '*':
|
3982
|
+
case '&':
|
3983
|
+
case '+':
|
3984
|
+
case '-':
|
3985
|
+
case '!':
|
3986
|
+
case Token_not:
|
3987
|
+
case '~':
|
3988
|
+
{
|
3989
|
+
std::size_t op = session->token_stream->cursor();
|
3990
|
+
advance();
|
3991
|
+
|
3992
|
+
ExpressionAST *expr = 0;
|
3993
|
+
if (!parseCastExpression(expr))
|
3994
|
+
return false;
|
3995
|
+
|
3996
|
+
UnaryExpressionAST *ast = CreateNode<UnaryExpressionAST>(session->mempool);
|
3997
|
+
ast->op = op;
|
3998
|
+
ast->expression = expr;
|
3999
|
+
|
4000
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
4001
|
+
node = ast;
|
4002
|
+
}
|
4003
|
+
return true;
|
4004
|
+
|
4005
|
+
case Token_sizeof:
|
4006
|
+
{
|
4007
|
+
std::size_t sizeof_token = session->token_stream->cursor();
|
4008
|
+
advance();
|
4009
|
+
|
4010
|
+
SizeofExpressionAST *ast = CreateNode<SizeofExpressionAST>(session->mempool);
|
4011
|
+
ast->sizeof_token = sizeof_token;
|
4012
|
+
|
4013
|
+
std::size_t index = session->token_stream->cursor();
|
4014
|
+
if (session->token_stream->lookAhead() == '(')
|
4015
|
+
{
|
4016
|
+
advance();
|
4017
|
+
if (parseTypeId(ast->type_id) && session->token_stream->lookAhead() == ')')
|
4018
|
+
{
|
4019
|
+
advance(); // skip )
|
4020
|
+
|
4021
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
4022
|
+
node = ast;
|
4023
|
+
return true;
|
4024
|
+
}
|
4025
|
+
|
4026
|
+
ast->type_id = 0;
|
4027
|
+
rewind(index);
|
4028
|
+
}
|
4029
|
+
|
4030
|
+
if (!parseUnaryExpression(ast->expression))
|
4031
|
+
return false;
|
4032
|
+
|
4033
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
4034
|
+
node = ast;
|
4035
|
+
return true;
|
4036
|
+
}
|
4037
|
+
|
4038
|
+
default:
|
4039
|
+
break;
|
4040
|
+
}
|
4041
|
+
|
4042
|
+
int token = session->token_stream->lookAhead();
|
4043
|
+
|
4044
|
+
if (token == Token_new
|
4045
|
+
|| (token == Token_scope && session->token_stream->lookAhead(1) == Token_new))
|
4046
|
+
return parseNewExpression(node);
|
4047
|
+
|
4048
|
+
if (token == Token_delete
|
4049
|
+
|| (token == Token_scope && session->token_stream->lookAhead(1) == Token_delete))
|
4050
|
+
return parseDeleteExpression(node);
|
4051
|
+
|
4052
|
+
return parsePostfixExpression(node);
|
4053
|
+
}
|
4054
|
+
|
4055
|
+
bool Parser::parseNewExpression(ExpressionAST *&node)
|
4056
|
+
{
|
4057
|
+
std::size_t start = session->token_stream->cursor();
|
4058
|
+
|
4059
|
+
NewExpressionAST *ast = CreateNode<NewExpressionAST>(session->mempool);
|
4060
|
+
|
4061
|
+
if (session->token_stream->lookAhead() == Token_scope
|
4062
|
+
&& session->token_stream->lookAhead(1) == Token_new)
|
4063
|
+
{
|
4064
|
+
ast->scope_token = session->token_stream->cursor();
|
4065
|
+
advance();
|
4066
|
+
}
|
4067
|
+
|
4068
|
+
size_t pos = session->token_stream->cursor();
|
4069
|
+
CHECK(Token_new);
|
4070
|
+
ast->new_token = pos;
|
4071
|
+
|
4072
|
+
if (session->token_stream->lookAhead() == '(')
|
4073
|
+
{
|
4074
|
+
advance();
|
4075
|
+
parseCommaExpression(ast->expression);
|
4076
|
+
CHECK(')');
|
4077
|
+
}
|
4078
|
+
|
4079
|
+
if (session->token_stream->lookAhead() == '(')
|
4080
|
+
{
|
4081
|
+
advance();
|
4082
|
+
parseTypeId(ast->type_id);
|
4083
|
+
CHECK(')');
|
4084
|
+
}
|
4085
|
+
else
|
4086
|
+
{
|
4087
|
+
parseNewTypeId(ast->new_type_id);
|
4088
|
+
}
|
4089
|
+
|
4090
|
+
parseNewInitializer(ast->new_initializer);
|
4091
|
+
|
4092
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
4093
|
+
node = ast;
|
4094
|
+
|
4095
|
+
return true;
|
4096
|
+
}
|
4097
|
+
|
4098
|
+
bool Parser::parseNewTypeId(NewTypeIdAST *&node)
|
4099
|
+
{
|
4100
|
+
std::size_t start = session->token_stream->cursor();
|
4101
|
+
|
4102
|
+
TypeSpecifierAST *typeSpec = 0;
|
4103
|
+
if (!parseTypeSpecifier(typeSpec))
|
4104
|
+
return false;
|
4105
|
+
|
4106
|
+
NewTypeIdAST *ast = CreateNode<NewTypeIdAST>(session->mempool);
|
4107
|
+
ast->type_specifier = typeSpec;
|
4108
|
+
|
4109
|
+
parseNewDeclarator(ast->new_declarator);
|
4110
|
+
|
4111
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
4112
|
+
node = ast;
|
4113
|
+
|
4114
|
+
return true;
|
4115
|
+
}
|
4116
|
+
|
4117
|
+
bool Parser::parseNewDeclarator(NewDeclaratorAST *&node)
|
4118
|
+
{
|
4119
|
+
std::size_t start = session->token_stream->cursor();
|
4120
|
+
|
4121
|
+
NewDeclaratorAST *ast = CreateNode<NewDeclaratorAST>(session->mempool);
|
4122
|
+
PtrOperatorAST *ptrOp = 0;
|
4123
|
+
if (parsePtrOperator(ptrOp))
|
4124
|
+
{
|
4125
|
+
ast->ptr_op = ptrOp;
|
4126
|
+
parseNewDeclarator(ast->sub_declarator);
|
4127
|
+
}
|
4128
|
+
|
4129
|
+
while (session->token_stream->lookAhead() == '[')
|
4130
|
+
{
|
4131
|
+
advance();
|
4132
|
+
ExpressionAST *expr = 0;
|
4133
|
+
parseExpression(expr);
|
4134
|
+
ast->expressions = snoc(ast->expressions, expr, session->mempool);
|
4135
|
+
ADVANCE(']', "]");
|
4136
|
+
}
|
4137
|
+
|
4138
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
4139
|
+
node = ast;
|
4140
|
+
|
4141
|
+
return true;
|
4142
|
+
}
|
4143
|
+
|
4144
|
+
bool Parser::parseNewInitializer(NewInitializerAST *&node)
|
4145
|
+
{
|
4146
|
+
std::size_t start = session->token_stream->cursor();
|
4147
|
+
|
4148
|
+
CHECK('(');
|
4149
|
+
|
4150
|
+
NewInitializerAST *ast = CreateNode<NewInitializerAST>(session->mempool);
|
4151
|
+
|
4152
|
+
parseCommaExpression(ast->expression);
|
4153
|
+
|
4154
|
+
CHECK(')');
|
4155
|
+
|
4156
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
4157
|
+
node = ast;
|
4158
|
+
|
4159
|
+
return true;
|
4160
|
+
}
|
4161
|
+
|
4162
|
+
bool Parser::parseDeleteExpression(ExpressionAST *&node)
|
4163
|
+
{
|
4164
|
+
std::size_t start = session->token_stream->cursor();
|
4165
|
+
|
4166
|
+
DeleteExpressionAST *ast = CreateNode<DeleteExpressionAST>(session->mempool);
|
4167
|
+
|
4168
|
+
if (session->token_stream->lookAhead() == Token_scope
|
4169
|
+
&& session->token_stream->lookAhead(1) == Token_delete)
|
4170
|
+
{
|
4171
|
+
ast->scope_token = session->token_stream->cursor();
|
4172
|
+
advance();
|
4173
|
+
}
|
4174
|
+
|
4175
|
+
size_t pos = session->token_stream->cursor();
|
4176
|
+
CHECK(Token_delete);
|
4177
|
+
ast->delete_token = pos;
|
4178
|
+
|
4179
|
+
if (session->token_stream->lookAhead() == '[')
|
4180
|
+
{
|
4181
|
+
ast->lbracket_token = session->token_stream->cursor();
|
4182
|
+
advance();
|
4183
|
+
size_t pos = session->token_stream->cursor();
|
4184
|
+
CHECK(']');
|
4185
|
+
ast->rbracket_token = pos;
|
4186
|
+
}
|
4187
|
+
|
4188
|
+
if (!parseCastExpression(ast->expression))
|
4189
|
+
return false;
|
4190
|
+
|
4191
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
4192
|
+
node = ast;
|
4193
|
+
|
4194
|
+
return true;
|
4195
|
+
}
|
4196
|
+
|
4197
|
+
bool Parser::parseCastExpression(ExpressionAST *&node)
|
4198
|
+
{
|
4199
|
+
std::size_t start = session->token_stream->cursor();
|
4200
|
+
|
4201
|
+
if (session->token_stream->lookAhead() == '(')
|
4202
|
+
{
|
4203
|
+
advance();
|
4204
|
+
|
4205
|
+
CastExpressionAST *ast = CreateNode<CastExpressionAST>(session->mempool);
|
4206
|
+
|
4207
|
+
if (parseTypeId(ast->type_id))
|
4208
|
+
{
|
4209
|
+
if (session->token_stream->lookAhead() == ')')
|
4210
|
+
{
|
4211
|
+
advance();
|
4212
|
+
|
4213
|
+
if (parseCastExpression(ast->expression))
|
4214
|
+
{
|
4215
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
4216
|
+
node = ast;
|
4217
|
+
|
4218
|
+
return true;
|
4219
|
+
}
|
4220
|
+
}
|
4221
|
+
}
|
4222
|
+
}
|
4223
|
+
|
4224
|
+
rewind(start);
|
4225
|
+
return parseUnaryExpression(node);
|
4226
|
+
}
|
4227
|
+
|
4228
|
+
bool Parser::parsePmExpression(ExpressionAST *&node)
|
4229
|
+
{
|
4230
|
+
std::size_t start = session->token_stream->cursor();
|
4231
|
+
|
4232
|
+
if (!parseCastExpression(node) || !node) // ### fixme
|
4233
|
+
return false;
|
4234
|
+
|
4235
|
+
while (session->token_stream->lookAhead() == Token_ptrmem)
|
4236
|
+
{
|
4237
|
+
std::size_t op = session->token_stream->cursor();
|
4238
|
+
advance();
|
4239
|
+
|
4240
|
+
ExpressionAST *rightExpr = 0;
|
4241
|
+
if (!parseCastExpression(rightExpr))
|
4242
|
+
return false;
|
4243
|
+
|
4244
|
+
BinaryExpressionAST *ast = CreateNode<BinaryExpressionAST>(session->mempool);
|
4245
|
+
ast->op = op;
|
4246
|
+
ast->left_expression = node;
|
4247
|
+
ast->right_expression = rightExpr;
|
4248
|
+
|
4249
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
4250
|
+
node = ast;
|
4251
|
+
}
|
4252
|
+
|
4253
|
+
return true;
|
4254
|
+
}
|
4255
|
+
|
4256
|
+
bool Parser::parseMultiplicativeExpression(ExpressionAST *&node)
|
4257
|
+
{
|
4258
|
+
std::size_t start = session->token_stream->cursor();
|
4259
|
+
|
4260
|
+
if (!parsePmExpression(node))
|
4261
|
+
return false;
|
4262
|
+
|
4263
|
+
while (session->token_stream->lookAhead() == '*'
|
4264
|
+
|| session->token_stream->lookAhead() == '/'
|
4265
|
+
|| session->token_stream->lookAhead() == '%')
|
4266
|
+
{
|
4267
|
+
std::size_t op = session->token_stream->cursor();
|
4268
|
+
advance();
|
4269
|
+
|
4270
|
+
ExpressionAST *rightExpr = 0;
|
4271
|
+
if (!parsePmExpression(rightExpr))
|
4272
|
+
return false;
|
4273
|
+
|
4274
|
+
BinaryExpressionAST *ast = CreateNode<BinaryExpressionAST>(session->mempool);
|
4275
|
+
ast->op = op;
|
4276
|
+
ast->left_expression = node;
|
4277
|
+
ast->right_expression = rightExpr;
|
4278
|
+
|
4279
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
4280
|
+
node = ast;
|
4281
|
+
}
|
4282
|
+
|
4283
|
+
return true;
|
4284
|
+
}
|
4285
|
+
|
4286
|
+
|
4287
|
+
bool Parser::parseAdditiveExpression(ExpressionAST *&node)
|
4288
|
+
{
|
4289
|
+
std::size_t start = session->token_stream->cursor();
|
4290
|
+
|
4291
|
+
if (!parseMultiplicativeExpression(node))
|
4292
|
+
return false;
|
4293
|
+
|
4294
|
+
while (session->token_stream->lookAhead() == '+' || session->token_stream->lookAhead() == '-')
|
4295
|
+
{
|
4296
|
+
std::size_t op = session->token_stream->cursor();
|
4297
|
+
advance();
|
4298
|
+
|
4299
|
+
ExpressionAST *rightExpr = 0;
|
4300
|
+
if (!parseMultiplicativeExpression(rightExpr))
|
4301
|
+
return false;
|
4302
|
+
|
4303
|
+
BinaryExpressionAST *ast = CreateNode<BinaryExpressionAST>(session->mempool);
|
4304
|
+
ast->op = op;
|
4305
|
+
ast->left_expression = node;
|
4306
|
+
ast->right_expression = rightExpr;
|
4307
|
+
|
4308
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
4309
|
+
node = ast;
|
4310
|
+
}
|
4311
|
+
|
4312
|
+
return true;
|
4313
|
+
}
|
4314
|
+
|
4315
|
+
bool Parser::parseShiftExpression(ExpressionAST *&node)
|
4316
|
+
{
|
4317
|
+
std::size_t start = session->token_stream->cursor();
|
4318
|
+
|
4319
|
+
if (!parseAdditiveExpression(node))
|
4320
|
+
return false;
|
4321
|
+
|
4322
|
+
while (session->token_stream->lookAhead() == Token_shift)
|
4323
|
+
{
|
4324
|
+
std::size_t op = session->token_stream->cursor();
|
4325
|
+
advance();
|
4326
|
+
|
4327
|
+
ExpressionAST *rightExpr = 0;
|
4328
|
+
if (!parseAdditiveExpression(rightExpr))
|
4329
|
+
return false;
|
4330
|
+
|
4331
|
+
BinaryExpressionAST *ast = CreateNode<BinaryExpressionAST>(session->mempool);
|
4332
|
+
ast->op = op;
|
4333
|
+
ast->left_expression = node;
|
4334
|
+
ast->right_expression = rightExpr;
|
4335
|
+
|
4336
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
4337
|
+
node = ast;
|
4338
|
+
}
|
4339
|
+
|
4340
|
+
return true;
|
4341
|
+
}
|
4342
|
+
|
4343
|
+
bool Parser::parseRelationalExpression(ExpressionAST *&node, bool templArgs)
|
4344
|
+
{
|
4345
|
+
std::size_t start = session->token_stream->cursor();
|
4346
|
+
|
4347
|
+
if (!parseShiftExpression(node))
|
4348
|
+
return false;
|
4349
|
+
|
4350
|
+
while (session->token_stream->lookAhead() == '<'
|
4351
|
+
|| (session->token_stream->lookAhead() == '>' && !templArgs)
|
4352
|
+
|| session->token_stream->lookAhead() == Token_leq
|
4353
|
+
|| session->token_stream->lookAhead() == Token_geq)
|
4354
|
+
{
|
4355
|
+
std::size_t op = session->token_stream->cursor();
|
4356
|
+
advance();
|
4357
|
+
|
4358
|
+
ExpressionAST *rightExpr = 0;
|
4359
|
+
if (!parseShiftExpression(rightExpr))
|
4360
|
+
return false;
|
4361
|
+
|
4362
|
+
BinaryExpressionAST *ast = CreateNode<BinaryExpressionAST>(session->mempool);
|
4363
|
+
ast->op = op;
|
4364
|
+
ast->left_expression = node;
|
4365
|
+
ast->right_expression = rightExpr;
|
4366
|
+
|
4367
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
4368
|
+
node = ast;
|
4369
|
+
}
|
4370
|
+
|
4371
|
+
return true;
|
4372
|
+
}
|
4373
|
+
|
4374
|
+
bool Parser::parseEqualityExpression(ExpressionAST *&node, bool templArgs)
|
4375
|
+
{
|
4376
|
+
std::size_t start = session->token_stream->cursor();
|
4377
|
+
|
4378
|
+
if (!parseRelationalExpression(node, templArgs))
|
4379
|
+
return false;
|
4380
|
+
|
4381
|
+
while (session->token_stream->lookAhead() == Token_eq
|
4382
|
+
|| session->token_stream->lookAhead() == Token_not_eq)
|
4383
|
+
{
|
4384
|
+
std::size_t op = session->token_stream->cursor();
|
4385
|
+
advance();
|
4386
|
+
|
4387
|
+
ExpressionAST *rightExpr = 0;
|
4388
|
+
if (!parseRelationalExpression(rightExpr, templArgs))
|
4389
|
+
return false;
|
4390
|
+
|
4391
|
+
BinaryExpressionAST *ast = CreateNode<BinaryExpressionAST>(session->mempool);
|
4392
|
+
ast->op = op;
|
4393
|
+
ast->left_expression = node;
|
4394
|
+
ast->right_expression = rightExpr;
|
4395
|
+
|
4396
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
4397
|
+
node = ast;
|
4398
|
+
}
|
4399
|
+
|
4400
|
+
return true;
|
4401
|
+
}
|
4402
|
+
|
4403
|
+
bool Parser::parseAndExpression(ExpressionAST *&node, bool templArgs)
|
4404
|
+
{
|
4405
|
+
std::size_t start = session->token_stream->cursor();
|
4406
|
+
|
4407
|
+
if (!parseEqualityExpression(node, templArgs))
|
4408
|
+
return false;
|
4409
|
+
|
4410
|
+
while (session->token_stream->lookAhead() == '&')
|
4411
|
+
{
|
4412
|
+
std::size_t op = session->token_stream->cursor();
|
4413
|
+
advance();
|
4414
|
+
|
4415
|
+
ExpressionAST *rightExpr = 0;
|
4416
|
+
if (!parseEqualityExpression(rightExpr, templArgs))
|
4417
|
+
return false;
|
4418
|
+
|
4419
|
+
BinaryExpressionAST *ast = CreateNode<BinaryExpressionAST>(session->mempool);
|
4420
|
+
ast->op = op;
|
4421
|
+
ast->left_expression = node;
|
4422
|
+
ast->right_expression = rightExpr;
|
4423
|
+
|
4424
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
4425
|
+
node = ast;
|
4426
|
+
}
|
4427
|
+
|
4428
|
+
return true;
|
4429
|
+
}
|
4430
|
+
|
4431
|
+
bool Parser::parseExclusiveOrExpression(ExpressionAST *&node, bool templArgs)
|
4432
|
+
{
|
4433
|
+
std::size_t start = session->token_stream->cursor();
|
4434
|
+
|
4435
|
+
if (!parseAndExpression(node, templArgs))
|
4436
|
+
return false;
|
4437
|
+
|
4438
|
+
while (session->token_stream->lookAhead() == '^')
|
4439
|
+
{
|
4440
|
+
std::size_t op = session->token_stream->cursor();
|
4441
|
+
advance();
|
4442
|
+
|
4443
|
+
ExpressionAST *rightExpr = 0;
|
4444
|
+
if (!parseAndExpression(rightExpr, templArgs))
|
4445
|
+
return false;
|
4446
|
+
|
4447
|
+
BinaryExpressionAST *ast = CreateNode<BinaryExpressionAST>(session->mempool);
|
4448
|
+
ast->op = op;
|
4449
|
+
ast->left_expression = node;
|
4450
|
+
ast->right_expression = rightExpr;
|
4451
|
+
|
4452
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
4453
|
+
node = ast;
|
4454
|
+
}
|
4455
|
+
|
4456
|
+
return true;
|
4457
|
+
}
|
4458
|
+
|
4459
|
+
bool Parser::parseInclusiveOrExpression(ExpressionAST *&node, bool templArgs)
|
4460
|
+
{
|
4461
|
+
std::size_t start = session->token_stream->cursor();
|
4462
|
+
|
4463
|
+
if (!parseExclusiveOrExpression(node, templArgs))
|
4464
|
+
return false;
|
4465
|
+
|
4466
|
+
while (session->token_stream->lookAhead() == '|')
|
4467
|
+
{
|
4468
|
+
std::size_t op = session->token_stream->cursor();
|
4469
|
+
advance();
|
4470
|
+
|
4471
|
+
ExpressionAST *rightExpr = 0;
|
4472
|
+
if (!parseExclusiveOrExpression(rightExpr, templArgs))
|
4473
|
+
return false;
|
4474
|
+
|
4475
|
+
BinaryExpressionAST *ast = CreateNode<BinaryExpressionAST>(session->mempool);
|
4476
|
+
ast->op = op;
|
4477
|
+
ast->left_expression = node;
|
4478
|
+
ast->right_expression = rightExpr;
|
4479
|
+
|
4480
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
4481
|
+
node = ast;
|
4482
|
+
}
|
4483
|
+
|
4484
|
+
return true;
|
4485
|
+
}
|
4486
|
+
|
4487
|
+
bool Parser::parseLogicalAndExpression(ExpressionAST *&node, bool templArgs)
|
4488
|
+
{
|
4489
|
+
std::size_t start = session->token_stream->cursor();
|
4490
|
+
|
4491
|
+
if (!parseInclusiveOrExpression(node, templArgs))
|
4492
|
+
return false;
|
4493
|
+
|
4494
|
+
while (session->token_stream->lookAhead() == Token_and)
|
4495
|
+
{
|
4496
|
+
std::size_t op = session->token_stream->cursor();
|
4497
|
+
advance();
|
4498
|
+
|
4499
|
+
ExpressionAST *rightExpr = 0;
|
4500
|
+
if (!parseInclusiveOrExpression(rightExpr, templArgs))
|
4501
|
+
return false;
|
4502
|
+
|
4503
|
+
BinaryExpressionAST *ast = CreateNode<BinaryExpressionAST>(session->mempool);
|
4504
|
+
ast->op = op;
|
4505
|
+
ast->left_expression = node;
|
4506
|
+
ast->right_expression = rightExpr;
|
4507
|
+
|
4508
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
4509
|
+
node = ast;
|
4510
|
+
}
|
4511
|
+
|
4512
|
+
return true;
|
4513
|
+
}
|
4514
|
+
|
4515
|
+
bool Parser::parseLogicalOrExpression(ExpressionAST *&node, bool templArgs)
|
4516
|
+
{
|
4517
|
+
std::size_t start = session->token_stream->cursor();
|
4518
|
+
|
4519
|
+
if (!parseLogicalAndExpression(node, templArgs))
|
4520
|
+
return false;
|
4521
|
+
|
4522
|
+
while (session->token_stream->lookAhead() == Token_or)
|
4523
|
+
{
|
4524
|
+
std::size_t op = session->token_stream->cursor();
|
4525
|
+
advance();
|
4526
|
+
|
4527
|
+
ExpressionAST *rightExpr = 0;
|
4528
|
+
if (!parseLogicalAndExpression(rightExpr, templArgs))
|
4529
|
+
return false;
|
4530
|
+
|
4531
|
+
BinaryExpressionAST *ast = CreateNode<BinaryExpressionAST>(session->mempool);
|
4532
|
+
ast->op = op;
|
4533
|
+
ast->left_expression = node;
|
4534
|
+
ast->right_expression = rightExpr;
|
4535
|
+
|
4536
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
4537
|
+
node = ast;
|
4538
|
+
}
|
4539
|
+
|
4540
|
+
return true;
|
4541
|
+
}
|
4542
|
+
|
4543
|
+
bool Parser::parseConditionalExpression(ExpressionAST *&node)
|
4544
|
+
{
|
4545
|
+
std::size_t start = session->token_stream->cursor();
|
4546
|
+
|
4547
|
+
if (!parseLogicalOrExpression(node))
|
4548
|
+
return false;
|
4549
|
+
|
4550
|
+
if (session->token_stream->lookAhead() == '?')
|
4551
|
+
{
|
4552
|
+
advance();
|
4553
|
+
|
4554
|
+
ExpressionAST *leftExpr = 0;
|
4555
|
+
if (!parseExpression(leftExpr))
|
4556
|
+
return false;
|
4557
|
+
|
4558
|
+
CHECK(':');
|
4559
|
+
|
4560
|
+
ExpressionAST *rightExpr = 0;
|
4561
|
+
if (!parseAssignmentExpression(rightExpr))
|
4562
|
+
return false;
|
4563
|
+
|
4564
|
+
ConditionalExpressionAST *ast
|
4565
|
+
= CreateNode<ConditionalExpressionAST>(session->mempool);
|
4566
|
+
|
4567
|
+
ast->condition = node;
|
4568
|
+
ast->left_expression = leftExpr;
|
4569
|
+
ast->right_expression = rightExpr;
|
4570
|
+
|
4571
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
4572
|
+
node = ast;
|
4573
|
+
}
|
4574
|
+
|
4575
|
+
return true;
|
4576
|
+
}
|
4577
|
+
|
4578
|
+
bool Parser::parseAssignmentExpression(ExpressionAST *&node)
|
4579
|
+
{
|
4580
|
+
std::size_t start = session->token_stream->cursor();
|
4581
|
+
|
4582
|
+
if(parseSignalSlotExpression(node))
|
4583
|
+
return true;
|
4584
|
+
//Parsed a signal/slot expression, fine
|
4585
|
+
|
4586
|
+
if (session->token_stream->lookAhead() == Token_throw && !parseThrowExpression(node))
|
4587
|
+
return false;
|
4588
|
+
else if (!parseConditionalExpression(node))
|
4589
|
+
return false;
|
4590
|
+
|
4591
|
+
while (session->token_stream->lookAhead() == Token_assign
|
4592
|
+
|| session->token_stream->lookAhead() == '=')
|
4593
|
+
{
|
4594
|
+
std::size_t op = session->token_stream->cursor();
|
4595
|
+
advance();
|
4596
|
+
|
4597
|
+
ExpressionAST *rightExpr = 0;
|
4598
|
+
if (!parseConditionalExpression(rightExpr))
|
4599
|
+
return false;
|
4600
|
+
|
4601
|
+
BinaryExpressionAST *ast = CreateNode<BinaryExpressionAST>(session->mempool);
|
4602
|
+
ast->op = op;
|
4603
|
+
ast->left_expression = node;
|
4604
|
+
ast->right_expression = rightExpr;
|
4605
|
+
|
4606
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
4607
|
+
node = ast;
|
4608
|
+
}
|
4609
|
+
|
4610
|
+
return true;
|
4611
|
+
}
|
4612
|
+
|
4613
|
+
bool Parser::parseConstantExpression(ExpressionAST *&node)
|
4614
|
+
{
|
4615
|
+
return parseConditionalExpression(node);
|
4616
|
+
}
|
4617
|
+
|
4618
|
+
bool Parser::parseExpression(ExpressionAST *&node)
|
4619
|
+
{
|
4620
|
+
return parseCommaExpression(node);
|
4621
|
+
}
|
4622
|
+
|
4623
|
+
bool Parser::parseSignalSlotExpression(ExpressionAST *&node) {
|
4624
|
+
if(session->token_stream->lookAhead() == Token___qt_sig_slot__) {
|
4625
|
+
std::size_t start = session->token_stream->cursor();
|
4626
|
+
CHECK(Token___qt_sig_slot__);
|
4627
|
+
CHECK('(');
|
4628
|
+
|
4629
|
+
SignalSlotExpressionAST *ast = CreateNode<SignalSlotExpressionAST>(session->mempool);
|
4630
|
+
parseUnqualifiedName(ast->name, false);
|
4631
|
+
CHECK('(');
|
4632
|
+
|
4633
|
+
if(ast->name)
|
4634
|
+
parseTemplateArgumentList(ast->name->template_arguments);
|
4635
|
+
|
4636
|
+
CHECK(')');
|
4637
|
+
|
4638
|
+
if(ast->name)
|
4639
|
+
ast->name->end_token = _M_last_valid_token+1;
|
4640
|
+
|
4641
|
+
CHECK(')');
|
4642
|
+
|
4643
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
4644
|
+
node = ast;
|
4645
|
+
|
4646
|
+
return true;
|
4647
|
+
}else{
|
4648
|
+
return false;
|
4649
|
+
}
|
4650
|
+
}
|
4651
|
+
|
4652
|
+
bool Parser::parseCommaExpression(ExpressionAST *&node)
|
4653
|
+
{
|
4654
|
+
std::size_t start = session->token_stream->cursor();
|
4655
|
+
|
4656
|
+
if (!parseAssignmentExpression(node))
|
4657
|
+
return false;
|
4658
|
+
|
4659
|
+
while (session->token_stream->lookAhead() == ',')
|
4660
|
+
{
|
4661
|
+
std::size_t op = session->token_stream->cursor();
|
4662
|
+
advance();
|
4663
|
+
|
4664
|
+
ExpressionAST *rightExpr = 0;
|
4665
|
+
if (!parseAssignmentExpression(rightExpr))
|
4666
|
+
return false;
|
4667
|
+
|
4668
|
+
BinaryExpressionAST *ast = CreateNode<BinaryExpressionAST>(session->mempool);
|
4669
|
+
ast->op = op;
|
4670
|
+
ast->left_expression = node;
|
4671
|
+
ast->right_expression = rightExpr;
|
4672
|
+
|
4673
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
4674
|
+
node = ast;
|
4675
|
+
}
|
4676
|
+
|
4677
|
+
return true;
|
4678
|
+
}
|
4679
|
+
|
4680
|
+
bool Parser::parseThrowExpression(ExpressionAST *&node)
|
4681
|
+
{
|
4682
|
+
std::size_t start = session->token_stream->cursor();
|
4683
|
+
|
4684
|
+
size_t pos = session->token_stream->cursor();
|
4685
|
+
|
4686
|
+
CHECK(Token_throw);
|
4687
|
+
|
4688
|
+
ThrowExpressionAST *ast = CreateNode<ThrowExpressionAST>(session->mempool);
|
4689
|
+
ast->throw_token = pos;
|
4690
|
+
|
4691
|
+
parseAssignmentExpression(ast->expression);
|
4692
|
+
|
4693
|
+
UPDATE_POS(ast, start, _M_last_valid_token+1);
|
4694
|
+
node = ast;
|
4695
|
+
|
4696
|
+
return true;
|
4697
|
+
}
|
4698
|
+
|
4699
|
+
bool Parser::holdErrors(bool hold)
|
4700
|
+
{
|
4701
|
+
bool current = _M_hold_errors;
|
4702
|
+
_M_hold_errors = hold;
|
4703
|
+
return current;
|
4704
|
+
}
|
4705
|
+
|
4706
|
+
|