The goal is to use strong typing, while still be able to use low level whenever you choose.
pas2js is written completely in FPC, runs on many platforms like Windows, Mac and Linux and more. It is built modular consisting of the following parts:
- file cache – loading, caching files, converting to UTF-8
- file resolver – handling search paths, finding used units and include files
- scanner – reading tokens, handling compiler directives like $IfDef and $Include
- parser – reading the tokens, checking syntax, creating Pascal nodes
- resolver – resolving references, type checking and checking duplicate identifiers
- use analyzer – finding unused identifiers, emit hints and warning
- compiler – handling config files, parameters, compiling recursively all used units, writes js
- command line interface – a small wrapper to embed the compiler into a console program
- library and interface – a small wrapper to embed the compiler into a library
Each part is tested separately and is used by other FPC tools as well. For example the scanner and parser are used by fpdoc too. Thus they are tested and extended by other programmers, reducing greatly the work for developing pas2js. Consistency is kept by several test suites, containing thousands of tests.
Command line parameters
Most parameters work the same as their FPC equivalent. pas2js has some options of its own (see -J options).