Commit graph

17 commits

Author SHA1 Message Date
turleypol
7627e3d353
"Preview/Initial"- Version sourcecode formatting feature (#626)
* Squash only prettify changes from escript_formating_try

* support of "format-off" / "format-on" comments to mark areas without
formatting

* fix typo

* added FormatterIdentLevel, FormatterMergeEmptyLines cfg entry
better line splits for dicts/arrays

* added several spacing options. the current setting list is now:
//LineWidth
FormatterLineWidth 80
// keep original keyword spelling
FormatterKeepKeywords 0
// number of spaces for ident
FormatterIdentLevel 2
// multiple newlines get merged to a single
FormatterMergeEmptyLines 1
// space between emtpy parenthesis eg foo() vs foo( )
FormatterEmptyParenthesisSpacing 0
// space between emtpy brackets eg struct{} vs struct{ }
FormatterEmptyBracketSpacing 0
// space after/before parenthesis in conditionals
// eg if ( true ) vs if (true)
FormatterConditionalParenthesisSpacing 1
// space after/before parenthesis
// eg foo( true ) vs foo(true)
FormatterParenthesisSpacing 1
// space after/before brackets
// eg array{ true } vs array{true}
FormatterBracketSpacing 1
// add space after delimiter comma or semi in for loops
// eg {1, 2, 3} vs {1,2,3}
FormatterDelimiterSpacing 1
// add space around assignment
// eg a := 1; vs a:=1;
FormatterAssignmentSpacing 1
// add space around comparison
// eg a == 1 vs a==1
FormatterComparisonSpacing 1
// add space around operations
// eg a + 1 vs a+1
FormatterOperatorSpacing 1
// use \r\n as newline instead of \n
FormatterWindowsLineEndings 0

* added tab support
// use tabs instead of spaces
FormatterUseTabs 0
// tab width
FormatterTabWidth 4

* extended example ecompile.cfg with formatter settings

* cleanup

* program args comma is optional...
fixed line comments in group splitting

* since tokenids are now correct no more guessing for linecomments needed

* comments use as start tokenid the whitespace token if its on the same
line

* splitted processing from linebuilding

* renamed TokenPart to FmtToken better matches the purpose.
Comments get directly stored as FmtToken
started with a context enum

* better(?) formatting for groups

* fix eof rawlines
added check that all comments/rawlines got parsed

* const correctness

* datatype adapted to antlr

* fixed warnings

* added InsertNewlineAtEOF

* add newline at the end if the original file had one
dont strip comment whitespace if its somejind of "header block"
use the defined lineending for /* */ comments

* docs

* \r\n is default on windows \n otherwise

* fixed warning

---------

Co-authored-by: Kevin Eady <8634912+KevinEady@users.noreply.github.com>
2024-02-26 21:21:44 +01:00
Kevin Eady
9c36b977cd
Internal work to remove OGC (#384)
* Remove LegacyFunctionOrder

* Remove compiler.cpp, compiler.h

* Remove parser.cpp/h and wordlist generation

* Update breaking-changes, core-changes
2021-03-06 01:39:26 +01:00
Kevin Eady
ae96ecbf77
Remove OGC from EcompileMain, testsuites (#383)
* Remove OGC from escript testsuite

* Remove compiler options

* Remove Facility::Compiler

* Update docs and options in ecompile help usage

* Update core-changes, breaking-changes
2021-03-04 17:39:14 +01:00
Eric Swanson
89d663ca00
Use new compiler (when configured) for compile_inc (#303) 2020-09-13 00:41:45 -07:00
Eric Swanson
7598c9486f
Disallow function names as variable, argument, and const names (#298) 2020-09-11 00:16:20 -07:00
Eric Swanson
50e42719b8
Add file/SourceFileCache (#222)
* Add file/SourceFileCache

Co-authored-by: Fernando Rozenblit <rozenblit@gmail.com>
2020-08-16 17:22:16 -07:00
Eric Swanson
841bc928d3
Normalize include paths (#221) 2020-08-15 08:01:19 +02:00
Eric Swanson
6b3fdcb263
Add CodeGenerator stub (#206)
* Add codegen/CodeGenerator stub

* Destructor is trivial
2020-08-11 09:08:48 +02:00
Eric Swanson
72bd179051
Add analyzer/Disambiguator stub (#205)
The Disambiguator will correct the AST based on context.

At present, it needs to handle ambiguities in the grammar between
case group selectors and named break/continue labels.
2020-08-11 08:21:34 +02:00
Eric Swanson
d184dda473
Add Optimizer stub (#203) 2020-08-10 13:54:59 +02:00
Eric Swanson
435db9dc07
bscript/compiler: use c++17 nested namespace definitions (#202) 2020-08-10 12:20:29 +02:00
Eric Swanson
eb6594b4c6
Add ast/NodeVisitor, analyzer/SemanticAnalyzer stubs (#201) 2020-08-10 10:37:07 +02:00
Eric Swanson
2e1870028b
Add model/CompilerWorkspace, astbuilder/BuilderWorkspace, astbuilder/CompilerWorkspaceBuilder (#200)
Add astbuilder/BuilderWorkspace:
  - Temporary workspace used while building the AST (which goes in the CompilerWorkspace)

Add astbuilder/CompilerWorkspaceBuilder:
  - Builds a CompilerWorkspace for a script

Add model/CompilerWorkspace:
  - Holds AST
  - Holds some intermediate data used by semantic analyzer, optimizer, code generator
2020-08-10 09:42:37 +02:00
Eric Swanson
63326cd44c
Add format/ CompiledScriptSerializer (#198)
* Add format/ CompiledScriptSerializer

* Add CompiledScript output, write with CompiledScriptSerializer
2020-08-10 09:00:47 +02:00
Eric Swanson
cc28f4f4f2
Add compiler/ Profile and Report (#193)
* Add compiler/Profile

* Add compiler/Report

* From CR notes: add newline on caught exception.
Also added comments that messages should have a newline at the end.
2020-08-08 16:31:55 +02:00
Eric Swanson
49ec52beae
Add ecompile mode: compare old and new compiler output (#187)
* Add -G / CompareCompilerOutput ecompile mode that runs old and new compiler and compares output.
Add LegacyFunctionOrder because parity needs to know how the old compiler ordered functions.

* Fix class/struct mixup, add to cmake sources
2020-08-05 09:01:07 +02:00
Eric Swanson
6e8c7ad074
Add stub for new compiler, with -g and UseCompiler2020 options to select. (#184) 2020-08-05 07:42:46 +02:00