-
Notifications
You must be signed in to change notification settings - Fork 361
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 #369 from Duhemm/wip/nir-parser
NIR parser
- Loading branch information
Showing
44 changed files
with
1,511 additions
and
39 deletions.
There are no files selected for viewing
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
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
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
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
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
14 changes: 14 additions & 0 deletions
14
tools/src/main/scala/scala/scalanative/nir/parser/Arg.scala
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,14 @@ | ||
package scala.scalanative | ||
package nir | ||
package parser | ||
|
||
import fastparse.all._ | ||
|
||
object Arg extends Base[nir.Arg] { | ||
|
||
override val parser: P[nir.Arg] = | ||
P(PassConv.parser.? ~ Type.parser map { | ||
case (pc, ty) => nir.Arg(ty, pc) | ||
}) | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
tools/src/main/scala/scala/scalanative/nir/parser/Attr.scala
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,30 @@ | ||
package scala.scalanative | ||
package nir | ||
package parser | ||
|
||
import fastparse.all._ | ||
|
||
object Attr extends Base[nir.Attr] { | ||
|
||
import Base._ | ||
import IgnoreWhitespace._ | ||
|
||
val MayInline = P("mayinline".! map (_ => nir.Attr.MayInline)) | ||
val InlineHint = P("inlinehint".! map (_ => nir.Attr.InlineHint)) | ||
val NoInline = P("noinline".! map (_ => nir.Attr.NoInline)) | ||
val AlwaysInline = P("alwaysinline".! map (_ => nir.Attr.AlwaysInline)) | ||
val Pure = P("pure".! map (_ => nir.Attr.Pure)) | ||
val Extern = P("extern".! map (_ => nir.Attr.Extern)) | ||
val Override = | ||
P("override(" ~ Global.parser ~ ")" map (nir.Attr.Override(_))) | ||
val Link = P("link(" ~ qualifiedId ~ ")" map (nir.Attr.Link(_))) | ||
val PinAlways = P("pin(" ~ Global.parser ~ ")" map (nir.Attr.PinAlways(_))) | ||
val PinIf = | ||
P("pin-if(" ~ Global.parser ~ "," ~ Global.parser ~ ")" map { | ||
case (name, cond) => nir.Attr.PinIf(name, cond) | ||
}) | ||
|
||
override val parser: P[nir.Attr] = | ||
MayInline | InlineHint | NoInline | AlwaysInline | Pure | Extern | Override | Link | PinAlways | PinIf | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
tools/src/main/scala/scala/scalanative/nir/parser/Attrs.scala
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,13 @@ | ||
package scala.scalanative | ||
package nir | ||
package parser | ||
|
||
import fastparse.all._ | ||
|
||
object Attrs extends Base[nir.Attrs] { | ||
|
||
import Base.IgnoreWhitespace._ | ||
|
||
override val parser: P[nir.Attrs] = | ||
P(Attr.parser.rep map (nir.Attrs.fromSeq(_))) | ||
} |
Oops, something went wrong.