Browse Source

improved circuit compiling

improved circuit compiling
still not fully working

improved circuit compiling
still not fully working
pull/8/head
mottla 5 years ago
parent
commit
6244b7a2ef
6 changed files with 383 additions and 331 deletions
  1. +139
    -144
      .idea/workspace.xml
  2. +119
    -93
      circuitcompiler/Programm.go
  3. +35
    -23
      circuitcompiler/Programm_test.go
  4. +88
    -69
      circuitcompiler/circuit.go
  5. +1
    -1
      circuitcompiler/lexer.go
  6. +1
    -1
      circuitcompiler/parser.go

+ 139
- 144
.idea/workspace.xml

@ -4,8 +4,6 @@
<list default="true" id="63e1f2c4-8982-42df-a3f2-1673aa7aec22" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/circuitcompiler/Programm.go" beforeDir="false" afterPath="$PROJECT_DIR$/circuitcompiler/Programm.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/circuitcompiler/circuit.go" beforeDir="false" afterPath="$PROJECT_DIR$/circuitcompiler/circuit.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/circuitcompiler/parser.go" beforeDir="false" afterPath="$PROJECT_DIR$/circuitcompiler/parser.go" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
@ -18,8 +16,8 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/circuitcompiler/Programm_test.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="381">
<caret line="38" column="19" lean-forward="true" selection-start-line="38" selection-start-column="19" selection-end-line="38" selection-end-column="19" />
<state relative-caret-position="615">
<caret line="46" column="5" selection-start-line="28" selection-start-column="4" selection-end-line="46" selection-end-column="5" />
</state>
</provider>
</entry>
@ -27,8 +25,8 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/circuitcompiler/test.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="330">
<caret line="22" column="10" selection-start-line="22" selection-start-column="10" selection-end-line="22" selection-end-column="10" />
<state relative-caret-position="420">
<caret line="28" column="21" selection-start-line="28" selection-start-column="21" selection-end-line="28" selection-end-column="21" />
</state>
</provider>
</entry>
@ -45,29 +43,30 @@
<file pinned="false" current-in-tab="false">
<entry file="file:///usr/local/go/src/runtime/panic.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="164">
<state relative-caret-position="10140">
<caret line="680" selection-start-line="680" selection-end-line="680" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="true">
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/circuitcompiler/Programm.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="210">
<caret line="364" column="33" lean-forward="true" selection-start-line="364" selection-start-column="33" selection-end-line="364" selection-end-column="33" />
<state relative-caret-position="224">
<caret line="527" column="5" lean-forward="true" selection-start-line="527" selection-start-column="5" selection-end-line="527" selection-end-column="5" />
<folding>
<element signature="e#25#165#0" expanded="true" />
<element signature="n#!!block;n#mulFactors#0" />
<element signature="n#!!block;n#addFactors#0" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/circuitcompiler/circuit.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="394">
<caret line="166" column="32" selection-start-line="166" selection-start-column="32" selection-end-line="166" selection-end-column="32" />
<state relative-caret-position="284">
<caret line="156" lean-forward="true" selection-start-line="156" selection-end-line="156" />
</state>
</provider>
</entry>
@ -75,8 +74,8 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/circuitcompiler/parser.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2265">
<caret line="156" column="34" selection-start-line="156" selection-start-column="34" selection-end-line="156" selection-end-column="34" />
<state relative-caret-position="825">
<caret line="60" column="15" lean-forward="true" selection-start-line="60" selection-start-column="15" selection-end-line="60" selection-end-column="15" />
<folding>
<element signature="e#25#72#0" expanded="true" />
</folding>
@ -85,10 +84,10 @@
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/r1csqap/r1csqap.go">
<entry file="file://$PROJECT_DIR$/circuitcompiler/lexer.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="315">
<caret line="27" column="30" lean-forward="true" selection-start-line="27" selection-start-column="30" selection-end-line="27" selection-end-column="30" />
<state relative-caret-position="600">
<caret line="44" column="19" selection-start-line="44" selection-start-column="19" selection-end-line="44" selection-end-column="19" />
</state>
</provider>
</entry>
@ -131,6 +130,12 @@
<find>new</find>
<find>newpro</find>
<find>clone</find>
<find>newProg</find>
<find>func</find>
<find>global</find>
<find>globalin</find>
<find>newcir</find>
<find>newprogr</find>
</findStrings>
<replaceStrings>
<replace>mottla</replace>
@ -152,7 +157,6 @@
<option value="$PROJECT_DIR$/cli/main.go" />
<option value="$PROJECT_DIR$/r1csqap/r1csqap_test.go" />
<option value="$PROJECT_DIR$/circuitcompiler/circuit_test.go" />
<option value="$PROJECT_DIR$/circuitcompiler/lexer.go" />
<option value="$PROJECT_DIR$/circuitcompiler/temp" />
<option value="$PROJECT_DIR$/README.md" />
<option value="$PROJECT_DIR$/../../go-lexer/lexer.go" />
@ -160,12 +164,13 @@
<option value="$PROJECT_DIR$/circuitcompiler/lexer/lexer_test/lexer_test.go" />
<option value="$PROJECT_DIR$/snark.go" />
<option value="$PROJECT_DIR$/snark_test.go" />
<option value="$PROJECT_DIR$/circuitcompiler/Programm_test.go" />
<option value="$PROJECT_DIR$/circuitcompiler/test.py" />
<option value="$PROJECT_DIR$/r1csqap/r1csqap.go" />
<option value="$PROJECT_DIR$/circuitcompiler/lexer.go" />
<option value="$PROJECT_DIR$/circuitcompiler/parser.go" />
<option value="$PROJECT_DIR$/circuitcompiler/Programm.go" />
<option value="$PROJECT_DIR$/circuitcompiler/test.py" />
<option value="$PROJECT_DIR$/circuitcompiler/Programm_test.go" />
<option value="$PROJECT_DIR$/circuitcompiler/circuit.go" />
<option value="$PROJECT_DIR$/circuitcompiler/Programm.go" />
</list>
</option>
</component>
@ -192,6 +197,11 @@
<item name="go-snark" type="462c0819:PsiDirectoryNode" />
<item name="circuitcompiler" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="go-snark" type="b2602c69:ProjectViewProjectNode" />
<item name="go-snark" type="462c0819:PsiDirectoryNode" />
<item name="cli" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="go-snark" type="b2602c69:ProjectViewProjectNode" />
<item name="External Libraries" type="cb654da1:ExternalLibrariesNode" />
@ -279,60 +289,70 @@
<pattern value="^TestProgramm_BuildConstraintTree$" />
<method v="2" />
</configuration>
<configuration name="Test_LexerRewind2 in github.com/mottla/go-snark/circuitcompiler/lexer/lexer_test" type="GoTestRunConfiguration" factoryName="Go Test" temporary="true" nameIsGenerated="true">
<configuration name="test" type="PythonConfigurationType" factoryName="Python" temporary="true">
<module name="go-snark" />
<working_directory value="$PROJECT_DIR$/circuitcompiler/lexer/lexer_test" />
<framework value="gotest" />
<kind value="PACKAGE" />
<package value="github.com/mottla/go-snark/circuitcompiler/lexer/lexer_test" />
<directory value="$PROJECT_DIR$/" />
<filePath value="$PROJECT_DIR$/" />
<pattern value="^Test_LexerRewind2$" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/circuitcompiler" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/circuitcompiler/test.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="true" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="Go Test.TestNewProgramm in github.com/mottla/go-snark/circuitcompiler" />
<item itemvalue="Python.test" />
<item itemvalue="Go Test.TestProgramm_BuildConstraintTree in github.com/mottla/go-snark/circuitcompiler" />
<item itemvalue="Go Test.TestNewProgramm in github.com/mottla/go-snark" />
<item itemvalue="Go Test.TestGenerateProofs in github.com/mottla/go-snark" />
<item itemvalue="Go Test.Test_LexerRewind2 in github.com/mottla/go-snark/circuitcompiler/lexer/lexer_test" />
</list>
</recent_temporary>
</component>
<component name="TestHistory">
<history-entry file="TestNewProgramm_in_github_com_mottla_go-snark_circuitcompiler - 2019.05.23 at 21h 42m 51s.xml">
<history-entry file="TestNewProgramm_in_github_com_mottla_go-snark_circuitcompiler - 2019.05.28 at 10h 20m 04s.xml">
<configuration name="TestNewProgramm in github.com/mottla/go-snark/circuitcompiler" configurationId="GoTestRunConfiguration" />
</history-entry>
<history-entry file="TestNewProgramm_in_github_com_mottla_go-snark_circuitcompiler - 2019.05.24 at 08h 36m 33s.xml">
<history-entry file="TestNewProgramm_in_github_com_mottla_go-snark_circuitcompiler - 2019.05.28 at 10h 20m 44s.xml">
<configuration name="TestNewProgramm in github.com/mottla/go-snark/circuitcompiler" configurationId="GoTestRunConfiguration" />
</history-entry>
<history-entry file="TestNewProgramm_in_github_com_mottla_go-snark_circuitcompiler - 2019.05.24 at 08h 38m 35s.xml">
<history-entry file="TestNewProgramm_in_github_com_mottla_go-snark_circuitcompiler - 2019.05.28 at 10h 25m 14s.xml">
<configuration name="TestNewProgramm in github.com/mottla/go-snark/circuitcompiler" configurationId="GoTestRunConfiguration" />
</history-entry>
<history-entry file="TestNewProgramm_in_github_com_mottla_go-snark_circuitcompiler - 2019.05.24 at 08h 42m 49s.xml">
<history-entry file="TestNewProgramm_in_github_com_mottla_go-snark_circuitcompiler - 2019.05.28 at 10h 25m 15s.xml">
<configuration name="TestNewProgramm in github.com/mottla/go-snark/circuitcompiler" configurationId="GoTestRunConfiguration" />
</history-entry>
<history-entry file="TestNewProgramm_in_github_com_mottla_go-snark_circuitcompiler - 2019.05.24 at 08h 47m 09s.xml">
<history-entry file="TestNewProgramm_in_github_com_mottla_go-snark_circuitcompiler - 2019.05.28 at 10h 28m 04s.xml">
<configuration name="TestNewProgramm in github.com/mottla/go-snark/circuitcompiler" configurationId="GoTestRunConfiguration" />
</history-entry>
<history-entry file="TestNewProgramm_in_github_com_mottla_go-snark_circuitcompiler - 2019.05.24 at 08h 49m 21s.xml">
<history-entry file="TestNewProgramm_in_github_com_mottla_go-snark_circuitcompiler - 2019.05.28 at 10h 33m 25s.xml">
<configuration name="TestNewProgramm in github.com/mottla/go-snark/circuitcompiler" configurationId="GoTestRunConfiguration" />
</history-entry>
<history-entry file="TestNewProgramm_in_github_com_mottla_go-snark_circuitcompiler - 2019.05.24 at 08h 52m 52s.xml">
<history-entry file="TestNewProgramm_in_github_com_mottla_go-snark_circuitcompiler - 2019.05.28 at 10h 39m 15s.xml">
<configuration name="TestNewProgramm in github.com/mottla/go-snark/circuitcompiler" configurationId="GoTestRunConfiguration" />
</history-entry>
<history-entry file="TestNewProgramm_in_github_com_mottla_go-snark_circuitcompiler - 2019.05.24 at 08h 52m 53s.xml">
<history-entry file="TestNewProgramm_in_github_com_mottla_go-snark_circuitcompiler - 2019.05.28 at 10h 39m 47s.xml">
<configuration name="TestNewProgramm in github.com/mottla/go-snark/circuitcompiler" configurationId="GoTestRunConfiguration" />
</history-entry>
<history-entry file="TestNewProgramm_in_github_com_mottla_go-snark_circuitcompiler - 2019.05.24 at 09h 57m 52s.xml">
<history-entry file="TestNewProgramm_in_github_com_mottla_go-snark_circuitcompiler - 2019.05.28 at 10h 41m 23s.xml">
<configuration name="TestNewProgramm in github.com/mottla/go-snark/circuitcompiler" configurationId="GoTestRunConfiguration" />
</history-entry>
<history-entry file="TestNewProgramm_in_github_com_mottla_go-snark_circuitcompiler - 2019.05.24 at 09h 57m 53s.xml">
<history-entry file="TestNewProgramm_in_github_com_mottla_go-snark_circuitcompiler - 2019.05.28 at 11h 03m 24s.xml">
<configuration name="TestNewProgramm in github.com/mottla/go-snark/circuitcompiler" configurationId="GoTestRunConfiguration" />
</history-entry>
</component>
<component name="TodoView" selected-index="4">
<component name="TodoView">
<todo-panel id="selected-file">
<is-autoscroll-to-source value="true" />
</todo-panel>
@ -342,22 +362,23 @@
</todo-panel>
</component>
<component name="ToolWindowManager">
<frame x="64" y="-11" width="1857" height="1020" extended-state="6" />
<frame x="65" y="-4" width="1855" height="1012" extended-state="6" />
<editor active="true" />
<layout>
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.18518518" />
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.19845219" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" weight="0.32893288" />
<window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.34543455" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.39823982" />
<window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.46314633" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.42244226" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" weight="0.19031903" />
<window_info anchor="bottom" id="Docker" order="7" show_stripe_button="false" />
<window_info anchor="bottom" id="Database Changes" order="8" />
<window_info anchor="bottom" id="Version Control" order="9" />
<window_info anchor="bottom" id="Terminal" order="10" />
<window_info anchor="bottom" id="Version Control" order="9" weight="0.32893288" />
<window_info anchor="bottom" id="Terminal" order="10" weight="0.32893288" />
<window_info anchor="bottom" id="Event Log" order="11" side_tool="true" weight="0.32893288" />
<window_info anchor="bottom" id="Messages" order="12" weight="0.32993197" />
<window_info anchor="bottom" id="Inspection Results" order="13" weight="0.32893288" />
@ -401,7 +422,10 @@
<MESSAGE value="working on multiplication gate reduction algo" />
<MESSAGE value="constraint is no longer a reference pointer" />
<MESSAGE value="new renaming logic preparations" />
<option name="LAST_COMMIT_MESSAGE" value="new renaming logic preparations" />
<MESSAGE value="changing gate structure from entirely" />
<MESSAGE value="improved circuit compiling" />
<MESSAGE value="improved circuit compiling&#10;still not fully working" />
<option name="LAST_COMMIT_MESSAGE" value="improved circuit compiling&#10;still not fully working" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
@ -453,78 +477,34 @@
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/circuitcompiler/Programm.go</url>
<line>204</line>
<option name="timeStamp" value="79" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/circuitcompiler/Programm.go</url>
<line>421</line>
<option name="timeStamp" value="107" />
<line>514</line>
<option name="timeStamp" value="172" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/circuitcompiler/Programm.go</url>
<line>425</line>
<option name="timeStamp" value="108" />
<line>218</line>
<option name="timeStamp" value="204" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/circuitcompiler/Programm.go</url>
<line>406</line>
<option name="timeStamp" value="109" />
<line>298</line>
<option name="timeStamp" value="220" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/circuitcompiler/Programm.go</url>
<line>410</line>
<option name="timeStamp" value="111" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/circuitcompiler/Programm.go</url>
<line>275</line>
<option name="timeStamp" value="135" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/circuitcompiler/Programm.go</url>
<line>276</line>
<properties />
<option name="timeStamp" value="138" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/circuitcompiler/Programm.go</url>
<line>299</line>
<properties />
<option name="timeStamp" value="140" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/circuitcompiler/Programm.go</url>
<line>292</line>
<properties />
<option name="timeStamp" value="141" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/circuitcompiler/Programm.go</url>
<line>370</line>
<properties />
<option name="timeStamp" value="144" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/circuitcompiler/Programm.go</url>
<line>380</line>
<properties />
<option name="timeStamp" value="145" />
<line>325</line>
<option name="timeStamp" value="263" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
<watches-manager>
<configuration name="GoTestRunConfiguration">
<watch expression="*(*&quot;map[string]bool&quot;)(824634576984)" />
<watch expression="mGatesUsed" />
</configuration>
</watches-manager>
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/bn128/g1.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="16">
<caret line="5" column="25" selection-start-line="5" selection-start-column="25" selection-end-line="5" selection-end-column="25" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/bn128/g1_test.go">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/bn128/g2.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="16">
@ -669,13 +649,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/circuitcompiler/lexer.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="75">
<caret line="9" column="5" selection-start-line="9" selection-start-column="5" selection-end-line="9" selection-end-column="5" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/circuitcompiler/circuit_test.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1815">
@ -725,10 +698,38 @@
</state>
</provider>
</entry>
<entry file="file:///usr/local/go/src/strings/strings.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="4710">
<caret line="318" selection-start-line="318" selection-end-line="318" selection-end-column="80" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/r1csqap/r1csqap.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="315">
<caret line="27" column="30" lean-forward="true" selection-start-line="27" selection-start-column="30" selection-end-line="27" selection-end-column="30" />
</state>
</provider>
</entry>
<entry file="file:///usr/local/go/src/runtime/asm_amd64.s">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="152">
<caret line="428" selection-start-line="428" selection-end-line="428" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/circuitcompiler/Programm_test.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="615">
<caret line="46" column="5" selection-start-line="28" selection-start-column="4" selection-end-line="46" selection-end-column="5" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/circuitcompiler/test.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="330">
<caret line="22" column="10" selection-start-line="22" selection-start-column="10" selection-end-line="22" selection-end-column="10" />
<state relative-caret-position="420">
<caret line="28" column="21" selection-start-line="28" selection-start-column="21" selection-end-line="28" selection-end-column="21" />
</state>
</provider>
</entry>
@ -739,20 +740,27 @@
</state>
</provider>
</entry>
<entry file="file:///usr/local/go/src/runtime/panic.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="10140">
<caret line="680" selection-start-line="680" selection-end-line="680" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/circuitcompiler/parser.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2265">
<caret line="156" column="34" selection-start-line="156" selection-start-column="34" selection-end-line="156" selection-end-column="34" />
<state relative-caret-position="825">
<caret line="60" column="15" lean-forward="true" selection-start-line="60" selection-start-column="15" selection-end-line="60" selection-end-column="15" />
<folding>
<element signature="e#25#72#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/r1csqap/r1csqap.go">
<entry file="file://$PROJECT_DIR$/circuitcompiler/lexer.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="315">
<caret line="27" column="30" lean-forward="true" selection-start-line="27" selection-start-column="30" selection-end-line="27" selection-end-column="30" />
<state relative-caret-position="600">
<caret line="44" column="19" selection-start-line="44" selection-start-column="19" selection-end-line="44" selection-end-column="19" />
</state>
</provider>
</entry>
@ -776,34 +784,21 @@
</state>
</provider>
</entry>
<entry file="file:///usr/local/go/src/runtime/panic.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="164">
<caret line="680" selection-start-line="680" selection-end-line="680" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/circuitcompiler/Programm_test.go">
<entry file="file://$PROJECT_DIR$/circuitcompiler/Programm.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="381">
<caret line="38" column="19" lean-forward="true" selection-start-line="38" selection-start-column="19" selection-end-line="38" selection-end-column="19" />
<state relative-caret-position="224">
<caret line="527" column="5" lean-forward="true" selection-start-line="527" selection-start-column="5" selection-end-line="527" selection-end-column="5" />
<folding>
<element signature="n#!!block;n#mulFactors#0" />
<element signature="n#!!block;n#addFactors#0" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/circuitcompiler/circuit.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="394">
<caret line="166" column="32" selection-start-line="166" selection-start-column="32" selection-end-line="166" selection-end-column="32" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/circuitcompiler/Programm.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="210">
<caret line="364" column="33" lean-forward="true" selection-start-line="364" selection-start-column="33" selection-end-line="364" selection-end-column="33" />
<folding>
<element signature="e#25#165#0" expanded="true" />
</folding>
<state relative-caret-position="284">
<caret line="156" lean-forward="true" selection-start-line="156" selection-end-line="156" />
</state>
</provider>
</entry>

+ 119
- 93
circuitcompiler/Programm.go

@ -17,7 +17,7 @@ type utils struct {
type Program struct {
functions map[string]*Circuit
globalInputs []Constraint
globalInputs []string
arithmeticEnvironment utils //find a better name
R1CS struct {
@ -45,6 +45,10 @@ func (p *Program) BuildConstraintTrees() {
p.getMainCircuit().gateMap[mainRoot.value.Out] = mainRoot
}
for _, in := range p.getMainCircuit().Inputs {
p.globalInputs = append(p.globalInputs, composeNewFunction(in, p.getMainCircuit().Inputs))
}
var wg = sync.WaitGroup{}
for _, circuit := range p.functions {
@ -103,39 +107,35 @@ func (p *Program) ReduceCombinedTree() (orderedmGates []gate) {
return orderedmGates
}
func (p *Program) r1CSRecursiveBuild(currentCircuit *Circuit, root *gate, mGatesUsed map[string]bool, orderedmGates *[]gate, negate bool, inverse bool) (isConstant bool) {
func (p *Program) r1CSRecursiveBuild(currentCircuit *Circuit, root *gate, mGatesUsed map[string]bool, orderedmGates *[]gate, negate bool, inverse bool) (variableEnd bool) {
if root.OperationType() == IN {
return false
}
if root.OperationType() == CONST {
return true
}
if _, alreadyComputed := mGatesUsed[root.value.Out]; alreadyComputed {
if root.OperationType() == CONST {
return false
}
if root.OperationType() == FUNC {
nextContext := p.extendedFunctionRenamer(currentCircuit, root.value)
isConstant = p.r1CSRecursiveBuild(nextContext, nextContext.root, mGatesUsed, orderedmGates, negate, inverse)
return isConstant
currentCircuit = nextContext
root = nextContext.root
}
if _, alreadyComputed := mGatesUsed[root.value.V1]; !alreadyComputed {
isConstant = p.r1CSRecursiveBuild(currentCircuit, root.left, mGatesUsed, orderedmGates, negate, inverse)
originOfVariable := p.functions[getContextFromVariable(root.value.Out)]
if _, alreadyComputed := mGatesUsed[composeNewFunction(root.value.Out, originOfVariable.currentOutputs())]; alreadyComputed {
return true
}
if _, alreadyComputed := mGatesUsed[root.value.V2]; !alreadyComputed {
cons := p.r1CSRecursiveBuild(currentCircuit, root.right, mGatesUsed, orderedmGates, Xor(negate, root.value.negate), Xor(inverse, root.value.invert))
isConstant = isConstant || cons
}
variableEnd = p.r1CSRecursiveBuild(currentCircuit, root.left, mGatesUsed, orderedmGates, negate, inverse)
cons := p.r1CSRecursiveBuild(currentCircuit, root.right, mGatesUsed, orderedmGates, Xor(negate, root.value.negate), Xor(inverse, root.value.invert))
if root.OperationType() == MULTIPLY {
if isConstant && !root.value.invert && root != p.getMainCircuit().root {
return false
if !(variableEnd && cons) && !root.value.invert && root != p.getMainCircuit().root {
return variableEnd || cons
}
root.leftIns = p.collectFactors(currentCircuit, root.left, mGatesUsed, false, false)
//if root.left.value.Out== root.right.value.Out{
@ -147,19 +147,21 @@ func (p *Program) r1CSRecursiveBuild(currentCircuit *Circuit, root *gate, mGates
//root.rightIns = collectAtomsInSubtree3(root.right, mGatesUsed, Xor(negate, root.value.negate), Xor(inverse, root.value.invert))
root.rightIns = p.collectFactors(currentCircuit, root.right, mGatesUsed, false, false)
root.index = len(mGatesUsed)
var nn = root.value.Out
//if _, ex := p.functions[nn]; ex {
// nn = composeNewFunction(root.value.Out, currentCircuit.Inputs)
var nn = composeNewFunction(root.value.Out, originOfVariable.currentOutputs())
//var nn = root.value.Out
//if _, ex := p.functions[root.value.Out]; ex {
// nn = currentCircuit.currentOutputName()
//}
if _, ex := mGatesUsed[nn]; ex {
panic(fmt.Sprintf("told ya so %v", nn))
}
mGatesUsed[nn] = true
rootGate := cloneGate(root)
rootGate.value.Out = nn
*orderedmGates = append(*orderedmGates, *rootGate)
}
return isConstant
return variableEnd || cons
//TODO optimize if output is not a multipication gate
}
@ -211,11 +213,18 @@ func mulFactors(leftFactors, rightFactors []factor) (result []factor) {
//this one should only be reached, after a true mgate had its left and right braches computed. here we
//a factor can appear at most in quadratic form. we reduce terms a*a^-1 here.
if facRight.typ&facLeft.typ == IN {
//if facRight.n
if facLeft.name == facRight.name {
if facRight.invert != facLeft.invert {
rightFactors[i] = factor{typ: CONST, negate: Xor(facRight.negate, facLeft.negate), multiplicative: mul2DVector(facRight.multiplicative, facLeft.multiplicative)}
continue
}
}
//rightFactors[i] = factor{typ: CONST, negate: Xor(facRight.negate, facLeft.negate), multiplicative: mul2DVector(facRight.multiplicative, facLeft.multiplicative)}
//continue
}
fmt.Println("dsf")
panic("unexpected")
}
@ -289,22 +298,10 @@ func addFactors(leftFactors, rightFactors []factor) []factor {
return res
}
func (p *Program) collectFactors(contextCircut *Circuit, g *gate, mGatesUsed map[string]bool, negate bool, invert bool) []factor {
if _, ex := mGatesUsed[g.value.Out]; ex {
return []factor{{typ: IN, name: g.value.Out, invert: invert, negate: negate, multiplicative: [2]int{1, 1}}}
}
func (p *Program) collectFactors(contextCircut *Circuit, node *gate, mGatesUsed map[string]bool, negate bool, invert bool) []factor {
if g.OperationType() == IN {
return []factor{{typ: IN, name: g.value.Out, invert: invert, negate: negate, multiplicative: [2]int{1, 1}}}
}
if g.OperationType() == FUNC {
nextContext := p.extendedFunctionRenamer(contextCircut, g.value)
return p.collectFactors(nextContext, nextContext.root, mGatesUsed, negate, invert)
}
if g.OperationType() == CONST {
b1, v1 := isValue(g.value.Out)
if node.OperationType() == CONST {
b1, v1 := isValue(node.value.Out)
if !b1 {
panic("not a constant")
}
@ -314,22 +311,38 @@ func (p *Program) collectFactors(contextCircut *Circuit, g *gate, mGatesUsed map
return []factor{{typ: CONST, negate: negate, multiplicative: [2]int{v1, 1}}}
}
var leftFactors, rightFactors []factor
if g.left.OperationType() == FUNC {
nextContext := p.extendedFunctionRenamer(contextCircut, g.left.value)
leftFactors = p.collectFactors(nextContext, nextContext.root, mGatesUsed, negate, invert)
} else {
leftFactors = p.collectFactors(contextCircut, g.left, mGatesUsed, negate, invert)
if node.OperationType() == FUNC {
nextContext := p.extendedFunctionRenamer(contextCircut, node.value)
//if _, ex := mGatesUsed[nextContext.currentOutputName()]; ex {
// return []factor{{typ: IN, name: nextContext.currentOutputName(), invert: invert, negate: negate, multiplicative: [2]int{1, 1}}}
//}
contextCircut = nextContext
node = nextContext.root
}
if g.right.OperationType() == FUNC {
nextContext := p.extendedFunctionRenamer(contextCircut, g.right.value)
rightFactors = p.collectFactors(nextContext, nextContext.root, mGatesUsed, Xor(negate, g.value.negate), Xor(invert, g.value.invert))
} else {
rightFactors = p.collectFactors(contextCircut, g.right, mGatesUsed, Xor(negate, g.value.negate), Xor(invert, g.value.invert))
originOfVariable := p.functions[getContextFromVariable(node.value.Out)]
if originOfVariable == nil {
fmt.Println("asdf")
}
lookingFOr := composeNewFunction(node.value.Out, originOfVariable.currentOutputs())
//if _, ex := mGatesUsed[node.value.Out]; ex {
// return []factor{{typ: IN, name: node.value.Out, invert: invert, negate: negate, multiplicative: [2]int{1, 1}}}
//}
if node.OperationType() == IN {
return []factor{{typ: IN, name: lookingFOr, invert: invert, negate: negate, multiplicative: [2]int{1, 1}}}
}
switch g.OperationType() {
if _, alreadyComputed := mGatesUsed[lookingFOr]; alreadyComputed {
return []factor{{typ: IN, name: lookingFOr, invert: invert, negate: negate, multiplicative: [2]int{1, 1}}}
}
leftFactors := p.collectFactors(contextCircut, node.left, mGatesUsed, negate, invert)
rightFactors := p.collectFactors(contextCircut, node.right, mGatesUsed, Xor(negate, node.value.negate), Xor(invert, node.value.invert))
switch node.OperationType() {
case MULTIPLY:
return mulFactors(leftFactors, rightFactors)
case PLUS:
@ -358,10 +371,10 @@ func (p *Program) getMainCircuit() *Circuit {
return p.functions["main"]
}
func (p *Program) addGlobalInput(c Constraint) {
c.Out = "main@" + c.Out
p.globalInputs = append(p.globalInputs, c)
}
//func (p *Program) addGlobalInput(c Constraint) {
// c.Out = "main@" + c.Out
// p.globalInputs = append(p.globalInputs, c)
//}
func prepareUtils() utils {
bn, err := bn128.NewBn128()
@ -388,46 +401,51 @@ func (p *Program) extendedFunctionRenamer(contextCircuit *Circuit, constraint *C
//if _, ex := contextCircuit.gateMap[constraint.Out]; !ex {
// panic("constraint must be within the contextCircuit circuit")
//}
if b, n, _ := isFunction(constraint.Out); b {
if newContext, v := p.functions[n]; v {
//am i certain that constraint.inputs is alwazs equal to n??? me dont like it
for i, argument := range constraint.Inputs {
isConst, _ := isValue(argument)
if isConst {
continue
}
isFunc, _, _ := isFunction(argument)
if isFunc {
panic("functions as arguments no supported yet")
//p.extendedFunctionRenamer(contextCircuit,)
}
//at this point I assert that argument is a variable. This can become troublesome later
inputOriginCircuit := p.functions[getContextFromVariable(argument)]
if gate, ex := inputOriginCircuit.gateMap[argument]; ex {
oldGate := newContext.gateMap[newContext.Inputs[i]]
//we take the old gate which was nothing but a input
//and link this input to its constituents comming from the calling contextCircuit.
//i think this is pretty neat
oldGate.value = gate.value
oldGate.right = gate.right
oldGate.left = gate.left
} else {
panic("not expected")
}
b, n, _ := isFunction(constraint.Out)
if !b {
panic("not expected")
}
if newContext, v := p.functions[n]; v {
//am i certain that constraint.inputs is alwazs equal to n??? me dont like it
for i, argument := range constraint.Inputs {
isConst, _ := isValue(argument)
if isConst {
continue
}
isFunc, _, _ := isFunction(argument)
if isFunc {
panic("functions as arguments no supported yet")
//p.extendedFunctionRenamer(contextCircuit,)
}
//at this point I assert that argument is a variable. This can become troublesome later
//first we get the circuit in which the argument was created
inputOriginCircuit := p.functions[getContextFromVariable(argument)]
//we pick the gate that has the argument as output
if gate, ex := inputOriginCircuit.gateMap[argument]; ex {
//we pick the old circuit inputs and let them now reference the same as the argument gate did,
oldGate := newContext.gateMap[newContext.Inputs[i]]
//we take the old gate which was nothing but a input
//and link this input to its constituents coming from the calling contextCircuit.
//i think this is pretty neat
oldGate.value = gate.value
oldGate.right = gate.right
oldGate.left = gate.left
} else {
panic("not expected")
}
newContext.renameInputs(constraint.Inputs)
return newContext
}
} else {
panic("not expected")
//newContext.renameInputs(constraint.Inputs)
return newContext
}
return nil
}
func NewProgram() (p *Program) {
p = &Program{functions: map[string]*Circuit{}, globalInputs: []Constraint{{Op: IN, Out: "one"}}, arithmeticEnvironment: prepareUtils()}
p = &Program{functions: map[string]*Circuit{}, globalInputs: []string{"one"}, arithmeticEnvironment: prepareUtils()}
return
}
@ -441,7 +459,7 @@ func (p *Program) GenerateReducedR1CS(mGates []gate) (a, b, c [][]*big.Int) {
indexMap := make(map[string]int)
for i, v := range p.globalInputs {
indexMap[v.Out] = i
indexMap[v] = i
}
for i, v := range mGates {
@ -456,10 +474,21 @@ func (p *Program) GenerateReducedR1CS(mGates []gate) (a, b, c [][]*big.Int) {
cConstraint := r1csqap.ArrayOfBigZeros(size)
for _, val := range gate.leftIns {
if val.typ != CONST {
if _, ex := indexMap[val.name]; !ex {
panic(fmt.Sprintf("%v index not found!!!", val.name))
}
}
convertAndInsertFactorAt(aConstraint, val, indexMap[val.name])
}
for _, val := range gate.rightIns {
if val.typ != CONST {
if _, ex := indexMap[val.name]; !ex {
panic(fmt.Sprintf("%v index not found!!!", val.name))
}
}
convertAndInsertFactorAt(bConstraint, val, indexMap[val.name])
}
@ -498,11 +527,8 @@ func convertAndInsertFactorAt(arr []*big.Int, val factor, index int) {
value.Neg(value)
}
if val.typ == CONST {
arr[0] = value
} else {
arr[index] = value
}
//not that index is 0 if its a constant, since 0 is the map default if no entry was found
arr[index] = value
}

+ 35
- 23
circuitcompiler/Programm_test.go

@ -14,37 +14,48 @@ func TestProgramm_BuildConstraintTree(t *testing.T) {
}
func TestNewProgramm(t *testing.T) {
//flat := `
//func do(x):
// e = x * 5
// b = e * 6
// c = b * 7
// f = c * 1
// d = c * f
// out = d * mul(d,e)
//
//func add(x ,k):
//def add(x ,k):
// z = k * x
// out = do(x) + mul(x,z)
// out = 6 + mul(x,z)
//
//func main(x,z):
// out = do(z) + add(x,x)
//def main(x,z):
// out = mul(x,z) - add(x,x)
//
//func mul(a,b):
//def mul(a,b):
// out = a * b
//`
flat := `
func mul(a,b):
out = a * b
def do(x):
e = x * 5
b = e * 6
c = b * 7
f = c * 1
d = c * f
out = d * mul(d,e)
func main(a):
b = a * a
c = 4 - b
d = 5 * c
out = mul(d,b) / mul(b,b)
def add(x ,k):
z = k * x
out = do(x) + mul(x,z)
def main(x,z):
out = do(z) + add(x,x)
def mul(a,b):
out = a * b
`
//flat := `
//func mul(a,b):
// out = a * b
//
//func main(a,aa):
// b = a * a
// c = 4 - b
// d = 5 * c
// out = mul(d,c) / mul(b,b)
//`
//flat := `
//func main(a,b):
// c = a + b
// e = c - a
@ -52,6 +63,7 @@ func TestNewProgramm(t *testing.T) {
// g = f + 2
// out = g * a
//`
parser := NewParser(strings.NewReader(flat))
program, err := parser.Parse()
@ -79,9 +91,9 @@ func TestNewProgramm(t *testing.T) {
fmt.Println(a)
fmt.Println(b)
fmt.Println(c)
a1 := big.NewInt(int64(6))
//a2 := big.NewInt(int64(5))
inputs := []*big.Int{a1}
a1 := big.NewInt(int64(7))
a2 := big.NewInt(int64(11))
inputs := []*big.Int{a1, a2}
w := program.CalculateWitness(inputs)
fmt.Println("witness")
fmt.Println(w)

+ 88
- 69
circuitcompiler/circuit.go

@ -26,7 +26,6 @@ type gate struct {
left *gate
right *gate
funcInputs []*gate
Op Token
value *Constraint //is a pointer a good thing here??
leftIns []factor //leftIns and RightIns after addition gates have been reduced. only multiplication gates remain
rightIns []factor
@ -95,9 +94,9 @@ func (p *Program) addFunction(constraint *Constraint) (c *Circuit) {
Op: IN,
Out: in,
}
if name == "main" {
p.addGlobalInput(*newConstr)
}
//if name == "main" {
// p.addGlobalInput(*newConstr)
//}
c.addConstraint(newConstr)
renamedInputs[i] = newConstr.Out
}
@ -125,7 +124,7 @@ func (circ *Circuit) addConstraint(constraint *Constraint) {
//todo this is dangerous.. if someone would use out as variable name, things would be fucked
if constraint.Out == "out" {
constraint.Out = composeNewFunction(circ.Name, circ.Inputs)
constraint.Out = circ.Name //composeNewFunction(circ.Name, circ.Inputs)
circ.root = gateToAdd
} else {
constraint.Out = circ.renamer(constraint.Out)
@ -137,6 +136,25 @@ func (circ *Circuit) addConstraint(constraint *Constraint) {
circ.gateMap[constraint.Out] = gateToAdd
}
func (circ *Circuit) currentOutputName() string {
return composeNewFunction(circ.Name, circ.currentOutputs())
}
func (circ *Circuit) currentOutputs() []string {
renamedInputs := make([]string, len(circ.Inputs))
for i, in := range circ.Inputs {
if _, ex := circ.gateMap[in]; !ex {
panic("not existing input")
}
renamedInputs[i] = circ.gateMap[in].value.Out
}
return renamedInputs
}
func (circ *Circuit) renamer(constraint string) string {
if constraint == "" {
@ -162,72 +180,73 @@ func (circ *Circuit) renamer(constraint string) string {
}
func (circ *Circuit) renameInputs(inputs []string) {
if len(inputs) != len(circ.Inputs) {
panic("given inputs != circuit.Inputs")
}
mapping := make(map[string]string)
for i := 0; i < len(inputs); i++ {
if _, ex := circ.gateMap[inputs[i]]; ex {
//this is a tricky part. So we replace former inputs with the new ones, thereby
//it might be, that the new input name has already been used for some output inside the function
//currently I dont know an elegant way how to handle this renaming issue
if circ.gateMap[inputs[i]].value.Op != IN {
panic(fmt.Sprintf("renaming collsion with %s", inputs[i]))
}
}
mapping[circ.Inputs[i]] = inputs[i]
}
//fmt.Println(mapping)
//circ.Inputs = inputs
permute := func(in string) string {
if out, ex := mapping[in]; ex {
return out
}
return in
}
permuteListe := func(in []string) []string {
for i := 0; i < len(in); i++ {
in[i] = permute(in[i])
}
return in
}
for _, constraint := range circ.gateMap {
if constraint.value.Op == IN {
constraint.value.Out = permute(constraint.value.Out)
continue
}
if b, n, in := isFunction(constraint.value.Out); b {
constraint.value.Out = composeNewFunction(n, permuteListe(in))
constraint.value.Inputs = permuteListe(in)
}
if b, n, in := isFunction(constraint.value.V1); b {
constraint.value.V1 = composeNewFunction(n, permuteListe(in))
constraint.value.Inputs = permuteListe(in)
}
if b, n, in := isFunction(constraint.value.V2); b {
constraint.value.V2 = composeNewFunction(n, permuteListe(in))
constraint.value.Inputs = permuteListe(in)
}
constraint.value.V1 = permute(constraint.value.V1)
constraint.value.V2 = permute(constraint.value.V2)
}
return
}
//func (circ *Circuit) renameInputs(inputs []string) {
// if len(inputs) != len(circ.Inputs) {
// panic("given inputs != circuit.Inputs")
// }
// mapping := make(map[string]string)
// for i := 0; i < len(inputs); i++ {
// if _, ex := circ.gateMap[inputs[i]]; ex {
//
// //this is a tricky part. So we replace former inputs with the new ones, thereby
// //it might be, that the new input name has already been used for some output inside the function
// //currently I dont know an elegant way how to handle this renaming issue
// if circ.gateMap[inputs[i]].value.Op != IN {
// panic(fmt.Sprintf("renaming collsion with %s", inputs[i]))
// }
//
// }
// mapping[circ.Inputs[i]] = inputs[i]
// }
// //fmt.Println(mapping)
// //circ.Inputs = inputs
// permute := func(in string) string {
// if out, ex := mapping[in]; ex {
// return out
// }
// return in
// }
//
// permuteListe := func(in []string) []string {
// for i := 0; i < len(in); i++ {
// in[i] = permute(in[i])
// }
// return in
// }
//
// for _, constraint := range circ.gateMap {
//
// if constraint.value.Op == IN {
// constraint.value.Out = permute(constraint.value.Out)
// continue
// }
//
// if b, n, in := isFunction(constraint.value.Out); b {
// constraint.value.Out = composeNewFunction(n, permuteListe(in))
// constraint.value.Inputs = permuteListe(in)
// }
// if b, n, in := isFunction(constraint.value.V1); b {
// constraint.value.V1 = composeNewFunction(n, permuteListe(in))
// constraint.value.Inputs = permuteListe(in)
// }
// if b, n, in := isFunction(constraint.value.V2); b {
// constraint.value.V2 = composeNewFunction(n, permuteListe(in))
// constraint.value.Inputs = permuteListe(in)
// }
//
// constraint.value.V1 = permute(constraint.value.V1)
// constraint.value.V2 = permute(constraint.value.V2)
//
// }
// return
//}
func getContextFromVariable(in string) string {
if strings.Contains(in, variableIndicationSign) {
return strings.Split(in, variableIndicationSign)[0]
}
return ""
//if strings.Contains(in, variableIndicationSign) {
// return strings.Split(in, variableIndicationSign)[0]
//}
//return ""
return strings.Split(in, variableIndicationSign)[0]
}
func composeNewFunction(fname string, inputs []string) string {

+ 1
- 1
circuitcompiler/lexer.go

@ -42,7 +42,7 @@ func (ch Token) String() string {
case EXP:
return "^"
case FUNC:
return "func"
return "def"
case IN:
return "In"
case CONST:

+ 1
- 1
circuitcompiler/parser.go

@ -58,7 +58,7 @@ func (p *Parser) parseLine() (*Constraint, error) {
c := &Constraint{}
tok, lit := p.scanIgnoreWhitespace()
switch lit {
case "func":
case "def":
c.Op = FUNC
// format: `func name(in):`
//todo this is all a bit hacky and unsafe

Loading…
Cancel
Save