Skip to content

Commit

Permalink
Merge pull request #149 from ortus-boxlang/development
Browse files Browse the repository at this point in the history
1.0.0-Beta25
  • Loading branch information
lmajano authored Dec 13, 2024
2 parents fee7d42 + e1c6c59 commit 69e60a2
Show file tree
Hide file tree
Showing 486 changed files with 16,129 additions and 12,619 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ root = true
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
trim_trailing_whitespace = false
insert_final_newline = false
indent_style = tab
indent_size = 4
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ jobs:
SLACK_TITLE: "${{ github.repository }} Build Failure"
SLACK_USERNAME: CI
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
MSG_MINIMAL: true

publish-test-results:
name: Publish Test Results
Expand Down
12 changes: 7 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ dependencies {
testImplementation "com.google.truth:truth:1.+"
testImplementation "commons-cli:commons-cli:1.9.0"
// https://wiremock.org/
testImplementation "org.wiremock:wiremock:3.9.2"
testImplementation "org.wiremock:wiremock:3.10.0"
// https://mvnrepository.com/artifact/org.apache.derby/derby
testImplementation 'org.apache.derby:derby:10.17.1.0'
testImplementation 'io.undertow:undertow-core:2.3.18.Final'
Expand All @@ -118,13 +118,13 @@ dependencies {
// https://mvnrepository.com/artifact/org.apache.commons/commons-cli
implementation "commons-cli:commons-cli:1.9.0"
// https://mvnrepository.com/artifact/com.fasterxml.jackson.jr/jackson-jr-objects
implementation 'com.fasterxml.jackson.jr:jackson-jr-objects:2.18.1'
implementation 'com.fasterxml.jackson.jr:jackson-jr-objects:2.18.2'
// https://mvnrepository.com/artifact/com.fasterxml.jackson.jr/jackson-jr-extension-javatime
implementation 'com.fasterxml.jackson.jr:jackson-jr-extension-javatime:2.18.1'
implementation 'com.fasterxml.jackson.jr:jackson-jr-extension-javatime:2.18.2'
// https://mvnrepository.com/artifact/com.fasterxml.jackson.jr/jackson-jr-stree
implementation 'com.fasterxml.jackson.jr:jackson-jr-stree:2.18.1'
implementation 'com.fasterxml.jackson.jr:jackson-jr-stree:2.18.2'
// https://mvnrepository.com/artifact/com.fasterxml.jackson.jr/jackson-jr-annotation-support
implementation 'com.fasterxml.jackson.jr:jackson-jr-annotation-support:2.18.1'
implementation 'com.fasterxml.jackson.jr:jackson-jr-annotation-support:2.18.2'
// https://mvnrepository.com/artifact/org.slf4j/slf4j-api
implementation 'org.slf4j:slf4j-api:2.0.16'
// https://mvnrepository.com/artifact/ch.qos.logback/logback-classic
Expand Down Expand Up @@ -235,6 +235,8 @@ shadowJar {
}

test {
systemProperty 'boxlang.experimental.compiler', System.getProperty('boxlang.experimental.compiler', "java")

testLogging {
events "FAILED", "STANDARD_ERROR"
}
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Sat Nov 23 12:24:04 UTC 2024
#Mon Dec 02 11:29:56 UTC 2024
antlrVersion=4.13.1
jdkVersion=21
version=1.0.0-beta24
version=1.0.0-beta25
2 changes: 1 addition & 1 deletion modules/bx-derby/ModuleConfig.bx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class{
/**
* This boolean flag tells the module service to skip the module registration/activation process.
*/
this.disabled = false;
this.enabled = true;

/**
* --------------------------------------------------------------------------
Expand Down
45 changes: 24 additions & 21 deletions src/main/antlr/CFLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -102,27 +102,6 @@ options {
@members {
public int popMode() {
System.out.println( "popMode back to "+
modeNames[_modeStack.peek()]);
return super.popMode();
}
public void pushMode(int m) {
System.out.println( "pushMode "+modeNames[m]);
super.pushMode(m);
System.out.println( "*****
modes ******" );
System.out.println( "mode: " + modeNames[_mode] );
for ( int m2 :
_modeStack.toArray() ) {
System.out.println( "mode: " + modeNames[m2] );
}
System.out.println(
"***** end modes ******" );
}
public Token emit() {
Token t =
_factory.create(_tokenFactorySourcePair, _type, _text, _channel, _tokenStartCharIndex,
Expand All @@ -133,6 +112,21 @@ options {
t.toString() + " " + _SYMBOLIC_NAMES[t.getType()] );
return t;
}
public int popMode() {
System.out.println( "popMode back to "+ modeNames[_modeStack.peek()]);
return super.popMode();
}
public void pushMode(int m) {
System.out.println( "pushMode "+modeNames[m]);
super.pushMode(m);
System.out.print( ">>>>> modes >>>>> " );
for ( int m2 : _modeStack.toArray() ) {
System.out.print( " > " + modeNames[m2] );
}
System.out.println( " > " + modeNames[_mode] );
}
}
*/
Expand Down Expand Up @@ -644,6 +638,10 @@ COMPONENT_SLASH_CLOSE2:
;

// There may be no value, so we need to pop out of ATTVALUE if we find the end of the component
COMPONENT_CLOSE6:
'>' {isQuery}? -> popMode, popMode, popMode, popMode, pushMode(TEMPLATE_OUTPUT_MODE), pushMode(DEFAULT_TEMPLATE_MODE), type(COMPONENT_CLOSE)
;

COMPONENT_CLOSE5: '>' -> popMode, popMode, popMode, popMode, type(COMPONENT_CLOSE);

COMPONENT_SLASH_CLOSE3:
Expand All @@ -664,6 +662,11 @@ COMPONENT_CLOSE_OUTPUT3:
'>' {lastModeWas(TEMPLATE_OUTPUT_MODE,2)}? -> popMode, popMode, pushMode(DEFAULT_TEMPLATE_MODE), type( COMPONENT_CLOSE)
;

COMPONENT_CLOSE7:
'>' {isQuery}? -> popMode, popMode, popMode, popMode, popMode, pushMode(TEMPLATE_OUTPUT_MODE), pushMode(DEFAULT_TEMPLATE_MODE), type(
COMPONENT_CLOSE)
;

// If we find the end of the component, pop all the way out of the component
COMPONENT_CLOSE3: '>' -> popMode, popMode, popMode, popMode, popMode, type(COMPONENT_CLOSE);

Expand Down
43 changes: 25 additions & 18 deletions src/main/antlr/SQLGrammar.g4
Original file line number Diff line number Diff line change
Expand Up @@ -230,16 +230,16 @@ expr:
| unary_operator expr
| expr PIPE2 expr
| expr ( STAR | DIV | MOD) expr
| expr ( PLUS | MINUS) expr
| expr ( LT2 | GT2 | AMP | PIPE) expr
| expr (PLUS | MINUS) expr
// | expr ( LT2 | GT2 | AMP | PIPE) expr
| expr ( LT | LT_EQ | GT | GT_EQ) expr
| expr (
ASSIGN
| EQ
| NOT_EQ1
| NOT_EQ2
| IS_
| IS_ NOT_
| IS_
// | IS_ NOT_? DISTINCT_ FROM_
// | IN_
| LIKE_
Expand All @@ -254,8 +254,7 @@ expr:
//| OPEN_PAR expr (COMMA expr)* CLOSE_PAR
// | CAST_ OPEN_PAR expr AS_ type_name CLOSE_PAR
// | expr COLLATE_ collation_name
| expr NOT_? (LIKE_ | GLOB_ | REGEXP_ | MATCH_) expr (ESCAPE_ expr)?
| expr ( ISNULL_ | NOTNULL_ | NOT_ NULL_)
| expr NOT_? LIKE_ expr (ESCAPE_ expr)?
| expr IS_ NOT_? expr
| expr NOT_? BETWEEN_ expr AND_ expr
| expr NOT_? IN_ (
Expand Down Expand Up @@ -340,25 +339,33 @@ reindex_stmt:
//select_stmt: common_table_stmt? select_core (compound_operator select_core)* order_by_stmt? limit_stmt?;

select_stmt:
select_core (UNION_ ALL_? select_core)* order_by_stmt? limit_stmt?
select_core (union)* order_by_stmt? limit_stmt?
;

union:
UNION_ ALL_? select_core
;

join_clause:
table (join_operator table join_constraint?)*
;

select_core: (
SELECT_ (DISTINCT_ /*| ALL_*/)? result_column (COMMA result_column)* (
FROM_ (table (COMMA table)* | join_clause)
)? (WHERE_ whereExpr = expr)? (
GROUP_ BY_ groupByExpr += expr (COMMA groupByExpr += expr)* (
HAVING_ havingExpr = expr
)?
)? //(WINDOW_ window_name AS_ window_defn ( COMMA window_name AS_ window_defn)*)?
)
select_core:
SELECT_ top? (DISTINCT_ /*| ALL_*/)? result_column (COMMA result_column)* (
FROM_ (table (COMMA table)* | join_clause)
)? (WHERE_ whereExpr = expr)? (
GROUP_ BY_ groupByExpr += expr (COMMA groupByExpr += expr)* (
HAVING_ havingExpr = expr
)?
)? limit_stmt?
//(WINDOW_ window_name AS_ window_defn ( COMMA window_name AS_ window_defn)*)?
// | values_clause
;

top:
TOP NUMERIC_LITERAL
;

factored_select_stmt:
select_stmt
;
Expand Down Expand Up @@ -581,7 +588,7 @@ unary_operator:
MINUS
| PLUS
// | TILDE
| NOT_
| BANG
;

error_message:
Expand Down Expand Up @@ -853,6 +860,6 @@ table_function_name:
any_name:
IDENTIFIER
| keyword
| STRING_LITERAL
| OPEN_PAR any_name CLOSE_PAR
// | STRING_LITERAL
//| OPEN_PAR any_name CLOSE_PAR
;
4 changes: 3 additions & 1 deletion src/main/antlr/SQLLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ GT: '>';
GT_EQ: '>=';
EQ: '==';
NOT_EQ1: '!=';
BANG: '!';
NOT_EQ2: '<>';

ABORT_: 'ABORT';
Expand Down Expand Up @@ -149,6 +150,7 @@ TEMP_: 'TEMP';
TEMPORARY_: 'TEMPORARY';
THEN_: 'THEN';
TO_: 'TO';
TOP: 'TOP';
TRANSACTION_: 'TRANSACTION';
TRIGGER_: 'TRIGGER';
UNION_: 'UNION';
Expand Down Expand Up @@ -207,7 +209,7 @@ IDENTIFIER:

NUMERIC_LITERAL: ((DIGIT+ ('.' DIGIT*)?) | ('.' DIGIT+)) ('E' [-+]? DIGIT+)? | '0x' HEX_DIGIT+;

BIND_PARAMETER: '?' DIGIT* | [:@$] IDENTIFIER;
BIND_PARAMETER: '?' | ':' IDENTIFIER;

STRING_LITERAL: '\'' ( ~'\'' | '\'\'')* '\'';

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/ortus/boxlang/compiler/BXCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.nio.file.Paths;
import java.util.List;

import ortus.boxlang.compiler.javaboxpiler.JavaBoxpiler;
import ortus.boxlang.runtime.BoxRuntime;
import ortus.boxlang.runtime.types.exceptions.BoxRuntimeException;
import ortus.boxlang.runtime.types.exceptions.ParseException;
Expand Down Expand Up @@ -181,7 +180,7 @@ public static void compileFile( Path sourcePath, Path targetPath, Boolean stopOn
// calculate relative path by replacing the base path with an empty string
Path relativePath = basePath.relativize( sourcePath );
// remove file name
bytesList = JavaBoxpiler.getInstance()
bytesList = runtime.getCompiler()
.compileTemplateBytes( ResolvedFilePath.of( mapping, basePath.toString(), relativePath.toString(), sourcePath ) );
} catch ( ParseException e ) {
if ( stopOnError ) {
Expand Down
42 changes: 32 additions & 10 deletions src/main/java/ortus/boxlang/compiler/DiskClassUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import ortus.boxlang.runtime.types.exceptions.BoxRuntimeException;
import ortus.boxlang.runtime.types.util.JSONUtil;
import ortus.boxlang.runtime.util.RegexBuilder;

/**
* Contains some utilities for working with non-class files in the class generation dir
Expand Down Expand Up @@ -57,10 +58,29 @@ public boolean hasLineNumbers( String classPoolName, String name ) {
return generateDiskpath( classPoolName, name, "json" ).toFile().exists();
}

/**
* Generate a disk path for a class file
*
* @param classPoolName class pool name
* @param name class name
* @param extension file extension
*
* @return The path to the file
*/
private Path generateDiskpath( String classPoolName, String name, String extension ) {
return Paths.get( diskStore.toString(), classPoolName.replaceAll( "[^a-zA-Z0-9]", "_" ), name.replace( ".", File.separator ) + "." + extension );
return Paths.get(
diskStore.toString(),
RegexBuilder.of( classPoolName, RegexBuilder.NON_ALPHANUMERIC ).replaceAllAndGet( "_" ),
new StringBuilder( name.replace( ".", File.separator ) ).append( "." ).append( extension ).toString()
);
}

/**
* Write line numbers to disk
*
* @param fqn The fully qualified name of the class
* @param lineNumberJSON The JSON representation of the line numbers
*/
public void writeLineNumbers( String classPoolName, String fqn, String lineNumberJSON ) {
if ( lineNumberJSON == null ) {
return;
Expand All @@ -74,7 +94,6 @@ public void writeLineNumbers( String classPoolName, String fqn, String lineNumbe
*
* @returns array of maps. Null if not found.
*/
@SuppressWarnings( "unchecked" )
public SourceMap readLineNumbers( String classPoolName, String fqn ) {
if ( !hasLineNumbers( classPoolName, fqn ) ) {
return null;
Expand Down Expand Up @@ -117,9 +136,9 @@ public void writeBytes( String classPoolName, String fqn, String extension, byte

/**
* Read the bytes from the class file and all inner classes from disk and return them
*
*
* @param fqn The fully qualified name of the class
*
*
* @return A list of byte arrays, one for each class file
*/
public List<byte[]> readClassBytes( String classPoolName, String fqn ) {
Expand Down Expand Up @@ -149,19 +168,22 @@ public List<byte[]> readClassBytes( String classPoolName, String fqn ) {
return bytes;
}

/**
* Checkf if the file is a Java bytecode file or source file
*
* @param sourceFile The file to check
*
* @return true if the file is a Java bytecode file
*/
public boolean isJavaBytecode( File sourceFile ) {
try ( FileInputStream fis = new FileInputStream( sourceFile );
DataInputStream dis = new DataInputStream( fis ) ) {
// File may be empty! At least 4 bytes are needed to read an int
if ( dis.available() < 4 ) {
return false;
}
if ( dis.readInt() == 0xCAFEBABE ) {
// The class file does start with the magic number
return true;
}

return false;
// Are we the Java Magic number?
return dis.readInt() == 0xCAFEBABE;
} catch ( IOException e ) {
throw new RuntimeException( "Failed to read file", e );
}
Expand Down
Loading

0 comments on commit 69e60a2

Please sign in to comment.