Comments (12)
Please download the latest sources. Then make sure that you defined a platform's defines before parsing. This was fine for me (tested with XE7):
ASTBuilder.AddDefine('MSWINDOWS');
ASTBuilder.AddDefine('CPUX86');
Please confirm that it works for you now :)
from delphiast.
Using latest version of your demo, @RomanYankovsky, parsing XE7's System.pas unit... I'm getting the same error as @sglienke.
The line it's failing on is 5442, and appears to be related to the Defines not being handled properly. I'm checking to see if this has anything to do with my modifications to the conditional defines handling, but it shouldn't because these are {$IFDEF} expressions not {$IF DEFINED(CONDITION)} (which is what I improved for you the other day).
I'll make the code break on IFDEF expressions only when Y > 5415 and step through the code to see where it's going wrong.
from delphiast.
I guess that's because demo doesn't define CPUX86.
from delphiast.
Extra bit of information, and this is a strange one.
Looking at the Lexer's FDefined list at the point of failure, the list is completely empty!
CPUX86' define is definitely in there (I added it myself along with all the other standard compiler defines up to XE7's list, which was in the merge you did from my pull request the other day).
EDIT: To be clear, the procedure on which it is failing is _UGetDir originating on line 5416 and ending line 5442.
from delphiast.
Okay, why is there an "Exit" call on line 2331 of SimpleParser.Lexer.pas? This means that none of the necessary defines are being added to the Lexer's FDefines list!
from delphiast.
Removing that "Exit" call from line 2331 makes it parse all the way up to line 39592 with a different error, which is the "initialization" section. Error message is "Begin expected, found initialization"
from delphiast.
Please make sure that you have merged latest changes. Empty define list was fixed yesterday with commit 7c061bb, and default defines were moved to other method with commit 7b5d5af.
from delphiast.
Also I updated the demo a couple of minutes ago. Now it's fine.
P.S. I moved default defines to other method because it's not always needed. For instance, you may run parser on Windows machine, but want to parse Android code. Especially, if you develop an IDE expert.
from delphiast.
I accidentally pulled from my fork instead of the upstream. Pulling from the upstream it now parses (and takes a VERY long time to produce the XML)
And yes, your "outsourcing" of the defines makes perfect sense in that context.
from delphiast.
Yup. Actually parser is fast (less than a second to parse System.pas on my laptop), but converting a tree of TSyntaxNode to XML takes A LOT of time...
from delphiast.
It's a massive unit, so it doesn't surprise me that generating all of that XML data takes a significant amount of time. For my purposes, that's not a problem as I'm not using the XML output, but rather the TSyntaxNode directly.
from delphiast.
Fixed.
from delphiast.
Related Issues (20)
- Can't parse System.Classes.pas HOT 2
- Can't parse Posix.SysSocket.pas
- Can't parse System.Internal.Unwinder.pas
- Attributes for variant record fields missing HOT 2
- How to compile in Lazarus v2.0.6 HOT 2
- Need list of all comments HOT 10
- Need feature to REMOVE all elements of a specific type from the source HOT 1
- Get the end_line and end_col of a multi-line comment? HOT 3
- Lexer does not fully initializes its state HOT 1
- Possible string mismatch? HOT 2
- Lexer does not parse Unicode characters
- Procedure declaration with varargs directive is not fully supported
- {$I ..\file.inc} is not proceed correctly
- delphi2007 compile failed HOT 1
- Cannot parse System.SysUtils in 10.4.2 - should there be a default set of defines? HOT 7
- FreePascal demo is not working HOT 2
- Lexer failes parsing generic types with default value without spacecing inbetween
- Error when assigning a initial value to generic "global" variable in a specific way. HOT 1
- Should an empty begin/end block be classified as `ntEmptyStatement` ? HOT 1
- Bing chat claims: DelphiAST.Helpers file exist but it's not there ? What is going on ?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from delphiast.