Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dart Back-End #487

Open
wants to merge 69 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
7eff429
[ANTLR4] added generation for ANTLR4 files without target-specific co…
linkstaple Oct 3, 2023
8fa226c
[ANTLR4] erased rule labels for start rules
linkstaple Oct 8, 2023
aee84f2
[ANTLRv4] added generation of Makefile for ANTLR backend and several …
linkstaple Oct 9, 2023
ac40bf2
[ANTLRv4] some refactoring of antlr files
linkstaple Oct 9, 2023
1473ec2
[ANTLRv4] changes for antlr Makefile generation
linkstaple Oct 9, 2023
b0c0c40
[ANTLRv4] created new function for parsing ANTLR CLI options
linkstaple Oct 9, 2023
0c5c47a
[ANTLRv4] added support for -Xlog ANTLR flag
linkstaple Oct 9, 2023
f14b890
[ANTLRv4] -Xlog flag added to BNFC.Options
linkstaple Oct 9, 2023
6b13f6f
[ANTLRv4] added support for -listener and -no-visitor ANTLR flags
linkstaple Oct 9, 2023
f5809ea
[ANTLRv4] added support for -XdbgST ANTLR flag
linkstaple Oct 9, 2023
1cdfcd3
[ANTLRv4] fixed description for -listener and -visitor ANTLR options
linkstaple Oct 9, 2023
ef3056a
[ANTLRv4] added support for -XdbgSTWait ANTLR flag
linkstaple Oct 10, 2023
baf1186
[ANTLRv4] added support for -atn ANTLR flag
linkstaple Oct 10, 2023
6a3b6c6
[ANTLRv4] minor formatting fix
linkstaple Oct 10, 2023
066f725
[ANTLRv4] added support for ANTLR options of type 'name value'
linkstaple Oct 10, 2023
413f351
[ANTLRv4] added option for passing string with ANTLR options directly…
linkstaple Oct 10, 2023
d51337c
[ANTLRv4] update description for ANTLR output
linkstaple Oct 10, 2023
d34f4b2
[ANTLRv4] Makefile LANG variable is set to be equal package name
linkstaple Oct 11, 2023
38ff8fb
[ANTLRv4] stylistic changes
linkstaple Oct 16, 2023
cf895ce
[ANTLRv4] permanent camel case for .g4 files
linkstaple Oct 16, 2023
a914279
[ANTLRv4] Some improvements for Makefile gen
linkstaple Oct 19, 2023
1c6074f
added AST for Dart
xdkomel Oct 29, 2023
95cba43
[ANTLRv4] remove unworking code
linkstaple Nov 6, 2023
f9f696d
Merge branch 'master' into bnfc-antlr
linkstaple Nov 6, 2023
1636c9e
added an AST builder from the ANTLR parser
xdkomel Nov 6, 2023
7929533
Merge pull request #1 from linkstaple/bnfc-antlr
xdkomel Nov 22, 2023
57ddbc3
fix ast, remove the custom parser generator
xdkomel Nov 22, 2023
b95bbbb
merge with add-antlr-backend
xdkomel Nov 22, 2023
d72f4ba
make builder use extensions, match arguments in the g4
xdkomel Nov 23, 2023
a55d2e2
use functions instead of extensions, resolve common issues, leaving o…
xdkomel Nov 27, 2023
40b47fe
builder 85% done
xdkomel Dec 4, 2023
1f8aee7
added pretty printer first draft
xdkomel Dec 11, 2023
2358676
fixed show methods collisions
xdkomel Dec 11, 2023
df4f1b2
fixed different precedence printers
xdkomel Dec 11, 2023
091f72b
[ANTLRv4] expose antlrRuleLabel
linkstaple Dec 6, 2023
82e3385
[ANTLRv4] expose function for making left-recursive rules
linkstaple Dec 16, 2023
0d0c282
[ANTLRv4] resolve name collision for coercion types for ANTLR rule la…
linkstaple Dec 16, 2023
7e51440
a bit reorganized
xdkomel Jan 30, 2024
5b0ae7e
Merge pull request #2 from linkstaple/bnfc-antlr
xdkomel Jan 30, 2024
bb3c9c8
Merge branch 'master' of github.com:xdkomel/bnfc-dart into addDartBui…
xdkomel Jan 30, 2024
6d8d93b
Merge branch 'addPrettyPrinter' of github.com:xdkomel/bnfc-dart into …
xdkomel Jan 30, 2024
7a0148b
support coercion number
xdkomel Jan 30, 2024
45f6e26
Merge pull request #3 from xdkomel/addDartBuilder
xdkomel Jan 30, 2024
af36017
pretty printer w/o coercions & lists
xdkomel Jan 30, 2024
45c86d8
added sep&term, bug w/ coercions
xdkomel Feb 12, 2024
fa14c03
add precedence to the list printers
xdkomel Feb 18, 2024
af8f9ed
Merge pull request #4 from xdkomel/pretty-printer-sep-term
xdkomel Feb 18, 2024
3629ec0
finish mvp
xdkomel Feb 21, 2024
f5b436a
Merge pull request #5 from xdkomel/add-lists-builders
xdkomel Feb 21, 2024
c11d327
add skeleton generator & use Iterable where possible
xdkomel May 1, 2024
e4d5c96
generate project structure, undone
xdkomel May 2, 2024
98898ce
add skeleton and makefile
xdkomel May 2, 2024
77ad7e2
add naming and diretory options to antlr
xdkomel May 21, 2024
0c6be6d
Merge pull request #1 from xdkomel/bnfc-antlr
linkstaple May 26, 2024
02b3365
Merge branch 'master' into bnfc-antlr
linkstaple Jun 2, 2024
558deec
add project structure and makefile
xdkomel Jun 2, 2024
ce57565
Merge pull request #6 from xdkomel/add-skeleton
xdkomel Jun 2, 2024
aa88214
Merge branch 'master' into bnfc-antlr
xdkomel Jun 2, 2024
3901f5a
Merge pull request #7 from xdkomel/bnfc-antlr
xdkomel Jun 2, 2024
2899ef0
fix bug when merged
xdkomel Jun 2, 2024
6359382
fix builder and PP naming issues
xdkomel Jun 2, 2024
5dfd109
[ANTLRv4]: change label generation function to funName
linkstaple Jun 5, 2024
c00d058
Merge branch 'bnfc-antlr' of https://github.com/linkstaple/bnfc-ts-ex…
xdkomel Jun 8, 2024
f6fcda2
mostly adequate version
xdkomel Sep 1, 2024
3faa18e
refactor
xdkomel Sep 13, 2024
e3a7004
fix refactoring caused errors
xdkomel Sep 13, 2024
9550c2d
use switch instead of if in the builder
xdkomel Sep 13, 2024
87a2dc9
Merge pull request #8 from xdkomel/finishing
xdkomel Sep 13, 2024
1f83797
Merge branch 'BNFC:master' into master
xdkomel Sep 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixed show methods collisions
xdkomel committed Dec 11, 2023

Verified

This commit was signed with the committer’s verified signature. The key has expired.
Gumball2415 Persune
commit 2358676958ce2ab0630581a043d0f46be7aef342
14 changes: 7 additions & 7 deletions source/src/BNFC/Backend/Dart/CFtoDartPrinter.hs
Original file line number Diff line number Diff line change
@@ -129,7 +129,7 @@ stringRenderer = [
"final _renderer = StringRenderer();" ]

buildUserToken :: String -> String
buildUserToken token = "extension on ast." ++ token +++ "{\n String get show => value;\n}"
buildUserToken token = "extension on ast." ++ token +++ "{\n String get show" ++ token +++ "=> value;\n}"

generatePrettifiers :: (Cat, [Rule]) -> [String]
generatePrettifiers (cat, rawRules) =
@@ -171,22 +171,22 @@ generateConcreteMapping cat (label, tokens)
["]);"]

generateRuleRHS :: [Either Cat String] -> [DartVar] -> [String] -> [String]
generateRuleRHS [] _ _ = []
generateRuleRHS _ [] _ = []
generateRuleRHS [] _ lines = lines
generateRuleRHS _ [] lines = lines
generateRuleRHS (token:rTokens) (variable@(vType, _):rVariables) lines = case token of
Right terminal ->
generateRuleRHS rTokens (variable:rVariables) $ lines ++ [terminal ++ ","]
generateRuleRHS rTokens (variable:rVariables) $ lines ++ ["\"" ++ terminal ++ "\","]
Left _ -> generateRuleRHS rTokens rVariables $
lines ++ [ buildArgument vType ("a." ++ buildVariableName variable) ]

buildArgument :: DartVarType -> String -> String
buildArgument (0, typeName) name = name ++ ".show"
buildArgument (0, typeName) name = name ++ ".show" ++ typeName ++ ","
-- TODO add correct separators from the CF
buildArgument (n, typeName) name =
"..." ++ name ++ ".expand((e" ++ show n ++ ") => [\'\', " ++ (buildArgument (n-1, typeName) ("e" ++ show n)) ++ "]).skip(1),"

generateExtensionShow :: String -> [String]
generateExtensionShow name = [
"extension on ast." ++ name +++ "{",
" String get show => _renderer.show(_prettify" ++ name ++ "(this));",
"extension" +++ name ++ "Show" +++ "on ast." ++ name +++ "{",
" String get show" ++ name +++ "=> _renderer.show(_prettify" ++ name ++ "(this));",
"}" ]