-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from fink-lang/latest-larix
feat(lang): support number and identifier token
- Loading branch information
Showing
12 changed files
with
106 additions
and
69 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`numbers transforms floats 1`] = ` | ||
"const x = 1.234578; | ||
const y = 1.23e+45; | ||
const z = 1.23e-45; | ||
const a = 1.23e+45; | ||
Object.assign(module.exports, { | ||
x, | ||
y, | ||
z, | ||
a | ||
});" | ||
`; | ||
|
||
exports[`numbers transforms hex, octet, binary 1`] = ` | ||
"const h = 0x123456789ABCDEF0; | ||
const o = 0o12345670; | ||
const b = 0b01010; | ||
Object.assign(module.exports, { | ||
h, | ||
o, | ||
b | ||
});" | ||
`; | ||
|
||
exports[`numbers transforms integers 1`] = ` | ||
"const x = 1234578; | ||
const y = 0123; | ||
Object.assign(module.exports, { | ||
x, | ||
y | ||
});" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`compiles regex 1`] = ` | ||
"const regex2 = /(?<year>\\\\d{4})-(?<month>\\\\d{2})-(?<day>\\\\d{2})mgex3=rx/(?<year>\\\\d{4})-(?<month>\\\\d{2})-(?<day>\\\\d{2})/; | ||
"const regex1 = /(?<year>\\\\d{4})-(?<month>\\\\d{2})-(?<day>\\\\d{2})/gm; | ||
const regex2 = /(?<year>\\\\d{4})-(?<month>\\\\d{2})-(?<day>\\\\d{2})/; | ||
const regex3 = /.+\\\\/.+/; | ||
Object.assign(module.exports, { | ||
regex2 | ||
regex1, | ||
regex2, | ||
regex3 | ||
});" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import {numericLiteral, bigIntLiteral} from '@babel/types'; | ||
|
||
|
||
export const transform_number = ({value})=> ( | ||
value.match(/\./) | ||
? numericLiteral(Number(value)) | ||
:bigIntLiteral(value) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import {fink2js} from '../testing'; | ||
|
||
|
||
describe('numbers', ()=> { | ||
it('transforms integers', ()=> { | ||
expect( | ||
fink2js(` | ||
x = 1234578 | ||
y = 0123 | ||
`) | ||
).toMatchSnapshot(); | ||
}); | ||
|
||
|
||
it('transforms floats', ()=> { | ||
expect( | ||
fink2js(` | ||
x = 1.234578 | ||
y = 1.23e45 | ||
z = 1.23e-45 | ||
a = 1.23e+45 | ||
`) | ||
).toMatchSnapshot(); | ||
}); | ||
|
||
|
||
it('transforms hex, octet, binary', ()=> { | ||
expect( | ||
fink2js(` | ||
h = 0x123456789ABCDEF0 | ||
o = 0o12345670 | ||
b = 0b01010 | ||
`) | ||
).toMatchSnapshot(); | ||
}); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters